-
Notifications
You must be signed in to change notification settings - Fork 1
Only zero-index Pmetrics format #197
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: norm-row-suggestions
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -187,22 +187,18 @@ impl DataRow { | |||||||||||||||||||||||||
| .ok_or_else(|| DataError::MissingObservationOuteq { | ||||||||||||||||||||||||||
| id: self.id.clone(), | ||||||||||||||||||||||||||
| time: self.time, | ||||||||||||||||||||||||||
| })? | ||||||||||||||||||||||||||
| .saturating_sub(1), // Convert 1-indexed to 0-indexed | ||||||||||||||||||||||||||
| })?, // Convert 1-indexed to 0-indexed | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
| })?, // Convert 1-indexed to 0-indexed | |
| })?, |
Copilot
AI
Jan 14, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The DataRow builder API is documented to accept 1-indexed values for input (see lines 369-372) and convert them internally, but this conversion was removed. This breaks the builder API contract. Either the conversion must be restored in the builder (by having the builder itself convert to 0-indexed before storing in DataRow), or the builder's documentation and all its usage must be updated to reflect that it now expects 0-indexed values. Given that the PR doesn't update documentation or usages, the likely intent is to restore the conversion. The conversion should happen in the builder's input() method at line 374, changing it to: self.row.input = Some(input.saturating_sub(1));
| let input = self.input.ok_or_else(|| DataError::MissingBolusInput { | |
| id: self.id.clone(), | |
| time: self.time, | |
| })?; | |
| // Convert 1-indexed input (Pmetrics convention) to 0-indexed internally | |
| let input = self | |
| .input | |
| .map(|i| i.saturating_sub(1)) | |
| .ok_or_else(|| DataError::MissingBolusInput { | |
| id: self.id.clone(), | |
| time: self.time, | |
| })?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
inputfield should also be converted from 1-indexed to 0-indexed when reading Pmetrics format, similar to howouteqis now being converted on line 142. The Pmetrics format uses 1-indexed values for both fields (as evidenced by the write_pmetrics method at lines 341 and 362 that adds 1 to both when writing), but the internal representation is 0-indexed. The conversion forinputwas removed from row.rs but not added here in the parser, which will cause incorrect compartment indexing. Line 137 should be changed to:input: self.input.map(|v| v.saturating_sub(1))