From 7495bb58529c530cf8453425a3c0068dd43a9f79 Mon Sep 17 00:00:00 2001 From: Max Freedom Pollard <272618364+MaxFreedomPollard@users.noreply.github.com> Date: Thu, 10 Sep 2026 08:10:28 -0400 Subject: [PATCH] fix(resources): stop transposing a tip spot's size_x and size_y `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. --- pylabrobot/resources/tip_rack.py | 4 ++-- pylabrobot/resources/tip_rack_tests.py | 29 ++++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 2 deletions(-) diff --git a/pylabrobot/resources/tip_rack.py b/pylabrobot/resources/tip_rack.py index fdcfc666de4..c7ac312c1d1 100644 --- a/pylabrobot/resources/tip_rack.py +++ b/pylabrobot/resources/tip_rack.py @@ -46,8 +46,8 @@ def __init__( super().__init__( name, - size_x=size_y, - size_y=size_x, + size_x=size_x, + size_y=size_y, size_z=size_z, category=category, metadata=metadata, diff --git a/pylabrobot/resources/tip_rack_tests.py b/pylabrobot/resources/tip_rack_tests.py index 6ad96a8195f..5bc9c48c328 100644 --- a/pylabrobot/resources/tip_rack_tests.py +++ b/pylabrobot/resources/tip_rack_tests.py @@ -48,3 +48,32 @@ def test_set_tip_state_fills_with_named_tips(self): spot = rack.get_item("A1") tip = spot.tracker.get_tip() self.assertIsNotNone(tip.name) + + +class TipSpotSizeTests(unittest.TestCase): + """Tests that a tip spot keeps the footprint it was created with.""" + + @staticmethod + def _make_tip(name: str) -> Tip: + return Tip( + name=name, + has_filter=False, + total_tip_length=50.0, + maximal_volume=300.0, + fitting_depth=8.0, + ) + + def test_size_x_and_size_y_are_not_transposed(self): + spot = TipSpot(name="spot", size_x=8.0, size_y=5.0, size_z=2.0, make_tip=self._make_tip) + + self.assertEqual(spot.get_size_x(), 8.0) + self.assertEqual(spot.get_size_y(), 5.0) + self.assertEqual(spot.center(), Coordinate(4.0, 2.5, 0.0)) + + def test_serialization_round_trip_preserves_footprint(self): + spot = TipSpot(name="spot", size_x=8.0, size_y=5.0, size_z=2.0, make_tip=self._make_tip) + + round_tripped = TipSpot.deserialize(spot.serialize()) + + self.assertEqual(round_tripped.get_size_x(), spot.get_size_x()) + self.assertEqual(round_tripped.get_size_y(), spot.get_size_y())