Skip to content

fit() crashes with do_approx_sphere=False + pcakeep (PCA-reduced non-symmetric sphere) #164

Description

@neuromechanist

Surfaced during #159 review while trying to construct a genuine num_pcs < data_dim test case for AmicaOutput.sources/loadmodout.

Observation

With the Fortran-parity default do_approx_sphere=True, pcakeep < data_dim still yields a full (data_dim, data_dim) (rank-deficient, not shape-reduced) sphere, so num_pcs == data_dim and nothing downstream reduces dimensionality. The only path that actually produces a non-square sphere / num_pcs < data_dim is do_approx_sphere=False + pcakeep, and that currently crashes during fit() itself:

RuntimeError: The size of tensor a (20) must match the size of tensor b (32) at ...

at pyAMICA/torch_impl/core.py:839 (the E-step b = (X - c).T @ W, where the reduced sphere makes the sphered-data channel count disagree with W's dimension).

Why it matters

The genuine PCA-reduction path is unreachable via the public API without hitting this crash, so:

  • AmicaOutput.sources/loadmodout/load_results have no test coverage for num_pcs < data_dim (they are correct dimensionally under the symmetric-ZCA default, but the reduced path can't be exercised).
  • Any user asking for real PCA reduction with do_approx_sphere=False cannot fit.

Not a regression from #159

Pre-existing; #159 only touches the loader/writer byte order. Filing separately per the parity-regression sequencing rule.

Acceptance

  • fit() with do_approx_sphere=False + pcakeep < data_dim runs (sphere/W/c dimensions consistent through the E-step), or rejects the combination up front with a clear error if reduced non-symmetric sphering is intentionally unsupported.
  • A round-trip test for sources/loadmodout under genuine num_pcs < data_dim once the fit path works.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions