@@ -62,3 +62,73 @@ def test__fast_chi_squared(
6262 chi_squared = aa .util .fit .chi_squared_complex_from (chi_squared_map = chi_squared_map )
6363
6464 assert inversion .fast_chi_squared == pytest .approx (chi_squared , 1.0e-4 )
65+
66+
67+ def test__apply_sparse_operator__delaunay_mapper__raises_not_implemented ():
68+ """``InversionInterferometerSparse.curvature_matrix_diag`` must raise a
69+ ``NotImplementedError`` rather than silently mis-computing when paired
70+ with a Delaunay mapper.
71+
72+ The interferometer sparse-operator curvature path
73+ (``InterferometerSparseOperator.curvature_matrix_via_sparse_operator_from``)
74+ was only validated against ``Rectangular*`` meshes (single source pixel per
75+ image pixel, weight 1). On a Delaunay mapper (three source pixels per image
76+ pixel via barycentric interpolation, weights summing to 1) the returned
77+ curvature matrix disagrees with the mapping path by ~34% Frobenius norm and
78+ the regularized matrix loses positive-definiteness, raising a numpy
79+ ``LinAlgError`` deep inside ``Inversion.log_det_curvature_reg_matrix_term``.
80+ The guard at the entry point catches the mis-use early with a clear message.
81+ """
82+ mask = aa .Mask2D (
83+ mask = [
84+ [True , True , True , True , True , True , True ],
85+ [True , True , True , True , True , True , True ],
86+ [True , True , True , False , True , True , True ],
87+ [True , True , False , False , False , True , True ],
88+ [True , True , True , False , True , True , True ],
89+ [True , True , True , True , True , True , True ],
90+ [True , True , True , True , True , True , True ],
91+ ],
92+ pixel_scales = 2.0 ,
93+ )
94+
95+ grid = aa .Grid2D .from_mask (mask = mask , over_sample_size = 1 )
96+
97+ mesh = aa .mesh .Delaunay (pixels = 9 )
98+ image_mesh = aa .image_mesh .Overlay (shape = (3 , 3 ))
99+ image_mesh_grid = image_mesh .image_plane_mesh_grid_from (
100+ mask = mask , adapt_data = None
101+ )
102+
103+ interpolator = mesh .interpolator_from (
104+ source_plane_data_grid = grid ,
105+ source_plane_mesh_grid = image_mesh_grid ,
106+ )
107+ mapper = aa .Mapper (interpolator = interpolator )
108+
109+ n_visibilities = 5
110+ rng = np .random .default_rng (seed = 0 )
111+ data = aa .Visibilities (
112+ visibilities = rng .normal (size = (n_visibilities , 2 )).astype (np .float64 )
113+ )
114+ noise_map = aa .VisibilitiesNoiseMap (
115+ visibilities = np .ones ((n_visibilities , 2 ), dtype = np .float64 )
116+ )
117+ uv_wavelengths = rng .normal (size = (n_visibilities , 2 )).astype (np .float64 )
118+
119+ dataset = aa .Interferometer (
120+ data = data ,
121+ noise_map = noise_map ,
122+ uv_wavelengths = uv_wavelengths ,
123+ real_space_mask = mask ,
124+ transformer_class = aa .TransformerDFT ,
125+ )
126+ dataset_sparse = dataset .apply_sparse_operator (use_jax = False )
127+
128+ inversion = aa .Inversion (
129+ dataset = dataset_sparse ,
130+ linear_obj_list = [mapper ],
131+ )
132+
133+ with pytest .raises (NotImplementedError , match = r"Delaunay" ):
134+ _ = inversion .curvature_matrix
0 commit comments