Use a default_factory for dict default values

`backlash_steps` and `axis_inverted` were `lt.setting`s with default values that were dictionaries. This means they had mutable default values, which caused crosstalk in the test suite.

This commit swaps them to default factory functions. This should isolate instances from each other and stop the offending behaviour.
This commit is contained in:
Richard Bowman 2026-03-30 17:05:14 +01:00 committed by Julian Stirling
parent d358d89334
commit cb9270c9e8
3 changed files with 4 additions and 4 deletions

View file

@ -147,7 +147,7 @@ class BaseStage(lt.Thing):
return self._apply_axis_direction(self._hardware_position)
backlash_steps: dict[str, int] = lt.setting(
default={"x": 200, "y": 200, "z": 200}, readonly=True
default_factory=lambda: {"x": 200, "y": 200, "z": 200}, readonly=True
)
"""The number of steps to elimate backlash. The sign sets the direction.
@ -161,7 +161,7 @@ class BaseStage(lt.Thing):
"""Whether the stage is in motion."""
axis_inverted: dict[str, bool] = lt.setting(
default={"x": False, "y": False, "z": False}, readonly=True
default_factory=lambda: {"x": False, "y": False, "z": False}, readonly=True
)
"""Used to convert coordinates between the program frame and the hardware frame."""

View file

@ -77,7 +77,7 @@ class DummyStage(BaseStage):
self._move_thread.join()
axis_inverted: dict[str, bool] = lt.setting(
default={"x": True, "y": False, "z": False}, readonly=True
default_factory=lambda: {"x": True, "y": False, "z": False}, readonly=True
)
"""Used to convert coordinates between the program frame and the hardware frame."""

View file

@ -76,7 +76,7 @@ class SangaboardThing(BaseStage):
self._sangaboard.close()
axis_inverted: dict[str, bool] = lt.setting(
default={"x": True, "y": False, "z": True}, readonly=True
default_factory=lambda: {"x": True, "y": False, "z": True}, readonly=True
)
"""Used to convert coordinates between the program frame and the hardware frame."""