Skip to content

Commit

Permalink
fixed incorrect formatting of enum values on soft signal set (#417)
Browse files Browse the repository at this point in the history
  • Loading branch information
evalott100 authored Jun 26, 2024
1 parent d739f0f commit ce3b85d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
5 changes: 1 addition & 4 deletions src/ophyd_async/core/soft_signal_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,7 @@ def __init__(self, datatype: Union[RuntimeSubsetEnum, Enum]):
self.choices = datatype.choices

def write_value(self, value: Union[Enum, str]) -> str:
if isinstance(value, Enum):
return value.value
else: # Runtime enum
return value
return value

def get_datakey(self, source: str, value, **metadata) -> DataKey:
return {
Expand Down
8 changes: 8 additions & 0 deletions tests/core/test_soft_signal_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,14 @@ async def test_soft_signal_backend_get_put_monitor(
q.close()


async def test_soft_signal_backend_enum_value_equivalence():
soft_signal = SoftSignalBackend(MyEnum)
await soft_signal.connect()
assert (await soft_signal.get_value()) is MyEnum.a
await soft_signal.put(MyEnum.b)
assert (await soft_signal.get_value()) is MyEnum.b


async def test_soft_signal_backend_with_numpy_typing():
soft_backend = SoftSignalBackend(npt.NDArray[np.float64])
await soft_backend.connect()
Expand Down

0 comments on commit ce3b85d

Please sign in to comment.