Sharpness monitor accepting 0 as None
This commit is contained in:
parent
59a93c673a
commit
78c01de6d5
2 changed files with 13 additions and 2 deletions
|
|
@ -274,7 +274,7 @@ class JPEGSharpnessMonitor:
|
||||||
dependency as required by the underlying class.
|
dependency as required by the underlying class.
|
||||||
:param method: The sharpness metric used when evaluating autofocus.
|
:param method: The sharpness metric used when evaluating autofocus.
|
||||||
:param record: Bitmask of sharpness metrics to record while monitoring.
|
:param record: Bitmask of sharpness metrics to record while monitoring.
|
||||||
If ``None``, only the metric specified by ``method`` is recorded.
|
If ``None`` or 0, only the metric specified by ``method`` is recorded.
|
||||||
|
|
||||||
:raises ValueError: If ``method`` is not included in ``record``.
|
:raises ValueError: If ``method`` is not included in ``record``.
|
||||||
:raises ValueError: If ``SharpnessMethod.FOCUS_FOM`` is requested but
|
:raises ValueError: If ``SharpnessMethod.FOCUS_FOM`` is requested but
|
||||||
|
|
@ -283,7 +283,7 @@ class JPEGSharpnessMonitor:
|
||||||
self.camera = camera
|
self.camera = camera
|
||||||
self.stage = stage
|
self.stage = stage
|
||||||
self.method = method
|
self.method = method
|
||||||
self.record = method if record is None else record
|
self.record = method if record is None or record == 0 else record
|
||||||
|
|
||||||
if not self.method & self.record:
|
if not self.method & self.record:
|
||||||
raise ValueError(
|
raise ValueError(
|
||||||
|
|
|
||||||
|
|
@ -129,6 +129,17 @@ def test_record_defaults_to_method(mock_stage, mock_camera):
|
||||||
|
|
||||||
assert monitor.record == SharpnessMethod.FOCUS_FOM
|
assert monitor.record == SharpnessMethod.FOCUS_FOM
|
||||||
|
|
||||||
|
def test_zero_record_defaults_to_method(mock_stage, mock_camera):
|
||||||
|
"""If record=0, only the selected method is recorded."""
|
||||||
|
monitor = JPEGSharpnessMonitor(
|
||||||
|
mock_stage,
|
||||||
|
mock_camera,
|
||||||
|
method=SharpnessMethod.FOCUS_FOM,
|
||||||
|
record=0,
|
||||||
|
)
|
||||||
|
|
||||||
|
assert monitor.record == SharpnessMethod.FOCUS_FOM
|
||||||
|
|
||||||
|
|
||||||
def test_record_must_include_selected_method(mock_stage, mock_camera):
|
def test_record_must_include_selected_method(mock_stage, mock_camera):
|
||||||
"""The selected autofocus metric must also be recorded."""
|
"""The selected autofocus metric must also be recorded."""
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue