From 64c8c25dec9b9511e39fea9b924da75ed4879ec9 Mon Sep 17 00:00:00 2001 From: Matt Clarke Date: Fri, 8 Sep 2023 14:40:35 +0200 Subject: [PATCH] Deserialising ADAr populates the dimensions field (#90) --- streaming_data_types/_version.py | 2 +- streaming_data_types/area_detector_ADAr.py | 2 ++ tests/test_ADAr.py | 2 ++ 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/streaming_data_types/_version.py b/streaming_data_types/_version.py index b1225ca..2a84c92 100644 --- a/streaming_data_types/_version.py +++ b/streaming_data_types/_version.py @@ -1,4 +1,4 @@ # Version is not directly defined in __init__ because that causes all # run time dependencies to become build-time dependencies when it is # imported in setup.py -version = "0.22.1" +version = "0.23.0" diff --git a/streaming_data_types/area_detector_ADAr.py b/streaming_data_types/area_detector_ADAr.py index 2ca7381..3eba0e1 100644 --- a/streaming_data_types/area_detector_ADAr.py +++ b/streaming_data_types/area_detector_ADAr.py @@ -130,6 +130,7 @@ def serialise_ADAr( ("source_name", str), ("unique_id", int), ("timestamp", datetime), + ("dimensions", np.ndarray), ("data", np.ndarray), ("attributes", List[Attribute]), ), @@ -200,6 +201,7 @@ def deserialise_ADAr(buffer: Union[bytearray, bytes]) -> ADArray: source_name=ad_array.SourceName().decode(), unique_id=unique_id, timestamp=datetime.fromtimestamp(used_timestamp, tz=timezone.utc), + dimensions=ad_array.DimensionsAsNumpy(), data=data, attributes=attributes_list, ) diff --git a/tests/test_ADAr.py b/tests/test_ADAr.py index 1840dc0..7ffc7ca 100644 --- a/tests/test_ADAr.py +++ b/tests/test_ADAr.py @@ -36,6 +36,8 @@ def test_serialises_and_deserialises_ADAr_int_array(self): assert entry.unique_id == original_entry["unique_id"] assert entry.source_name == original_entry["source_name"] assert entry.timestamp == original_entry["timestamp"] + assert np.array_equal(entry.dimensions, original_entry["data"].shape) + assert np.array_equal(entry.data.shape, entry.dimensions) # Sanity check assert np.array_equal(entry.data, original_entry["data"]) assert entry.data.dtype == original_entry["data"].dtype assert len(entry.attributes) == len(original_entry["attributes"])