Skip to content

Commit c609e8a

Browse files
authored
feat: make af-device name optional (#145)
* feat: make af-device name optional * add tests
1 parent 17e6533 commit c609e8a

File tree

3 files changed

+26
-11
lines changed

3 files changed

+26
-11
lines changed

src/useq/_actions.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typing import Union
1+
from typing import Optional, Union
22

33
from typing_extensions import Literal
44

@@ -43,18 +43,21 @@ class HardwareAutofocus(Action):
4343
----------
4444
type : Literal["hardware_autofocus"]
4545
This action can be used to trigger hardware autofocus.
46-
autofocus_device_name : str
47-
The name of the hardware autofocus device.
48-
autofocus_motor_offset: float
46+
autofocus_device_name : str, optional
47+
The name of the autofocus offset motor device (if applicable). If `None`,
48+
acquisition engines may attempt to set the offset however they see fit (such as
49+
using a current or default autofocus device.)
50+
autofocus_motor_offset: float, optional
4951
Before autofocus is performed, the autofocus motor should be moved to this
50-
offset.
52+
offset, if applicable. (Not all autofocus devices have an offset motor.)
53+
If None, the autofocus motor should not be moved.
5154
max_retries : int
5255
The number of retries if autofocus fails. By default, 3.
5356
"""
5457

5558
type: Literal["hardware_autofocus"] = "hardware_autofocus"
56-
autofocus_device_name: str
57-
autofocus_motor_offset: float
59+
autofocus_device_name: Optional[str] = None
60+
autofocus_motor_offset: Optional[float] = None
5861
max_retries: int = 3
5962

6063

src/useq/_hardware_autofocus.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,17 @@ class AutoFocusPlan(FrozenModel):
1212
1313
Attributes
1414
----------
15-
autofocus_device_name : str
16-
Name of the hardware autofocus z device.
15+
autofocus_device_name : str | None
16+
Optional name of the offset motor device. If `None`, acquisition engines may
17+
attempt to set the offset however they see fit (such as using a current
18+
or default autofocus device.)
1719
autofocus_motor_offset : float | None
1820
Before autofocus is performed, the autofocus motor should be moved to this
19-
offset.
21+
offset, if applicable. (Not all autofocus devices have an offset motor.)
22+
If None, the autofocus motor should not be moved.
2023
"""
2124

22-
autofocus_device_name: str
25+
autofocus_device_name: Optional[str] = None
2326
autofocus_motor_offset: Optional[float] = None
2427

2528
def as_action(self) -> HardwareAutofocus:

tests/test_autofocus.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,3 +113,12 @@ def test_autofocus_z_pos_multi_plans() -> None:
113113
)
114114

115115
assert all(e.z_pos == 200 for e in mda if isinstance(e.action, HardwareAutofocus))
116+
117+
118+
def test_af_no_name() -> None:
119+
list(
120+
MDASequence(
121+
time_plan={"interval": 1, "loops": 2},
122+
autofocus_plan=AxesBasedAF(axes=("t", "c")),
123+
)
124+
)

0 commit comments

Comments
 (0)