Skip to content

Commit

Permalink
fix(api): made a mistake in math when i removed the isclose check (#1…
Browse files Browse the repository at this point in the history
…5913)

<!--
Thanks for taking the time to open a Pull Request (PR)! Please make sure
you've read the "Opening Pull Requests" section of our Contributing
Guide:


https://github.com/Opentrons/opentrons/blob/edge/CONTRIBUTING.md#opening-pull-requests

GitHub provides robust markdown to format your PR. Links, diagrams,
pictures, and videos along with text formatting make it possible to
create a rich and informative PR. For more information on GitHub
markdown, see:


https://docs.github.com/en/get-started/writing-on-github/getting-started-with-writing-and-formatting-on-github/basic-writing-and-formatting-syntax

To ensure your code is reviewed quickly and thoroughly, please fill out
the sections below to the best of your ability!
-->

# Overview
Should have realized it was wrong when I had to change the test
<!--
Describe your PR at a high level. State acceptance criteria and how this
PR fits into other work. Link issues, PRs, and other relevant resources.
-->

## Test Plan and Hands on Testing

<!--
Describe your testing of the PR. Emphasize testing not reflected in the
code. Attach protocols, logs, screenshots and any other assets that
support your testing.
-->

## Changelog

<!--
List changes introduced by this PR considering future developers and the
end user. Give careful thought and clear documentation to breaking
changes.
-->

## Review requests

<!--
- What do you need from reviewers to feel confident this PR is ready to
merge?
- Ask questions.
-->

## Risk assessment

<!--
- Indicate the level of attention this PR needs.
- Provide context to guide reviewers.
- Discuss trade-offs, coupling, and side effects.
- Look for the possibility, even if you think it's small, that your
change may affect some other part of the system.
- For instance, changing return tip behavior may also change the
behavior of labware calibration.
- How do your unit tests and on hands on testing mitigate this PR's
risks and the risk of future regressions?
- Especially in high risk PRs, explain how you know your testing is
enough.
-->

Co-authored-by: caila-marashaj <[email protected]>
  • Loading branch information
ryanthecoder and caila-marashaj authored Aug 7, 2024
1 parent 837d5ae commit fe6252c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
7 changes: 5 additions & 2 deletions api/src/opentrons/hardware_control/ot3api.py
Original file line number Diff line number Diff line change
Expand Up @@ -2714,7 +2714,10 @@ async def liquid_probe(

error: Optional[PipetteLiquidNotFoundError] = None
pos = await self.gantry_position(checked_mount, refresh=True)
while (probe_start_pos.z - pos.z) < max_z_dist:
# probe_start_pos.z + z_distance of pass - pos.z should be < max_z_dist
# due to rounding errors this can get caught in an infinite loop when the distance is almost equal
# so we check to see if they're within 0.01 which is 1/5th the minimum movement distance from move_utils.py
while (probe_start_pos.z - pos.z) < (max_z_dist + 0.01):
# safe distance so we don't accidentally aspirate liquid if we're already close to liquid
safe_plunger_pos = top_types.Point(
pos.x, pos.y, pos.z + probe_safe_reset_mm
Expand All @@ -2724,7 +2727,7 @@ async def liquid_probe(
pos.x, pos.y, pos.z + probe_pass_z_offset_mm
)
max_z_time = (
max_z_dist - (probe_start_pos.z - safe_plunger_pos.z)
max_z_dist - probe_start_pos.z + pass_start_pos.z
) / probe_settings.mount_speed
p_travel_required_for_z = max_z_time * probe_settings.plunger_speed
p_pass_travel = min(p_travel_required_for_z, p_working_mm)
Expand Down
4 changes: 2 additions & 2 deletions api/tests/opentrons/hardware_control/test_ot3_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -838,7 +838,7 @@ async def test_liquid_probe(
mock_move_to_plunger_bottom.call_count == 2
mock_liquid_probe.assert_called_once_with(
mount,
52,
46,
fake_settings_aspirate.mount_speed,
(fake_settings_aspirate.plunger_speed * -1),
fake_settings_aspirate.sensor_threshold_pascals,
Expand Down Expand Up @@ -990,7 +990,7 @@ async def _fake_pos_update_and_raise(
OT3Mount.LEFT, fake_max_z_dist, fake_settings_aspirate
)
# assert that it went through 4 passes and then prepared to aspirate
assert mock_move_to_plunger_bottom.call_count == 5
assert mock_move_to_plunger_bottom.call_count == 4


@pytest.mark.parametrize(
Expand Down

0 comments on commit fe6252c

Please sign in to comment.