Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add no fields if no signal name #366

Merged
merged 6 commits into from
Jun 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading