feat(omny): port zero_deg_reference_at_each_subtomo to types 1/4/5
CI for csaxs_bec / test (push) Successful in 2m35s
CI for csaxs_bec / test (push) Successful in 2m35s
flomni already has this (type-1-only: a dedicated projection at exactly 0 degrees before every odd/forward sub-tomogram, plus once more at the end, for tracking radiation damage over a tomogram). Deliberately excluded from OMNY during the Phase 1 port as flomni-specific; Mirko asked for it to be extended to OMNY's generalized equally-spaced types (1/4/5, 2/4/8 sub-tomograms), and confirmed the pre-shot should fire even for sub-tomogram 1 (whose own first projection already lands on 0) to get two consecutive 0-degree shots as an immediate baseline pair. Also fixes a second hardcoded `tomo_type != 1` bug in the widget's _irrelevant_params_for_type() (same class as the earlier _validate() fix) that would have hidden this setting from OMNY type-4/5 job tooltips even when enabled. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QLrD7sVYGLAzsQjLVJpCgt
This commit is contained in:
1 parent
70696756f1
commit
78f0c8fa3b
7 files changed
+252
-14
No files matched your search
@@ -20,6 +20,7 @@ from csaxs_bec.bec_widgets.widgets.tomo_params.tomo_params import (
|
||||
_compute_type1,
|
||||
_compute_type1_omny,
|
||||
_format_projections,
|
||||
_irrelevant_params_for_type,
|
||||
_lamni_compute_type1,
|
||||
_requested_to_stepsize,
|
||||
_requested_to_stepsize_omny,
|
||||
@@ -119,11 +120,15 @@ def test_omny_field_order_matches_flomni_minus_omny_only_gaps():
|
||||
]
|
||||
|
||||
|
||||
def test_omny_has_no_180_mode_single_point_or_zero_deg_reference():
|
||||
def test_omny_has_no_180_mode_or_single_point():
|
||||
"""has_zero_deg_reference IS True for OMNY (unlike 180-mode/single-point,
|
||||
which genuinely don't exist here): zero_deg_reference_at_each_subtomo
|
||||
applies to any equally spaced tomo type, not just type 1 -- see
|
||||
omny.py's own property docstring and tomo_scan()'s type-1-like loop."""
|
||||
profile = SETUP_PROFILES["omny"]
|
||||
assert profile["has_180_mode"] is False
|
||||
assert profile["has_single_point"] is False
|
||||
assert profile["has_zero_deg_reference"] is False
|
||||
assert profile["has_zero_deg_reference"] is True
|
||||
|
||||
|
||||
def test_compute_fermat_positions_omny_matches_scan_class_below_threshold():
|
||||
@@ -182,6 +187,20 @@ def test_format_projections_still_distinguishes_flomni_and_lamni_jobs():
|
||||
assert _format_projections(lamni_params) == str(lamni_N * 8)
|
||||
|
||||
|
||||
# --- _irrelevant_params_for_type(): regression guard for the type-4/5 gap --
|
||||
|
||||
|
||||
def test_irrelevant_params_for_type_keeps_zero_deg_reference_for_omny_types_4_and_5():
|
||||
"""_irrelevant_params_for_type() used to hardcode `tomo_type != 1`, which
|
||||
would hide zero_deg_reference_at_each_subtomo from an OMNY type-4/5 job's
|
||||
tooltip even though it's a real, applicable setting for those types too
|
||||
(only flomni/lamni are limited to type 1) -- fixed to `not in (1, 4, 5)`."""
|
||||
for tomo_type in (1, 4, 5):
|
||||
assert "zero_deg_reference_at_each_subtomo" not in _irrelevant_params_for_type(tomo_type)
|
||||
for tomo_type in (2, 3):
|
||||
assert "zero_deg_reference_at_each_subtomo" in _irrelevant_params_for_type(tomo_type)
|
||||
|
||||
|
||||
# --- _validate()'s tomo_type check: regression guard for the critical fix --
|
||||
|
||||
|
||||
|
||||
@@ -58,14 +58,17 @@ def make_omny(fake_client=None):
|
||||
|
||||
def test_tomo_scan_param_names_have_no_flomni_only_concepts():
|
||||
"""OMNY mirrors flomni's names for shared concepts, but has no
|
||||
180/360 toggle, no single-point acquisition, no zero-deg reference,
|
||||
and no frames_per_trigger -- none of these exist as OMNY properties."""
|
||||
180/360 toggle, no single-point acquisition, and no frames_per_trigger --
|
||||
none of these exist as OMNY properties. zero_deg_reference_at_each_subtomo
|
||||
is a deliberate exception: it applies to any equally spaced tomo type
|
||||
(1/4/5 for OMNY, not just type 1), so unlike the others it *is* present --
|
||||
see tomo_scan()'s type-1-like loop and the property's own docstring."""
|
||||
names = OMNY._TOMO_SCAN_PARAM_NAMES
|
||||
assert "tomo_angle_range" not in names
|
||||
assert "single_point_instead_of_fermat_scan" not in names
|
||||
assert "single_point_random_shift_max" not in names
|
||||
assert "zero_deg_reference_at_each_subtomo" not in names
|
||||
assert "frames_per_trigger" not in names
|
||||
assert "zero_deg_reference_at_each_subtomo" in names
|
||||
# shared-with-flomni names are present, using OMNY's own property names
|
||||
assert "fovx" in names
|
||||
assert "stitch_x" in names
|
||||
|
||||
@@ -147,6 +147,67 @@ def test_tomo_scan_accepts_interactive_kwarg(monkeypatch):
|
||||
assert omny.progress["tomo_start_time"] is not None
|
||||
|
||||
|
||||
def test_tomo_scan_zero_deg_reference_disabled_by_default_no_extra_shots(monkeypatch):
|
||||
"""zero_deg_reference_at_each_subtomo defaults to False -- no extra
|
||||
_tomo_scan_at_angle(0, ...) calls beyond whatever sub_tomo_scan() does
|
||||
on its own (stubbed to a no-op here, so none at all)."""
|
||||
omny = make_omny_for_tomo_scan(monkeypatch, 45.0, active_account="")
|
||||
calls = []
|
||||
omny._tomo_scan_at_angle = lambda angle, subtomo_number: calls.append((angle, subtomo_number))
|
||||
|
||||
omny.tomo_scan()
|
||||
|
||||
assert calls == []
|
||||
|
||||
|
||||
def test_tomo_scan_zero_deg_reference_type1_fires_before_subtomo1_and_after_subtomo2(monkeypatch):
|
||||
"""Type 1 (n_subtomos=2): a pre-shot before sub-tomogram 1 (even though
|
||||
its own first projection already lands on 0 -- two consecutive 0-degree
|
||||
shots right at the start is deliberate) and a final shot after
|
||||
sub-tomogram 2, giving exactly one extra projection at the end plus one
|
||||
at the very start for this type."""
|
||||
omny = make_omny_for_tomo_scan(monkeypatch, 45.0, active_account="")
|
||||
omny.tomo_type = 1
|
||||
omny.zero_deg_reference_at_each_subtomo = True
|
||||
calls = []
|
||||
omny._tomo_scan_at_angle = lambda angle, subtomo_number: calls.append((angle, subtomo_number))
|
||||
|
||||
omny.tomo_scan()
|
||||
|
||||
assert calls == [(0, 1), (0, 2)]
|
||||
|
||||
|
||||
def test_tomo_scan_zero_deg_reference_type5_fires_before_every_odd_subtomo(monkeypatch):
|
||||
"""Type 5 (n_subtomos=8): a pre-shot before every odd/forward
|
||||
sub-tomogram (1, 3, 5, 7), plus the final shot after sub-tomogram 8."""
|
||||
omny = make_omny_for_tomo_scan(monkeypatch, 45.0, active_account="")
|
||||
omny.tomo_type = 5
|
||||
omny.zero_deg_reference_at_each_subtomo = True
|
||||
calls = []
|
||||
omny._tomo_scan_at_angle = lambda angle, subtomo_number: calls.append((angle, subtomo_number))
|
||||
|
||||
omny.tomo_scan()
|
||||
|
||||
assert calls == [(0, 1), (0, 3), (0, 5), (0, 7), (0, 8)]
|
||||
|
||||
|
||||
def test_tomo_scan_zero_deg_reference_skipped_only_for_the_resumed_subtomo(monkeypatch):
|
||||
"""Resuming mid-sub-tomogram (start_angle given explicitly) must skip the
|
||||
pre-shot only for that specific sub-tomogram -- we aren't actually
|
||||
passing through 0 deg at that moment -- but later odd sub-tomograms in
|
||||
the same tomo_scan() call still get theirs, and the final shot is
|
||||
unaffected either way."""
|
||||
omny = make_omny_for_tomo_scan(monkeypatch, 45.0, active_account="")
|
||||
omny.tomo_type = 5
|
||||
omny.zero_deg_reference_at_each_subtomo = True
|
||||
calls = []
|
||||
omny._tomo_scan_at_angle = lambda angle, subtomo_number: calls.append((angle, subtomo_number))
|
||||
|
||||
omny.tomo_scan(subtomo_start=3, start_angle=12.5)
|
||||
|
||||
assert calls == [(0, 5), (0, 7), (0, 8)]
|
||||
|
||||
|
||||
def test_tomo_scan_clears_heartbeat_on_normal_completion(monkeypatch):
|
||||
"""The busy-detector heartbeat must be cleared as soon as the scan
|
||||
finishes, not left for the next poll to time out before the GUI stops
|
||||
|
||||
Reference in new issue
Block a user