From 1f7da38fa41f0e6cced21d8d55c0e4ed3fe5c8ec Mon Sep 17 00:00:00 2001 From: Mark Wolfman Date: Thu, 5 Dec 2024 18:43:05 -0600 Subject: [PATCH 1/3] Converted ophyd enum types to uppercase. --- src/haven/devices/srs570.py | 34 +++++++++++++++++----------------- src/haven/positioner.py | 4 ++-- src/haven/tests/test_srs570.py | 2 +- 3 files changed, 20 insertions(+), 20 deletions(-) diff --git a/src/haven/devices/srs570.py b/src/haven/devices/srs570.py index c189dd5f..f41e4a36 100644 --- a/src/haven/devices/srs570.py +++ b/src/haven/devices/srs570.py @@ -302,27 +302,27 @@ class GainMode(StrictEnum): LOW_DRIFT = "LOW DRIFT" class SensValue(StrictEnum): - _1 = "1" - _2 = "2" - _5 = "5" - _10 = "10" - _20 = "20" - _50 = "50" - _100 = "100" - _200 = "200" - _500 = "500" + ONE = "1" + TWO = "2" + FIVE = "5" + TEN = "10" + TWENTY = "20" + FIFTY = "50" + ONE_HUNDRED = "100" + TWO_HUNDRED = "200" + FIVE_HUNDRED = "500" class SensUnit(StrictEnum): - pA_V = "pA/V" - nA_V = "nA/V" - uA_V = "uA/V" - mA_V = "mA/V" + PICOAMP_PER_VOLT = "pA/V" + NANOAMP_PER_VOLT = "nA/V" + MICROAMP_PER_VOLT = "uA/V" + MILLIAMP_PER_VOLT = "mA/V" class OffsetUnit(StrictEnum): - pA = "pA" - nA = "nA" - uA = "uA" - mA = "mA" + PICOAMP = "pA" + NANOAMP = "nA" + MICROAMP = "uA" + MILLIAMP = "mA" def __init__(self, prefix: str, name: str = ""): """ diff --git a/src/haven/positioner.py b/src/haven/positioner.py index e5e9e5e2..6d357c67 100644 --- a/src/haven/positioner.py +++ b/src/haven/positioner.py @@ -54,10 +54,10 @@ def __init__( self.put_complete = put_complete super().__init__(name=name) - def set_name(self, name: str): + def set_name(self, name: str, *args, **kwargs): super().set_name(name) # Readback should be named the same as its parent in read() - self.readback.set_name(name) + self.readback.set_name(name, *args, **kwargs) def watch_done( self, value, done_event: asyncio.Event, started_event: asyncio.Event diff --git a/src/haven/tests/test_srs570.py b/src/haven/tests/test_srs570.py index 8feef2dd..0b34873d 100644 --- a/src/haven/tests/test_srs570.py +++ b/src/haven/tests/test_srs570.py @@ -112,7 +112,7 @@ async def preamp(): async def test_preamp_signals(preamp): # Check the enums - await preamp.sensitivity_value.set(SRS570PreAmplifier.SensValue._5) + await preamp.sensitivity_value.set(SRS570PreAmplifier.SensValue.FIVE) @pytest.mark.parametrize("gain_mode", gain_modes) From 365f0cb289f1069d3db97fa9da10cda533603f47 Mon Sep 17 00:00:00 2001 From: Mark Wolfman Date: Fri, 6 Dec 2024 08:07:31 -0600 Subject: [PATCH 2/3] Removed the *min_move* argument from the undulator positioner. --- src/haven/devices/xray_source.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/haven/devices/xray_source.py b/src/haven/devices/xray_source.py index 5f292dd9..9e645034 100644 --- a/src/haven/devices/xray_source.py +++ b/src/haven/devices/xray_source.py @@ -42,7 +42,6 @@ def __init__( stop_signal: Signal, done_signal: Signal = None, name: str = "", - min_move: float = 0.0, ): with self.add_children_as_readables(StandardReadableFormat.HINTED_SIGNAL): self.readback = epics_signal_rw(float, f"{prefix}M.VAL") @@ -64,7 +63,7 @@ def __init__( self.done = derived_signal_r( int, derived_from={"parent_signal": done_signal} ) - super().__init__(name=name, min_move=min_move) + super().__init__(name=name) class PlanarUndulator(StandardReadable): @@ -115,7 +114,6 @@ def __init__(self, prefix: str, name: str = ""): actuate_signal=self.start_button, stop_signal=self.stop_button, done_signal=self.busy, - min_move=0.010, ) self.energy_taper = UndulatorPositioner( prefix=f"{prefix}TaperEnergy", @@ -128,7 +126,6 @@ def __init__(self, prefix: str, name: str = ""): actuate_signal=self.start_button, stop_signal=self.stop_button, done_signal=self.busy, - min_move=0.004, ) self.gap_taper = UndulatorPositioner( prefix=f"{prefix}TaperGap", From b4684455380cd26a0cf19e6b412b36ab808fa6e4 Mon Sep 17 00:00:00 2001 From: Mark Wolfman Date: Mon, 16 Dec 2024 12:20:09 -0600 Subject: [PATCH 3/3] Updated the tests to use the new ``testing`` module from ophyd-async. --- environment.yml | 2 +- src/firefly/tests/test_grid_scan_window.py | 2 +- src/firefly/tests/test_line_scan_window.py | 2 +- src/haven/tests/test_energy_positioner.py | 2 +- src/haven/tests/test_ion_chamber.py | 3 ++- src/haven/tests/test_motor.py | 2 +- src/haven/tests/test_positioner.py | 2 +- src/haven/tests/test_save_motor_positions.py | 2 +- src/haven/tests/test_shutter.py | 2 +- src/haven/tests/test_signal.py | 3 ++- src/haven/tests/test_srs570.py | 2 +- src/haven/tests/test_xray_source.py | 2 +- 12 files changed, 14 insertions(+), 12 deletions(-) diff --git a/environment.yml b/environment.yml index 5949a583..325f1dc2 100644 --- a/environment.yml +++ b/environment.yml @@ -59,7 +59,7 @@ dependencies: - bluesky-adaptive - bluesky >=1.8.1 - ophyd >=1.6.3 - - ophyd-async >=0.8.0a5 + - ophyd-async >=0.9.0a1 - apstools == 1.6.20 # Leave at 1.6.20 until this is fixed: https://github.com/BCDA-APS/apstools/issues/1022 - pcdsdevices # For extra signal types - pydm >=1.18.0 diff --git a/src/firefly/tests/test_grid_scan_window.py b/src/firefly/tests/test_grid_scan_window.py index 4d1efb54..5bc3d6b3 100644 --- a/src/firefly/tests/test_grid_scan_window.py +++ b/src/firefly/tests/test_grid_scan_window.py @@ -3,7 +3,7 @@ import pytest from bluesky_queueserver_api import BPlan -from ophyd_async.core import set_mock_value +from ophyd_async.testing import set_mock_value from qtpy import QtCore from firefly.plans.grid_scan import GridScanDisplay diff --git a/src/firefly/tests/test_line_scan_window.py b/src/firefly/tests/test_line_scan_window.py index 693d4cae..8c10abeb 100644 --- a/src/firefly/tests/test_line_scan_window.py +++ b/src/firefly/tests/test_line_scan_window.py @@ -2,7 +2,7 @@ import pytest from bluesky_queueserver_api import BPlan -from ophyd_async.core import set_mock_value +from ophyd_async.testing import set_mock_value from qtpy import QtCore from firefly.plans.line_scan import LineScanDisplay diff --git a/src/haven/tests/test_energy_positioner.py b/src/haven/tests/test_energy_positioner.py index 161f03d3..34cdf4c4 100644 --- a/src/haven/tests/test_energy_positioner.py +++ b/src/haven/tests/test_energy_positioner.py @@ -1,7 +1,7 @@ import asyncio import pytest -from ophyd_async.core import get_mock_put, set_mock_value +from ophyd_async.testing import get_mock_put, set_mock_value from haven.devices.energy_positioner import EnergyPositioner from haven.devices.xray_source import BusyStatus diff --git a/src/haven/tests/test_ion_chamber.py b/src/haven/tests/test_ion_chamber.py index bfa9f79e..2dad0e12 100644 --- a/src/haven/tests/test_ion_chamber.py +++ b/src/haven/tests/test_ion_chamber.py @@ -4,7 +4,8 @@ import numpy as np import pytest from numpy.testing import assert_allclose -from ophyd_async.core import TriggerInfo, assert_value, get_mock_put, set_mock_value +from ophyd_async.core import TriggerInfo +from ophyd_async.testing import assert_value, get_mock_put, set_mock_value from haven.devices.ion_chamber import IonChamber diff --git a/src/haven/tests/test_motor.py b/src/haven/tests/test_motor.py index 25b3171c..935585b2 100644 --- a/src/haven/tests/test_motor.py +++ b/src/haven/tests/test_motor.py @@ -2,7 +2,7 @@ import pytest from bluesky.protocols import Flyable -from ophyd_async.core import get_mock_put +from ophyd_async.testing import get_mock_put from haven.devices.motor import HavenMotor from haven.devices.motor import Motor as AsyncMotor diff --git a/src/haven/tests/test_positioner.py b/src/haven/tests/test_positioner.py index 40e031cc..6b7e14f2 100644 --- a/src/haven/tests/test_positioner.py +++ b/src/haven/tests/test_positioner.py @@ -1,8 +1,8 @@ import asyncio import pytest -from ophyd_async.core import get_mock_put, set_mock_value from ophyd_async.epics.core import epics_signal_r, epics_signal_rw, epics_signal_x +from ophyd_async.testing import get_mock_put, set_mock_value from haven.positioner import Positioner diff --git a/src/haven/tests/test_save_motor_positions.py b/src/haven/tests/test_save_motor_positions.py index 18249f66..22f5b40f 100644 --- a/src/haven/tests/test_save_motor_positions.py +++ b/src/haven/tests/test_save_motor_positions.py @@ -7,7 +7,7 @@ import pandas as pd import pytest import time_machine -from ophyd_async.core import set_mock_value +from ophyd_async.testing import set_mock_value from tiled.adapters.mapping import MapAdapter from tiled.adapters.xarray import DatasetAdapter from tiled.client import Context, from_context diff --git a/src/haven/tests/test_shutter.py b/src/haven/tests/test_shutter.py index 8b37ec6f..520fb7cf 100644 --- a/src/haven/tests/test_shutter.py +++ b/src/haven/tests/test_shutter.py @@ -1,6 +1,6 @@ import pytest from ophyd.utils.errors import ReadOnlyError -from ophyd_async.core import get_mock_put, set_mock_value +from ophyd_async.testing import get_mock_put, set_mock_value from haven.devices.shutter import PssShutter, ShutterState diff --git a/src/haven/tests/test_signal.py b/src/haven/tests/test_signal.py index b62f1bdf..01a7f701 100644 --- a/src/haven/tests/test_signal.py +++ b/src/haven/tests/test_signal.py @@ -3,9 +3,10 @@ from unittest.mock import MagicMock import pytest -from ophyd_async.core import Device, DeviceVector, get_mock_put +from ophyd_async.core import Device, DeviceVector from ophyd_async.core._signal import soft_signal_rw from ophyd_async.epics.core import epics_signal_rw, epics_signal_x +from ophyd_async.testing import get_mock_put from haven.devices.signal import derived_signal_rw, derived_signal_x diff --git a/src/haven/tests/test_srs570.py b/src/haven/tests/test_srs570.py index 0b34873d..50393b25 100644 --- a/src/haven/tests/test_srs570.py +++ b/src/haven/tests/test_srs570.py @@ -2,7 +2,7 @@ from unittest import mock import pytest -from ophyd_async.core import get_mock_put +from ophyd_async.testing import get_mock_put from haven.devices.srs570 import GainSignal, SRS570PreAmplifier diff --git a/src/haven/tests/test_xray_source.py b/src/haven/tests/test_xray_source.py index 7601e83f..a09ccc1d 100644 --- a/src/haven/tests/test_xray_source.py +++ b/src/haven/tests/test_xray_source.py @@ -1,7 +1,7 @@ import asyncio import pytest -from ophyd_async.core import get_mock_put, set_mock_value +from ophyd_async.testing import get_mock_put, set_mock_value from haven.devices.xray_source import BusyStatus, PlanarUndulator