File tree Expand file tree Collapse file tree 3 files changed +12
-2
lines changed Expand file tree Collapse file tree 3 files changed +12
-2
lines changed Original file line number Diff line number Diff line change
1
+ from typing import Union
2
+
1
3
from typing_extensions import Literal
2
4
3
5
from useq ._base_model import FrozenModel
@@ -54,3 +56,6 @@ class HardwareAutofocus(Action):
54
56
autofocus_device_name : str
55
57
autofocus_motor_offset : float
56
58
max_retries : int = 3
59
+
60
+
61
+ AnyAction = Union [HardwareAutofocus , AcquireImage ]
Original file line number Diff line number Diff line change 15
15
16
16
from pydantic import Field , validator
17
17
18
- from useq ._actions import AcquireImage , Action
18
+ from useq ._actions import AcquireImage , AnyAction
19
19
from useq ._base_model import UseqModel
20
20
from useq ._utils import ReadOnlyDict
21
21
@@ -138,7 +138,7 @@ class MDAEvent(UseqModel):
138
138
sequence : Optional [MDASequence ] = Field (default = None , repr = False )
139
139
properties : Optional [List [PropertyTuple ]] = None
140
140
metadata : Dict [str , Any ] = Field (default_factory = dict )
141
- action : Action = Field (default_factory = AcquireImage )
141
+ action : AnyAction = Field (default_factory = AcquireImage )
142
142
keep_shutter_open : bool = False
143
143
144
144
# action
Original file line number Diff line number Diff line change @@ -321,3 +321,8 @@ def test_mda_warns_extra() -> None:
321
321
def test_skip_channel_do_stack_no_zplan ():
322
322
mda = MDASequence (channels = [{"config" : "DAPI" , "do_stack" : False }])
323
323
assert len (list (mda )) == 1
324
+
325
+
326
+ def test_event_action_union () -> None :
327
+ # test that action unions work
328
+ MDAEvent (action = {"autofocus_device_name" : "Z" , "autofocus_motor_offset" : 25 })
You can’t perform that action at this time.
0 commit comments