feat(lamni): golden ratio bunch size range 30..200, default 100
CI for csaxs_bec / test (push) Successful in 3m1s

Setter, tomo_parameters() prompt and the tomo params GUI spinbox (lamni
profile) now allow 30 to 200 (was 20 to 100); default 100 (was 20).
flomni's GUI range is unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ALDnH16dC6iyHjhe5Ey4w9
This commit is contained in:
x12saandClaude Opus 5.5 committed 2026-10-16 06:56:37 +02:00
1 parent 60ad8f056e
commit 45609b6ef0
6 files changed
+30 -23

No files matched your search

@@ -355,7 +355,7 @@ class LamNI(
self.tomo_stitch_overlap = 0.2
self.golden_projections_at_0_deg_for_damage_estimation = 0
self.zero_deg_reference_at_each_subtomo = False
self.golden_ratio_bunch_size = 20
self.golden_ratio_bunch_size = 100
self.frames_per_trigger = 1
self.lamni_piezo_range_x = 20
self.lamni_piezo_range_y = 20
@@ -1038,13 +1038,13 @@ class LamNI(
def golden_ratio_bunch_size(self):
val = self.client.get_global_var("golden_ratio_bunch_size")
if val is None:
return 20
return 100
return val
@golden_ratio_bunch_size.setter
def golden_ratio_bunch_size(self, val: int):
if val < 20:
raise ValueError("golden_ratio_bunch_size must be at least 20.")
if not 30 <= val <= 200:
raise ValueError("golden_ratio_bunch_size must be between 30 and 200.")
self.client.set_global_var("golden_ratio_bunch_size", val)
@property
@@ -2608,11 +2608,11 @@ class LamNI(
elif self.tomo_type == 2:
self.golden_ratio_bunch_size = self._get_val(
"Number of projections sorted per bunch (minimum 20)",
"Number of projections sorted per bunch (30 to 200)",
self.golden_ratio_bunch_size,
int,
min_=20,
max_=100,
min_=30,
max_=200,
)
self.golden_max_number_of_projections = self._get_val(
"Stop after number of projections (0 for endless)",
@@ -276,7 +276,7 @@ LAMNI_DEFAULTS: dict[str, Any] = {
"tomo_type": 1,
"tomo_angle_file": "",
"tomo_angle_stepsize": 10.0,
"golden_ratio_bunch_size": 20,
"golden_ratio_bunch_size": 100,
"golden_max_number_of_projections": 1000.0,
"golden_projections_at_0_deg_for_damage_estimation": 0,
"zero_deg_reference_at_each_subtomo": False,
@@ -752,7 +752,7 @@ class OMNY_TomoParams(BECWidget, QWidget):
form, "_numprj_type3", "Projections per sub-tomo (type 3)", min_=1, max_=10000
)
# per-setup floor (SETUP_PROFILES[...]["golden_bunch_size_min"]): lamni's
# golden_ratio_bunch_size setter/CLI reject < 20, so a GUI-legal
# golden_ratio_bunch_size setter/CLI reject values outside 30..200, so a GUI-legal
# smaller value would raise ValueError in tomo_queue_execute() (which
# setattr()s every job param) and pause the queue.
self._add_int(
@@ -760,7 +760,7 @@ class OMNY_TomoParams(BECWidget, QWidget):
"golden_ratio_bunch_size",
"Bunch size (type 2 only)",
min_=self._profile.get("golden_bunch_size_min", 1),
max_=100,
max_=self._profile.get("golden_bunch_size_max", 100),
)
self._add_double(
form,
@@ -2763,9 +2763,10 @@ SETUP_PROFILES: dict[str, dict[str, Any]] = {
# laminography: 180-deg-opposite angles are not redundant
"angle_file_opposite_warning": False,
"has_zero_deg_reference": True,
# lamni.golden_ratio_bunch_size setter/CLI require >= 20 (see
# lamni.golden_ratio_bunch_size setter/CLI require 30..200 (see
# _build_params_panel's bunch-size spinbox)
"golden_bunch_size_min": 20,
"golden_bunch_size_min": 30,
"golden_bunch_size_max": 200,
"fov_fields": [("tomo_circfov", "Circular FOV (µm, 0 = disabled)", 0.0, 500.0, 2)],
"stitch_fields": [
("lamni_stitch_x", "Stitch x", 0, 50),
@@ -130,23 +130,23 @@ def test_cli_type1_rejects_fewer_than_8_projections(monkeypatch):
assert lamni._tomo_type1_actual_grid()[2] == 144
def test_cli_type2_enforces_bunch_size_of_at_least_20(monkeypatch, capsys):
def test_cli_type2_enforces_bunch_size_30_to_200(monkeypatch, capsys):
lamni = _make_cli_lamni(
monkeypatch,
{
"Tomography type": ["2"],
"sorted per bunch": ["5", "19", "150", "25"],
"sorted per bunch": ["5", "29", "250", "150"],
"Stop after": ["-1", "2000000", "800"],
},
)
lamni.tomo_parameters_cli()
assert lamni.golden_ratio_bunch_size == 25
assert lamni.golden_ratio_bunch_size == 150
assert lamni.golden_max_number_of_projections == 800
out = capsys.readouterr().out
assert "must be >= 20" in out
assert "must be <= 100" in out
assert "must be >= 30" in out
assert "must be <= 200" in out
assert "must be <= 1000000" in out
@@ -131,7 +131,7 @@ def test_golden_ratio_report_does_not_use_the_stale_type1_grid(report_lamni):
def test_golden_ratio_endless_scan_reports_manual_stop(report_lamni):
report_lamni.tomo_type = 2
report_lamni.golden_max_number_of_projections = 0
report_lamni.golden_ratio_bunch_size = 20
report_lamni.golden_ratio_bunch_size = 30
report = _report(report_lamni)
@@ -537,7 +537,7 @@ def _fake_golden(ii, bunch_size, maxangle=360, reverse=True):
def make_lamni_for_golden_resume(monkeypatch, tomo_type: int) -> LamNI:
lamni = make_lamni_for_tomo_scan(monkeypatch, 45.0, active_account="")
lamni.tomo_type = tomo_type
lamni.golden_ratio_bunch_size = 20
lamni.golden_ratio_bunch_size = 30
lamni.golden_projections_at_0_deg_for_damage_estimation = 1
lamni.golden_max_number_of_projections = 21
lamni.add_sample_database = lambda *a, **k: 0
@@ -253,7 +253,7 @@ def test_compute_fermat_positions_lamni_zero_step_is_safe():
# ── golden bunch-size floor + manual-shift units ────────────────────────────
#
# lamni's golden_ratio_bunch_size setter/CLI reject < 20, but the shared GUI
# lamni's golden_ratio_bunch_size setter/CLI reject values outside 30..200 (was < 20), but the shared GUI
# spinbox allowed 1..100: a GUI-queued job with a smaller value made
# tomo_queue_execute()'s setattr() raise ValueError and pause the queue.
# The manual-shift fields were labelled um (+-1000) but lamni's manual shift is
@@ -272,12 +272,12 @@ def _bare_widget_for(setup: str):
return widget
def test_lamni_bunch_size_spinbox_floor_is_20():
def test_lamni_bunch_size_spinbox_range_is_30_to_200():
widget = _bare_widget_for("lamni")
box = widget._build_type23_section() # keep a reference: it owns the spinboxes
assert box is not None
assert widget._pw["golden_ratio_bunch_size"].minimum() == 20
assert widget._pw["golden_ratio_bunch_size"].maximum() == 100
assert widget._pw["golden_ratio_bunch_size"].minimum() == 30
assert widget._pw["golden_ratio_bunch_size"].maximum() == 200
def test_flomni_bunch_size_spinbox_is_unchanged():
@@ -285,6 +285,7 @@ def test_flomni_bunch_size_spinbox_is_unchanged():
box = widget._build_type23_section() # keep a reference: it owns the spinboxes
assert box is not None
assert widget._pw["golden_ratio_bunch_size"].minimum() == 1
assert widget._pw["golden_ratio_bunch_size"].maximum() == 100
def test_lamni_gui_bunch_size_floor_matches_the_setter():
@@ -304,9 +305,14 @@ def test_lamni_gui_bunch_size_floor_matches_the_setter():
lamni.client = FakeClient()
floor = SETUP_PROFILES["lamni"]["golden_bunch_size_min"]
ceiling = SETUP_PROFILES["lamni"]["golden_bunch_size_max"]
lamni.golden_ratio_bunch_size = floor # must not raise
lamni.golden_ratio_bunch_size = ceiling # must not raise
with pytest.raises(ValueError):
lamni.golden_ratio_bunch_size = floor - 1
with pytest.raises(ValueError):
lamni.golden_ratio_bunch_size = ceiling + 1
def test_lamni_manual_shift_fields_are_in_mm():