Skip to content

Document mir_history offset; fix waypoint assertion - #245

Open
neuromechanist wants to merge 1 commit into
devfrom
161-mir-history-tests
Open

Document mir_history offset; fix waypoint assertion#245
neuromechanist wants to merge 1 commit into
devfrom
161-mir-history-tests

Conversation

@neuromechanist

Copy link
Copy Markdown
Member

Closes #161, and repairs a test my own #241 broke.

#161 was mostly already done

Both of its testable claims already have tests in test_ng_convergence.pytest_mir_history_survives_keep_best_restore and test_mir_history_empty_after_save_load. Only the third, informational item was outstanding.

Verified before documenting it: ll comes from the E-step accumulator at the top of the loop, _update_parameters runs, and the MIR waypoint is computed after. So mir_history_[i] reflects the parameters after iteration i's update while ll_history[i] is the likelihood of the parameters before it. Zipping them by index compares different parameter states. Now stated on both the backend attribute and the AMICA.mir_history_ docstring.

A regression from #241

Running the whole file rather than a subset surfaced test_mir_history_survives_keep_best_restore failing on dev:

assert 50 == (55 - 1)

I bisected it: the test passes at 257d20e (the commit before #241 merged) and fails at c80fb33 (the merge). #241 caused it. That PR's gm-ordering change shifts multi-model trajectories by ~1e-6, which moved the min_dll stop to iteration 55; MIR waypoints land on multiples of mir_step=5, so the last one is at 50, not 54.

The assertion last_it == len(ll_history) - 1 was fragile from the start — it only held while the stop happened to coincide with a waypoint, and any trajectory perturbation could break it. It now asserts what the test is actually about: the last waypoint is the highest multiple of mir_step at or below the final iteration, and is within one interval of the end, so a restore that truncated the trajectory would still fail it.

Why CI did not catch it

The test is not slow-marked, so CI runs it, and CI was green on #241's branch. I have not established why the branch and the squashed merge behave differently here; the practical lesson is that I ran a subset locally on #241 and would not have seen this either way. Flagging rather than leaving it implicit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant