feat(omny): drop redundant tomo auth code, cap type-3 step at 2.5 deg
CI for csaxs_bec / test (push) Successful in 1m45s

The "Enter authorization code" (x12sa) prompt gating advanced tomo modes
(types 2-5) predates the account-based _SUPERUSER_ACCOUNTS gate added
earlier this branch, and is now fully redundant with it -- Mirko asked to
remove it. Each mode still prints the existing "significant wear" warning
unconditionally instead of only after entering the code.

Also added a hard 2.5 degree ceiling on tomo type 3's angular step (golden
ratio starting angle mode), replacing its old minimum-100-projections floor
with an explicit wear-motivated cap; if the requested projection count
implies a larger step, it's clamped down to 2.5 degrees. Type 2's
golden_ratio_bunch_size minimum stays at 100 per Mirko's call -- wear
avoidance there is handled by the warning message, not a lower floor.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QLrD7sVYGLAzsQjLVJpCgt
This commit is contained in:
x01dcandClaude Sonnet 5 committed 2026-09-02 13:32:19 +02:00
1 parent bd129b6313
commit 2fbaa6679f
3 files changed
+130 -79

No files matched your search

@@ -244,8 +244,9 @@ def test_tomo_parameters_forces_type_1_for_non_superuser(monkeypatch, fake_bec):
def test_tomo_parameters_allows_superuser_to_unlock_8_subtomo_mode(monkeypatch, fake_bec):
"""A superuser account can select and unlock tomo_type 5 (8 sub-tomograms)
with the correct authorization code."""
"""A superuser account can select and unlock tomo_type 5 (8 sub-tomograms).
No authorization code is required -- access is gated purely by the account
check (_is_superuser_account()), which is already exercised above."""
monkeypatch.setattr(omny_module, "_SUPERUSER_ACCOUNTS", frozenset({"e99999"}))
fake_bec.active_account = "e99999" # superuser
omny = make_omny()
@@ -265,9 +266,9 @@ def test_tomo_parameters_allows_superuser_to_unlock_8_subtomo_mode(monkeypatch,
omny.OMNYTools = types.SimpleNamespace(yesno=lambda *a, **k: False)
# canned answers for: ctime, step, fovx, fovy, stitch_x, stitch_y,
# reconstruct_foldername, tomo_type (=5, 8 sub-tomograms), authorization
# code, total number of projections
canned = iter([1.0, 0.1, 20, 20, 1, 1, "queue", 5, "x12sa", 144])
# reconstruct_foldername, tomo_type (=5, 8 sub-tomograms), total number of
# projections
canned = iter([1.0, 0.1, 20, 20, 1, 1, "queue", 5, 144])
monkeypatch.setattr(OMNY, "_get_val", staticmethod(lambda *a, **k: next(canned)))
omny.tomo_parameters()
@@ -275,3 +276,39 @@ def test_tomo_parameters_allows_superuser_to_unlock_8_subtomo_mode(monkeypatch,
assert omny.tomo_type == 5
# 144 total projections / 8 sub-tomograms -> stepsize 180/(144/8) = 10.0
assert omny.tomo_angle_stepsize == pytest.approx(10.0)
def test_tomo_parameters_clamps_type_3_step_size_to_max_2_5_degrees(monkeypatch, fake_bec):
"""tomo_type 3 (equally spaced, golden ratio starting angle) enforces a
maximum angular step of 2.5 degrees, to limit wear from too many
rotations. A superuser requesting too few projections per sub-tomogram
(i.e. too large a step) gets clamped down to 2.5 degrees."""
monkeypatch.setattr(omny_module, "_SUPERUSER_ACCOUNTS", frozenset({"e99999"}))
fake_bec.active_account = "e99999" # superuser
omny = make_omny()
omny.tomo_countingtime = 1.0
omny.tomo_shellstep = 0.1
omny.fovx = 20
omny.fovy = 20
omny.stitch_x = 1
omny.stitch_y = 1
omny.ptycho_reconstruct_foldername = "queue"
omny.tomo_angle_stepsize = 10.0
omny.tomo_type = 1
fake_dev = types.SimpleNamespace(
omny_samples=types.SimpleNamespace(get_sample_name_in_samplestage=lambda: "test_sample")
)
monkeypatch.setattr(omny_module, "dev", fake_dev, raising=False)
omny.OMNYTools = types.SimpleNamespace(yesno=lambda *a, **k: False)
# canned answers for: ctime, step, fovx, fovy, stitch_x, stitch_y,
# reconstruct_foldername, tomo_type (=3), projections per sub-tomogram
# (=10 -> would be an 18 degree step, far above the 2.5 degree cap),
# stop-after-projections, repeat-at-0-deg
canned = iter([1.0, 0.1, 20, 20, 1, 1, "queue", 3, 10, 0, 0])
monkeypatch.setattr(OMNY, "_get_val", staticmethod(lambda *a, **k: next(canned)))
omny.tomo_parameters()
assert omny.tomo_type == 3
assert omny.tomo_angle_stepsize == pytest.approx(2.5)