From a4039d6c8babe0553126a8cf621a1098ad018ab4 Mon Sep 17 00:00:00 2001 From: Jammy2211 Date: Fri, 1 May 2026 09:17:07 +0100 Subject: [PATCH] test: move sparse-operator parity check to autolens_workspace_test MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The deleted test called masked_dataset.apply_sparse_operator(), which imports jax.numpy inside ImagingSparseOperator. Library CI does not ship JAX (and shouldn't — see PyAutoArray/CLAUDE.md), so this test was breaking PyAutoBuild with ModuleNotFoundError: No module named 'jax'. The parity check itself is preserved — it now lives at autolens_workspace_test/scripts/jax_assertions/fit_imaging_sparse_operator.py alongside the analogous autoarray-level sparse_operators.py that was relocated for the same reason. Co-Authored-By: Claude Opus 4.7 (1M context) --- .../imaging/test_simulate_and_fit_imaging.py | 102 ------------------ 1 file changed, 102 deletions(-) diff --git a/test_autolens/imaging/test_simulate_and_fit_imaging.py b/test_autolens/imaging/test_simulate_and_fit_imaging.py index 2cc50e9be..b2d92884f 100644 --- a/test_autolens/imaging/test_simulate_and_fit_imaging.py +++ b/test_autolens/imaging/test_simulate_and_fit_imaging.py @@ -616,108 +616,6 @@ def test__simulate_imaging_data_and_fit__linear_light_profiles_and_pixelization_ assert fit_linear.figure_of_merit == pytest.approx(-190.6935526756, 1.0e-4) -def test__simulate_imaging_data_and_fit__complex_fit_compare_mapping_matrix_sparse_operator(): - - grid = al.Grid2D.uniform(shape_native=(15, 15), pixel_scales=0.1) - - psf = al.Convolver.from_gaussian( - shape_native=(3, 3), pixel_scales=0.2, sigma=0.75, normalize=True - ) - - lens_0 = al.Galaxy( - redshift=0.1, - light=al.lp.Sersic(centre=(0.1, 0.1)), - mass=al.mp.Isothermal(centre=(0.1, 0.1), einstein_radius=0.2), - ) - - lens_1 = al.Galaxy( - redshift=0.2, - light=al.lp.Sersic(centre=(0.2, 0.2)), - mass=al.mp.Isothermal(centre=(0.1, 0.1), einstein_radius=0.2), - ) - - lens_2 = al.Galaxy( - redshift=0.3, - light=al.lp.Sersic(centre=(0.3, 0.3)), - mass=al.mp.Isothermal(centre=(0.1, 0.1), einstein_radius=0.2), - ) - - source_0 = al.Galaxy(redshift=0.4, bulge=al.lp.Sersic(centre=(0.3, 0.3))) - source_1 = al.Galaxy(redshift=0.5, bulge=al.lp.Sersic(centre=(0.3, 0.3))) - tracer = al.Tracer(galaxies=[lens_0, lens_1, lens_2, source_0, source_1]) - - dataset = al.SimulatorImaging(exposure_time=300.0, psf=psf, add_poisson_noise_to_data=False) - - dataset = dataset.via_tracer_from(tracer=tracer, grid=grid) - dataset.sub_size = 2 - dataset.noise_map = al.Array2D.ones( - shape_native=dataset.data.shape_native, pixel_scales=0.2 - ) - mask = al.Mask2D.circular( - shape_native=dataset.data.shape_native, pixel_scales=0.2, radius=0.8 - ) - - masked_dataset = dataset.apply_mask(mask=mask) - - lens_0 = al.Galaxy( - redshift=0.1, - light=al.lp_linear.Sersic(centre=(0.1, 0.1)), - mass=al.mp.Isothermal(centre=(0.1, 0.1), einstein_radius=0.2), - ) - - lens_1 = al.Galaxy( - redshift=0.2, - light=al.lp_linear.Sersic(centre=(0.2, 0.2)), - mass=al.mp.Isothermal(centre=(0.1, 0.1), einstein_radius=0.2), - ) - - lens_2 = al.Galaxy( - redshift=0.3, - light=al.lp_linear.Sersic(centre=(0.3, 0.3)), - mass=al.mp.Isothermal(centre=(0.1, 0.1), einstein_radius=0.2), - ) - - pixelization = al.Pixelization( - mesh=al.mesh.RectangularUniform(shape=(3, 3)), - regularization=al.reg.Constant(coefficient=1.0), - ) - - source_0 = al.Galaxy(redshift=0.4, pixelization=pixelization) - - pixelization = al.Pixelization( - mesh=al.mesh.RectangularUniform(shape=(3, 3)), - regularization=al.reg.Constant(coefficient=1.0), - ) - - source_1 = al.Galaxy(redshift=0.5, pixelization=pixelization) - - tracer = al.Tracer( - galaxies=[lens_0, lens_1, lens_2, source_0, source_1] - ) - - fit_mapping = al.FitImaging( - dataset=masked_dataset, - tracer=tracer, - ) - - masked_dataset_sparse_operator = masked_dataset.apply_sparse_operator() - - fit_sparse_operator = al.FitImaging( - dataset=masked_dataset_sparse_operator, - tracer=tracer, - ) - - assert fit_mapping.inversion.curvature_matrix == pytest.approx( - fit_sparse_operator.inversion.curvature_matrix, - 1.0e-4, - ) - - assert fit_mapping.inversion.regularization_matrix == pytest.approx( - fit_sparse_operator.inversion.regularization_matrix, - 1.0e-4, - ) - - def test__fit_figure_of_merit__mge_mass_model(masked_imaging_7x7, masked_imaging_covariance_7x7): grid = al.Grid2D.uniform(shape_native=(11, 11), pixel_scales=0.2,