Skip to content

Commit d3df2b7

Browse files
authored
test: moving more tests into test cases pattern (#234)
* tests: move keep shutter tests * feat: add TypedDicts for kwargs in Channel, SLMImage, and MDAEvent classes * test: add reset event timer test cases and clean up unused code
1 parent e83b7b7 commit d3df2b7

File tree

3 files changed

+439
-375
lines changed

3 files changed

+439
-375
lines changed

src/useq/_mda_event.py

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
Any,
88
NamedTuple,
99
Optional,
10+
TypedDict,
1011
)
1112

1213
import numpy as np
@@ -51,6 +52,14 @@ def __eq__(self, _value: object) -> bool:
5152
return self.config == _value
5253
return super().__eq__(_value)
5354

55+
if TYPE_CHECKING:
56+
57+
class Kwargs(TypedDict, total=False):
58+
"""Type for the kwargs passed to the channel."""
59+
60+
config: str
61+
group: str
62+
5463

5564
class SLMImage(UseqModel):
5665
"""SLM Image in a MDA event.
@@ -97,6 +106,15 @@ def __eq__(self, other: object) -> bool:
97106
and np.array_equal(self.data, other.data)
98107
)
99108

109+
if TYPE_CHECKING:
110+
111+
class Kwargs(TypedDict, total=False):
112+
"""Type for the kwargs passed to the SLM image."""
113+
114+
data: npt.ArrayLike
115+
device: Optional[str]
116+
exposure: Optional[float]
117+
100118

101119
class PropertyTuple(NamedTuple):
102120
"""Three-tuple capturing a device, property, and value.
@@ -244,3 +262,24 @@ def _validate_channel(cls, val: Any) -> Any:
244262
_sx = field_serializer("x_pos", mode="plain")(_float_or_none)
245263
_sy = field_serializer("y_pos", mode="plain")(_float_or_none)
246264
_sz = field_serializer("z_pos", mode="plain")(_float_or_none)
265+
266+
if TYPE_CHECKING:
267+
268+
class Kwargs(TypedDict, total=False):
269+
"""Type for the kwargs passed to the MDA event."""
270+
271+
index: dict[str, int]
272+
channel: Channel | Channel.Kwargs
273+
exposure: float
274+
min_start_time: float
275+
pos_name: str
276+
x_pos: float
277+
y_pos: float
278+
z_pos: float
279+
slm_image: SLMImage | SLMImage.Kwargs | npt.ArrayLike
280+
sequence: MDASequence | dict
281+
properties: list[tuple[str, str, Any]]
282+
metadata: dict
283+
action: AnyAction
284+
keep_shutter_open: bool
285+
reset_event_timer: bool

0 commit comments

Comments
 (0)