Skip to content
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

fix(api): truncate plate reader floating point results to third decimal place #16919

Merged
merged 1 commit into from
Nov 20, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion api/src/opentrons/protocol_engine/state/modules.py
Original file line number Diff line number Diff line change
Expand Up @@ -1268,7 +1268,10 @@ def convert_absorbance_reader_data_points(
row = chr(ord("A") + i // 12) # Convert index to row (A-H)
col = (i % 12) + 1 # Convert index to column (1-12)
well_key = f"{row}{col}"
well_map[well_key] = value
truncated_value = float(
"{:.5}".format(str(value))
) # Truncate the returned value to the third decimal place
well_map[well_key] = truncated_value
Comment on lines -1271 to +1274
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

round(value, 3) instead of going back and forth to a str?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We didn't want to round the read results, we want the exact reading value from the reader but truncated to the third decimal place.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This does round, though.

>>> "{:.5}".format(123.45678)
'123.46'

It also goes to more than 3 decimal places if the integer part is too short:

>>> "{:.5}".format(1.23456)
'1.2346'

return well_map
else:
raise ValueError(
Expand Down
Loading