|
| 1 | +from pathlib import Path |
| 2 | + |
| 3 | +import autoarray as aa |
| 4 | +import autolens as al |
| 5 | + |
| 6 | +import pytest |
| 7 | + |
| 8 | +from autolens.weak.model.plotter import PlotterWeak |
| 9 | + |
| 10 | +directory = Path(__file__).resolve().parent |
| 11 | + |
| 12 | + |
| 13 | +def _isothermal_tracer(einstein_radius=1.6, ell_comps=(0.0, 0.05)): |
| 14 | + lens = al.Galaxy( |
| 15 | + redshift=0.5, |
| 16 | + mass=al.mp.Isothermal( |
| 17 | + centre=(0.0, 0.0), |
| 18 | + ell_comps=ell_comps, |
| 19 | + einstein_radius=einstein_radius, |
| 20 | + ), |
| 21 | + ) |
| 22 | + source = al.Galaxy(redshift=1.0) |
| 23 | + return al.Tracer(galaxies=[lens, source]) |
| 24 | + |
| 25 | + |
| 26 | +@pytest.fixture(name="fit_weak") |
| 27 | +def make_fit_weak(): |
| 28 | + grid = aa.Grid2DIrregular( |
| 29 | + values=[(0.7, 0.5), (1.0, 1.0), (-0.3, 0.6), (-1.1, -0.8)] |
| 30 | + ) |
| 31 | + truth = _isothermal_tracer(einstein_radius=1.6) |
| 32 | + dataset = al.SimulatorShearYX(noise_sigma=0.0, seed=0).via_tracer_from( |
| 33 | + tracer=truth, grid=grid, name="test" |
| 34 | + ) |
| 35 | + dataset.noise_map = aa.ArrayIrregular(values=[0.3, 0.3, 0.3, 0.3]) |
| 36 | + model = _isothermal_tracer(einstein_radius=1.5) |
| 37 | + return al.FitWeak(dataset=dataset, tracer=model) |
| 38 | + |
| 39 | + |
| 40 | +@pytest.fixture(name="plot_path") |
| 41 | +def make_plot_path(): |
| 42 | + return directory / "files" |
| 43 | + |
| 44 | + |
| 45 | +def test__fit_weak__quick_update__writes_normal_fit_subplot( |
| 46 | + fit_weak, plot_path, plot_patch |
| 47 | +): |
| 48 | + plotter = PlotterWeak(image_path=plot_path) |
| 49 | + |
| 50 | + plotter.fit_weak(fit=fit_weak, quick_update=True) |
| 51 | + |
| 52 | + assert str(plot_path / "subplot_fit_weak.png") in plot_patch.paths |
| 53 | + assert str(plot_path / "fit_quick.png") not in plot_patch.paths |
0 commit comments