Skip to content

fix(resources): stop transposing a tip spot's size_x and size_y - #1251

Open
MaxFreedomPollard wants to merge 1 commit into
PyLabRobot:mainfrom
MaxFreedomPollard:fix-tip-spot-size-transposed
Open

fix(resources): stop transposing a tip spot's size_x and size_y#1251
MaxFreedomPollard wants to merge 1 commit into
PyLabRobot:mainfrom
MaxFreedomPollard:fix-tip-spot-size-transposed

Conversation

@MaxFreedomPollard

Copy link
Copy Markdown
Contributor

A TipSpot reports the two sizes it was created with swapped. TipSpot.__init__ passes size_x=size_y, size_y=size_x up to Resource (pylabrobot/resources/tip_rack.py:49-50), so a spot built with size_x=8.0, size_y=5.0 answers get_size_x() == 5.0 and get_size_y() == 8.0. center() then returns Coordinate(2.5, 4.0, 0) instead of Coordinate(4.0, 2.5, 0), and TipSpot.deserialize(spot.serialize()) transposes the sizes a second time rather than reproducing the spot.

The constructor's own docstring settles which is which: "size_x: the size of the tip spot in the x direction", "size_y: the size of the tip spot in the y direction", and Resource.get_size_x is documented as the local size in the x direction. No other resource in the repo transposes its sizes, and nothing downstream compensates: the OT-2 driver targets tip_spot.get_location_wrt(self.robot.deck, "c", "c", "b") (pylabrobot/opentrons/ot2/pipette.py:237) and the STAR and Vantage backends add tip_spot_a1.center(), all of which read those two sizes back, so a non-square spot is approached half the difference off center in each axis.

Nothing in the repo trips it because every tip spot defined here is square, so the two sizes are equal. It shows up on a spot whose x and y footprint differ, which is what two separate parameters are for.

The fix passes each size to the axis it names. TipSpotSizeTests in tip_rack_tests.py builds an 8.0 by 5.0 mm spot and checks the reported sizes, center(), and a serialize/deserialize round trip; against the unfixed constructor it fails with AssertionError: 5.0 != 8.0.

Verified with python -m pytest (whole suite green), make lint and make format-check ("All checks passed!"), and make typecheck clean on the changed files.

`TipSpot.__init__` passed its `size_x` to `Resource` as `size_y` and its
`size_y` as `size_x`, so a spot whose two sizes differ reported them
swapped. Its center landed half the difference off in each axis, and a
serialize/deserialize round trip transposed the sizes again instead of
reproducing the spot. Every tip spot defined here is square, so the two
sizes are equal and the transposition never shows up on them.
@MaxFreedomPollard
MaxFreedomPollard requested a review from a team as a code owner September 10, 2026 12:11
fitting_depth=8.0,
)

def test_size_x_and_size_y_are_not_transposed(self):

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Do you think we really need this now that is fixed? :)

@BioCam

BioCam commented Sep 10, 2026

Copy link
Copy Markdown
Collaborator

This is hilarious, such an innocent bug - thank you for catching! 😅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants