Skip to content

Commit

Permalink
Deserialising ADAr populates the dimensions field (#90)
Browse files Browse the repository at this point in the history
  • Loading branch information
mattclarke authored Sep 8, 2023
1 parent 3c2564c commit 64c8c25
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion streaming_data_types/_version.py
Original file line number Diff line number Diff line change
@@ -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"
2 changes: 2 additions & 0 deletions streaming_data_types/area_detector_ADAr.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ def serialise_ADAr(
("source_name", str),
("unique_id", int),
("timestamp", datetime),
("dimensions", np.ndarray),
("data", np.ndarray),
("attributes", List[Attribute]),
),
Expand Down Expand Up @@ -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,
)
2 changes: 2 additions & 0 deletions tests/test_ADAr.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"])
Expand Down

0 comments on commit 64c8c25

Please sign in to comment.