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
Micromanager: switch to DataTools.parseDouble for double parsing #3253
Conversation
This automatically prevents NumberFormatExceptions for invalid double values and handles the case when the decimal separator in the file doesn't match the current locale's decimal separator.
Closing/reopening to include #3251 |
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.
Barring an extra comment about further cleanup, generally reads fine.
} | ||
catch (NumberFormatException e) { } | ||
} | ||
else if (key.equals("YPositionUm")) { | ||
try { | ||
Position p = positions.get(getCoreIndex()); | ||
p.positions[i][1] = new Double(value); | ||
p.positions[i][1] = DataTools.parseDouble(value); | ||
} | ||
catch (NumberFormatException e) { } |
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.
With the usage of the DataTools
API, could we further simplify this code and remove the NumberFormatException
handling in the reader?
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.
Done in 59ed134
DataTools.parseDouble should catch NumberFormatException internally.
This change looks good and has no negative impact on existing datasets. Tested by modifying existing datasets to produce the PR is good to merge |
Backported from a private PR.
This automatically prevents
NumberFormatException
s for invalid double values and handles the case when the decimal separator in the file doesn't match the current locale's decimal separator.To test, use
curated/micromanager/pr-3253
, which was copied fromcurated/micromanager/qa-4984/
, but with0.5,
replaced by"0,5",
inmetadata.txt
. Without this PR,showinf -nopix -omexml metadata.txt
will throw:With this PR, the same test should successfully initialize the file and display OME-XML with
PhysicalSizeX
andPhysicalSizeY
set to0.5
.Builds and memo files should not be impacted.