Skip to content

Commit

Permalink
add no fields if no signal name (#366)
Browse files Browse the repository at this point in the history
* add no fields if no signal name

* fix trailing whitespace

* add the test

* fix the imports

* add an assert line and try changing encodings

* add new line at the end
  • Loading branch information
stan-dot committed Jun 5, 2024
1 parent 6ee3cfd commit 0b05b9c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/ophyd_async/core/standard_readable.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,8 @@ def name(self) -> str:

@property
def hints(self) -> Hints:
if self.signal.name == "":
return {"fields": []}
return {"fields": [self.signal.name]}

@classmethod
Expand Down
13 changes: 12 additions & 1 deletion tests/core/test_standard_readable.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from ophyd_async.core import ConfigSignal, HintedSignal, StandardReadable
from ophyd_async.core.device import Device, DeviceVector
from ophyd_async.core.mock_signal_backend import MockSignalBackend
from ophyd_async.core.signal import SignalR
from ophyd_async.core.signal import SignalR, soft_signal_r_and_setter
from ophyd_async.protocols import AsyncConfigurable, AsyncReadable, AsyncStageable


Expand Down Expand Up @@ -219,3 +219,14 @@ def test_standard_readable_set_readable_signals():
assert all(isinstance(x, ConfigSignal) for x in sr._configurables)
assert len(sr._stageables) == 1
assert all(isinstance(x, HintedSignal) for x in sr._stageables)


def test_standard_readable_add_children_multi_nested():
inner = StandardReadable()
outer = StandardReadable()
with inner.add_children_as_readables(HintedSignal):
inner.a, _ = soft_signal_r_and_setter(float, initial_value=5.0)
inner.b, _ = soft_signal_r_and_setter(float, initial_value=6.0)
with outer.add_children_as_readables():
outer.inner = inner
assert outer

0 comments on commit 0b05b9c

Please sign in to comment.