From cf6b4a5e156daa1b4fafced5f063cbde4e81b629 Mon Sep 17 00:00:00 2001 From: Mathias Guijarro Date: Thu, 31 Oct 2024 12:56:07 +0100 Subject: [PATCH] fix: data shape returns a tuple --- ophyd/tests/test_utils.py | 18 +++++++++--------- ophyd/utils/epics_pvs.py | 6 +++--- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/ophyd/tests/test_utils.py b/ophyd/tests/test_utils.py index 2fd1a26d4..bd1b26af3 100644 --- a/ophyd/tests/test_utils.py +++ b/ophyd/tests/test_utils.py @@ -48,15 +48,15 @@ def test_records_from_db(): @pytest.mark.parametrize( "value, dtype, shape", [ - [1, "integer", []], - [1.0, "number", []], - [1e-3, "number", []], - ["foo", "string", []], - [np.array([1, 2, 3]), "array", [3]], - [np.array([[1, 2], [3, 4]]), "array", [2, 2]], - [(1, 2, 3), "array", [3]], - [[1, 2, 3], "array", [3]], - [[], "array", [0]], + [1, "integer", ()], + [1.0, "number", ()], + [1e-3, "number", ()], + ["foo", "string", ()], + [np.array([1, 2, 3]), "array", (3,)], + [np.array([[1, 2], [3, 4]]), "array", (2, 2)], + [(1, 2, 3), "array", (3,)], + [[1, 2, 3], "array", (3,)], + [[], "array", (0,)], ], ) def test_data_type_and_shape(value, dtype, shape): diff --git a/ophyd/utils/epics_pvs.py b/ophyd/utils/epics_pvs.py index ce3733e0c..39d9ad298 100644 --- a/ophyd/utils/epics_pvs.py +++ b/ophyd/utils/epics_pvs.py @@ -401,12 +401,12 @@ def data_shape(val): ``list(np.ndarray.shape)`` """ if data_type(val) != "array": - return [] + return () try: - return list(val.shape) + return tuple(val.shape) except AttributeError: - return [len(val)] + return (len(val),) # Vendored from pyepics v3.3.0