Repository navigation
Add annotation x rank-reduction and sphere-guard tests - #282
Merged
Merged
Conversation
This was referenced Aug 24, 2026
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #261.
Adds the two automated tests the fresh-context reviews of #252 and #256 flagged as residual (both judged low-probability, neither blocking merge at the time).
pamica/tests/mne_tests/test_annotation_rank_reduction.pyfitsAMICAICAwithreject_by_annotation=Truecombined with rank reduction (explicitpcakeepand automaticmineig_relnumerical-rank detection) on the bundled annotatedeeglab_data.set, pinning that the fit completes,n_components_reflects the reduced rank,good_sample_mask_/get_model_probabilitystay timeline-aligned with NaN at rejected samples,pmi()matches a manual computation, and the exported MNE ICA'spca_components_is rank-sized and orthonormal -- the exact production configuration the external MEG tester runs by hand on Maxwell-filtered rank-deficient data plusbad_*annotations.pamica/tests/torch_tests/test_ng_sharing.pygets a direct test thatAMICATorchNG.get_sensor_mixing_matrix()raises the same clearRuntimeErroron a non-finite sphere that the internal_identify_shared_comps()route already pinned; this is the twin of the NumPy backend's existingtest_non_finite_sphere_fails_loudly, which already covered this route forAMICA_NumPy.Non-blocking defect found (not fixed here; test-only PR)
While prototyping the auto-rank variant,
AMICAICA(...).mir()on a fit whose rank reduction came from automaticmineig_reldetection (no explicitpcakeep/pcadb) raises an opaquenumpy.linalg.LinAlgError: Last 2 dimensions of the array must be squareinstead of the intended, documentedValueError("mir() is incompatible with PCA reduction").Root cause:
AMICATorchNG._pca_reduced()(pamica/torch_impl/core.py) only checksself.pcakeep is not None or self.pcadb is not None, not the sphere's actual shape, so an auto-detected rank reduction slips past the guard. Repro:No test was written pinning this failure mode, since that would encode the bug as expected behavior; left for a follow-up fix.
Test plan
uv run pytest pamica/tests/mne_tests/ pamica/tests/torch_tests/test_ng_sharing.py -q --no-cov(99 passed)uv run pytest -m "not slow" -n auto(487 passed, 21 skipped, 1 xfailed)uv run ruff check ./uv run ruff format --check ./uv run ty check(all clean)