diff --git a/src/ophyd_async/core/_detector.py b/src/ophyd_async/core/_detector.py index d2990c9fc8..507c33f50e 100644 --- a/src/ophyd_async/core/_detector.py +++ b/src/ophyd_async/core/_detector.py @@ -30,13 +30,13 @@ class DetectorTrigger(StrictEnum): """Type of mechanism for triggering a detector to take frames""" #: Detector generates internal trigger for given rate - internal = "internal" + INTERNAL = "internal" #: Expect a series of arbitrary length trigger signals - edge_trigger = "edge_trigger" + EDGE_TRIGGER = "edge_trigger" #: Expect a series of constant width external gate signals - constant_gate = "constant_gate" + CONSTANT_GATE = "constant_gate" #: Expect a series of variable width external gate signals - variable_gate = "variable_gate" + VARIABLE_GATE = "variable_gate" class TriggerInfo(BaseModel): @@ -53,7 +53,7 @@ class TriggerInfo(BaseModel): #: - 3 times for final flat field images number_of_triggers: NonNegativeInt | list[NonNegativeInt] #: Sort of triggers that will be sent - trigger: DetectorTrigger = Field(default=DetectorTrigger.internal) + trigger: DetectorTrigger = Field(default=DetectorTrigger.INTERNAL) #: What is the minimum deadtime between triggers deadtime: float | None = Field(default=None, ge=0) #: What is the maximum high time of the triggers @@ -265,14 +265,14 @@ async def trigger(self) -> None: await self.prepare( TriggerInfo( number_of_triggers=1, - trigger=DetectorTrigger.internal, + trigger=DetectorTrigger.INTERNAL, deadtime=None, livetime=None, frame_timeout=None, ) ) assert self._trigger_info - assert self._trigger_info.trigger is DetectorTrigger.internal + assert self._trigger_info.trigger is DetectorTrigger.INTERNAL # Arm the detector and wait for it to finish. indices_written = await self.writer.get_indices_written() await self.controller.arm() @@ -303,7 +303,7 @@ async def prepare(self, value: TriggerInfo) -> None: Args: value: TriggerInfo describing how to trigger the detector """ - if value.trigger != DetectorTrigger.internal: + if value.trigger != DetectorTrigger.INTERNAL: assert ( value.deadtime ), "Deadtime must be supplied when in externally triggered mode" @@ -323,7 +323,7 @@ async def prepare(self, value: TriggerInfo) -> None: self._describe, _ = await asyncio.gather( self.writer.open(value.multiplier), self.controller.prepare(value) ) - if value.trigger != DetectorTrigger.internal: + if value.trigger != DetectorTrigger.INTERNAL: await self.controller.arm() self._fly_start = time.monotonic() diff --git a/src/ophyd_async/core/_utils.py b/src/ophyd_async/core/_utils.py index edb8b2c4b2..43ce473b8b 100644 --- a/src/ophyd_async/core/_utils.py +++ b/src/ophyd_async/core/_utils.py @@ -17,11 +17,20 @@ ErrorText = str | Mapping[str, Exception] -class StrictEnum(str, Enum): +class StrictEnumMeta(EnumMeta): + def __new__(metacls, *args, **kwargs): + ret = super().__new__(metacls, *args, **kwargs) + lowercase_names = [x.name for x in ret if not x.name.isupper()] # type: ignore + if lowercase_names: + raise TypeError(f"Names {lowercase_names} should be uppercase") + return ret + + +class StrictEnum(str, Enum, metaclass=StrictEnumMeta): """All members should exist in the Backend, and there will be no extras""" -class SubsetEnumMeta(EnumMeta): +class SubsetEnumMeta(StrictEnumMeta): def __call__(self, value, *args, **kwargs): # type: ignore if isinstance(value, str) and not isinstance(value, self): return value diff --git a/src/ophyd_async/epics/adaravis/_aravis_controller.py b/src/ophyd_async/epics/adaravis/_aravis_controller.py index ee75affe4d..2137785ddd 100644 --- a/src/ophyd_async/epics/adaravis/_aravis_controller.py +++ b/src/ophyd_async/epics/adaravis/_aravis_controller.py @@ -31,9 +31,9 @@ def get_deadtime(self, exposure: float | None) -> float: async def prepare(self, trigger_info: TriggerInfo): if trigger_info.total_number_of_triggers == 0: - image_mode = adcore.ImageMode.continuous + image_mode = adcore.ImageMode.CONTINUOUS else: - image_mode = adcore.ImageMode.multiple + image_mode = adcore.ImageMode.MULTIPLE if (exposure := trigger_info.livetime) is not None: await self._drv.acquire_time.set(exposure) @@ -58,9 +58,9 @@ def _get_trigger_info( self, trigger: DetectorTrigger ) -> tuple[AravisTriggerMode, AravisTriggerSource]: supported_trigger_types = ( - DetectorTrigger.constant_gate, - DetectorTrigger.edge_trigger, - DetectorTrigger.internal, + DetectorTrigger.CONSTANT_GATE, + DetectorTrigger.EDGE_TRIGGER, + DetectorTrigger.INTERNAL, ) if trigger not in supported_trigger_types: raise ValueError( @@ -68,10 +68,10 @@ def _get_trigger_info( f"types: {supported_trigger_types} but was asked to " f"use {trigger}" ) - if trigger == DetectorTrigger.internal: - return AravisTriggerMode.off, AravisTriggerSource.freerun + if trigger == DetectorTrigger.INTERNAL: + return AravisTriggerMode.OFF, AravisTriggerSource.FREERUN else: - return (AravisTriggerMode.on, f"Line{self.gpio_number}") # type: ignore + return (AravisTriggerMode.ON, f"Line{self.gpio_number}") # type: ignore async def disarm(self): await adcore.stop_busy_record(self._drv.acquire, False, timeout=1) diff --git a/src/ophyd_async/epics/adaravis/_aravis_io.py b/src/ophyd_async/epics/adaravis/_aravis_io.py index e16beb41f4..40db8e2aec 100644 --- a/src/ophyd_async/epics/adaravis/_aravis_io.py +++ b/src/ophyd_async/epics/adaravis/_aravis_io.py @@ -6,8 +6,8 @@ class AravisTriggerMode(StrictEnum): """GigEVision GenICAM standard: on=externally triggered""" - on = "On" - off = "Off" + ON = "On" + OFF = "Off" """A minimal set of TriggerSources that must be supported by the underlying record. @@ -20,8 +20,8 @@ class AravisTriggerMode(StrictEnum): class AravisTriggerSource(SubsetEnum): - freerun = "Freerun" - line1 = "Line1" + FREERUN = "Freerun" + LINE1 = "Line1" class AravisDriverIO(adcore.ADBaseIO): diff --git a/src/ophyd_async/epics/adcore/_core_io.py b/src/ophyd_async/epics/adcore/_core_io.py index 97332d9a15..8f231b425e 100644 --- a/src/ophyd_async/epics/adcore/_core_io.py +++ b/src/ophyd_async/epics/adcore/_core_io.py @@ -9,8 +9,8 @@ class Callback(StrictEnum): - Enable = "Enable" - Disable = "Disable" + ENABLE = "Enable" + DISABLE = "Disable" class NDArrayBaseIO(Device): @@ -72,17 +72,17 @@ class DetectorState(StrictEnum): See definition in ADApp/ADSrc/ADDriver.h in https://github.com/areaDetector/ADCore """ - Idle = "Idle" - Acquire = "Acquire" - Readout = "Readout" - Correct = "Correct" - Saving = "Saving" - Aborting = "Aborting" - Error = "Error" - Waiting = "Waiting" - Initializing = "Initializing" - Disconnected = "Disconnected" - Aborted = "Aborted" + IDLE = "Idle" + ACQUIRE = "Acquire" + READOUT = "Readout" + CORRECT = "Correct" + SAVING = "Saving" + ABORTING = "Aborting" + ERROR = "Error" + WAITING = "Waiting" + INITIALIZING = "Initializing" + DISCONNECTED = "Disconnected" + ABORTED = "Aborted" class ADBaseIO(NDArrayBaseIO): @@ -99,14 +99,14 @@ def __init__(self, prefix: str, name: str = "") -> None: class Compression(StrictEnum): - none = "None" - nbit = "N-bit" - szip = "szip" - zlib = "zlib" - blosc = "Blosc" - bslz4 = "BSLZ4" - lz4 = "LZ4" - jpeg = "JPEG" + NONE = "None" + NBIT = "N-bit" + SZIP = "szip" + ZLIB = "zlib" + BLOSC = "Blosc" + BSLZ4 = "BSLZ4" + LZ4 = "LZ4" + JPEG = "JPEG" class NDFileHDFIO(NDPluginBaseIO): diff --git a/src/ophyd_async/epics/adcore/_core_logic.py b/src/ophyd_async/epics/adcore/_core_logic.py index e927717046..54e642a081 100644 --- a/src/ophyd_async/epics/adcore/_core_logic.py +++ b/src/ophyd_async/epics/adcore/_core_logic.py @@ -14,7 +14,7 @@ # Default set of states that we should consider "good" i.e. the acquisition # is complete and went well DEFAULT_GOOD_STATES: frozenset[DetectorState] = frozenset( - [DetectorState.Idle, DetectorState.Aborted] + [DetectorState.IDLE, DetectorState.ABORTED] ) diff --git a/src/ophyd_async/epics/adcore/_hdf_writer.py b/src/ophyd_async/epics/adcore/_hdf_writer.py index 7d9bfd2b11..c33be0f8f5 100644 --- a/src/ophyd_async/epics/adcore/_hdf_writer.py +++ b/src/ophyd_async/epics/adcore/_hdf_writer.py @@ -67,7 +67,7 @@ async def open(self, multiplier: int = 1) -> dict[str, DataKey]: self.hdf.file_path.set(str(info.directory_path)), self.hdf.file_name.set(info.filename), self.hdf.file_template.set("%s/%s.h5"), - self.hdf.file_write_mode.set(FileWriteMode.stream), + self.hdf.file_write_mode.set(FileWriteMode.STREAM), # Never use custom xml layout file but use the one defined # in the source code file NDFileHDF5LayoutXML.cpp self.hdf.xml_file_name.set(""), diff --git a/src/ophyd_async/epics/adcore/_single_trigger.py b/src/ophyd_async/epics/adcore/_single_trigger.py index 165204d371..e3caa40af2 100644 --- a/src/ophyd_async/epics/adcore/_single_trigger.py +++ b/src/ophyd_async/epics/adcore/_single_trigger.py @@ -34,7 +34,7 @@ def __init__( @AsyncStatus.wrap async def stage(self) -> None: await asyncio.gather( - self.drv.image_mode.set(ImageMode.single), + self.drv.image_mode.set(ImageMode.SINGLE), self.drv.wait_for_plugins.set(True), ) await super().stage() diff --git a/src/ophyd_async/epics/adcore/_utils.py b/src/ophyd_async/epics/adcore/_utils.py index bedbd474c2..ec56efb723 100644 --- a/src/ophyd_async/epics/adcore/_utils.py +++ b/src/ophyd_async/epics/adcore/_utils.py @@ -11,42 +11,42 @@ class ADBaseDataType(StrictEnum): - Int8 = "Int8" - UInt8 = "UInt8" - Int16 = "Int16" - UInt16 = "UInt16" - Int32 = "Int32" - UInt32 = "UInt32" - Int64 = "Int64" - UInt64 = "UInt64" - Float32 = "Float32" - Float64 = "Float64" + INT8 = "Int8" + UINT8 = "UInt8" + INT16 = "Int16" + UINT16 = "UInt16" + INT32 = "Int32" + UINT32 = "UInt32" + INT64 = "Int64" + UINT64 = "UInt64" + FLOAT32 = "Float32" + FLOAT64 = "Float64" def convert_ad_dtype_to_np(ad_dtype: ADBaseDataType) -> str: ad_dtype_to_np_dtype = { - ADBaseDataType.Int8: "|i1", - ADBaseDataType.UInt8: "|u1", - ADBaseDataType.Int16: " str: _pvattribute_to_ad_datatype = { - "DBR_SHORT": ADBaseDataType.Int16, - "DBR_ENUM": ADBaseDataType.Int16, - "DBR_INT": ADBaseDataType.Int32, - "DBR_LONG": ADBaseDataType.Int32, - "DBR_FLOAT": ADBaseDataType.Float32, - "DBR_DOUBLE": ADBaseDataType.Float64, + "DBR_SHORT": ADBaseDataType.INT16, + "DBR_ENUM": ADBaseDataType.INT16, + "DBR_INT": ADBaseDataType.INT32, + "DBR_LONG": ADBaseDataType.INT32, + "DBR_FLOAT": ADBaseDataType.FLOAT32, + "DBR_DOUBLE": ADBaseDataType.FLOAT64, } if datatype in ["DBR_STRING", "DBR_CHAR"]: np_datatype = "s40" @@ -62,9 +62,9 @@ def convert_pv_dtype_to_np(datatype: str) -> str: def convert_param_dtype_to_np(datatype: str) -> str: _paramattribute_to_ad_datatype = { - "INT": ADBaseDataType.Int32, - "INT64": ADBaseDataType.Int64, - "DOUBLE": ADBaseDataType.Float64, + "INT": ADBaseDataType.INT32, + "INT64": ADBaseDataType.INT64, + "DOUBLE": ADBaseDataType.FLOAT64, } if datatype in ["STRING"]: np_datatype = "s40" @@ -79,15 +79,15 @@ def convert_param_dtype_to_np(datatype: str) -> str: class FileWriteMode(StrictEnum): - single = "Single" - capture = "Capture" - stream = "Stream" + SINGLE = "Single" + CAPTURE = "Capture" + STREAM = "Stream" class ImageMode(StrictEnum): - single = "Single" - multiple = "Multiple" - continuous = "Continuous" + SINGLE = "Single" + MULTIPLE = "Multiple" + CONTINUOUS = "Continuous" class NDAttributeDataType(StrictEnum): diff --git a/src/ophyd_async/epics/adkinetix/_kinetix_controller.py b/src/ophyd_async/epics/adkinetix/_kinetix_controller.py index 7bc142d321..53dbb9a029 100644 --- a/src/ophyd_async/epics/adkinetix/_kinetix_controller.py +++ b/src/ophyd_async/epics/adkinetix/_kinetix_controller.py @@ -11,10 +11,10 @@ from ._kinetix_io import KinetixDriverIO, KinetixTriggerMode KINETIX_TRIGGER_MODE_MAP = { - DetectorTrigger.internal: KinetixTriggerMode.internal, - DetectorTrigger.constant_gate: KinetixTriggerMode.gate, - DetectorTrigger.variable_gate: KinetixTriggerMode.gate, - DetectorTrigger.edge_trigger: KinetixTriggerMode.edge, + DetectorTrigger.INTERNAL: KinetixTriggerMode.INTERNAL, + DetectorTrigger.CONSTANT_GATE: KinetixTriggerMode.GATE, + DetectorTrigger.VARIABLE_GATE: KinetixTriggerMode.GATE, + DetectorTrigger.EDGE_TRIGGER: KinetixTriggerMode.EDGE, } @@ -33,11 +33,11 @@ async def prepare(self, trigger_info: TriggerInfo): await asyncio.gather( self._drv.trigger_mode.set(KINETIX_TRIGGER_MODE_MAP[trigger_info.trigger]), self._drv.num_images.set(trigger_info.total_number_of_triggers), - self._drv.image_mode.set(adcore.ImageMode.multiple), + self._drv.image_mode.set(adcore.ImageMode.MULTIPLE), ) if trigger_info.livetime is not None and trigger_info.trigger not in [ - DetectorTrigger.variable_gate, - DetectorTrigger.constant_gate, + DetectorTrigger.VARIABLE_GATE, + DetectorTrigger.CONSTANT_GATE, ]: await self._drv.acquire_time.set(trigger_info.livetime) diff --git a/src/ophyd_async/epics/adkinetix/_kinetix_io.py b/src/ophyd_async/epics/adkinetix/_kinetix_io.py index bbe53eb410..d2fda58562 100644 --- a/src/ophyd_async/epics/adkinetix/_kinetix_io.py +++ b/src/ophyd_async/epics/adkinetix/_kinetix_io.py @@ -4,16 +4,16 @@ class KinetixTriggerMode(StrictEnum): - internal = "Internal" - edge = "Rising Edge" - gate = "Exp. Gate" + INTERNAL = "Internal" + EDGE = "Rising Edge" + GATE = "Exp. Gate" class KinetixReadoutMode(StrictEnum): - sensitivity = 1 - speed = 2 - dynamic_range = 3 - sub_electron = 4 + SENSITIVITY = 1 + SPEED = 2 + DYNAMIC_RANGE = 3 + SUB_ELECTRON = 4 class KinetixDriverIO(adcore.ADBaseIO): diff --git a/src/ophyd_async/epics/adpilatus/_pilatus.py b/src/ophyd_async/epics/adpilatus/_pilatus.py index 113b780fa2..89c464c145 100644 --- a/src/ophyd_async/epics/adpilatus/_pilatus.py +++ b/src/ophyd_async/epics/adpilatus/_pilatus.py @@ -17,10 +17,10 @@ class PilatusReadoutTime(float, Enum): """Pilatus readout time per model in ms""" # Cite: https://media.dectris.com/User_Manual-PILATUS2-V1_4.pdf - pilatus2 = 2.28e-3 + PILATUS2 = 2.28e-3 # Cite: https://media.dectris.com/user-manual-pilatus3-2020.pdf - pilatus3 = 0.95e-3 + PILATUS3 = 0.95e-3 class PilatusDetector(StandardDetector): @@ -33,7 +33,7 @@ def __init__( self, prefix: str, path_provider: PathProvider, - readout_time: PilatusReadoutTime = PilatusReadoutTime.pilatus3, + readout_time: PilatusReadoutTime = PilatusReadoutTime.PILATUS3, drv_suffix: str = "cam1:", hdf_suffix: str = "HDF1:", name: str = "", diff --git a/src/ophyd_async/epics/adpilatus/_pilatus_controller.py b/src/ophyd_async/epics/adpilatus/_pilatus_controller.py index 89a47914f4..46966357b8 100644 --- a/src/ophyd_async/epics/adpilatus/_pilatus_controller.py +++ b/src/ophyd_async/epics/adpilatus/_pilatus_controller.py @@ -15,9 +15,9 @@ class PilatusController(DetectorController): _supported_trigger_types = { - DetectorTrigger.internal: PilatusTriggerMode.internal, - DetectorTrigger.constant_gate: PilatusTriggerMode.ext_enable, - DetectorTrigger.variable_gate: PilatusTriggerMode.ext_enable, + DetectorTrigger.INTERNAL: PilatusTriggerMode.INTERNAL, + DetectorTrigger.CONSTANT_GATE: PilatusTriggerMode.EXT_ENABLE, + DetectorTrigger.VARIABLE_GATE: PilatusTriggerMode.EXT_ENABLE, } def __init__( @@ -44,7 +44,7 @@ async def prepare(self, trigger_info: TriggerInfo): if trigger_info.total_number_of_triggers == 0 else trigger_info.total_number_of_triggers ), - self._drv.image_mode.set(adcore.ImageMode.multiple), + self._drv.image_mode.set(adcore.ImageMode.MULTIPLE), ) async def arm(self): diff --git a/src/ophyd_async/epics/adpilatus/_pilatus_io.py b/src/ophyd_async/epics/adpilatus/_pilatus_io.py index 093398ec61..54c69f72c8 100644 --- a/src/ophyd_async/epics/adpilatus/_pilatus_io.py +++ b/src/ophyd_async/epics/adpilatus/_pilatus_io.py @@ -4,11 +4,11 @@ class PilatusTriggerMode(StrictEnum): - internal = "Internal" - ext_enable = "Ext. Enable" - ext_trigger = "Ext. Trigger" - mult_trigger = "Mult. Trigger" - alignment = "Alignment" + INTERNAL = "Internal" + EXT_ENABLE = "Ext. Enable" + EXT_TRIGGER = "Ext. Trigger" + MULT_TRIGGER = "Mult. Trigger" + ALIGNMENT = "Alignment" class PilatusDriverIO(adcore.ADBaseIO): diff --git a/src/ophyd_async/epics/adsimdetector/_sim_controller.py b/src/ophyd_async/epics/adsimdetector/_sim_controller.py index cf10674f12..84b458c78b 100644 --- a/src/ophyd_async/epics/adsimdetector/_sim_controller.py +++ b/src/ophyd_async/epics/adsimdetector/_sim_controller.py @@ -26,14 +26,14 @@ def get_deadtime(self, exposure: float | None) -> float: async def prepare(self, trigger_info: TriggerInfo): assert ( - trigger_info.trigger == DetectorTrigger.internal + trigger_info.trigger == DetectorTrigger.INTERNAL ), "fly scanning (i.e. external triggering) is not supported for this device" self.frame_timeout = ( DEFAULT_TIMEOUT + await self.driver.acquire_time.get_value() ) await asyncio.gather( self.driver.num_images.set(trigger_info.total_number_of_triggers), - self.driver.image_mode.set(adcore.ImageMode.multiple), + self.driver.image_mode.set(adcore.ImageMode.MULTIPLE), ) async def arm(self): diff --git a/src/ophyd_async/epics/advimba/_vimba_controller.py b/src/ophyd_async/epics/advimba/_vimba_controller.py index 69aba6bf39..b96e5a208d 100644 --- a/src/ophyd_async/epics/advimba/_vimba_controller.py +++ b/src/ophyd_async/epics/advimba/_vimba_controller.py @@ -11,17 +11,17 @@ from ._vimba_io import VimbaDriverIO, VimbaExposeOutMode, VimbaOnOff, VimbaTriggerSource TRIGGER_MODE = { - DetectorTrigger.internal: VimbaOnOff.off, - DetectorTrigger.constant_gate: VimbaOnOff.on, - DetectorTrigger.variable_gate: VimbaOnOff.on, - DetectorTrigger.edge_trigger: VimbaOnOff.on, + DetectorTrigger.INTERNAL: VimbaOnOff.OFF, + DetectorTrigger.CONSTANT_GATE: VimbaOnOff.ON, + DetectorTrigger.VARIABLE_GATE: VimbaOnOff.ON, + DetectorTrigger.EDGE_TRIGGER: VimbaOnOff.ON, } EXPOSE_OUT_MODE = { - DetectorTrigger.internal: VimbaExposeOutMode.timed, - DetectorTrigger.constant_gate: VimbaExposeOutMode.trigger_width, - DetectorTrigger.variable_gate: VimbaExposeOutMode.trigger_width, - DetectorTrigger.edge_trigger: VimbaExposeOutMode.timed, + DetectorTrigger.INTERNAL: VimbaExposeOutMode.TIMED, + DetectorTrigger.CONSTANT_GATE: VimbaExposeOutMode.TRIGGER_WIDTH, + DetectorTrigger.VARIABLE_GATE: VimbaExposeOutMode.TRIGGER_WIDTH, + DetectorTrigger.EDGE_TRIGGER: VimbaExposeOutMode.TIMED, } @@ -41,17 +41,17 @@ async def prepare(self, trigger_info: TriggerInfo): self._drv.trigger_mode.set(TRIGGER_MODE[trigger_info.trigger]), self._drv.exposure_mode.set(EXPOSE_OUT_MODE[trigger_info.trigger]), self._drv.num_images.set(trigger_info.total_number_of_triggers), - self._drv.image_mode.set(adcore.ImageMode.multiple), + self._drv.image_mode.set(adcore.ImageMode.MULTIPLE), ) if trigger_info.livetime is not None and trigger_info.trigger not in [ - DetectorTrigger.variable_gate, - DetectorTrigger.constant_gate, + DetectorTrigger.VARIABLE_GATE, + DetectorTrigger.CONSTANT_GATE, ]: await self._drv.acquire_time.set(trigger_info.livetime) - if trigger_info.trigger != DetectorTrigger.internal: - self._drv.trigger_source.set(VimbaTriggerSource.line1) + if trigger_info.trigger != DetectorTrigger.INTERNAL: + self._drv.trigger_source.set(VimbaTriggerSource.LINE1) else: - self._drv.trigger_source.set(VimbaTriggerSource.freerun) + self._drv.trigger_source.set(VimbaTriggerSource.FREERUN) async def arm(self): self._arm_status = await adcore.start_acquiring_driver_and_ensure_status( diff --git a/src/ophyd_async/epics/advimba/_vimba_io.py b/src/ophyd_async/epics/advimba/_vimba_io.py index c95a873831..82d877d136 100644 --- a/src/ophyd_async/epics/advimba/_vimba_io.py +++ b/src/ophyd_async/epics/advimba/_vimba_io.py @@ -4,44 +4,44 @@ class VimbaPixelFormat(StrictEnum): - internal = "Mono8" - ext_enable = "Mono12" - ext_trigger = "Ext. Trigger" - mult_trigger = "Mult. Trigger" - alignment = "Alignment" + INTERNAL = "Mono8" + EXT_ENABLE = "Mono12" + EXT_TRIGGER = "Ext. Trigger" + MULT_TRIGGER = "Mult. Trigger" + ALIGNMENT = "Alignment" class VimbaConvertFormat(StrictEnum): - none = "None" - mono8 = "Mono8" - mono16 = "Mono16" - rgb8 = "RGB8" - rgb16 = "RGB16" + NONE = "None" + MONO8 = "Mono8" + MONO16 = "Mono16" + RGB8 = "RGB8" + RGB16 = "RGB16" class VimbaTriggerSource(StrictEnum): - freerun = "Freerun" - line1 = "Line1" - line2 = "Line2" - fixed_rate = "FixedRate" - software = "Software" - action0 = "Action0" - action1 = "Action1" + FREERUN = "Freerun" + LINE1 = "Line1" + LINE2 = "Line2" + FIXED_RATE = "FixedRate" + SOFTWARE = "Software" + ACTION0 = "Action0" + ACTION1 = "Action1" class VimbaOverlap(StrictEnum): - off = "Off" - prev_frame = "PreviousFrame" + OFF = "Off" + PREV_FRAME = "PreviousFrame" class VimbaOnOff(StrictEnum): - on = "On" - off = "Off" + ON = "On" + OFF = "Off" class VimbaExposeOutMode(StrictEnum): - timed = "Timed" # Use ExposureTime PV - trigger_width = "TriggerWidth" # Expose for length of high signal + TIMED = "Timed" # Use ExposureTime PV + TRIGGER_WIDTH = "TriggerWidth" # Expose for length of high signal class VimbaDriverIO(adcore.ADBaseIO): diff --git a/src/ophyd_async/epics/demo/_sensor.py b/src/ophyd_async/epics/demo/_sensor.py index 1004a04dae..0cc99d090a 100644 --- a/src/ophyd_async/epics/demo/_sensor.py +++ b/src/ophyd_async/epics/demo/_sensor.py @@ -15,9 +15,9 @@ class EnergyMode(StrictEnum): """Energy mode for `Sensor`""" #: Low energy mode - low = "Low Energy" + LOW = "Low Energy" #: High energy mode - high = "High Energy" + HIGH = "High Energy" class Sensor(StandardReadable, EpicsDevice): diff --git a/src/ophyd_async/epics/eiger/_eiger_controller.py b/src/ophyd_async/epics/eiger/_eiger_controller.py index b8d5319dad..2b5049eac2 100644 --- a/src/ophyd_async/epics/eiger/_eiger_controller.py +++ b/src/ophyd_async/epics/eiger/_eiger_controller.py @@ -11,10 +11,10 @@ from ._eiger_io import EigerDriverIO, EigerTriggerMode EIGER_TRIGGER_MODE_MAP = { - DetectorTrigger.internal: EigerTriggerMode.internal, - DetectorTrigger.constant_gate: EigerTriggerMode.gate, - DetectorTrigger.variable_gate: EigerTriggerMode.gate, - DetectorTrigger.edge_trigger: EigerTriggerMode.edge, + DetectorTrigger.INTERNAL: EigerTriggerMode.INTERNAL, + DetectorTrigger.CONSTANT_GATE: EigerTriggerMode.GATE, + DetectorTrigger.VARIABLE_GATE: EigerTriggerMode.GATE, + DetectorTrigger.EDGE_TRIGGER: EigerTriggerMode.EDGE, } diff --git a/src/ophyd_async/epics/eiger/_eiger_io.py b/src/ophyd_async/epics/eiger/_eiger_io.py index ef4451aa7d..484843ed30 100644 --- a/src/ophyd_async/epics/eiger/_eiger_io.py +++ b/src/ophyd_async/epics/eiger/_eiger_io.py @@ -3,9 +3,9 @@ class EigerTriggerMode(StrictEnum): - internal = "ints" - edge = "exts" - gate = "exte" + INTERNAL = "ints" + EDGE = "exts" + GATE = "exte" class EigerDriverIO(Device): diff --git a/src/ophyd_async/epics/testing/_example_ioc.py b/src/ophyd_async/epics/testing/_example_ioc.py index bffbf074b1..7c1b64ed11 100644 --- a/src/ophyd_async/epics/testing/_example_ioc.py +++ b/src/ophyd_async/epics/testing/_example_ioc.py @@ -23,9 +23,9 @@ class ExampleEnum(StrictEnum): - a = "Aaa" - b = "Bbb" - c = "Ccc" + A = "Aaa" + B = "Bbb" + C = "Ccc" class ExampleTable(Table): diff --git a/src/ophyd_async/fastcs/panda/_block.py b/src/ophyd_async/fastcs/panda/_block.py index 67767ba372..45943a491f 100644 --- a/src/ophyd_async/fastcs/panda/_block.py +++ b/src/ophyd_async/fastcs/panda/_block.py @@ -36,14 +36,14 @@ class PulseBlock(Device): class PcompDirection(StrictEnum): - positive = "Positive" - negative = "Negative" - either = "Either" + POSITIVE = "Positive" + NEGATIVE = "Negative" + EITHER = "Either" class BitMux(SubsetEnum): - zero = "ZERO" - one = "ONE" + ZERO = "ZERO" + ONE = "ONE" class PcompBlock(Device): @@ -57,10 +57,10 @@ class PcompBlock(Device): class TimeUnits(StrictEnum): - min = "min" - s = "s" - ms = "ms" - us = "us" + MIN = "min" + S = "s" + MS = "ms" + US = "us" class SeqBlock(Device): diff --git a/src/ophyd_async/fastcs/panda/_control.py b/src/ophyd_async/fastcs/panda/_control.py index 1fe14c7909..35a995aaae 100644 --- a/src/ophyd_async/fastcs/panda/_control.py +++ b/src/ophyd_async/fastcs/panda/_control.py @@ -19,8 +19,8 @@ def get_deadtime(self, exposure: float | None) -> float: async def prepare(self, trigger_info: TriggerInfo): assert trigger_info.trigger in ( - DetectorTrigger.constant_gate, - DetectorTrigger.variable_gate, + DetectorTrigger.CONSTANT_GATE, + DetectorTrigger.VARIABLE_GATE, ), "Only constant_gate and variable_gate triggering is supported on the PandA" async def arm(self): diff --git a/src/ophyd_async/fastcs/panda/_trigger.py b/src/ophyd_async/fastcs/panda/_trigger.py index 0aa3633760..05702a0b14 100644 --- a/src/ophyd_async/fastcs/panda/_trigger.py +++ b/src/ophyd_async/fastcs/panda/_trigger.py @@ -20,8 +20,8 @@ def __init__(self, seq: SeqBlock) -> None: async def prepare(self, value: SeqTableInfo): await asyncio.gather( - self.seq.prescale_units.set(TimeUnits.us), - self.seq.enable.set(BitMux.zero), + self.seq.prescale_units.set(TimeUnits.US), + self.seq.enable.set(BitMux.ZERO), ) await asyncio.gather( self.seq.prescale.set(value.prescale_as_us), @@ -30,14 +30,14 @@ async def prepare(self, value: SeqTableInfo): ) async def kickoff(self) -> None: - await self.seq.enable.set(BitMux.one) + await self.seq.enable.set(BitMux.ONE) await wait_for_value(self.seq.active, True, timeout=1) async def complete(self) -> None: await wait_for_value(self.seq.active, False, timeout=None) async def stop(self): - await self.seq.enable.set(BitMux.zero) + await self.seq.enable.set(BitMux.ZERO) await wait_for_value(self.seq.active, False, timeout=1) @@ -68,7 +68,7 @@ def __init__(self, pcomp: PcompBlock) -> None: self.pcomp = pcomp async def prepare(self, value: PcompInfo): - await self.pcomp.enable.set(BitMux.zero) + await self.pcomp.enable.set(BitMux.ZERO) await asyncio.gather( self.pcomp.start.set(value.start_postion), self.pcomp.width.set(value.pulse_width), @@ -78,12 +78,12 @@ async def prepare(self, value: PcompInfo): ) async def kickoff(self) -> None: - await self.pcomp.enable.set(BitMux.one) + await self.pcomp.enable.set(BitMux.ONE) await wait_for_value(self.pcomp.active, True, timeout=1) async def complete(self, timeout: float | None = None) -> None: await wait_for_value(self.pcomp.active, False, timeout=timeout) async def stop(self): - await self.pcomp.enable.set(BitMux.zero) + await self.pcomp.enable.set(BitMux.ZERO) await wait_for_value(self.pcomp.active, False, timeout=1) diff --git a/src/ophyd_async/plan_stubs/_fly.py b/src/ophyd_async/plan_stubs/_fly.py index d2e757681e..c4f2e81a2a 100644 --- a/src/ophyd_async/plan_stubs/_fly.py +++ b/src/ophyd_async/plan_stubs/_fly.py @@ -62,7 +62,7 @@ def prepare_static_seq_table_flyer_and_detectors_with_same_trigger( trigger_info = TriggerInfo( number_of_triggers=number_of_frames * repeats, - trigger=DetectorTrigger.constant_gate, + trigger=DetectorTrigger.CONSTANT_GATE, deadtime=deadtime, livetime=exposure, frame_timeout=frame_timeout, diff --git a/system_tests/epics/eiger/test_eiger_system.py b/system_tests/epics/eiger/test_eiger_system.py index 4cfc81dae3..8a27c41689 100644 --- a/system_tests/epics/eiger/test_eiger_system.py +++ b/system_tests/epics/eiger/test_eiger_system.py @@ -72,7 +72,7 @@ async def test_trigger_saves_file(test_eiger: EigerDetector, setup_device: Setup single_shot = EigerTriggerInfo( frame_timeout=None, number_of_triggers=1, - trigger=DetectorTrigger.internal, + trigger=DetectorTrigger.INTERNAL, deadtime=None, livetime=None, energy_ev=10000, diff --git a/tests/conftest.py b/tests/conftest.py index 3bcab2a2b1..1ac45442b0 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -236,7 +236,7 @@ def one_shot_trigger_info() -> TriggerInfo: return TriggerInfo( frame_timeout=None, number_of_triggers=1, - trigger=DetectorTrigger.internal, + trigger=DetectorTrigger.INTERNAL, deadtime=None, livetime=None, ) diff --git a/tests/core/test_device_save_loader.py b/tests/core/test_device_save_loader.py index 2eb1b6967d..f4a5711da5 100644 --- a/tests/core/test_device_save_loader.py +++ b/tests/core/test_device_save_loader.py @@ -95,7 +95,7 @@ async def test_save_device_all_types( await device_all_types.my_int.set(1) await device_all_types.my_float.set(1.234) await device_all_types.my_str.set("test_string") - await device_all_types.enum.set(ExampleEnum.b) + await device_all_types.enum.set(ExampleEnum.B) await device_all_types.enum2.set("Bbb") for pv, dtype in { device_all_types.int8a: np.int8, @@ -141,7 +141,7 @@ async def test_save_device_all_types( int=np.array([1, 8, -9, 32], np.int32), float=np.array([1.8, 8.2, -6, 32.9887], np.float64), str=["Hello", "World", "Foo", "Bar"], - enum=[ExampleEnum.a, ExampleEnum.b, ExampleEnum.a, ExampleEnum.c], + enum=[ExampleEnum.A, ExampleEnum.B, ExampleEnum.A, ExampleEnum.C], ) ) diff --git a/tests/core/test_flyer.py b/tests/core/test_flyer.py index 6c894974b2..44b353534a 100644 --- a/tests/core/test_flyer.py +++ b/tests/core/test_flyer.py @@ -28,28 +28,28 @@ class TriggerState(StrictEnum): - null = "null" - preparing = "preparing" - starting = "starting" - stopping = "stopping" + NULL = "null" + PREPARING = "preparing" + STARTING = "starting" + STOPPING = "stopping" class DummyTriggerLogic(FlyerController[int]): def __init__(self): - self.state = TriggerState.null + self.state = TriggerState.NULL async def prepare(self, value: int): - self.state = TriggerState.preparing + self.state = TriggerState.PREPARING return value async def kickoff(self): - self.state = TriggerState.starting + self.state = TriggerState.STARTING async def complete(self): - self.state = TriggerState.null + self.state = TriggerState.NULL async def stop(self): - self.state = TriggerState.stopping + self.state = TriggerState.STOPPING class DummyWriter(DetectorWriter): @@ -160,7 +160,7 @@ def append_and_print(name, doc): def flying_plan(): yield from bps.stage_all(*detectors, flyer) - assert flyer._trigger_logic.state == TriggerState.stopping + assert flyer._trigger_logic.state == TriggerState.STOPPING # move the flyer to the correct place, before fly scanning. # Prepare the flyer first to get the trigger info for the detectors @@ -172,14 +172,14 @@ def flying_plan(): detector, TriggerInfo( number_of_triggers=number_of_triggers, - trigger=DetectorTrigger.constant_gate, + trigger=DetectorTrigger.CONSTANT_GATE, deadtime=2, livetime=2, ), wait=True, ) - assert flyer._trigger_logic.state == TriggerState.preparing + assert flyer._trigger_logic.state == TriggerState.PREPARING for detector in detectors: detector.controller.disarm.assert_called_once() # type: ignore @@ -195,7 +195,7 @@ def flying_plan(): for detector in detectors: yield from bps.complete(detector, wait=False, group="complete") - assert flyer._trigger_logic.state == TriggerState.null + assert flyer._trigger_logic.state == TriggerState.NULL # Manually increment the index as if a frame was taken frames_completed += frames @@ -227,7 +227,7 @@ def flying_plan(): yield from bps.unstage_all(flyer, *detectors) for detector in detectors: assert detector.controller.disarm.called # type: ignore - assert trigger_logic.state == TriggerState.stopping + assert trigger_logic.state == TriggerState.STOPPING # fly scan RE(flying_plan()) @@ -282,14 +282,14 @@ async def test_hardware_triggered_flyable_too_many_kickoffs( flyer = StandardFlyer(trigger_logic, name="flyer") trigger_info = TriggerInfo( number_of_triggers=number_of_triggers, - trigger=DetectorTrigger.constant_gate, + trigger=DetectorTrigger.CONSTANT_GATE, deadtime=2, livetime=2, ) def flying_plan(): yield from bps.stage_all(*detectors, flyer) - assert flyer._trigger_logic.state == TriggerState.stopping + assert flyer._trigger_logic.state == TriggerState.STOPPING # move the flyer to the correct place, before fly scanning. # Prepare the flyer first to get the trigger info for the detectors @@ -316,7 +316,7 @@ def flying_plan(): for detector in detectors: yield from bps.complete(detector, wait=False, group="complete") - assert flyer._trigger_logic.state == TriggerState.null + assert flyer._trigger_logic.state == TriggerState.NULL # Manually increment the index as if a frame was taken for detector in detectors: @@ -367,7 +367,7 @@ def flying_plan(): ( { "number_of_triggers": 1, - "trigger": DetectorTrigger.constant_gate, + "trigger": DetectorTrigger.CONSTANT_GATE, "deadtime": 2, "livetime": 2, "frame_timeout": "a", @@ -388,7 +388,7 @@ def flying_plan(): ( { "number_of_triggers": 1, - "trigger": DetectorTrigger.internal, + "trigger": DetectorTrigger.INTERNAL, "deadtime": 2, "livetime": 1, "frame_timeout": -1, diff --git a/tests/core/test_soft_signal_backend.py b/tests/core/test_soft_signal_backend.py index 89eb87cc36..f5c0b15c88 100644 --- a/tests/core/test_soft_signal_backend.py +++ b/tests/core/test_soft_signal_backend.py @@ -19,9 +19,9 @@ class MyEnum(StrictEnum): - a = "Aaa" - b = "Bbb" - c = "Ccc" + A = "Aaa" + B = "Bbb" + C = "Ccc" def integer_d(value): @@ -80,7 +80,7 @@ def close(self): (int, 0, 43, integer_d, default_int_type), (float, 0.0, 43.5, number_d, " adpilatus.PilatusDetector: async def test_deadtime_overridable(test_adpilatus: adpilatus.PilatusDetector): pilatus_controller = test_adpilatus._controller - pilatus_controller._readout_time = adpilatus.PilatusReadoutTime.pilatus2 + pilatus_controller._readout_time = adpilatus.PilatusReadoutTime.PILATUS2 # deadtime invariant with exposure time assert pilatus_controller.get_deadtime(0) == 2.28e-3 @@ -37,9 +37,9 @@ async def test_deadtime_invariant( @pytest.mark.parametrize( "detector_trigger,expected_trigger_mode", [ - (DetectorTrigger.internal, adpilatus.PilatusTriggerMode.internal), - (DetectorTrigger.internal, adpilatus.PilatusTriggerMode.internal), - (DetectorTrigger.internal, adpilatus.PilatusTriggerMode.internal), + (DetectorTrigger.INTERNAL, adpilatus.PilatusTriggerMode.INTERNAL), + (DetectorTrigger.INTERNAL, adpilatus.PilatusTriggerMode.INTERNAL), + (DetectorTrigger.INTERNAL, adpilatus.PilatusTriggerMode.INTERNAL), ], ) async def test_trigger_mode_set( @@ -63,7 +63,7 @@ async def test_trigger_mode_set_without_armed_pv( ): async def trigger_and_complete(): await test_adpilatus.controller.prepare( - TriggerInfo(number_of_triggers=1, trigger=DetectorTrigger.internal) + TriggerInfo(number_of_triggers=1, trigger=DetectorTrigger.INTERNAL) ) await test_adpilatus.controller.arm() await test_adpilatus.controller.wait_for_idle() @@ -75,7 +75,7 @@ async def trigger_and_complete(): with pytest.raises(asyncio.TimeoutError): await _trigger( test_adpilatus, - adpilatus.PilatusTriggerMode.internal, + adpilatus.PilatusTriggerMode.INTERNAL, trigger_and_complete, ) @@ -88,7 +88,7 @@ async def _trigger( # Default TriggerMode assert ( await test_adpilatus.drv.trigger_mode.get_value() - ) == adpilatus.PilatusTriggerMode.internal + ) == adpilatus.PilatusTriggerMode.INTERNAL await trigger_and_complete() @@ -109,7 +109,7 @@ async def test_unsupported_trigger_excepts(test_adpilatus: adpilatus.PilatusDete await test_adpilatus.prepare( TriggerInfo( number_of_triggers=1, - trigger=DetectorTrigger.edge_trigger, + trigger=DetectorTrigger.EDGE_TRIGGER, deadtime=1.0, livetime=1.0, ) @@ -127,7 +127,7 @@ async def dummy_open(multiplier: int = 0): await test_adpilatus.prepare( TriggerInfo( number_of_triggers=1, - trigger=DetectorTrigger.internal, + trigger=DetectorTrigger.INTERNAL, deadtime=1.0, livetime=1.0, ) @@ -141,16 +141,16 @@ async def test_pilatus_controller(test_adpilatus: adpilatus.PilatusDetector): pilatus_driver = pilatus._drv set_mock_value(pilatus_driver.armed, True) await pilatus.prepare( - TriggerInfo(number_of_triggers=1, trigger=DetectorTrigger.constant_gate) + TriggerInfo(number_of_triggers=1, trigger=DetectorTrigger.CONSTANT_GATE) ) await pilatus.arm() await pilatus.wait_for_idle() assert await pilatus_driver.num_images.get_value() == 1 - assert await pilatus_driver.image_mode.get_value() == adcore.ImageMode.multiple + assert await pilatus_driver.image_mode.get_value() == adcore.ImageMode.MULTIPLE assert ( await pilatus_driver.trigger_mode.get_value() - == adpilatus.PilatusTriggerMode.ext_enable + == adpilatus.PilatusTriggerMode.EXT_ENABLE ) assert await pilatus_driver.acquire.get_value() is True diff --git a/tests/epics/adsimdetector/test_sim.py b/tests/epics/adsimdetector/test_sim.py index ecb446a6e1..5ab7dea121 100644 --- a/tests/epics/adsimdetector/test_sim.py +++ b/tests/epics/adsimdetector/test_sim.py @@ -78,7 +78,7 @@ async def test_two_detectors_fly_different_rate( ): trigger_info = TriggerInfo( number_of_triggers=15, - trigger=DetectorTrigger.internal, + trigger=DetectorTrigger.INTERNAL, ) docs = defaultdict(list) @@ -166,13 +166,13 @@ def plan(): drv = controller_a.driver assert False is (yield from bps.rd(drv.acquire)) - assert adcore.ImageMode.multiple == (yield from bps.rd(drv.image_mode)) + assert adcore.ImageMode.MULTIPLE == (yield from bps.rd(drv.image_mode)) hdfb = writer_b.hdf assert True is (yield from bps.rd(hdfb.lazy_open)) assert True is (yield from bps.rd(hdfb.swmr_mode)) assert 0 == (yield from bps.rd(hdfb.num_capture)) - assert adcore.FileWriteMode.stream == (yield from bps.rd(hdfb.file_write_mode)) + assert adcore.FileWriteMode.STREAM == (yield from bps.rd(hdfb.file_write_mode)) assert (yield from bps.rd(writer_a.hdf.file_path)) == str(info_a.directory_path) file_name_a = yield from bps.rd(writer_a.hdf.file_name) @@ -364,14 +364,14 @@ async def test_ad_sim_controller(test_adsimdetector: adsimdetector.SimDetector): ad = test_adsimdetector._controller with patch("ophyd_async.core._signal.wait_for_value", return_value=None): await ad.prepare( - TriggerInfo(number_of_triggers=1, trigger=DetectorTrigger.internal) + TriggerInfo(number_of_triggers=1, trigger=DetectorTrigger.INTERNAL) ) await ad.arm() await ad.wait_for_idle() driver = ad.driver assert await driver.num_images.get_value() == 1 - assert await driver.image_mode.get_value() == adcore.ImageMode.multiple + assert await driver.image_mode.get_value() == adcore.ImageMode.MULTIPLE assert await driver.acquire.get_value() is True await ad.disarm() diff --git a/tests/epics/advimba/test_vimba.py b/tests/epics/advimba/test_vimba.py index 2e9c484bc5..adede5f362 100644 --- a/tests/epics/advimba/test_vimba.py +++ b/tests/epics/advimba/test_vimba.py @@ -27,9 +27,9 @@ async def test_get_deadtime( async def test_arming_trig_modes(test_advimba: advimba.VimbaDetector): - set_mock_value(test_advimba.drv.trigger_source, VimbaTriggerSource.freerun) - set_mock_value(test_advimba.drv.trigger_mode, VimbaOnOff.off) - set_mock_value(test_advimba.drv.exposure_mode, VimbaExposeOutMode.timed) + set_mock_value(test_advimba.drv.trigger_source, VimbaTriggerSource.FREERUN) + set_mock_value(test_advimba.drv.trigger_mode, VimbaOnOff.OFF) + set_mock_value(test_advimba.drv.exposure_mode, VimbaExposeOutMode.TIMED) async def setup_trigger_mode(trig_mode: DetectorTrigger): await test_advimba.controller.prepare( @@ -45,22 +45,22 @@ async def setup_trigger_mode(trig_mode: DetectorTrigger): assert (await test_advimba.drv.trigger_mode.get_value()) == "Off" assert (await test_advimba.drv.exposure_mode.get_value()) == "Timed" - await setup_trigger_mode(DetectorTrigger.edge_trigger) + await setup_trigger_mode(DetectorTrigger.EDGE_TRIGGER) assert (await test_advimba.drv.trigger_source.get_value()) == "Line1" assert (await test_advimba.drv.trigger_mode.get_value()) == "On" assert (await test_advimba.drv.exposure_mode.get_value()) == "Timed" - await setup_trigger_mode(DetectorTrigger.constant_gate) + await setup_trigger_mode(DetectorTrigger.CONSTANT_GATE) assert (await test_advimba.drv.trigger_source.get_value()) == "Line1" assert (await test_advimba.drv.trigger_mode.get_value()) == "On" assert (await test_advimba.drv.exposure_mode.get_value()) == "TriggerWidth" - await setup_trigger_mode(DetectorTrigger.internal) + await setup_trigger_mode(DetectorTrigger.INTERNAL) assert (await test_advimba.drv.trigger_source.get_value()) == "Freerun" assert (await test_advimba.drv.trigger_mode.get_value()) == "Off" assert (await test_advimba.drv.exposure_mode.get_value()) == "Timed" - await setup_trigger_mode(DetectorTrigger.variable_gate) + await setup_trigger_mode(DetectorTrigger.VARIABLE_GATE) assert (await test_advimba.drv.trigger_source.get_value()) == "Line1" assert (await test_advimba.drv.trigger_mode.get_value()) == "On" assert (await test_advimba.drv.exposure_mode.get_value()) == "TriggerWidth" diff --git a/tests/epics/demo/test_demo.py b/tests/epics/demo/test_demo.py index e29e13bf29..333d1a78a7 100644 --- a/tests/epics/demo/test_demo.py +++ b/tests/epics/demo/test_demo.py @@ -279,14 +279,14 @@ async def test_read_sensor(mock_sensor: demo.Sensor): assert (await mock_sensor.read())["mock_sensor-value"]["value"] == 0 assert (await mock_sensor.read_configuration())["mock_sensor-mode"][ "value" - ] == demo.EnergyMode.low + ] == demo.EnergyMode.LOW desc = (await mock_sensor.describe_configuration())["mock_sensor-mode"] assert desc["dtype"] == "string" assert desc["choices"] == ["Low Energy", "High Energy"] - set_mock_value(mock_sensor.mode, demo.EnergyMode.high) + set_mock_value(mock_sensor.mode, demo.EnergyMode.HIGH) assert (await mock_sensor.read_configuration())["mock_sensor-mode"][ "value" - ] == demo.EnergyMode.high + ] == demo.EnergyMode.HIGH async def test_sensor_in_plan(RE: RunEngine, mock_sensor: demo.Sensor): diff --git a/tests/epics/eiger/test_eiger_detector.py b/tests/epics/eiger/test_eiger_detector.py index 5fe6ebc836..422da84cf1 100644 --- a/tests/epics/eiger/test_eiger_detector.py +++ b/tests/epics/eiger/test_eiger_detector.py @@ -26,7 +26,7 @@ async def test_when_prepared_with_energy_then_energy_set_on_detector(detector): EigerTriggerInfo( frame_timeout=None, number_of_triggers=1, - trigger=DetectorTrigger.internal, + trigger=DetectorTrigger.INTERNAL, deadtime=None, livetime=None, energy_ev=10000, diff --git a/tests/epics/signal/test_signals.py b/tests/epics/signal/test_signals.py index 07e8a21950..b44221b192 100644 --- a/tests/epics/signal/test_signals.py +++ b/tests/epics/signal/test_signals.py @@ -49,9 +49,9 @@ class MySubsetEnum(SubsetEnum): - a = "Aaa" - b = "Bbb" - c = "Ccc" + A = "Aaa" + B = "Bbb" + C = "Ccc" Protocol = Literal["ca", "pva"] @@ -307,7 +307,7 @@ async def assert_backend_get_put_monitor( (int, "my_int", 42, 43), (float, "my_float", 3.141, 43.5), (str, "my_str", "hello", "goodbye"), - (ExampleEnum, "enum", ExampleEnum.b, ExampleEnum.c), + (ExampleEnum, "enum", ExampleEnum.B, ExampleEnum.C), # numpy arrays of numpy types ( Array1D[np.uint8], @@ -495,9 +495,9 @@ async def test_error_raised_on_disconnected_PV(ioc, protocol) -> None: class BadEnum(StrictEnum): - a = "Aaa" - b = "B" - c = "Ccc" + A = "Aaa" + B = "B" + C = "Ccc" def test_enum_equality(): @@ -507,39 +507,39 @@ def test_enum_equality(): """ class GeneratedChoices(StrictEnum): - a = "Aaa" - b = "B" - c = "Ccc" + A = "Aaa" + B = "B" + C = "Ccc" class ExtendedGeneratedChoices(StrictEnum): - a = "Aaa" - b = "B" - c = "Ccc" - d = "Ddd" + A = "Aaa" + B = "B" + C = "Ccc" + D = "Ddd" for enum_class in (GeneratedChoices, ExtendedGeneratedChoices): - assert BadEnum.a == enum_class.a - assert BadEnum.a.value == enum_class.a - assert BadEnum.a.value == enum_class.a.value - assert BadEnum(enum_class.a) is BadEnum.a - assert BadEnum(enum_class.a.value) is BadEnum.a + assert BadEnum.A == enum_class.A + assert BadEnum.A.value == enum_class.A + assert BadEnum.A.value == enum_class.A.value + assert BadEnum(enum_class.A) is BadEnum.A + assert BadEnum(enum_class.A.value) is BadEnum.A assert not BadEnum == enum_class # We will always PUT BadEnum by String, and GET GeneratedChoices by index, # so shouldn't ever run across this from conversion code, but may occur if # casting returned values or passing as enum rather than value. with pytest.raises(ValueError): - BadEnum(ExtendedGeneratedChoices.d) + BadEnum(ExtendedGeneratedChoices.D) class EnumNoString(Enum): - a = "Aaa" + A = "Aaa" class SubsetEnumWrongChoices(SubsetEnum): - a = "Aaa" - b = "B" - c = "Ccc" + A = "Aaa" + B = "B" + C = "Ccc" @PARAMETERISE_PROTOCOLS @@ -612,7 +612,7 @@ async def test_backend_put_enum_string(ioc, protocol) -> None: backend = device.enum2._connector.backend # Don't do this in production code, but allow on CLI await backend.put("Ccc", wait=True) # type: ignore - assert ExampleEnum.c == await backend.get_value() + assert ExampleEnum.C == await backend.get_value() @PARAMETERISE_PROTOCOLS @@ -626,7 +626,7 @@ async def test_backend_get_setpoint(ioc, protocol) -> None: device = await connect_example_device(ioc, protocol) backend = device.enum2._connector.backend await backend.put("Ccc", wait=True) - assert await backend.get_setpoint() == ExampleEnum.c + assert await backend.get_setpoint() == ExampleEnum.C def approx_table(datatype: type[Table], table: Table): @@ -647,14 +647,14 @@ async def test_pva_table(ioc) -> None: int=np.array([1, 8, -9, 32], np.int32), float=np.array([1.8, 8.2, -6, 32.9887], np.float64), str=["Hello", "World", "Foo", "Bar"], - enum=[ExampleEnum.a, ExampleEnum.b, ExampleEnum.a, ExampleEnum.c], + enum=[ExampleEnum.A, ExampleEnum.B, ExampleEnum.A, ExampleEnum.C], ) put = ExampleTable( bool=np.array([True, False], np.bool_), int=np.array([-5, 32], np.int32), float=np.array([8.5, -6.97], np.float64), str=["Hello", "Bat"], - enum=[ExampleEnum.c, ExampleEnum.b], + enum=[ExampleEnum.C, ExampleEnum.B], ) # Make and connect the backend for t, i, p in [(ExampleTable, initial, put), (None, put, initial)]: @@ -774,8 +774,8 @@ def test_signal_helpers(): async def test_str_enum_returns_enum(ioc, protocol): device = await connect_example_device(ioc, protocol) val = await device.enum.get_value() - assert repr(val) == "" - assert val is ExampleEnum.b + assert repr(val) == "" + assert val is ExampleEnum.B assert val == "Bbb" diff --git a/tests/fastcs/panda/test_panda_control.py b/tests/fastcs/panda/test_panda_control.py index 4f9bb8c546..867d97330a 100644 --- a/tests/fastcs/panda/test_panda_control.py +++ b/tests/fastcs/panda/test_panda_control.py @@ -30,7 +30,7 @@ class PcapBlock(Device): with patch("ophyd_async.fastcs.panda._control.wait_for_value", return_value=None): with pytest.raises(AttributeError) as exc: await pandaController.prepare( - TriggerInfo(number_of_triggers=1, trigger=DetectorTrigger.constant_gate) + TriggerInfo(number_of_triggers=1, trigger=DetectorTrigger.CONSTANT_GATE) ) await pandaController.arm() assert ("'PcapBlock' object has no attribute 'arm'") in str(exc.value) @@ -40,7 +40,7 @@ async def test_panda_controller_arm_disarm(mock_panda): pandaController = PandaPcapController(mock_panda.pcap) with patch("ophyd_async.fastcs.panda._control.wait_for_value", return_value=None): await pandaController.prepare( - TriggerInfo(number_of_triggers=1, trigger=DetectorTrigger.constant_gate) + TriggerInfo(number_of_triggers=1, trigger=DetectorTrigger.CONSTANT_GATE) ) await pandaController.arm() await pandaController.wait_for_idle() @@ -51,5 +51,5 @@ async def test_panda_controller_wrong_trigger(): pandaController = PandaPcapController(None) with pytest.raises(AssertionError): await pandaController.prepare( - TriggerInfo(number_of_triggers=1, trigger=DetectorTrigger.internal) + TriggerInfo(number_of_triggers=1, trigger=DetectorTrigger.INTERNAL) ) diff --git a/tests/fastcs/panda/test_trigger.py b/tests/fastcs/panda/test_trigger.py index f12b5f6051..af92c817f2 100644 --- a/tests/fastcs/panda/test_trigger.py +++ b/tests/fastcs/panda/test_trigger.py @@ -57,7 +57,7 @@ async def test_pcomp_trigger_logic(mock_panda): pulse_width=1, rising_edge_step=1, number_of_pulses=5, - direction=PcompDirection.positive, + direction=PcompDirection.POSITIVE, ) async def set_active(value: bool):