Refactor cache validation and optimize alignment wizard incremental updates
- Extract cache mismatch logic into reusable cache_mismatch_reasons() function for cleaner validation and consistent miss reporting - Expose memory_budget_bytes() for external callers (aligned exporter) - Optimize rebuild_stack() with incremental layer updates when only one angle parameters change, avoiding full reprojection overhead - Remove unused seed_per_angle parameter from alignment wizard - Simplify cached_rf_image() DC masking with cleaner early exit logic - Clean up internal state tracking with explicit origin caching Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
This commit is contained in:
+13
-3
@@ -392,6 +392,14 @@ def test_wizard_nudges(ctx):
|
||||
assert len(wiz.state.layers) == s.n_angles, \
|
||||
"stack rebuilt for every angle after a rotation nudge"
|
||||
|
||||
# A nudge only reprojects the angle that moved, patching the overlap counts
|
||||
# in place. That shortcut is only sound if it lands on exactly what a full
|
||||
# rebuild would have produced.
|
||||
incremental = wiz.state.counts.copy()
|
||||
wiz.rebuild_stack()
|
||||
assert np.array_equal(wiz.state.counts, incremental), \
|
||||
"incremental nudge update matches a full stack rebuild"
|
||||
|
||||
# Real key-event wiring (keyPressEvent -> signal -> slot).
|
||||
before = wiz.state.params[active].shift_mm
|
||||
QTest.keyClick(p1.canvas, Qt.Key.Key_Right)
|
||||
@@ -529,7 +537,8 @@ def test_wizard_crop_dropped_when_going_back(ctx):
|
||||
pump(120)
|
||||
assert wiz.currentId() == wiz.PAGE_CORRELATE
|
||||
assert wiz.state.crop is None, "cleanupPage discarded the stale crop"
|
||||
assert wiz.state.cropped_result is None
|
||||
assert wiz.cropped_plan() == (None, None), \
|
||||
"nothing derived from the dropped crop survives either"
|
||||
wiz.next()
|
||||
pump(150)
|
||||
assert wiz.state.crop is not None, "a fresh default crop is offered again"
|
||||
@@ -546,8 +555,9 @@ def test_wizard_export(ctx):
|
||||
pump(150)
|
||||
assert wiz.currentId() == wiz.PAGE_SAVE, "advanced to the save page"
|
||||
ctx.p3 = p3 = wiz.page(wiz.PAGE_SAVE)
|
||||
assert wiz.state.cropped_result is not None, "crop applied on leaving page 2"
|
||||
assert wiz.state.cropped_result.canvas_shape == ctx.crop[2:], \
|
||||
cropped, _ = wiz.cropped_plan()
|
||||
assert cropped is not None, "crop applied on leaving page 2"
|
||||
assert cropped.canvas_shape == ctx.crop[2:], \
|
||||
"cropped result carries the chosen shape"
|
||||
assert not p3.isComplete(), "Finish unavailable before anything is written"
|
||||
assert p3.lbl_summary.text(), "a summary of what will be written is shown"
|
||||
|
||||
Reference in New Issue
Block a user