Skip to content

Commit 4b42d1e

Browse files
authored
fix: fix slm image data repr and eq (#209)
1 parent 3628eed commit 4b42d1e

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

src/useq/_mda_event.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ class SLMImage(UseqModel):
7171
used. By default, `None`.
7272
"""
7373

74-
data: Any
74+
data: Any = Field(..., repr=False)
7575
device: Optional[str] = None
7676
exposure: Optional[float] = None
7777

@@ -86,6 +86,15 @@ def __array__(self, *args: Any, **kwargs: Any) -> npt.NDArray:
8686
"""Cast the image data to a numpy array."""
8787
return np.asarray(self.data, *args, **kwargs)
8888

89+
def __eq__(self, other: object) -> bool:
90+
if not isinstance(other, SLMImage):
91+
return False
92+
return (
93+
self.device == other.device
94+
and self.exposure == other.exposure
95+
and np.array_equal(self.data, other.data)
96+
)
97+
8998

9099
class PropertyTuple(NamedTuple):
91100
"""Three-tuple capturing a device, property, and value.

tests/test_sequence.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -488,3 +488,5 @@ def test_slm_image() -> None:
488488
# directly provide numpy array
489489
event3 = MDAEvent(slm_image=SLMImage(data=np.ones((10, 10))))
490490
print(repr(event3))
491+
492+
assert event3 != event2

0 commit comments

Comments
 (0)