diff --git a/autolens/lens/plot/tracer_plotters.py b/autolens/lens/plot/tracer_plotters.py index a670a58f7..03cba0065 100644 --- a/autolens/lens/plot/tracer_plotters.py +++ b/autolens/lens/plot/tracer_plotters.py @@ -233,7 +233,6 @@ def figures_2d_of_planes( plane_indexes = self.plane_indexes_from(plane_index=plane_index) for plane_index in plane_indexes: - galaxies_plotter = self.galaxies_plotter_from(plane_index=plane_index) if plane_index == 1: @@ -432,5 +431,7 @@ def subplot_galaxies_images(self): plane_image=True, title_suffix=f" Of Plane {plane_index}" ) - self.mat_plot_2d.output.subplot_to_figure(auto_filename=f"subplot_galaxies_images") + self.mat_plot_2d.output.subplot_to_figure( + auto_filename=f"subplot_galaxies_images" + ) self.close_subplot_figure() diff --git a/autolens/lens/tracer.py b/autolens/lens/tracer.py index 6f09356c6..755a6e628 100644 --- a/autolens/lens/tracer.py +++ b/autolens/lens/tracer.py @@ -54,7 +54,7 @@ def __init__( different calculations. """ - self.galaxies = galaxies=galaxies + self.galaxies = galaxies = galaxies self.cosmology = cosmology @@ -189,9 +189,7 @@ def sliced_tracer_from( The cosmology used to perform ray-tracing calculations. """ - lens_redshifts = tracer_util.plane_redshifts_from( - galaxies=lens_galaxies - ) + lens_redshifts = tracer_util.plane_redshifts_from(galaxies=lens_galaxies) plane_redshifts = tracer_util.ordered_plane_redshifts_with_slicing_from( lens_redshifts=lens_redshifts, diff --git a/autolens/lens/tracer_util.py b/autolens/lens/tracer_util.py index 7c0ff8a64..db6d03759 100644 --- a/autolens/lens/tracer_util.py +++ b/autolens/lens/tracer_util.py @@ -5,7 +5,8 @@ import autoarray as aa import autogalaxy as ag -def plane_redshifts_from(galaxies : List[ag.Galaxy]) -> List[float]: + +def plane_redshifts_from(galaxies: List[ag.Galaxy]) -> List[float]: """ Returns a list of plane redshifts from a list of galaxies, using the redshifts of the galaxies to determine the unique redshifts of the planes. @@ -34,7 +35,9 @@ def plane_redshifts_from(galaxies : List[ag.Galaxy]) -> List[float]: return list(dict.fromkeys(plane_redshifts)) -def planes_from(galaxies : List[ag.Galaxy], plane_redshifts : Optional[List[float]] = None) -> List[List[ag.Galaxy]]: +def planes_from( + galaxies: List[ag.Galaxy], plane_redshifts: Optional[List[float]] = None +) -> List[List[ag.Galaxy]]: """ Returns a list of list of galaxies grouped into their planes, where planes contained all galaxies at the same unique redshift. @@ -219,9 +222,7 @@ def grid_2d_at_redshift_from( if redshift <= plane_redshifts[0]: return grid.copy() - planes = planes_from( - galaxies=galaxies, plane_redshifts=plane_redshifts - ) + planes = planes_from(galaxies=galaxies, plane_redshifts=plane_redshifts) plane_index_with_redshift = [ plane_index @@ -249,8 +250,6 @@ def grid_2d_at_redshift_from( return traced_grid_list[plane_index_insert] - - def ordered_plane_redshifts_with_slicing_from( lens_redshifts, planes_between_lenses, source_plane_redshift ): diff --git a/test_autolens/lens/test_operate.py b/test_autolens/lens/test_operate.py index b9fd6c96f..6e9493296 100644 --- a/test_autolens/lens/test_operate.py +++ b/test_autolens/lens/test_operate.py @@ -74,9 +74,7 @@ def test__operate_image__blurred_images_2d_via_convolver_from__for_tracer_gives_ blurring_grid=source_blurring_grid_2d_7x7, ) - tracer = al.Tracer( - galaxies=[g0, g1], cosmology=al.cosmo.Planck15() - ) + tracer = al.Tracer(galaxies=[g0, g1], cosmology=al.cosmo.Planck15()) blurred_image = tracer.blurred_image_2d_from( grid=sub_grid_2d_7x7, @@ -115,8 +113,7 @@ def test__operate_image__visibilities_of_planes_from_grid_and_transformer( grid=sub_grid_2d_7x7, transformer=transformer_7x7_7 ) - tracer = al.Tracer(galaxies=[g0, g1], cosmology=al.cosmo.Planck15() - ) + tracer = al.Tracer(galaxies=[g0, g1], cosmology=al.cosmo.Planck15()) visibilities = tracer.visibilities_list_from( grid=sub_grid_2d_7x7, transformer=transformer_7x7_7 diff --git a/test_autolens/lens/test_tracer.py b/test_autolens/lens/test_tracer.py index ef1b20b9b..28b92e4bd 100644 --- a/test_autolens/lens/test_tracer.py +++ b/test_autolens/lens/test_tracer.py @@ -758,7 +758,6 @@ def test__extract_plane_index_of_profile(): def test__sliced_tracer_from(sub_grid_2d_7x7, sub_grid_2d_7x7_simple): - lens_g0 = al.Galaxy(redshift=0.5) source_g0 = al.Galaxy(redshift=2.0) los_g0 = al.Galaxy(redshift=0.1) @@ -780,7 +779,6 @@ def test__sliced_tracer_from(sub_grid_2d_7x7, sub_grid_2d_7x7_simple): def test__regression__centre_of_profile_in_right_place(): - grid = al.Grid2D.uniform(shape_native=(7, 7), pixel_scales=1.0) g0 = al.Galaxy( @@ -873,6 +871,7 @@ def test__decorators__grid_iterate_in__iterates_array_result_correctly(gal_x1_lp assert image[0] == image_sub_4[0] + def test__decorators__grid_iterate_in__method_returns_array_list__uses_highest_sub_size_of_iterate( gal_x1_lp, ): @@ -1003,4 +1002,4 @@ def test__output_to_and_load_from_json(): assert tracer_from_json.galaxies[1].redshift == 1.0 assert tracer_from_json.galaxies[0].mass_profile.einstein_radius == 1.0 - assert isinstance(tracer_from_json.cosmology, al.cosmo.wrap.Planck15) \ No newline at end of file + assert isinstance(tracer_from_json.cosmology, al.cosmo.wrap.Planck15) diff --git a/test_autolens/lens/test_tracer_util.py b/test_autolens/lens/test_tracer_util.py index 837c2cd79..80d883dfd 100644 --- a/test_autolens/lens/test_tracer_util.py +++ b/test_autolens/lens/test_tracer_util.py @@ -5,27 +5,13 @@ import autolens as al -def test__xtraced_grid_2d_list_from( - sub_grid_2d_7x7_simple -): - g0 = al.Galaxy( - redshift=2.0, mass_profile=al.mp.IsothermalSph(einstein_radius=1.0) - ) - g1 = al.Galaxy( - redshift=2.0, mass_profile=al.mp.IsothermalSph(einstein_radius=1.0) - ) - g2 = al.Galaxy( - redshift=0.1, mass_profile=al.mp.IsothermalSph(einstein_radius=1.0) - ) - g3 = al.Galaxy( - redshift=3.0, mass_profile=al.mp.IsothermalSph(einstein_radius=1.0) - ) - g4 = al.Galaxy( - redshift=1.0, mass_profile=al.mp.IsothermalSph(einstein_radius=1.0) - ) - g5 = al.Galaxy( - redshift=3.0, mass_profile=al.mp.IsothermalSph(einstein_radius=1.0) - ) +def test__xtraced_grid_2d_list_from(sub_grid_2d_7x7_simple): + g0 = al.Galaxy(redshift=2.0, mass_profile=al.mp.IsothermalSph(einstein_radius=1.0)) + g1 = al.Galaxy(redshift=2.0, mass_profile=al.mp.IsothermalSph(einstein_radius=1.0)) + g2 = al.Galaxy(redshift=0.1, mass_profile=al.mp.IsothermalSph(einstein_radius=1.0)) + g3 = al.Galaxy(redshift=3.0, mass_profile=al.mp.IsothermalSph(einstein_radius=1.0)) + g4 = al.Galaxy(redshift=1.0, mass_profile=al.mp.IsothermalSph(einstein_radius=1.0)) + g5 = al.Galaxy(redshift=3.0, mass_profile=al.mp.IsothermalSph(einstein_radius=1.0)) galaxies = [g0, g1, g2, g3, g4, g5] @@ -55,9 +41,7 @@ def test__xtraced_grid_2d_list_from( defl11 = g0.deflections_yx_2d_from( grid=np.array([[(1.0 - beta_01 * val), (1.0 - beta_01 * val)]]) ) - defl12 = g0.deflections_yx_2d_from( - grid=np.array([[(1.0 - beta_01 * 1.0), 0.0]]) - ) + defl12 = g0.deflections_yx_2d_from(grid=np.array([[(1.0 - beta_01 * 1.0), 0.0]])) assert traced_grid_list[2][0] == pytest.approx( np.array( @@ -155,9 +139,8 @@ def test__grid_2d_at_redshift_from(sub_grid_2d_7x7): assert grid_at_redshift == pytest.approx(traced_grid_list[4], 1.0e-4) -def test__grid_2d_at_redshift_from__redshift_between_planes( - sub_grid_2d_7x7 -): + +def test__grid_2d_at_redshift_from__redshift_between_planes(sub_grid_2d_7x7): sub_grid_2d_7x7[0] = np.array([[1.0, -1.0]]) sub_grid_2d_7x7[1] = np.array([[1.0, 0.0]]) @@ -188,8 +171,4 @@ def test__grid_2d_at_redshift_from__redshift_between_planes( redshift=0.3, ) - assert ( - grid_at_redshift == sub_grid_2d_7x7.mask.derive_grid.all_false_sub_1 - ).all() - - + assert (grid_at_redshift == sub_grid_2d_7x7.mask.derive_grid.all_false_sub_1).all()