Skip to content

Commit

Permalink
Remove tolerance in BimorphMirror.set
Browse files Browse the repository at this point in the history
  • Loading branch information
dan-fernandes committed Jan 16, 2025
1 parent fe8bae5 commit c81c50c
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 25 deletions.
11 changes: 2 additions & 9 deletions src/dodal/devices/bimorph_mirror.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
Expand All @@ -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()
Expand All @@ -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
16 changes: 0 additions & 16 deletions tests/devices/unit_tests/test_bimorph_mirror.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down

0 comments on commit c81c50c

Please sign in to comment.