Skip to content

fix: give each basis independent ell_comps in mge_model_from#342

Merged
Jammy2211 merged 1 commit intomainfrom
feature/mge-fix
Apr 12, 2026
Merged

fix: give each basis independent ell_comps in mge_model_from#342
Jammy2211 merged 1 commit intomainfrom
feature/mge-fix

Conversation

@Jammy2211
Copy link
Copy Markdown
Collaborator

Summary

mge_model_from constructed centre and ell_comps priors once outside the per-basis loop, so gaussian_per_basis > 1 added redundant Gaussians with zero extra flexibility (always 4 free params). Now each basis gets independent ell_comps, and a new centre_per_basis flag optionally gives each basis its own centre priors.

Closes #341

API Changes

  • New parameter: centre_per_basis: bool = False on mge_model_from — when True, each basis gets independent centre priors
  • Behaviour change: mge_model_from with gaussian_per_basis > 1 now produces independent ell_comps per basis (was previously tied). Calls with gaussian_per_basis=1 are unchanged.

See full details below.

Test Plan

  • 11 new unit tests covering all parameter count scenarios (1/2/3 bases, spherical, centre_per_basis, centre_fixed)
  • Full test suite passes (822 tests)
  • Smoke test workspace scripts
Full API Changes (for automation & release notes)

Added

  • mge_model_from(..., centre_per_basis: bool = False) — new keyword argument. When True, each basis gets independently drawn centre priors instead of sharing one set.

Changed Behaviour

  • mge_model_from with gaussian_per_basis > 1: ell_comps are now independent per basis. Previously all bases shared the same ell_comps prior instances, giving 4 free params regardless of basis count. Now gives 2 + 2K free params for K bases (shared centre) or 4K (with centre_per_basis=True).
  • No change for gaussian_per_basis=1 (backward compatible).

Migration

  • Before: mge_model_from(mask_radius=3.0, gaussian_per_basis=2) → 4 free params (bug)
  • After: mge_model_from(mask_radius=3.0, gaussian_per_basis=2) → 6 free params (intended)
  • New: mge_model_from(mask_radius=3.0, gaussian_per_basis=2, centre_per_basis=True) → 8 free params

🤖 Generated with Claude Code

Previously, centre and ell_comps priors were constructed once outside the
per-basis loop, so gaussian_per_basis > 1 added redundant Gaussians with
zero extra flexibility (always 4 free params regardless of basis count).

Now ell_comps are always independent per basis, and a new centre_per_basis
flag optionally gives each basis its own centre priors. Existing calls with
gaussian_per_basis=1 produce identical output. Calls with gaussian_per_basis>1
now get the intended extra flexibility (e.g. 6 free params for 2 bases).

Closes #341

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@Jammy2211 Jammy2211 added the pending-release Merged PR awaiting inclusion in the next release build label Apr 12, 2026
@Jammy2211 Jammy2211 merged commit 3a74452 into main Apr 12, 2026
0 of 2 checks passed
@Jammy2211 Jammy2211 deleted the feature/mge-fix branch April 12, 2026 11:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pending-release Merged PR awaiting inclusion in the next release build

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix: mge_model_from ties ell_comps across bases when gaussian_per_basis > 1

1 participant