bluesky / ophyd-async

Hardware abstraction for bluesky written using asyncio
https://blueskyproject.io/ophyd-async
BSD 3-Clause "New" or "Revised" License
10 stars 23 forks source link

Mock table signals should have sensible default values #390

Open callumforrester opened 3 months ago

callumforrester commented 3 months ago

The expected behaviour of signals with mock backends is that they have a sensible default value for their type. For example, int signals default to 0.

For table signals, whose type is a typed dict, the default is {}. For consistent behaviour with the rest of ophyd-async, I think it should mirror the required types of the dictionary, for example:

class MyTable(TypedDict):
    foo: npt.ndarray[int]
    bar: npt.ndarray[float]

class MyDevice(Device):
    def __init__(self):
        self.table = epics_signal_r(MyTable, "PREFIX")

with DeviceCollector(mock=True):
    device = MyDevice()

The value of table would be {}, I think it should be {"foo": [], "bar": []}