Skip to content

Commit 6536a48

Browse files
author
James Souter
committed
zero initialise WaveformWs in ca transport
1 parent c9aeea3 commit 6536a48

File tree

2 files changed

+4
-6
lines changed

2 files changed

+4
-6
lines changed

src/fastcs/transport/epics/ca/util.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
from dataclasses import asdict
22

3-
import numpy as np
43
from softioc import builder
54

65
from fastcs.attributes import Attribute, AttrR, AttrRW, AttrW
@@ -45,17 +44,17 @@
4544

4645
def record_metadata_from_attribute(
4746
attribute: Attribute[T],
48-
) -> dict[str, str | None]:
47+
) -> dict[str, str | object | None]:
4948
"""Converts attributes on the `Attribute` to the
5049
field name/value in the record metadata."""
51-
metadata = {"DESC": attribute.description}
50+
metadata: dict[str, str | object | None] = {"DESC": attribute.description}
5251
initial = None
5352
match attribute:
5453
case AttrR():
5554
initial = attribute.get()
5655
case AttrW():
5756
initial = attribute.datatype.initial_value
58-
if np.any(initial):
57+
if initial is not None:
5958
metadata["initial_value"] = cast_to_epics_type(attribute.datatype, initial)
6059
return metadata
6160

tests/transport/epics/ca/test_initial_value.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,7 @@ async def test_initial_values_set_in_ca(mocker):
105105
18,
106106
19,
107107
],
108-
# waveforms are not zero initialised currently
109-
"SOFTIOC_INITIAL_DEVICE:WaveformW": [],
108+
"SOFTIOC_INITIAL_DEVICE:WaveformW": 10 * [0],
110109
"SOFTIOC_INITIAL_DEVICE:Waveform_RBV": [0, 1, 2, 3, 4, 5, 6, 7, 8, 9],
111110
}.items():
112111
assert np.array_equal(value, initial_values[name])

0 commit comments

Comments
 (0)