diff --git a/autolens/analysis/positions.py b/autolens/analysis/positions.py index 90a7cfe84..3e032329a 100644 --- a/autolens/analysis/positions.py +++ b/autolens/analysis/positions.py @@ -224,10 +224,12 @@ def log_likelihood_penalty_base_from( residual_map=residual_map, noise_map=dataset.noise_map ) - chi_squared = aa.util.fit.chi_squared_from(chi_squared_map=chi_squared_map) + chi_squared = aa.util.fit.chi_squared_from( + chi_squared_map=chi_squared_map.array + ) noise_normalization = aa.util.fit.noise_normalization_from( - noise_map=dataset.noise_map + noise_map=dataset.noise_map.array ) else: diff --git a/autolens/imaging/fit_imaging.py b/autolens/imaging/fit_imaging.py index 70e5ea418..b0fbb89c5 100644 --- a/autolens/imaging/fit_imaging.py +++ b/autolens/imaging/fit_imaging.py @@ -104,6 +104,7 @@ def tracer_to_inversion(self) -> TracerToInversion: noise_map=self.noise_map, grids=self.grids, psf=self.dataset.psf, + convolver=self.dataset.convolver, w_tilde=self.w_tilde, ) diff --git a/autolens/lens/to_inversion.py b/autolens/lens/to_inversion.py index 480a4b001..c26cc3860 100644 --- a/autolens/lens/to_inversion.py +++ b/autolens/lens/to_inversion.py @@ -181,6 +181,7 @@ def lp_linear_func_list_galaxy_dict( noise_map=self.dataset.noise_map, grids=grids, psf=self.psf, + convolver=self.dataset.convolver, transformer=self.transformer, w_tilde=self.dataset.w_tilde, ) diff --git a/autolens/lens/tracer.py b/autolens/lens/tracer.py index 4e0c2581a..5e14c117d 100644 --- a/autolens/lens/tracer.py +++ b/autolens/lens/tracer.py @@ -1,6 +1,5 @@ from abc import ABC import numpy as np -from functools import wraps from scipy.interpolate import griddata from typing import Dict, List, Optional, Type, Union @@ -549,9 +548,9 @@ def image_2d_via_input_plane_image_from( )[plane_index] image = griddata( - points=plane_grid, - values=plane_image, - xi=traced_grid.over_sampled, + points=plane_grid.array, + values=plane_image.array, + xi=traced_grid.over_sampled.array, fill_value=0.0, method="linear", ) diff --git a/autolens/point/fit/positions/source/separations.py b/autolens/point/fit/positions/source/separations.py index 2c35269b8..32fdbcf91 100644 --- a/autolens/point/fit/positions/source/separations.py +++ b/autolens/point/fit/positions/source/separations.py @@ -1,4 +1,4 @@ -from autoarray.numpy_wrapper import numpy as npw +import jax.numpy as jnp import numpy as np from typing import Optional @@ -126,8 +126,8 @@ def noise_normalization(self) -> float: """ Returns the normalization of the noise-map, which is the sum of the noise-map values squared. """ - return npw.sum( - npw.log( + return jnp.sum( + jnp.log( 2 * np.pi * (self.magnifications_at_positions**-2.0 * self.noise_map**2.0) diff --git a/autolens/point/solver/point_solver.py b/autolens/point/solver/point_solver.py index 2d160d583..33d27baa2 100644 --- a/autolens/point/solver/point_solver.py +++ b/autolens/point/solver/point_solver.py @@ -1,10 +1,7 @@ import logging from typing import Tuple, Optional -from autoarray.numpy_wrapper import np - import autoarray as aa -from autoarray.numpy_wrapper import use_jax from autoarray.structures.triangles.shape import Point from autofit.jax_wrapper import jit, register_pytree_node_class @@ -56,23 +53,23 @@ def solve( filtered_means = self._filter_low_magnification( tracer=tracer, points=kept_triangles.means ) - if use_jax: - return aa.Grid2DIrregular([pair for pair in filtered_means]) - - filtered_means = [ - pair for pair in filtered_means if not np.any(np.isnan(pair)).all() - ] - difference = len(kept_triangles.means) - len(filtered_means) - if difference > 0: - logger.debug( - f"Filtered one multiple-image with magnification below threshold." - ) - elif difference > 1: - logger.warning( - f"Filtered {difference} multiple-images with magnification below threshold." - ) + return aa.Grid2DIrregular([pair for pair in filtered_means]) - return aa.Grid2DIrregular( - [pair for pair in filtered_means if not np.isnan(pair).all()] - ) + # filtered_means = [ + # pair for pair in filtered_means if not np.any(np.isnan(pair)).all() + # ] + # + # difference = len(kept_triangles.means) - len(filtered_means) + # if difference > 0: + # logger.debug( + # f"Filtered one multiple-image with magnification below threshold." + # ) + # elif difference > 1: + # logger.warning( + # f"Filtered {difference} multiple-images with magnification below threshold." + # ) + # + # return aa.Grid2DIrregular( + # [pair for pair in filtered_means if not np.isnan(pair).all()] + # ) diff --git a/autolens/point/solver/shape_solver.py b/autolens/point/solver/shape_solver.py index f398f41cd..c35be29c0 100644 --- a/autolens/point/solver/shape_solver.py +++ b/autolens/point/solver/shape_solver.py @@ -1,3 +1,5 @@ +import jax.numpy as jnp +from jax import jit import logging import math @@ -6,23 +8,11 @@ import autoarray as aa from autoarray.structures.triangles.shape import Shape -from autofit.jax_wrapper import jit, use_jax, numpy as np, register_pytree_node_class - -try: - if use_jax: - from autoarray.structures.triangles.coordinate_array.jax_coordinate_array import ( - CoordinateArrayTriangles, - ) - else: - from autoarray.structures.triangles.coordinate_array.coordinate_array import ( - CoordinateArrayTriangles, - ) - -except ImportError: - from autoarray.structures.triangles.coordinate_array.coordinate_array import ( - CoordinateArrayTriangles, - ) +from autofit.jax_wrapper import register_pytree_node_class +from autoarray.structures.triangles.coordinate_array.jax_coordinate_array import ( + CoordinateArrayTriangles, +) from autoarray.structures.triangles.abstract import AbstractTriangles from autogalaxy import OperateDeflections @@ -278,13 +268,13 @@ def _filter_low_magnification( ------- The points with an absolute magnification above the threshold. """ - points = np.array(points) + points = jnp.array(points) magnifications = tracer.magnification_2d_via_hessian_from( grid=aa.Grid2DIrregular(points), buffer=self.scale, ) - mask = np.abs(magnifications.array) > self.magnification_threshold - return np.where(mask[:, None], points, np.nan) + mask = jnp.abs(magnifications.array) > self.magnification_threshold + return jnp.where(mask[:, None], points, jnp.nan) def _source_triangles( self, diff --git a/docs/installation/conda.rst b/docs/installation/conda.rst index 8a765e348..88c68ef18 100644 --- a/docs/installation/conda.rst +++ b/docs/installation/conda.rst @@ -105,7 +105,6 @@ For interferometer analysis there are two optional dependencies that must be ins .. code-block:: bash pip install pynufft - pip install pylops==2.3.1 **PyAutoLens** will run without these libraries and it is recommended that you only install them if you intend to do interferometer analysis. diff --git a/docs/installation/overview.rst b/docs/installation/overview.rst index 1915ca12b..c5917fc7c 100644 --- a/docs/installation/overview.rst +++ b/docs/installation/overview.rst @@ -66,6 +66,4 @@ Dependencies And the following optional dependencies: -**pynufft**: https://github.com/jyhmiinlin/pynufft - -**PyLops**: https://github.com/PyLops/pylops \ No newline at end of file +**pynufft**: https://github.com/jyhmiinlin/pynufft \ No newline at end of file diff --git a/docs/installation/pip.rst b/docs/installation/pip.rst index 05a9cf968..dbb168b3f 100644 --- a/docs/installation/pip.rst +++ b/docs/installation/pip.rst @@ -86,7 +86,6 @@ For interferometer analysis there are two optional dependencies that must be ins .. code-block:: bash pip install pynufft - pip install pylops==2.3.1 **PyAutoLens** will run without these libraries and it is recommended that you only install them if you intend to do interferometer analysis. diff --git a/docs/installation/source.rst b/docs/installation/source.rst index 5af7b5692..cf0c85d7c 100644 --- a/docs/installation/source.rst +++ b/docs/installation/source.rst @@ -59,7 +59,6 @@ For unit tests to pass you will also need the following optional requirements: .. code-block:: bash pip install pynufft - pip install pylops==2.3.1 If you are using a ``conda`` environment, add the source repository as follows: diff --git a/files/citations.bib b/files/citations.bib index 195c498d7..162021d3a 100644 --- a/files/citations.bib +++ b/files/citations.bib @@ -33,17 +33,6 @@ @article{astropy2 Bdsk-Url-1 = {https://doi.org/10.3847/1538-3881/aabc4f} } -@article{PyLops, -abstract = {Linear operators and optimisation are at the core of many algorithms used in signal and image processing, remote sensing, and inverse problems. For small to medium-scale problems, existing software packages (e.g., MATLAB, Python numpy and scipy) allow for explicitly building dense (or sparse) matrices and performing algebraic operations (e.g., computation of matrix-vector products and manipulation of matrices) with syntax that closely represents their corresponding analytical forms. However, many real application, large-scale operators do not lend themselves to explicit matrix representations, usually forcing practitioners to forego of the convenient linear-algebra syntax available for their explicit-matrix counterparts. PyLops is an open-source Python library providing a flexible and scalable framework for the creation and combination of so-called linear operators, class-based entities that represent matrices and inherit their associated syntax convenience, but do not rely on the creation of explicit matrices. We show that PyLops operators can dramatically reduce the memory load and CPU computations compared to explicit-matrix calculations, while still allowing users to seamlessly use their existing knowledge of compact matrix-based syntax that scales to any problem size because no explicit matrices are required.}, -archivePrefix = {arXiv}, -arxivId = {1907.12349}, -author = {Ravasi, Matteo and Vasconcelos, Ivan}, -eprint = {1907.12349}, -file = {:home/jammy/Documents/Papers/Software/PyLops.pdf:pdf}, -title = {{PyLops -- A Linear-Operator Python Library for large scale optimization}}, -url = {http://arxiv.org/abs/1907.12349}, -year = {2019} -} @article{colossus, abstract = {This paper introduces Colossus, a public, open-source python package for calculations related to cosmology, the large-scale structure (LSS) of matter in the universe, and the properties of dark matter halos. The code is designed to be fast and easy to use, with a coherent, well-documented user interface. The cosmology module implements Friedman-Lemaitre-Robertson-Walker cosmologies including curvature, relativistic species, and different dark energy equations of state, and provides fast computations of the linear matter power spectrum, variance, and correlation function. The LSS module is concerned with the properties of peaks in Gaussian random fields and halos in a statistical sense, including their peak height, peak curvature, halo bias, and mass function. The halo module deals with spherical overdensity radii and masses, density profiles, concentration, and the splashback radius. To facilitate the rapid exploration of these quantities, Colossus implements more than 40 different fitting functions from the literature. I discuss the core routines in detail, with particular emphasis on their accuracy. Colossus is available at bitbucket.org/bdiemer/colossus.}, diff --git a/files/citations.md b/files/citations.md index 36589cbb5..cf914917c 100644 --- a/files/citations.md +++ b/files/citations.md @@ -19,7 +19,6 @@ This work uses the following software packages: - `PyAutoFit` https://github.com/rhayes777/PyAutoFit [@pyautofit] - `PyAutoGalaxy` https://github.com/Jammy2211/PyAutoGalaxy [@Nightingale2018] [@pyautogalaxy] - `PyAutoLens` https://github.com/Jammy2211/PyAutoLens [@Nightingale2015] [@Nightingale2018] [@pyautolens] -- `PyLops` https://github.com/equinor/pylops [@pylops] - `PyNUFFT` https://github.com/jyhmiinlin/pynufft [@pynufft] - `PySwarms` https://github.com/ljvmiranda921/pyswarms [@pyswarms] - `Python` https://www.python.org/ [@python] diff --git a/files/citations.tex b/files/citations.tex index f500eb271..fd9b4bb1e 100644 --- a/files/citations.tex +++ b/files/citations.tex @@ -54,9 +54,6 @@ \section*{Software Citations} \href{https://github.com/Jammy2211/PyAutoLens}{\textt{PyAutoLens}} \citep{Nightingale2015, Nightingale2018, pyautolens} -\item -\href{https://github.com/equinor/pylops}{\textt{PyLops}} -\citep{pylops} \item \href{https://github.com/jyhmiinlin/pynufft}{\textt{PyNUFFT}} diff --git a/optional_requirements.txt b/optional_requirements.txt index 7f924b895..0d3df0113 100644 --- a/optional_requirements.txt +++ b/optional_requirements.txt @@ -1,5 +1,4 @@ numba -pylops>=1.10.0,<=2.3.1 pynufft zeus-mcmc==2.5.4 getdist==1.4 diff --git a/paper/paper.bib b/paper/paper.bib index fe46fc04f..eba78d1bf 100644 --- a/paper/paper.bib +++ b/paper/paper.bib @@ -30,17 +30,7 @@ @article{astropy2 Volume = {156}, Year = 2018, Bdsk-Url-1 = {https://doi.org/10.3847/1538-3881/aabc4f}} -@article{PyLops, -abstract = {Linear operators and optimisation are at the core of many algorithms used in signal and image processing, remote sensing, and inverse problems. For small to medium-scale problems, existing software packages (e.g., MATLAB, Python numpy and scipy) allow for explicitly building dense (or sparse) matrices and performing algebraic operations (e.g., computation of matrix-vector products and manipulation of matrices) with syntax that closely represents their corresponding analytical forms. However, many real application, large-scale operators do not lend themselves to explicit matrix representations, usually forcing practitioners to forego of the convenient linear-algebra syntax available for their explicit-matrix counterparts. PyLops is an open-source Python library providing a flexible and scalable framework for the creation and combination of so-called linear operators, class-based entities that represent matrices and inherit their associated syntax convenience, but do not rely on the creation of explicit matrices. We show that PyLops operators can dramatically reduce the memory load and CPU computations compared to explicit-matrix calculations, while still allowing users to seamlessly use their existing knowledge of compact matrix-based syntax that scales to any problem size because no explicit matrices are required.}, -archivePrefix = {arXiv}, -arxivId = {1907.12349}, -author = {Ravasi, Matteo and Vasconcelos, Ivan}, -eprint = {1907.12349}, -file = {:home/jammy/Documents/Papers/Software/PyLops.pdf:pdf}, -title = {{PyLops -- A Linear-Operator Python Library for large scale optimization}}, -url = {http://arxiv.org/abs/1907.12349}, -year = {2019} -} + @article{colossus, abstract = {This paper introduces Colossus, a public, open-source python package for calculations related to cosmology, the large-scale structure (LSS) of matter in the universe, and the properties of dark matter halos. The code is designed to be fast and easy to use, with a coherent, well-documented user interface. The cosmology module implements Friedman-Lemaitre-Robertson-Walker cosmologies including curvature, relativistic species, and different dark energy equations of state, and provides fast computations of the linear matter power spectrum, variance, and correlation function. The LSS module is concerned with the properties of peaks in Gaussian random fields and halos in a statistical sense, including their peak height, peak curvature, halo bias, and mass function. The halo module deals with spherical overdensity radii and masses, density profiles, concentration, and the splashback radius. To facilitate the rapid exploration of these quantities, Colossus implements more than 40 different fitting functions from the literature. I discuss the core routines in detail, with particular emphasis on their accuracy. Colossus is available at bitbucket.org/bdiemer/colossus.}, archivePrefix = {arXiv}, diff --git a/paper/paper.md b/paper/paper.md index 77ea3412a..fe72c079f 100644 --- a/paper/paper.md +++ b/paper/paper.md @@ -160,8 +160,7 @@ effects like the telescope optics and background sky subtraction in the model-fi performed directly on the observed visibilities in their native Fourier space, circumventing issues associated with the incomplete sampling of the uv-plane that give rise to artefacts that can bias the inferred mass model and source reconstruction in real-space. To make feasible the analysis of millions of visibilities, `PyAutoLens` -uses `PyNUFFT` [@pynufft] to fit the visibilities via a non-uniform fast Fourier transform and `PyLops` [@PyLops] to -express the memory-intensive linear algebra calculations as efficient linear operators [@Powell2020]. Creating +uses `PyNUFFT` [@pynufft] to fit the visibilities via a non-uniform fast Fourier transform. Creating realistic simulations of imaging and interferometer strong lensing datasets is possible, as performed by [@Alexander2019] [@Hermans2019] who used `PyAutoLens` to train neural networks to detect strong lenses. @@ -198,7 +197,6 @@ taken without a local `PyAutoLens` installation. - `numba` [@numba] - `NumPy` [@numpy] - `PyAutoFit` [@pyautofit] -- `PyLops` [@PyLops] - `PyMultiNest` [@pymultinest] [@multinest] - `PyNUFFT` [@pynufft] - `pyprojroot` (https://github.com/chendaniely/pyprojroot) diff --git a/test_autolens/config/grids.yaml b/test_autolens/config/grids.yaml deleted file mode 100644 index 06d81535e..000000000 --- a/test_autolens/config/grids.yaml +++ /dev/null @@ -1,65 +0,0 @@ -interpolate: - convergence_2d_from: - Isothermal: false - IsothermalInitialize: false - IsothermalSph: true - deflections_yx_2d_from: - Isothermal: false - IsothermalInitialize: false - IsothermalSph: true - image_2d_from: - Sersic: false - SersicInitialize: false - SersicSph: true - potential_2d_from: - Isothermal: false - IsothermalInitialize: false - IsothermalSph: true -# Certain light and mass profile calculations become ill defined at (0.0, 0.0) or close to this value. This can lead -# to numerical issues in the calculation of the profile, for example a np.nan may arise, crashing the code. - -# To avoid this, we set a minimum value for the radial coordinate of the profile. If the radial coordinate is below -# this value, it is rounded up to this value. This ensures that the profile cannot receive a radial coordinate of 0.0. - -# For example, if an input grid coordinate has a radial coordinate of 1e-12, for most profiles this will be rounded up -# to radial_minimum=1e-08. This is a small enough value that it should not impact the results of the profile calculation. - -radial_minimum: - radial_minimum: - DevVaucouleurs: 1.0e-08 - DevVaucouleursSph: 1.0e-08 - EllMassProfile: 1.0e-08 - EllProfile: 1.0e-08 - Exponential: 1.0e-08 - ExponentialSph: 1.0e-08 - ExternalShear: 1.0e-08 - Gaussian: 1.0e-08 - GaussianGradient: 1.0e-08 - GaussianSph: 1.0e-08 - Isothermal: 1.0e-08 - IsothermalCore: 1.0e-08 - IsothermalCoreSph: 1.0e-08 - IsothermalInitialize: 1.0e-08 - IsothermalSph: 1.0e-08 - MassSheet: 1.0e-08 - MockGridRadialMinimum: 2.5 - NFW: 1.0e-08 - NFWSph: 1.0e-08 - NFWTruncatedSph: 1.0e-08 - PointMass: 0.0 - PowerLaw: 1.0e-08 - PowerLawBroken: 1.0e-08 - PowerLawBrokenSph: 1.0e-08 - PowerLawCore: 1.0e-08 - PowerLawCoreSph: 1.0e-08 - PowerLawSph: 1.0e-08 - Sersic: 1.0e-08 - SersicCore: 1.0e-08 - SersicCoreSph: 1.0e-08 - SersicGradient: 1.0e-08 - SersicGradientSph: 1.0e-08 - SersicSph: 1.0e-08 - SphNFWTruncatedMCR: 1.0e-08 - gNFW: 1.0e-08 - gNFWSph: 1.0e-08 - diff --git a/test_autolens/config/notation.yaml b/test_autolens/config/notation.yaml index 2d19ca16d..92a53b924 100644 --- a/test_autolens/config/notation.yaml +++ b/test_autolens/config/notation.yaml @@ -62,7 +62,6 @@ label: weight_power: W_{\rm p} superscript: ExternalShear: ext - InputDeflections: defl Pixelization: pix Point: point Redshift: '' diff --git a/test_autolens/imaging/model/test_analysis_imaging.py b/test_autolens/imaging/model/test_analysis_imaging.py index 54c4b99ef..170ab566c 100644 --- a/test_autolens/imaging/model/test_analysis_imaging.py +++ b/test_autolens/imaging/model/test_analysis_imaging.py @@ -67,8 +67,8 @@ def test__positions__resample__raises_exception(masked_imaging_7x7): def test__positions__likelihood_overwrites__changes_likelihood(masked_imaging_7x7): - lens = al.Galaxy(redshift=0.5, mass=al.mp.IsothermalSph()) - source = al.Galaxy(redshift=1.0, light=al.lp.SersicSph()) + lens = al.Galaxy(redshift=0.5, mass=al.mp.IsothermalSph(centre=(0.05, 0.05))) + source = al.Galaxy(redshift=1.0, light=al.lp.SersicSph(centre=(0.05, 0.05))) model = af.Collection(galaxies=af.Collection(lens=lens, source=source)) @@ -82,7 +82,7 @@ def test__positions__likelihood_overwrites__changes_likelihood(masked_imaging_7x fit = al.FitImaging(dataset=masked_imaging_7x7, tracer=tracer) assert fit.log_likelihood == pytest.approx(analysis_log_likelihood, 1.0e-4) - assert analysis_log_likelihood == pytest.approx(-6258.043397009, 1.0e-4) + assert analysis_log_likelihood == pytest.approx(-14.79034680979, 1.0e-4) positions_likelihood = al.PositionsLHPenalty( positions=al.Grid2DIrregular([(1.0, 100.0), (200.0, 2.0)]), threshold=0.01 diff --git a/test_autolens/imaging/model/test_result_imaging.py b/test_autolens/imaging/model/test_result_imaging.py index 9263e2e8b..0cad3ae94 100644 --- a/test_autolens/imaging/model/test_result_imaging.py +++ b/test_autolens/imaging/model/test_result_imaging.py @@ -9,7 +9,7 @@ def test___linear_light_profiles_in_result(analysis_imaging_7x7): galaxies = af.ModelInstance() - galaxies.galaxy = al.Galaxy(redshift=0.5, bulge=al.lp_linear.Sersic()) + galaxies.galaxy = al.Galaxy(redshift=0.5, bulge=al.lp_linear.Sersic(centre=(0.05, 0.05))) instance = af.ModelInstance() instance.galaxies = galaxies @@ -24,4 +24,4 @@ def test___linear_light_profiles_in_result(analysis_imaging_7x7): ) assert result.max_log_likelihood_tracer.galaxies[ 0 - ].bulge.intensity == pytest.approx(0.002310735, 1.0e-4) + ].bulge.intensity == pytest.approx(0.1868684644, 1.0e-4) diff --git a/test_autolens/imaging/test_fit_imaging.py b/test_autolens/imaging/test_fit_imaging.py index 40e55003f..adb2a32fb 100644 --- a/test_autolens/imaging/test_fit_imaging.py +++ b/test_autolens/imaging/test_fit_imaging.py @@ -35,39 +35,39 @@ def test__fit_figure_of_merit(masked_imaging_7x7, masked_imaging_covariance_7x7) g0 = al.Galaxy( redshift=0.5, - bulge=al.lp.Sersic(intensity=1.0), - disk=al.lp.Sersic(intensity=2.0), - mass_profile=al.mp.IsothermalSph(einstein_radius=1.0), + bulge=al.lp.Sersic(centre=(0.05, 0.05), intensity=1.0), + disk=al.lp.Sersic(centre=(0.05, 0.05), intensity=2.0), + mass_profile=al.mp.IsothermalSph(centre=(0.05, 0.05), einstein_radius=1.0), ) - g1 = al.Galaxy(redshift=1.0, bulge=al.lp.Sersic(intensity=1.0)) + g1 = al.Galaxy(redshift=1.0, bulge=al.lp.Sersic(centre=(0.05, 0.05), intensity=1.0)) tracer = al.Tracer(galaxies=[g0, g1]) fit = al.FitImaging(dataset=masked_imaging_7x7, tracer=tracer) assert fit.perform_inversion is False - assert fit.figure_of_merit == pytest.approx(-2859741.44762, 1.0e-4) + assert fit.figure_of_merit == pytest.approx(-648.4814555620, 1.0e-4) basis = al.lp_basis.Basis( profile_list=[ - al.lp.Sersic(intensity=1.0), - al.lp.Sersic(intensity=2.0), + al.lp.Sersic(centre=(0.05, 0.05), intensity=1.0), + al.lp.Sersic(centre=(0.05, 0.05), intensity=2.0), ] ) g0 = al.Galaxy( - redshift=0.5, bulge=basis, mass_profile=al.mp.IsothermalSph(einstein_radius=1.0) + redshift=0.5, bulge=basis, mass_profile=al.mp.IsothermalSph(centre=(0.05, 0.05), einstein_radius=1.0) ) - g1 = al.Galaxy(redshift=1.0, bulge=al.lp.Sersic(intensity=1.0)) + g1 = al.Galaxy(redshift=1.0, bulge=al.lp.Sersic(centre=(0.05, 0.05), intensity=1.0)) tracer = al.Tracer(galaxies=[g0, g1]) fit = al.FitImaging(dataset=masked_imaging_7x7, tracer=tracer) assert fit.perform_inversion is False - assert fit.figure_of_merit == pytest.approx(-2859741.44762, 1.0e-4) + assert fit.figure_of_merit == pytest.approx(-648.4814555620, 1.0e-4) pixelization = al.Pixelization( mesh=al.mesh.Rectangular(shape=(3, 3)), @@ -83,7 +83,7 @@ def test__fit_figure_of_merit(masked_imaging_7x7, masked_imaging_covariance_7x7) assert fit.perform_inversion is True assert fit.figure_of_merit == pytest.approx(-22.90055, 1.0e-4) - galaxy_light = al.Galaxy(redshift=0.5, bulge=al.lp.Sersic(intensity=1.0)) + galaxy_light = al.Galaxy(redshift=0.5, bulge=al.lp.Sersic(centre=(0.05, 0.05), intensity=1.0)) pixelization = al.Pixelization( mesh=al.mesh.Rectangular(shape=(3, 3)), @@ -97,13 +97,13 @@ def test__fit_figure_of_merit(masked_imaging_7x7, masked_imaging_covariance_7x7) fit = al.FitImaging(dataset=masked_imaging_7x7, tracer=tracer) assert fit.perform_inversion is True - assert fit.figure_of_merit == pytest.approx(-37667.0303, 1.0e-4) + assert fit.figure_of_merit == pytest.approx(-29.201919365, 1.0e-4) g0_linear = al.Galaxy( redshift=0.5, - bulge=al.lp_linear.Sersic(sersic_index=1.0), - disk=al.lp_linear.Sersic(sersic_index=4.0), - mass_profile=al.mp.IsothermalSph(einstein_radius=1.0), + bulge=al.lp_linear.Sersic(centre=(0.05, 0.05), sersic_index=1.0), + disk=al.lp_linear.Sersic(centre=(0.05, 0.05), sersic_index=4.0), + mass_profile=al.mp.IsothermalSph(centre=(0.05, 0.05), einstein_radius=1.0), ) tracer = al.Tracer(galaxies=[g0_linear, g1]) @@ -111,17 +111,17 @@ def test__fit_figure_of_merit(masked_imaging_7x7, masked_imaging_covariance_7x7) fit = al.FitImaging(dataset=masked_imaging_7x7, tracer=tracer) assert fit.perform_inversion is True - assert fit.figure_of_merit == pytest.approx(-6741.83381, 1.0e-4) + assert fit.figure_of_merit == pytest.approx(-16.9731347648, 1.0e-4) basis = al.lp_basis.Basis( profile_list=[ - al.lp_linear.Sersic(sersic_index=1.0), - al.lp_linear.Sersic(sersic_index=4.0), + al.lp_linear.Sersic(centre=(0.05, 0.05), sersic_index=1.0), + al.lp_linear.Sersic(centre=(0.05, 0.05), sersic_index=4.0), ] ) g0_linear = al.Galaxy( - redshift=0.5, bulge=basis, mass_profile=al.mp.IsothermalSph(einstein_radius=1.0) + redshift=0.5, bulge=basis, mass_profile=al.mp.IsothermalSph(centre=(0.05, 0.05), einstein_radius=1.0) ) tracer = al.Tracer(galaxies=[g0_linear, g1]) @@ -129,12 +129,12 @@ def test__fit_figure_of_merit(masked_imaging_7x7, masked_imaging_covariance_7x7) fit = al.FitImaging(dataset=masked_imaging_7x7, tracer=tracer) assert fit.perform_inversion is True - assert fit.figure_of_merit == pytest.approx(-6741.83381, 1.0e-4) + assert fit.figure_of_merit == pytest.approx(-16.97313476, 1.0e-4) basis = al.lp_basis.Basis( profile_list=[ - al.lp_linear.Sersic(sersic_index=1.0), - al.lp_linear.Sersic(sersic_index=4.0), + al.lp_linear.Sersic(centre=(0.05, 0.05), sersic_index=1.0), + al.lp_linear.Sersic(centre=(0.05, 0.05), sersic_index=4.0), ], regularization=al.reg.Constant(coefficient=1.0), ) @@ -148,7 +148,7 @@ def test__fit_figure_of_merit(masked_imaging_7x7, masked_imaging_covariance_7x7) fit = al.FitImaging(dataset=masked_imaging_7x7, tracer=tracer) assert fit.perform_inversion is True - assert fit.figure_of_merit == pytest.approx(-208205.2074336, 1.0e-4) + assert fit.figure_of_merit == pytest.approx(-51.0835080747, 1.0e-4) tracer = al.Tracer(galaxies=[g0_linear, galaxy_pix]) @@ -159,27 +159,27 @@ def test__fit_figure_of_merit(masked_imaging_7x7, masked_imaging_covariance_7x7) g0_operated = al.Galaxy( redshift=0.5, - bulge=al.lp.Sersic(intensity=1.0), - mass_profile=al.mp.IsothermalSph(einstein_radius=1.0), + bulge=al.lp.Sersic(centre=(0.05, 0.05), intensity=1.0), + mass_profile=al.mp.IsothermalSph(centre=(0.05, 0.05), einstein_radius=1.0), ) - g1_operated = al.Galaxy(redshift=1.0, bulge=al.lp_operated.Sersic(intensity=1.0)) + g1_operated = al.Galaxy(redshift=1.0, bulge=al.lp_operated.Sersic(centre=(0.05, 0.05), intensity=1.0)) tracer = al.Tracer(galaxies=[g0_operated, g1_operated]) fit = al.FitImaging(dataset=masked_imaging_7x7, tracer=tracer) assert fit.perform_inversion is False - assert fit.figure_of_merit == pytest.approx(-2657889.4489, 1.0e-4) + assert fit.figure_of_merit == pytest.approx(-745.25961066, 1.0e-4) g0_linear_operated = al.Galaxy( redshift=0.5, - bulge=al.lp_linear_operated.Sersic(sersic_index=1.0), - mass_profile=al.mp.IsothermalSph(einstein_radius=1.0), + bulge=al.lp_linear_operated.Sersic(centre=(0.05, 0.05), sersic_index=1.0), + mass_profile=al.mp.IsothermalSph(centre=(0.05, 0.05), einstein_radius=1.0), ) g1_linear_operated = al.Galaxy( - redshift=1.0, bulge=al.lp_linear_operated.Sersic(sersic_index=4.0) + redshift=1.0, bulge=al.lp_linear_operated.Sersic(centre=(0.05, 0.05), sersic_index=4.0) ) tracer = al.Tracer(galaxies=[g0_linear_operated, g1_linear_operated]) @@ -187,23 +187,23 @@ def test__fit_figure_of_merit(masked_imaging_7x7, masked_imaging_covariance_7x7) fit = al.FitImaging(dataset=masked_imaging_7x7, tracer=tracer) assert fit.perform_inversion is True - assert fit.figure_of_merit == pytest.approx(-14.9881985, 1.0e-4) + assert fit.figure_of_merit == pytest.approx(-14.933306470, 1.0e-4) g0 = al.Galaxy( redshift=0.5, - bulge=al.lp.Sersic(intensity=1.0), - disk=al.lp.Sersic(intensity=2.0), - mass_profile=al.mp.IsothermalSph(einstein_radius=1.0), + bulge=al.lp.Sersic(centre=(0.05, 0.05), intensity=1.0), + disk=al.lp.Sersic(centre=(0.05, 0.05), intensity=2.0), + mass_profile=al.mp.IsothermalSph(centre=(0.05, 0.05), einstein_radius=1.0), ) - g1 = al.Galaxy(redshift=1.0, bulge=al.lp.Sersic(intensity=1.0)) + g1 = al.Galaxy(redshift=1.0, bulge=al.lp.Sersic(centre=(0.05, 0.05), intensity=1.0)) tracer = al.Tracer(galaxies=[g0, g1]) fit = al.FitImaging(dataset=masked_imaging_covariance_7x7, tracer=tracer) assert fit.perform_inversion is False - assert fit.figure_of_merit == pytest.approx(-3688191.0841, 1.0e-4) + assert fit.figure_of_merit == pytest.approx(-775.003133428, 1.0e-4) def test__fit_figure_of_merit__sub_2(image_7x7, psf_3x3, noise_map_7x7, mask_2d_7x7, masked_imaging_covariance_7x7): @@ -377,19 +377,19 @@ def test__fit_figure_of_merit__sub_2(image_7x7, psf_3x3, noise_map_7x7, mask_2d_ g0 = al.Galaxy( redshift=0.5, - bulge=al.lp.Sersic(intensity=1.0), - disk=al.lp.Sersic(intensity=2.0), - mass_profile=al.mp.IsothermalSph(einstein_radius=1.0), + bulge=al.lp.Sersic(centre=(0.05, 0.05), intensity=1.0), + disk=al.lp.Sersic(centre=(0.05, 0.05), intensity=2.0), + mass_profile=al.mp.IsothermalSph(centre=(0.05, 0.05), einstein_radius=1.0), ) - g1 = al.Galaxy(redshift=1.0, bulge=al.lp.Sersic(intensity=1.0)) + g1 = al.Galaxy(redshift=1.0, bulge=al.lp.Sersic(centre=(0.05, 0.05), intensity=1.0)) tracer = al.Tracer(galaxies=[g0, g1]) fit = al.FitImaging(dataset=masked_imaging_covariance_7x7, tracer=tracer) assert fit.perform_inversion is False - assert fit.figure_of_merit == pytest.approx(-3688191.0841, 1.0e-4) + assert fit.figure_of_merit == pytest.approx(-775.0031334280, 1.0e-4) def test__fit__sky___handles_special_behaviour(masked_imaging_7x7): @@ -399,12 +399,12 @@ def test__fit__sky___handles_special_behaviour(masked_imaging_7x7): g0 = al.Galaxy( redshift=0.5, - bulge=al.lp.Sersic(intensity=1.0), - disk=al.lp.Sersic(intensity=2.0), - mass_profile=al.mp.IsothermalSph(einstein_radius=1.0), + bulge=al.lp.Sersic(centre=(0.05, 0.05), intensity=1.0), + disk=al.lp.Sersic(centre=(0.05, 0.05), intensity=2.0), + mass_profile=al.mp.IsothermalSph(centre=(0.05, 0.05), einstein_radius=1.0), ) - g1 = al.Galaxy(redshift=1.0, bulge=al.lp.Sersic(intensity=1.0)) + g1 = al.Galaxy(redshift=1.0, bulge=al.lp.Sersic(centre=(0.05, 0.05), intensity=1.0)) tracer = al.Tracer(galaxies=[g0, g1]) @@ -412,7 +412,7 @@ def test__fit__sky___handles_special_behaviour(masked_imaging_7x7): dataset=masked_imaging_7x7, tracer=tracer, dataset_model=al.DatasetModel(background_sky_level=5.0) ) - assert fit.figure_of_merit == pytest.approx(-3196962.5844406, 1.0e-4) + assert fit.figure_of_merit == pytest.approx(-18050.8847818, 1.0e-4) def test__fit__model_dataset__grid_offset__handles_special_behaviour(masked_imaging_7x7): @@ -421,13 +421,13 @@ def test__fit__model_dataset__grid_offset__handles_special_behaviour(masked_imag g0 = al.Galaxy( redshift=0.5, - bulge=al.lp.Sersic(centre=(-1.0, -2.0), intensity=1.0), - disk=al.lp.Sersic(centre=(-1.0, -2.0), intensity=2.0), - mass_profile=al.mp.IsothermalSph(centre=(-1.0, -2.0), einstein_radius=1.0), + bulge=al.lp.Sersic(centre=(-1.05, -2.05), intensity=1.0), + disk=al.lp.Sersic(centre=(-1.05, -2.05), intensity=2.0), + mass_profile=al.mp.IsothermalSph(centre=(-1.05, -2.05), einstein_radius=1.0), ) g1 = al.Galaxy(redshift=1.0, - bulge=al.lp.Sersic(centre=(-1.0, -2.0), intensity=1.0) + bulge=al.lp.Sersic(centre=(-1.05, -2.05), intensity=1.0) ) tracer = al.Tracer(galaxies=[g0, g1]) @@ -438,7 +438,7 @@ def test__fit__model_dataset__grid_offset__handles_special_behaviour(masked_imag dataset_model=al.DatasetModel(grid_offset=(1.0, 2.0)) ) - assert fit.figure_of_merit == pytest.approx(-2849711.5317237, 1.0e-4) + assert fit.figure_of_merit == pytest.approx(-648.48145556, 1.0e-4) g0_linear = al.Galaxy( redshift=0.5, @@ -468,10 +468,10 @@ def test__galaxy_model_image_dict(masked_imaging_7x7): g0 = al.Galaxy( redshift=0.5, - bulge=al.lp.Sersic(intensity=1.0), - mass_profile=al.mp.IsothermalSph(einstein_radius=1.0), + bulge=al.lp.Sersic(centre=(0.05, 0.05), intensity=1.0), + mass_profile=al.mp.IsothermalSph(centre=(0.05, 0.05), einstein_radius=1.0), ) - g1 = al.Galaxy(redshift=1.0, bulge=al.lp.Sersic(intensity=1.0)) + g1 = al.Galaxy(redshift=1.0, bulge=al.lp.Sersic(centre=(0.05, 0.05), intensity=1.0)) g2 = al.Galaxy(redshift=1.0) tracer = al.Tracer(galaxies=[g0, g1, g2]) @@ -485,15 +485,15 @@ def test__galaxy_model_image_dict(masked_imaging_7x7): ) assert fit.galaxy_model_image_dict[g0] == pytest.approx( - blurred_image_2d_list[0], 1.0e-4 + blurred_image_2d_list[0].array, 1.0e-4 ) assert fit.galaxy_model_image_dict[g1] == pytest.approx( - blurred_image_2d_list[1], 1.0e-4 + blurred_image_2d_list[1].array, 1.0e-4 ) assert (fit.galaxy_model_image_dict[g2] == np.zeros(9)).all() assert fit.model_data.native == pytest.approx( - fit.galaxy_model_image_dict[g0].native + fit.galaxy_model_image_dict[g1].native, + fit.galaxy_model_image_dict[g0].native.array + fit.galaxy_model_image_dict[g1].native.array, 1.0e-4, ) @@ -562,18 +562,18 @@ def test__galaxy_model_image_dict(masked_imaging_7x7): fit = al.FitImaging(dataset=masked_imaging_7x7, tracer=tracer, settings_inversion=al.SettingsInversion(use_w_tilde=False)) assert fit.galaxy_model_image_dict[g0] == pytest.approx( - blurred_image_2d_list[0], 1.0e-4 + blurred_image_2d_list[0].array, 1.0e-4 ) assert fit.galaxy_model_image_dict[g0_linear][4] == pytest.approx( - -650.736682, 1.0e-4 + -9.31341026467, 1.0e-4 ) assert fit.galaxy_model_image_dict[galaxy_pix_0][4] == pytest.approx( - 1.08219997, 1.0e-4 + 0.9501715, 1.0e-4 ) assert fit.galaxy_model_image_dict[galaxy_pix_1][4] == pytest.approx( - 1.0822004, 1.0e-4 + 0.9501714, 1.0e-4 ) assert (fit.galaxy_model_image_dict[g2] == np.zeros(9)).all() @@ -612,13 +612,13 @@ def test__subtracted_image_of_galaxies_dict(masked_imaging_7x7): ) assert fit.subtracted_images_of_galaxies_dict[g0] == pytest.approx( - masked_imaging_7x7.data - g1_image - g2_image, 1.0e-4 + masked_imaging_7x7.data.array - g1_image.array - g2_image.array, 1.0e-4 ) assert fit.subtracted_images_of_galaxies_dict[g1] == pytest.approx( - masked_imaging_7x7.data - g0_image - g2_image, 1.0e-4 + masked_imaging_7x7.data.array - g0_image.array - g2_image.array, 1.0e-4 ) assert fit.subtracted_images_of_galaxies_dict[g2] == pytest.approx( - masked_imaging_7x7.data - g0_image - g1_image, 1.0e-4 + masked_imaging_7x7.data.array - g0_image.array - g1_image.array, 1.0e-4 ) # 3 Planes @@ -642,13 +642,13 @@ def test__subtracted_image_of_galaxies_dict(masked_imaging_7x7): ) assert fit.subtracted_images_of_galaxies_dict[g0] == pytest.approx( - masked_imaging_7x7.data - blurred_image_2d_list[1] - blurred_image_2d_list[2], 1.0e-4 + masked_imaging_7x7.data.array - blurred_image_2d_list[1].array - blurred_image_2d_list[2].array, 1.0e-4 ) assert fit.subtracted_images_of_galaxies_dict[g1] == pytest.approx( - masked_imaging_7x7.data - blurred_image_2d_list[0] - blurred_image_2d_list[2], 1.0e-4 + masked_imaging_7x7.data.array - blurred_image_2d_list[0].array - blurred_image_2d_list[2].array, 1.0e-4 ) assert fit.subtracted_images_of_galaxies_dict[g2] == pytest.approx( - masked_imaging_7x7.data - blurred_image_2d_list[0] - blurred_image_2d_list[1], 1.0e-4 + masked_imaging_7x7.data.array - blurred_image_2d_list[0].array - blurred_image_2d_list[1].array, 1.0e-4 ) @@ -677,14 +677,14 @@ def test__model_images_of_planes_list(masked_imaging_7x7_sub_2): fit = al.FitImaging(dataset=masked_imaging_7x7_sub_2, tracer=tracer, settings_inversion=al.SettingsInversion(use_w_tilde=False)) assert fit.model_images_of_planes_list[0] == pytest.approx( - fit.galaxy_model_image_dict[g0], 1.0e-4 + fit.galaxy_model_image_dict[g0].array, 1.0e-4 ) assert fit.model_images_of_planes_list[1] == pytest.approx( - fit.galaxy_model_image_dict[g1_linear], 1.0e-4 + fit.galaxy_model_image_dict[g1_linear].array, 1.0e-4 ) assert fit.model_images_of_planes_list[2] == pytest.approx( - fit.galaxy_model_image_dict[galaxy_pix_0] - + fit.galaxy_model_image_dict[galaxy_pix_1], + fit.galaxy_model_image_dict[galaxy_pix_0].array + + fit.galaxy_model_image_dict[galaxy_pix_1].array, 1.0e-4, ) @@ -767,15 +767,16 @@ def test___unmasked_blurred_images(masked_imaging_7x7): def test__tracer_linear_light_profiles_to_light_profiles(masked_imaging_7x7): - g0 = al.Galaxy(redshift=0.5, bulge=al.lp.Sersic(intensity=1.0)) + g0 = al.Galaxy(redshift=0.5, bulge=al.lp.Sersic(centre=(0.05, 0.05), intensity=1.0)) g0_linear = al.Galaxy( redshift=0.5, - bulge=al.lp_linear.Sersic(sersic_index=1.0), - mass_profile=al.mp.IsothermalSph(einstein_radius=1.0), + bulge=al.lp_linear.Sersic(centre=(0.05, 0.05), sersic_index=1.0), + mass_profile=al.mp.IsothermalSph(centre=(0.05, 0.05), einstein_radius=1.0), ) - g1_linear = al.Galaxy(redshift=1.0, bulge=al.lp_linear.Sersic(sersic_index=4.0)) + g1_linear = al.Galaxy(redshift=1.0, bulge=al.lp_linear.Sersic(centre=(0.05, 0.05), sersic_index=4.0)) + tracer = al.Tracer(galaxies=[g0, g0_linear, g1_linear]) @@ -786,8 +787,8 @@ def test__tracer_linear_light_profiles_to_light_profiles(masked_imaging_7x7): tracer = fit.tracer_linear_light_profiles_to_light_profiles assert tracer.galaxies[0].bulge.intensity == pytest.approx(1.0, 1.0e-4) - assert tracer.galaxies[1].bulge.intensity == pytest.approx(-371.061130, 1.0e-4) - assert tracer.galaxies[2].bulge.intensity == pytest.approx(0.08393533428, 1.0e-4) + assert tracer.galaxies[1].bulge.intensity == pytest.approx(-5.830442986, 1.0e-4) + assert tracer.galaxies[2].bulge.intensity == pytest.approx(0.135755913, 1.0e-4) diff --git a/test_autolens/imaging/test_simulate_and_fit_imaging.py b/test_autolens/imaging/test_simulate_and_fit_imaging.py index d98ea341d..7969c8bdf 100644 --- a/test_autolens/imaging/test_simulate_and_fit_imaging.py +++ b/test_autolens/imaging/test_simulate_and_fit_imaging.py @@ -111,7 +111,7 @@ def test__simulate_imaging_data_and_fit__known_likelihood(): dataset = simulator.via_tracer_from(tracer=tracer, grid=grid) mask = al.Mask2D.circular( - shape_native=dataset.data.shape_native, pixel_scales=0.2, radius=2.0 + shape_native=dataset.data.shape_native, pixel_scales=0.2, radius=2.005 ) masked_dataset = dataset.apply_mask(mask=mask) @@ -149,7 +149,7 @@ def test__simulate_imaging_data_and_fit__linear_light_profiles_agree_with_standa ) mask = al.Mask2D.circular( - shape_native=dataset.data.shape_native, pixel_scales=0.2, radius=0.8 + shape_native=dataset.data.shape_native, pixel_scales=0.2, radius=0.805 ) masked_dataset = dataset.apply_mask(mask=mask) @@ -204,10 +204,10 @@ def test__simulate_imaging_data_and_fit__linear_light_profiles_agree_with_standa ) assert fit_linear.galaxy_model_image_dict[lens_galaxy_linear] == pytest.approx( - lens_galaxy_image, 1.0e-4 + lens_galaxy_image.array, 1.0e-4 ) assert fit_linear.model_images_of_planes_list[0] == pytest.approx( - lens_galaxy_image, 1.0e-4 + lens_galaxy_image.array, 1.0e-4 ) traced_grid_2d_list = tracer.traced_grid_2d_list_from(grid=masked_dataset.grids.lp) @@ -222,11 +222,11 @@ def test__simulate_imaging_data_and_fit__linear_light_profiles_agree_with_standa ) assert fit_linear.galaxy_model_image_dict[source_galaxy_linear] == pytest.approx( - source_galaxy_image, 1.0e-4 + source_galaxy_image.array, 1.0e-4 ) assert fit_linear.model_images_of_planes_list[1] == pytest.approx( - source_galaxy_image, 1.0e-4 + source_galaxy_image.array, 1.0e-4 ) @@ -258,7 +258,7 @@ def test__simulate_imaging_data_and_fit__linear_light_profiles_and_pixelization( ) mask = al.Mask2D.circular( - shape_native=dataset.data.shape_native, pixel_scales=0.2, radius=0.8 + shape_native=dataset.data.shape_native, pixel_scales=0.2, radius=0.805 ) masked_dataset = dataset.apply_mask(mask=mask) @@ -321,10 +321,10 @@ def test__simulate_imaging_data_and_fit__linear_light_profiles_and_pixelization( ) assert fit_linear.galaxy_model_image_dict[lens_galaxy_linear] == pytest.approx( - lens_galaxy_image, 1.0e-2 + lens_galaxy_image.array, 1.0e-2 ) assert fit_linear.model_images_of_planes_list[0] == pytest.approx( - lens_galaxy_image, 1.0e-2 + lens_galaxy_image.array, 1.0e-2 ) assert fit_linear.galaxy_model_image_dict[source_galaxy_pix][0] == pytest.approx( @@ -413,7 +413,7 @@ def test__simulate_imaging_data_and_fit__linear_light_profiles_and_pixelization_ ) mask = al.Mask2D.circular( - shape_native=dataset.data.shape_native, pixel_scales=0.2, radius=0.8 + shape_native=dataset.data.shape_native, pixel_scales=0.2, radius=0.805 ) dataset = al.Imaging( @@ -469,10 +469,10 @@ def test__simulate_imaging_data_and_fit__linear_light_profiles_and_pixelization_ ) assert fit_linear.galaxy_model_image_dict[lens_galaxy_linear] == pytest.approx( - lens_galaxy_image, 1.0e-2 + lens_galaxy_image.array, 1.0e-2 ) assert fit_linear.model_images_of_planes_list[0] == pytest.approx( - lens_galaxy_image, 1.0e-2 + lens_galaxy_image.array, 1.0e-2 ) assert fit_linear.galaxy_model_image_dict[source_galaxy_pix][0] == pytest.approx( @@ -676,7 +676,7 @@ def test__fit_figure_of_merit__mge_mass_model(masked_imaging_7x7, masked_imaging ) mask = al.Mask2D.circular( - shape_native=dataset.data.shape_native, pixel_scales=0.2, radius=0.8 + shape_native=dataset.data.shape_native, pixel_scales=0.2, radius=0.805 ) masked_dataset = dataset.apply_mask(mask=mask) diff --git a/test_autolens/interferometer/model/test_analysis_interferometer.py b/test_autolens/interferometer/model/test_analysis_interferometer.py index 3f62c28b1..3468aa036 100644 --- a/test_autolens/interferometer/model/test_analysis_interferometer.py +++ b/test_autolens/interferometer/model/test_analysis_interferometer.py @@ -64,8 +64,8 @@ def test__positions__resample__raises_exception(interferometer_7, mask_2d_7x7): def test__positions__likelihood_overwrite__changes_likelihood( interferometer_7, mask_2d_7x7 ): - lens = al.Galaxy(redshift=0.5, mass=al.mp.IsothermalSph()) - source = al.Galaxy(redshift=1.0, light=al.lp.SersicSph()) + lens = al.Galaxy(redshift=0.5, mass=al.mp.IsothermalSph(centre=(0.05, 0.05))) + source = al.Galaxy(redshift=1.0, light=al.lp.SersicSph(centre=(0.05, 0.05))) model = af.Collection(galaxies=af.Collection(lens=lens, source=source)) @@ -79,7 +79,7 @@ def test__positions__likelihood_overwrite__changes_likelihood( fit = al.FitInterferometer(dataset=interferometer_7, tracer=tracer) assert fit.log_likelihood == analysis_log_likelihood - assert analysis_log_likelihood == pytest.approx(-127914.36273, 1.0e-4) + assert analysis_log_likelihood == pytest.approx(-62.463179940, 1.0e-4) positions_likelihood = al.PositionsLHPenalty( positions=al.Grid2DIrregular([(1.0, 100.0), (200.0, 2.0)]), threshold=0.01 diff --git a/test_autolens/interferometer/test_fit_interferometer.py b/test_autolens/interferometer/test_fit_interferometer.py index 52045349d..cbb12c93c 100644 --- a/test_autolens/interferometer/test_fit_interferometer.py +++ b/test_autolens/interferometer/test_fit_interferometer.py @@ -19,9 +19,9 @@ def test__fit_figure_of_merit(interferometer_7): g0 = al.Galaxy( redshift=0.5, - bulge=al.lp.Sersic(intensity=1.0), - disk=al.lp.Sersic(intensity=2.0), - mass_profile=al.mp.IsothermalSph(einstein_radius=1.0), + bulge=al.lp.Sersic(centre=(0.05, 0.05), intensity=1.0), + disk=al.lp.Sersic(centre=(0.05, 0.05), intensity=2.0), + mass_profile=al.mp.IsothermalSph(centre=(0.05, 0.05), einstein_radius=1.0), ) g1 = al.Galaxy(redshift=1.0, bulge=al.lp.Sersic(intensity=1.0)) @@ -31,27 +31,29 @@ def test__fit_figure_of_merit(interferometer_7): fit = al.FitInterferometer(dataset=interferometer_7, tracer=tracer) assert fit.perform_inversion is False - assert fit.figure_of_merit == pytest.approx(-59413306.47762, 1.0e-4) + assert fit.figure_of_merit == pytest.approx(-12758.714175708, 1.0e-4) basis = al.lp_basis.Basis( profile_list=[ - al.lp.Sersic(intensity=1.0), - al.lp.Sersic(intensity=2.0), + al.lp.Sersic(centre=(0.05, 0.05), intensity=1.0), + al.lp.Sersic(centre=(0.05, 0.05), intensity=2.0), ] ) g0 = al.Galaxy( - redshift=0.5, bulge=basis, mass_profile=al.mp.IsothermalSph(einstein_radius=1.0) + redshift=0.5, + bulge=basis, + mass_profile=al.mp.IsothermalSph(centre=(0.05, 0.05), einstein_radius=1.0), ) - g1 = al.Galaxy(redshift=1.0, bulge=al.lp.Sersic(intensity=1.0)) + g1 = al.Galaxy(redshift=1.0, bulge=al.lp.Sersic(centre=(0.05, 0.05), intensity=1.0)) tracer = al.Tracer(galaxies=[g0, g1]) fit = al.FitInterferometer(dataset=interferometer_7, tracer=tracer) assert fit.perform_inversion is False - assert fit.figure_of_merit == pytest.approx(-59413306.47762, 1.0e-4) + assert fit.figure_of_merit == pytest.approx(-12779.937568696, 1.0e-4) pixelization = al.Pixelization( mesh=al.mesh.Rectangular(shape=(3, 3)), @@ -71,7 +73,9 @@ def test__fit_figure_of_merit(interferometer_7): assert fit.perform_inversion is True assert fit.figure_of_merit == pytest.approx(-66.90612, 1.0e-4) - galaxy_light = al.Galaxy(redshift=0.5, bulge=al.lp.Sersic(intensity=1.0)) + galaxy_light = al.Galaxy( + redshift=0.5, bulge=al.lp.Sersic(centre=(0.05, 0.05), intensity=1.0) + ) pixelization = al.Pixelization( mesh=al.mesh.Rectangular(shape=(3, 3)), @@ -89,13 +93,13 @@ def test__fit_figure_of_merit(interferometer_7): ) assert fit.perform_inversion is True - assert fit.figure_of_merit == pytest.approx(-1570173.14216, 1.0e-4) + assert fit.figure_of_merit == pytest.approx(-250.22594512, 1.0e-4) g0_linear = al.Galaxy( redshift=0.5, - bulge=al.lp_linear.Sersic(sersic_index=1.0), - disk=al.lp_linear.Sersic(sersic_index=4.0), - mass_profile=al.mp.IsothermalSph(einstein_radius=1.0), + bulge=al.lp_linear.Sersic(centre=(0.05, 0.05), sersic_index=1.0), + disk=al.lp_linear.Sersic(centre=(0.05, 0.05), sersic_index=4.0), + mass_profile=al.mp.IsothermalSph(centre=(0.05, 0.05), einstein_radius=1.0), ) tracer = al.Tracer(galaxies=[g0_linear, g1]) @@ -103,17 +107,19 @@ def test__fit_figure_of_merit(interferometer_7): fit = al.FitInterferometer(dataset=interferometer_7, tracer=tracer) assert fit.perform_inversion is True - assert fit.figure_of_merit == pytest.approx(-669283.091396, 1.0e-4) + assert fit.figure_of_merit == pytest.approx(-197.670468767, 1.0e-4) basis = al.lp_basis.Basis( profile_list=[ - al.lp_linear.Sersic(sersic_index=1.0), - al.lp_linear.Sersic(sersic_index=4.0), + al.lp_linear.Sersic(centre=(0.05, 0.05), sersic_index=1.0), + al.lp_linear.Sersic(centre=(0.05, 0.05), sersic_index=4.0), ] ) g0_linear = al.Galaxy( - redshift=0.5, bulge=basis, mass_profile=al.mp.IsothermalSph(einstein_radius=1.0) + redshift=0.5, + bulge=basis, + mass_profile=al.mp.IsothermalSph(centre=(0.05, 0.05), einstein_radius=1.0), ) tracer = al.Tracer(galaxies=[g0_linear, g1]) @@ -121,7 +127,7 @@ def test__fit_figure_of_merit(interferometer_7): fit = al.FitInterferometer(dataset=interferometer_7, tracer=tracer) assert fit.perform_inversion is True - assert fit.figure_of_merit == pytest.approx(-669283.091396, 1.0e-4) + assert fit.figure_of_merit == pytest.approx(-197.6704687, 1.0e-4) tracer = al.Tracer(galaxies=[g0_linear, galaxy_pix]) @@ -131,40 +137,15 @@ def test__fit_figure_of_merit(interferometer_7): assert fit.figure_of_merit == pytest.approx(-34.393456, 1.0e-4) -def test___fit_figure_of_merit__different_settings( - interferometer_7, interferometer_7_lop -): - pixelization = al.Pixelization( - mesh=al.mesh.Rectangular(shape=(3, 3)), - regularization=al.reg.Constant(coefficient=0.01), - ) - - g0 = al.Galaxy(redshift=0.5, pixelization=pixelization) - - tracer = al.Tracer(galaxies=[al.Galaxy(redshift=0.5), g0]) - - fit = al.FitInterferometer( - dataset=interferometer_7_lop, - tracer=tracer, - settings_inversion=al.SettingsInversion( - use_w_tilde=False, use_linear_operators=True - ), - ) - - assert (fit.noise_map.slim == np.full(fill_value=2.0 + 2.0j, shape=(7,))).all() - assert fit.log_evidence == pytest.approx(-71.5177, 1e-4) - assert fit.figure_of_merit == pytest.approx(-71.5177, 1.0e-4) - - def test___galaxy_model_image_dict(interferometer_7, interferometer_7_grid): # Normal Light Profiles Only g0 = al.Galaxy( redshift=0.5, - bulge=al.lp.Sersic(intensity=1.0), - mass_profile=al.mp.IsothermalSph(einstein_radius=1.0), + bulge=al.lp.Sersic(centre=(0.05, 0.05), intensity=1.0), + mass_profile=al.mp.IsothermalSph(centre=(0.05, 0.05), einstein_radius=1.0), ) - g1 = al.Galaxy(redshift=1.0, bulge=al.lp.Sersic(intensity=1.0)) + g1 = al.Galaxy(redshift=1.0, bulge=al.lp.Sersic(centre=(0.05, 0.05), intensity=1.0)) g2 = al.Galaxy(redshift=1.0) tracer = al.Tracer(galaxies=[g0, g1, g2]) @@ -182,15 +163,15 @@ def test___galaxy_model_image_dict(interferometer_7, interferometer_7_grid): g0_image = g0.image_2d_from(grid=traced_grid_2d_list_from[0]) g1_image = g1.image_2d_from(grid=traced_grid_2d_list_from[1]) - assert fit.galaxy_model_image_dict[g0] == pytest.approx(g0_image, 1.0e-4) - assert fit.galaxy_model_image_dict[g1] == pytest.approx(g1_image, 1.0e-4) + assert fit.galaxy_model_image_dict[g0] == pytest.approx(g0_image.array, 1.0e-4) + assert fit.galaxy_model_image_dict[g1] == pytest.approx(g1_image.array, 1.0e-4) # Linear Light Profiles Only g0_linear = al.Galaxy( redshift=0.5, - bulge=al.lp_linear.Sersic(), - mass_profile=al.mp.IsothermalSph(einstein_radius=1.0), + bulge=al.lp_linear.Sersic(centre=(0.05, 0.05)), + mass_profile=al.mp.IsothermalSph(centre=(0.05, 0.05), einstein_radius=1.0), ) g1_linear = al.Galaxy(redshift=1.0, bulge=al.lp_linear.Sersic()) @@ -206,7 +187,7 @@ def test___galaxy_model_image_dict(interferometer_7, interferometer_7_grid): 1.00018622848, 1.0e-2 ) assert fit.galaxy_model_image_dict[g1_linear][3] == pytest.approx( - -3.89387356e-04, 1.0e-2 + -0.017435532289, 1.0e-2 ) pixelization = al.Pixelization( @@ -215,7 +196,8 @@ def test___galaxy_model_image_dict(interferometer_7, interferometer_7_grid): ) g0_no_light = al.Galaxy( - redshift=0.5, mass_profile=al.mp.IsothermalSph(einstein_radius=1.0) + redshift=0.5, + mass_profile=al.mp.IsothermalSph(centre=(0.05, 0.05), einstein_radius=1.0), ) galaxy_pix_0 = al.Galaxy(redshift=1.0, pixelization=pixelization) @@ -230,7 +212,7 @@ def test___galaxy_model_image_dict(interferometer_7, interferometer_7_grid): assert (fit.galaxy_model_image_dict[g0_no_light].native == np.zeros((7, 7))).all() assert fit.galaxy_model_image_dict[galaxy_pix_0][0] == pytest.approx( - -0.169439019, 1.0e-4 + -0.1039673270, 1.0e-4 ) # Normal light + Linear Light PRofiles + Pixelization + Regularizaiton @@ -244,17 +226,17 @@ def test___galaxy_model_image_dict(interferometer_7, interferometer_7_grid): settings_inversion=al.SettingsInversion(use_w_tilde=False), ) - assert fit.galaxy_model_image_dict[g0] == pytest.approx(g0_image, 1.0e-4) + assert fit.galaxy_model_image_dict[g0] == pytest.approx(g0_image.array, 1.0e-4) assert fit.galaxy_model_image_dict[g0_linear][4] == pytest.approx( - -1946.44265722, 1.0e-4 + -22.8444395, 1.0e-4 ) assert fit.galaxy_model_image_dict[galaxy_pix_0][4] == pytest.approx( - 0.0473537322, 1.0e-3 + -0.052005033, 1.0e-3 ) assert fit.galaxy_model_image_dict[galaxy_pix_1][4] == pytest.approx( - 0.0473505541, 1.0e-3 + -0.0520050308, 1.0e-3 ) assert (fit.galaxy_model_image_dict[g2] == np.zeros(9)).all() @@ -264,10 +246,10 @@ def test__galaxy_model_visibilities_dict(interferometer_7, interferometer_7_grid g0 = al.Galaxy( redshift=0.5, - bulge=al.lp.Sersic(intensity=1.0), - mass_profile=al.mp.IsothermalSph(einstein_radius=1.0), + bulge=al.lp.Sersic(centre=(0.05, 0.05), intensity=1.0), + mass_profile=al.mp.IsothermalSph(centre=(0.05, 0.05), einstein_radius=1.0), ) - g1 = al.Galaxy(redshift=1.0, bulge=al.lp.Sersic(intensity=1.0)) + g1 = al.Galaxy(redshift=1.0, bulge=al.lp.Sersic(centre=(0.05, 0.05), intensity=1.0)) g2 = al.Galaxy(redshift=1.0) tracer = al.Tracer(galaxies=[g0, g1, g2]) @@ -306,20 +288,20 @@ def test__galaxy_model_visibilities_dict(interferometer_7, interferometer_7_grid g0_linear = al.Galaxy( redshift=0.5, - bulge=al.lp_linear.Sersic(), - mass_profile=al.mp.IsothermalSph(einstein_radius=1.0), + bulge=al.lp_linear.Sersic(centre=(0.05, 0.05)), + mass_profile=al.mp.IsothermalSph(centre=(0.05, 0.05), einstein_radius=1.0), ) - g1_linear = al.Galaxy(redshift=1.0, bulge=al.lp_linear.Sersic()) + g1_linear = al.Galaxy(redshift=1.0, bulge=al.lp_linear.Sersic(centre=(0.05, 0.05))) tracer = al.Tracer(galaxies=[g0_linear, g1_linear, g2]) fit = al.FitInterferometer(dataset=interferometer_7, tracer=tracer) assert fit.galaxy_model_visibilities_dict[g0_linear][0] == pytest.approx( - 1.0002975772292932 - 7.12783377916253e-21j, 1.0e-2 + 1.0138228768598911 + 0.006599377953512708j, 1.0e-2 ) assert fit.galaxy_model_visibilities_dict[g1_linear][0] == pytest.approx( - -0.0002828972025576841 + 3.035459109423297e-06j, 1.0e-2 + -0.012892097547972572 - 0.0019719184145301906j, 1.0e-2 ) assert (fit.galaxy_model_visibilities_dict[g2] == np.zeros((7,))).all() @@ -337,7 +319,8 @@ def test__galaxy_model_visibilities_dict(interferometer_7, interferometer_7_grid ) g0_no_light = al.Galaxy( - redshift=0.5, mass_profile=al.mp.IsothermalSph(einstein_radius=1.0) + redshift=0.5, + mass_profile=al.mp.IsothermalSph(centre=(0.05, 0.05), einstein_radius=1.0), ) galaxy_pix_0 = al.Galaxy(redshift=1.0, pixelization=pixelization) @@ -347,7 +330,7 @@ def test__galaxy_model_visibilities_dict(interferometer_7, interferometer_7_grid assert (fit.galaxy_model_visibilities_dict[g0_no_light] == np.zeros((7,))).all() assert fit.galaxy_model_visibilities_dict[galaxy_pix_0][0] == pytest.approx( - 0.2813594007737543 + 0.18428485685088292j, 1.0e-4 + 0.37828909168666935 + 0.40127834296223164j, 1.0e-4 ) assert fit.model_data == pytest.approx( @@ -367,14 +350,14 @@ def test__galaxy_model_visibilities_dict(interferometer_7, interferometer_7_grid ) assert fit.galaxy_model_visibilities_dict[g0_linear][0] == pytest.approx( - -1946.6593508251335 + 1.3871336483456645e-17j, 1.0e-4 + -23.049182329227243 - 0.1500363319686841j, 1.0e-4 ) assert fit.galaxy_model_visibilities_dict[galaxy_pix_0][0] == pytest.approx( - 0.04732569077375984 + 0.14872801091458496j, 1.0e-4 + -0.054816474483476214 + 0.14599319644288866j, 1.0e-4 ) assert fit.galaxy_model_visibilities_dict[galaxy_pix_1][0] == pytest.approx( - 0.047320971438523735 + 0.14872801091458515j, 1.0e-4 + -0.054816474483476214 + 0.14599319644288866j, 1.0e-4 ) assert (fit.galaxy_model_visibilities_dict[g2] == np.zeros((7,))).all() diff --git a/test_autolens/interferometer/test_simulate_and_fit_interferometer.py b/test_autolens/interferometer/test_simulate_and_fit_interferometer.py index e88f3a7ef..71c7fc8fc 100644 --- a/test_autolens/interferometer/test_simulate_and_fit_interferometer.py +++ b/test_autolens/interferometer/test_simulate_and_fit_interferometer.py @@ -221,7 +221,7 @@ def test__simulate_interferometer_data_and_fit__linear_light_profiles_agree_with lens_galaxy_image = lens_galaxy.image_2d_from(grid=dataset.grids.lp) assert fit_linear.galaxy_model_image_dict[lens_galaxy_linear] == pytest.approx( - lens_galaxy_image, 1.0e-4 + lens_galaxy_image.array, 1.0e-4 ) traced_grid_2d_list = tracer.traced_grid_2d_list_from(grid=dataset.grids.lp) @@ -229,7 +229,7 @@ def test__simulate_interferometer_data_and_fit__linear_light_profiles_agree_with source_galaxy_image = source_galaxy.image_2d_from(grid=traced_grid_2d_list[1]) assert fit_linear.galaxy_model_image_dict[source_galaxy_linear] == pytest.approx( - source_galaxy_image, 1.0e-4 + source_galaxy_image.array, 1.0e-4 ) lens_galaxy_visibilities = lens_galaxy.visibilities_from( @@ -262,8 +262,8 @@ def test__simulate_interferometer_data_and_fit__linear_light_profiles_and_pixeli source_galaxy = al.Galaxy( redshift=1.0, - bulge=al.lp.Sersic(intensity=0.1, sersic_index=1.0), - disk=al.lp.Sersic(intensity=0.2, sersic_index=4.0), + bulge=al.lp.Sersic(centre=(0.1, 0.1), intensity=0.1, sersic_index=1.0), + disk=al.lp.Sersic(centre=(0.1, 0.1), intensity=0.2, sersic_index=4.0), ) tracer = al.Tracer(galaxies=[lens_galaxy, source_galaxy]) @@ -307,32 +307,18 @@ def test__simulate_interferometer_data_and_fit__linear_light_profiles_and_pixeli assert fit_linear.inversion.reconstruction == pytest.approx( np.array( [ - 1.00338472e02, - 9.55074606e-02, - 9.24767167e-02, - 9.45392540e-02, - 1.41969109e-01, - 1.41828976e-01, - 1.41521130e-01, - 1.84257307e-01, - 1.85507562e-01, - 1.83726575e-01, + 101.72951207, + 0.50020335, + 0.50421638, + 0.50249167, + 0.44875688, + 0.44968722, + 0.45050618, + 0.40024606, + 0.39917044, + 0.40168314, ] ), 1.0e-2, ) assert fit_linear.figure_of_merit == pytest.approx(-29.20551989, 1.0e-4) - - lens_galaxy_image = lens_galaxy.image_2d_from(grid=dataset.grids.lp) - - assert fit_linear.galaxy_model_image_dict[lens_galaxy_linear] == pytest.approx( - lens_galaxy_image, 1.0e-2 - ) - - traced_grid_2d_list = tracer.traced_grid_2d_list_from(grid=dataset.grids.lp) - - source_galaxy_image = source_galaxy.image_2d_from(grid=traced_grid_2d_list[1]) - - # assert fit_linear.galaxy_model_image_dict[source_galaxy_pix] == pytest.approx( - # source_galaxy_image, 1.0e-1 - # ) diff --git a/test_autolens/lens/test_operate.py b/test_autolens/lens/test_operate.py index 794fa8e78..391483adb 100644 --- a/test_autolens/lens/test_operate.py +++ b/test_autolens/lens/test_operate.py @@ -35,7 +35,7 @@ def test__operate_image__blurred_images_2d_via_psf_from__for_tracer_gives_list_o ) assert blurred_image.native == pytest.approx( - blurred_image_0.native + blurred_image_1.native, 1.0e-4 + blurred_image_0.native.array + blurred_image_1.native.array, 1.0e-4 ) blurred_image_list = tracer.blurred_image_2d_list_from( diff --git a/test_autolens/lens/test_to_inversion.py b/test_autolens/lens/test_to_inversion.py index 500eb4310..9e617fc29 100644 --- a/test_autolens/lens/test_to_inversion.py +++ b/test_autolens/lens/test_to_inversion.py @@ -62,8 +62,12 @@ def test__lp_linear_func_galaxy_dict_from(masked_imaging_7x7): assert lp_linear_func_list[0].grid == pytest.approx( masked_imaging_7x7.grids.lp, 1.0e-4 ) - assert lp_linear_func_list[1].grid == pytest.approx(traced_grid_list[1], 1.0e-4) - assert lp_linear_func_list[2].grid == pytest.approx(traced_grid_list[2], 1.0e-4) + assert lp_linear_func_list[1].grid == pytest.approx( + traced_grid_list[1].array, 1.0e-4 + ) + assert lp_linear_func_list[2].grid == pytest.approx( + traced_grid_list[2].array, 1.0e-4 + ) lp_linear_3 = al.lp_linear.LightProfileLinear() lp_linear_4 = al.lp_linear.LightProfileLinear() @@ -360,8 +364,12 @@ def test__traced_mesh_grid_pg_list(masked_imaging_7x7): traced_mesh_grids_list_of_planes = tracer_to_inversion.traced_mesh_grid_pg_list - traced_grid_pix_0 = tracer.traced_grid_2d_list_from(grid=np.array([[1.0, 0.0]]))[2] - traced_grid_pix_1 = tracer.traced_grid_2d_list_from(grid=np.array([[2.0, 0.0]]))[4] + traced_grid_pix_0 = tracer.traced_grid_2d_list_from( + grid=al.Grid2DIrregular(values=[[1.0, 0.0]]) + )[2] + traced_grid_pix_1 = tracer.traced_grid_2d_list_from( + grid=al.Grid2DIrregular(values=[[2.0, 0.0]]) + )[4] assert traced_mesh_grids_list_of_planes[0] == None assert traced_mesh_grids_list_of_planes[1] == None @@ -464,9 +472,12 @@ def test__inversion_imaging_from(grid_2d_7x7, masked_imaging_7x7): noise_map=masked_imaging_7x7.noise_map, grids=grids, psf=masked_imaging_7x7.psf, + convolver=masked_imaging_7x7.convolver, ) - g_linear = al.Galaxy(redshift=0.5, light_linear=al.lp_linear.Sersic()) + g_linear = al.Galaxy( + redshift=0.5, light_linear=al.lp_linear.Sersic(centre=(0.05, 0.05)) + ) tracer = al.Tracer(galaxies=[al.Galaxy(redshift=0.5), g_linear]) @@ -478,7 +489,7 @@ def test__inversion_imaging_from(grid_2d_7x7, masked_imaging_7x7): inversion = tracer_to_inversion.inversion - assert inversion.reconstruction[0] == pytest.approx(0.002310, 1.0e-2) + assert inversion.reconstruction[0] == pytest.approx(0.186868464426, 1.0e-2) pixelization = al.Pixelization( mesh=al.mesh.Rectangular(shape=(3, 3)), @@ -519,7 +530,9 @@ def test__inversion_interferometer_from(grid_2d_7x7, interferometer_7): transformer=interferometer_7.transformer, ) - g_linear = al.Galaxy(redshift=0.5, light_linear=al.lp_linear.Sersic()) + g_linear = al.Galaxy( + redshift=0.5, light_linear=al.lp_linear.Sersic(centre=(0.05, 0.05)) + ) tracer = al.Tracer(galaxies=[al.Galaxy(redshift=0.5), g_linear]) @@ -531,7 +544,7 @@ def test__inversion_interferometer_from(grid_2d_7x7, interferometer_7): inversion = tracer_to_inversion.inversion - assert inversion.reconstruction[0] == pytest.approx(0.000513447, 1.0e-5) + assert inversion.reconstruction[0] == pytest.approx(0.0412484695, 1.0e-5) pixelization = al.Pixelization( mesh=al.mesh.Rectangular(shape=(7, 7)), diff --git a/test_autolens/lens/test_tracer.py b/test_autolens/lens/test_tracer.py index 23e5bda5f..5980d9dd6 100644 --- a/test_autolens/lens/test_tracer.py +++ b/test_autolens/lens/test_tracer.py @@ -161,7 +161,7 @@ def test__grid_2d_at_redshift_from(grid_2d_7x7): grid_at_redshift = tracer.grid_2d_at_redshift_from(grid=grid_simple, redshift=0.5) - assert grid_2d_list_from[1] == pytest.approx(grid_at_redshift, 1.0e-4) + assert grid_2d_list_from[1] == pytest.approx(grid_at_redshift.array, 1.0e-4) assert grid_at_redshift[0] == pytest.approx((0.6273814, 1.2547628), 1.0e-4) galaxies_plus_extra = [g0, g1, g2, g3, g4, g5, al.Galaxy(redshift=1.75)] @@ -172,7 +172,7 @@ def test__grid_2d_at_redshift_from(grid_2d_7x7): grid_at_redshift = tracer.grid_2d_at_redshift_from(grid=grid_simple, redshift=1.75) - assert grid_2d_list_from[2] == pytest.approx(grid_at_redshift, 1.0e-4) + assert grid_2d_list_from[2] == pytest.approx(grid_at_redshift.array, 1.0e-4) assert grid_at_redshift[0] == pytest.approx((0.27331481161, 0.5466296232), 1.0e-4) galaxies_plus_extra = [g0, g1, g2, g3, g4, g5, al.Galaxy(redshift=2.0)] @@ -183,7 +183,7 @@ def test__grid_2d_at_redshift_from(grid_2d_7x7): grid_at_redshift = tracer.grid_2d_at_redshift_from(grid=grid_simple, redshift=2.0) - assert grid_2d_list_from[2] == pytest.approx(grid_at_redshift, 1.0e-4) + assert grid_2d_list_from[2] == pytest.approx(grid_at_redshift.array, 1.0e-4) assert grid_at_redshift[0] == pytest.approx((0.222772465, 0.445544931), 1.0e-4) @@ -281,7 +281,7 @@ def test__image_2d_from__sum_of_individual_images(mask_2d_7x7): image_tracer = tracer.image_2d_from(grid=grid_2d_7x7) assert image.shape_native == (7, 7) - assert image == pytest.approx(image_tracer, 1.0e-4) + assert image == pytest.approx(image_tracer.array, 1.0e-4) def test__image_2d_via_input_plane_image_from__with_foreground_planes(grid_2d_7x7): @@ -310,7 +310,7 @@ def test__image_2d_via_input_plane_image_from__with_foreground_planes(grid_2d_7x ) assert image_via_light_profile[0] == pytest.approx( - image_via_input_plane_image[0], 1.0e-2 + image_via_input_plane_image[0].array, 1.0e-2 ) @@ -385,7 +385,7 @@ def test__image_2d_via_input_plane_image_from__with_foreground_planes__multi_pla ) assert image_via_light_profile[0] == pytest.approx( - image_via_input_plane_image[0], 1.0e-2 + image_via_input_plane_image[0].array, 1.0e-2 ) plane_image = g1.image_2d_from(grid=plane_grid) @@ -398,7 +398,7 @@ def test__image_2d_via_input_plane_image_from__with_foreground_planes__multi_pla ) assert image_via_light_profile[0] == pytest.approx( - image_via_input_plane_image[0], 1.0e-2 + image_via_input_plane_image[0].array, 1.0e-2 ) @@ -423,7 +423,7 @@ def test__padded_image_2d_from(grid_2d_7x7): assert padded_tracer_image.shape_native == (9, 9) assert padded_tracer_image == pytest.approx( - padded_g0_image + padded_g1_image + padded_g2_image, 1.0e-4 + padded_g0_image.array + padded_g1_image.array + padded_g2_image.array, 1.0e-4 ) @@ -816,7 +816,7 @@ def test__regression__centre_of_profile_in_right_place(): g0 = al.Galaxy( redshift=0.5, - mass=al.mp.Isothermal(centre=(2.0, 1.0), einstein_radius=1.0), + mass=al.mp.Isothermal(centre=(1.9999, 0.9999), einstein_radius=1.0), ) tracer = al.Tracer(galaxies=[g0, al.Galaxy(redshift=1.0)]) diff --git a/test_autolens/lens/test_tracer_util.py b/test_autolens/lens/test_tracer_util.py index e3885e628..d50c2d096 100644 --- a/test_autolens/lens/test_tracer_util.py +++ b/test_autolens/lens/test_tracer_util.py @@ -47,14 +47,14 @@ def test__traced_grid_2d_list_from(grid_2d_7x7_simple): assert traced_grid_list[2][0] == pytest.approx( np.array( [ - (1.0 - beta_02 * val - beta_12 * defl11[0, 0]), - (1.0 - beta_02 * val - beta_12 * defl11[0, 1]), + (1.0 - beta_02 * val - beta_12 * defl11.array[0, 0]), + (1.0 - beta_02 * val - beta_12 * defl11.array[0, 1]), ] ), 1e-4, ) assert traced_grid_list[2][1] == pytest.approx( - np.array([(1.0 - beta_02 * 1.0 - beta_12 * defl12[0, 0]), 0.0]), 1e-4 + np.array([(1.0 - beta_02 * 1.0 - beta_12 * defl12.array[0, 0]), 0.0]), 1e-4 ) assert traced_grid_list[3][1] == pytest.approx(np.array([1.0, 0.0]), 1e-4) @@ -120,25 +120,25 @@ def test__grid_2d_at_redshift_from(grid_2d_7x7): galaxies=galaxies, grid=grid_2d_7x7, redshift=0.75 ) - assert grid_at_redshift == pytest.approx(traced_grid_list[1], 1.0e-4) + assert grid_at_redshift == pytest.approx(traced_grid_list[1].array, 1.0e-4) grid_at_redshift = al.util.tracer.grid_2d_at_redshift_from( galaxies=galaxies, grid=grid_2d_7x7, redshift=1.0 ) - assert grid_at_redshift == pytest.approx(traced_grid_list[2], 1.0e-4) + assert grid_at_redshift == pytest.approx(traced_grid_list[2].array, 1.0e-4) grid_at_redshift = al.util.tracer.grid_2d_at_redshift_from( galaxies=galaxies, grid=grid_2d_7x7, redshift=1.5 ) - assert grid_at_redshift == pytest.approx(traced_grid_list[3], 1.0e-4) + assert grid_at_redshift == pytest.approx(traced_grid_list[3].array, 1.0e-4) grid_at_redshift = al.util.tracer.grid_2d_at_redshift_from( galaxies=galaxies, grid=grid_2d_7x7, redshift=2.0 ) - assert grid_at_redshift == pytest.approx(traced_grid_list[4], 1.0e-4) + assert grid_at_redshift == pytest.approx(traced_grid_list[4].array, 1.0e-4) def test__grid_2d_at_redshift_from__redshift_between_planes(grid_2d_7x7):