From c81c50c816b567a0cb626c6978a4fffec9766f44 Mon Sep 17 00:00:00 2001 From: Daniel Fernandes Date: Thu, 16 Jan 2025 13:16:11 +0000 Subject: [PATCH] Remove tolerance in BimorphMirror.set --- src/dodal/devices/bimorph_mirror.py | 11 ++--------- tests/devices/unit_tests/test_bimorph_mirror.py | 16 ---------------- 2 files changed, 2 insertions(+), 25 deletions(-) diff --git a/src/dodal/devices/bimorph_mirror.py b/src/dodal/devices/bimorph_mirror.py index 246756e66b..50c54489b1 100644 --- a/src/dodal/devices/bimorph_mirror.py +++ b/src/dodal/devices/bimorph_mirror.py @@ -126,8 +126,8 @@ async def set(self, value: Mapping[int, float], tolerance: float = 0.0001) -> No await wait_for_value( self.status, BimorphMirrorStatus.BUSY, timeout=DEFAULT_TIMEOUT ) - # Trigger set target voltages: + # Trigger set target voltages: await wait_for_value( self.status, BimorphMirrorStatus.IDLE, timeout=DEFAULT_TIMEOUT ) @@ -138,7 +138,7 @@ async def set(self, value: Mapping[int, float], tolerance: float = 0.0001) -> No *[ wait_for_value( self.channels[i].output_voltage, - tolerance_func_builder(tolerance, target), + target, timeout=DEFAULT_TIMEOUT, ) for i, target in value.items() @@ -147,10 +147,3 @@ async def set(self, value: Mapping[int, float], tolerance: float = 0.0001) -> No self.status, BimorphMirrorStatus.IDLE, timeout=DEFAULT_TIMEOUT ), ) - - -def tolerance_func_builder(tolerance: float, target_value: float): - def is_within_value(x): - return abs(x - target_value) <= tolerance - - return is_within_value diff --git a/tests/devices/unit_tests/test_bimorph_mirror.py b/tests/devices/unit_tests/test_bimorph_mirror.py index 10113b515e..178116185b 100644 --- a/tests/devices/unit_tests/test_bimorph_mirror.py +++ b/tests/devices/unit_tests/test_bimorph_mirror.py @@ -104,22 +104,6 @@ async def test_set_channels_waits_for_vout_readback( ) -@pytest.mark.parametrize("mirror", VALID_BIMORPH_CHANNELS, indirect=True) -async def test_set_channels_allows_tolerance( - mirror: BimorphMirror, - valid_bimorph_values: dict[int, float], - bimorph_functionality, -): - for channel in mirror.channels.values(): - - def out_by_a_little(value: float, wait=False, signal=channel.output_voltage): - signal.set(value + 0.00001, wait=wait) - - get_mock_put(channel.target_voltage).side_effect = out_by_a_little - - await mirror.set(valid_bimorph_values) - - @pytest.mark.parametrize("mirror", VALID_BIMORPH_CHANNELS, indirect=True) async def test_set_one_channel(mirror: BimorphMirror, bimorph_functionality): values = {1: 1}