Skip to content

fix(interferometer-sparse): guard against Delaunay mappers (issue #314)#315

Merged
Jammy2211 merged 1 commit into
mainfrom
feature/datacube-sparse-operator
May 15, 2026
Merged

fix(interferometer-sparse): guard against Delaunay mappers (issue #314)#315
Jammy2211 merged 1 commit into
mainfrom
feature/datacube-sparse-operator

Conversation

@Jammy2211
Copy link
Copy Markdown
Collaborator

Summary

Guards InversionInterferometerSparse.curvature_matrix_diag against Delaunay mappers with a clear NotImplementedError instead of silently producing a wrong curvature matrix. Surfaced while attempting to enable dataset.apply_sparse_operator(use_jax=True) on Hannah Stacey's ALMA cube profiler (shipped #311 / autolens_workspace_developer#63): the sparse-operator curvature disagrees with the mapping path by ~34% Frobenius norm for Delaunay, the regularized matrix loses positive-definiteness, and Inversion.log_det_curvature_reg_matrix_term raises numpy.linalg.LinAlgError.

The underlying math bug is filed as #314 — that issue tracks the actual fix. This PR is just the silent-failure guard.

API Changes

InversionInterferometerSparse.curvature_matrix_diag (and therefore curvature_matrix, data_vector, and any downstream method that materialises the curvature) now raises NotImplementedError when constructed with a Delaunay-mesh mapper. Users running Interferometer.apply_sparse_operator(...) + Delaunay get a clear early failure pointing at #314 instead of a confusing Cholesky error deep inside the inversion solver. See full details below.

Test Plan

  • pytest test_autoarray/inversion/inversion/interferometer/test_interferometer.py -xvs — 3 passed (existing 2 + new test__apply_sparse_operator__delaunay_mapper__raises_not_implemented).
  • pytest test_autoarray/inversion/ — 165 passed.
  • CI green.
Full API Changes (for automation & release notes)

Changed Behaviour

  • autoarray.inversion.inversion.interferometer.sparse.InversionInterferometerSparse.curvature_matrix_diag — now raises NotImplementedError when the first mapper in linear_obj_list uses a Delaunay mesh. The previous behaviour returned a numerically-incorrect curvature matrix (~34% Frobenius disagreement with the mapping path) and downstream operations failed loudly in the Cholesky factorisation step. After this PR the failure surfaces at the construction of the curvature matrix itself with a message pointing at issue Interferometer + Delaunay sparse-operator curvature math is wrong (silent ~34% error) #314.

Migration

For Delaunay interferometer fits that previously called dataset.apply_sparse_operator(...), drop the call and use the plain TransformerDFT (or TransformerNUFFT) path directly:

# Before — silently wrong then crashes at Cholesky
dataset = al.Interferometer.from_fits(..., transformer_class=al.TransformerDFT)
dataset = dataset.apply_sparse_operator(use_jax=True)  # Delaunay path

# After — no sparse-operator for Delaunay; use the plain DFT path
dataset = al.Interferometer.from_fits(..., transformer_class=al.TransformerDFT)
# (no apply_sparse_operator call — eager and JIT both work)

Rectangular interferometer fits are unaffected — they continue to work with apply_sparse_operator (the optimisation is validated for Rectangular meshes).

Related

🤖 Generated with Claude Code

`InversionInterferometerSparse.curvature_matrix_diag` now raises
`NotImplementedError` when paired with a Delaunay mapper. The sparse-operator
curvature path (`InterferometerSparseOperator.curvature_matrix_via_sparse_operator_from`)
has only been validated against `Rectangular*` meshes; on a Delaunay mapper
the returned curvature disagrees with the mapping path by ~34% Frobenius norm
and the regularized matrix loses positive-definiteness, raising a numpy
LinAlgError deep inside `log_det_curvature_reg_matrix_term`. Guard early at
the entry point with a clear message rather than silently mis-computing.

Adds a regression test verifying the guard fires for a Delaunay mapper paired
with `apply_sparse_operator(use_jax=False)`.

The underlying math bug remains: the W-tilde-formalism curvature for
interferometer + Delaunay needs rewriting to correctly handle barycentric
weights (Pmax > 1). Filed as a follow-up issue; this PR only stops the silent
failure.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@Jammy2211 Jammy2211 added the pending-release PR queued for the next release build label May 15, 2026
@Jammy2211 Jammy2211 merged commit dabe993 into main May 15, 2026
6 checks passed
@Jammy2211 Jammy2211 deleted the feature/datacube-sparse-operator branch May 15, 2026 15:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pending-release PR queued for the next release build

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant