fix: skip double conversion when time values are already in milliseconds#47
Open
Sufiyan-MSA wants to merge 1 commit intoOSIPI:mainfrom
Open
fix: skip double conversion when time values are already in milliseconds#47Sufiyan-MSA wants to merge 1 commit intoOSIPI:mainfrom
Sufiyan-MSA wants to merge 1 commit intoOSIPI:mainfrom
Conversation
|
Main issue here is deciding why and how are we fixing the threshold. Any threshold wont work. This change is suggested by AI. Please refrain the indiscriminate use of AI and check what it edits. Please explain why you chose this threshold in the code. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #14
What this fixes
Stops time fields (e.g. PostLabelingDelay, EchoTime, RepetitionTimePreparation) that are already in milliseconds in the input from being multiplied by 1000 again, which was producing wrong values (e.g. 1800 → 1,800,000).
What I changed
convert_to_milliseconds, added a heuristic so that if a scalar time value is greater than 10, or any element in a list is greater than 10, the value(s) are treated as already in milliseconds and conversion is skipped. Typical ASL times in seconds (EchoTime ~0.01–0.03 s, PLD ~1–3 s, RepetitionTime ~3–6 s) are all below 10, so this threshold avoids double conversion while keeping seconds→ms conversion for values in seconds.How I tested it
Ran the four scenarios from the issue: (1) scalar seconds → ms (e.g. 1.8 → 1800), (2) scalar already ms unchanged (e.g. 1800 → 1800, 15 → 15, 4000.0 → 4000.0), (3) list already ms unchanged ([1800, 2000, 2200]), (4) list seconds → ms ([1.8, 2.0, 2.2] → [1800, 2000, 2200]). Confirmed no new linter issues on the modified file.
Notes
Fix is implemented only in
UnitConverterUtils.convert_to_milliseconds; both the session normalization path and the M0 time conversion path inprocessor.pyuse this method, so both are fixed without further changes.