Skip to content

Commit

Permalink
fix: data shape returns a tuple
Browse files Browse the repository at this point in the history
  • Loading branch information
Mathias Guijarro committed Oct 31, 2024
1 parent 1cc52ef commit 051d146
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
18 changes: 9 additions & 9 deletions ophyd/tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
6 changes: 3 additions & 3 deletions ophyd/utils/epics_pvs.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 051d146

Please sign in to comment.