From dcdd33fa11b2db430176976780b6ddce2dbe0986 Mon Sep 17 00:00:00 2001 From: Richard Date: Mon, 8 Jul 2024 12:59:11 +0100 Subject: [PATCH 01/24] introduce new triangle representation --- autolens/point/triangles/triangle_solver.py | 55 +++------------------ 1 file changed, 7 insertions(+), 48 deletions(-) diff --git a/autolens/point/triangles/triangle_solver.py b/autolens/point/triangles/triangle_solver.py index d9b3887d7..21aa954cb 100644 --- a/autolens/point/triangles/triangle_solver.py +++ b/autolens/point/triangles/triangle_solver.py @@ -3,12 +3,12 @@ from typing import Tuple, List from autoarray import Grid2D, Grid2DIrregular +from autoarray.structures.triangles.array import ArrayTriangles from autoarray.structures.triangles.subsample_triangles import SubsampleTriangles from autoarray.structures.triangles.triangles import Triangles from autoarray.type import Grid2DLike from autogalaxy import OperateDeflections - logger = logging.getLogger(__name__) @@ -87,7 +87,7 @@ def solve( ------- A list of image plane coordinates that are traced to the source plane coordinate. """ - triangles = Triangles.for_grid(grid=self.grid) + triangles = ArrayTriangles.for_grid(grid=self.grid) if self.n_steps == 0: raise ValueError( @@ -97,21 +97,13 @@ def solve( kept_triangles = [] for _ in range(self.n_steps): - kept_triangles = self._filter_triangles( - triangles=triangles, - source_plane_coordinate=source_plane_coordinate, - ) - with_neighbourhood = { - triangle - for kept_triangle in kept_triangles - for triangle in kept_triangle.neighbourhood - } - triangles = SubsampleTriangles(parent_triangles=list(with_neighbourhood)) + kept_triangles = triangles.containing(point=source_plane_coordinate) + with_neighbourhood = kept_triangles.neighborhood() + triangles = with_neighbourhood.up_sample() - means = [triangle.mean for triangle in kept_triangles] - filtered_means = self._filter_low_magnification(points=means) + filtered_means = self._filter_low_magnification(points=kept_triangles.means) - difference = len(means) - len(filtered_means) + difference = len(kept_triangles.means) - len(filtered_means) if difference > 0: logger.debug( f"Filtered one multiple-image with magnification below threshold." @@ -149,36 +141,3 @@ def _filter_low_magnification( ) if abs(magnification) > self.magnification_threshold ] - - def _filter_triangles( - self, - triangles: Triangles, - source_plane_coordinate: Tuple[float, float], - ): - """ - Filter the triangles to keep only those that contain the source plane coordinate. - - Parameters - ---------- - triangles - A set of triangles that may contain the source plane coordinate. - source_plane_coordinate - The source plane coordinate to check if it is contained within the triangles. - - Returns - ------- - The triangles that contain the source plane coordinate. - """ - source_plane_grid = self._source_plane_grid(grid=triangles.grid_2d) - - kept_triangles = [] - for image_triangle, source_triangle in zip( - triangles.triangles, - triangles.with_updated_grid(source_plane_grid), - ): - if source_triangle.contains( - point=source_plane_coordinate, - ): - kept_triangles.append(image_triangle) - - return kept_triangles From 2eab1851cc871cf9a9083e37e473ab0943a0f07a Mon Sep 17 00:00:00 2001 From: Richard Date: Mon, 15 Jul 2024 10:24:41 +0100 Subject: [PATCH 02/24] reimplemented _filter_triangles to work with new ArrayTriangles methods --- autolens/point/triangles/triangle_solver.py | 33 +++++++++++++++++++-- 1 file changed, 30 insertions(+), 3 deletions(-) diff --git a/autolens/point/triangles/triangle_solver.py b/autolens/point/triangles/triangle_solver.py index 21aa954cb..714fc5c4e 100644 --- a/autolens/point/triangles/triangle_solver.py +++ b/autolens/point/triangles/triangle_solver.py @@ -4,8 +4,6 @@ from autoarray import Grid2D, Grid2DIrregular from autoarray.structures.triangles.array import ArrayTriangles -from autoarray.structures.triangles.subsample_triangles import SubsampleTriangles -from autoarray.structures.triangles.triangles import Triangles from autoarray.type import Grid2DLike from autogalaxy import OperateDeflections @@ -97,7 +95,10 @@ def solve( kept_triangles = [] for _ in range(self.n_steps): - kept_triangles = triangles.containing(point=source_plane_coordinate) + kept_triangles = self._filter_triangles( + triangles, + source_plane_coordinate, + ) with_neighbourhood = kept_triangles.neighborhood() triangles = with_neighbourhood.up_sample() @@ -141,3 +142,29 @@ def _filter_low_magnification( ) if abs(magnification) > self.magnification_threshold ] + + def _filter_triangles( + self, + triangles: ArrayTriangles, + source_plane_coordinate: Tuple[float, float], + ): + """ + Filter the triangles to keep only those that contain the source plane coordinate. + + Parameters + ---------- + triangles + A set of triangles that may contain the source plane coordinate. + source_plane_coordinate + The source plane coordinate to check if it is contained within the triangles. + + Returns + ------- + The triangles that contain the source plane coordinate. + """ + source_plane_grid = self._source_plane_grid( + grid=Grid2DIrregular(triangles.vertices) + ) + source_triangles = triangles.with_vertices(source_plane_grid) + indexes = source_triangles.containing_indices(point=source_plane_coordinate) + return triangles.for_indexes(indexes=indexes) From 91471bc23d8da9261a4bcd48844933929a36db99 Mon Sep 17 00:00:00 2001 From: Richard Date: Mon, 15 Jul 2024 11:49:15 +0100 Subject: [PATCH 03/24] extracting steps to allow visualisation of intermediate states --- autolens/point/triangles/triangle_solver.py | 43 +++++++++++++++------ autolens/point/triangles/visualise.py | 5 +++ 2 files changed, 36 insertions(+), 12 deletions(-) create mode 100644 autolens/point/triangles/visualise.py diff --git a/autolens/point/triangles/triangle_solver.py b/autolens/point/triangles/triangle_solver.py index 714fc5c4e..a5b82a821 100644 --- a/autolens/point/triangles/triangle_solver.py +++ b/autolens/point/triangles/triangle_solver.py @@ -1,6 +1,7 @@ import logging import math -from typing import Tuple, List +from dataclasses import dataclass +from typing import Tuple, List, Iterator from autoarray import Grid2D, Grid2DIrregular from autoarray.structures.triangles.array import ArrayTriangles @@ -10,6 +11,14 @@ logger = logging.getLogger(__name__) +@dataclass +class Step: + initial_triangles: ArrayTriangles + filtered_triangles: ArrayTriangles + neighbourhood: ArrayTriangles + up_sampled: ArrayTriangles + + class TriangleSolver: def __init__( self, @@ -85,22 +94,14 @@ def solve( ------- A list of image plane coordinates that are traced to the source plane coordinate. """ - triangles = ArrayTriangles.for_grid(grid=self.grid) - if self.n_steps == 0: raise ValueError( "The target pixel scale is too large to subdivide the triangles." ) - kept_triangles = [] - - for _ in range(self.n_steps): - kept_triangles = self._filter_triangles( - triangles, - source_plane_coordinate, - ) - with_neighbourhood = kept_triangles.neighborhood() - triangles = with_neighbourhood.up_sample() + steps = list(self.steps(source_plane_coordinate=source_plane_coordinate)) + final_step = steps[-1] + kept_triangles = final_step.filtered_triangles filtered_means = self._filter_low_magnification(points=kept_triangles.means) @@ -168,3 +169,21 @@ def _filter_triangles( source_triangles = triangles.with_vertices(source_plane_grid) indexes = source_triangles.containing_indices(point=source_plane_coordinate) return triangles.for_indexes(indexes=indexes) + + def steps(self, source_plane_coordinate: Tuple[float, float]) -> Iterator[Step]: + triangles = ArrayTriangles.for_grid(grid=self.grid) + + for _ in range(self.n_steps): + kept_triangles = self._filter_triangles( + triangles, + source_plane_coordinate, + ) + with_neighbourhood = kept_triangles.neighborhood() + triangles = with_neighbourhood.up_sample() + + yield Step( + initial_triangles=triangles, + filtered_triangles=kept_triangles, + neighbourhood=with_neighbourhood, + up_sampled=triangles, + ) diff --git a/autolens/point/triangles/visualise.py b/autolens/point/triangles/visualise.py new file mode 100644 index 000000000..af4f75906 --- /dev/null +++ b/autolens/point/triangles/visualise.py @@ -0,0 +1,5 @@ +from .triangle_solver import Step + + +def visualise(step: Step): + pass From c110c88f0fd9f30f1b55f90990ef828688ab6b4c Mon Sep 17 00:00:00 2001 From: Richard Date: Mon, 15 Jul 2024 12:22:47 +0100 Subject: [PATCH 04/24] working through issue using visualisation --- autolens/point/triangles/triangle_solver.py | 20 ++++++++++++-------- autolens/point/triangles/visualise.py | 13 ++++++++++++- test_autolens/point/triangles/conftest.py | 4 ++-- test_autolens/point/triangles/test_solver.py | 13 ++++++++----- 4 files changed, 34 insertions(+), 16 deletions(-) diff --git a/autolens/point/triangles/triangle_solver.py b/autolens/point/triangles/triangle_solver.py index a5b82a821..ff263b4ae 100644 --- a/autolens/point/triangles/triangle_solver.py +++ b/autolens/point/triangles/triangle_solver.py @@ -13,6 +13,7 @@ @dataclass class Step: + number: int initial_triangles: ArrayTriangles filtered_triangles: ArrayTriangles neighbourhood: ArrayTriangles @@ -171,19 +172,22 @@ def _filter_triangles( return triangles.for_indexes(indexes=indexes) def steps(self, source_plane_coordinate: Tuple[float, float]) -> Iterator[Step]: - triangles = ArrayTriangles.for_grid(grid=self.grid) + initial_triangles = ArrayTriangles.for_grid(grid=self.grid) - for _ in range(self.n_steps): + for number in range(self.n_steps): kept_triangles = self._filter_triangles( - triangles, + initial_triangles, source_plane_coordinate, ) - with_neighbourhood = kept_triangles.neighborhood() - triangles = with_neighbourhood.up_sample() + neighbourhood = kept_triangles.neighborhood() + up_sampled = neighbourhood.up_sample() yield Step( - initial_triangles=triangles, + number=number, + initial_triangles=initial_triangles, filtered_triangles=kept_triangles, - neighbourhood=with_neighbourhood, - up_sampled=triangles, + neighbourhood=neighbourhood, + up_sampled=up_sampled, ) + + initial_triangles = up_sampled diff --git a/autolens/point/triangles/visualise.py b/autolens/point/triangles/visualise.py index af4f75906..9c6fe9a21 100644 --- a/autolens/point/triangles/visualise.py +++ b/autolens/point/triangles/visualise.py @@ -1,5 +1,16 @@ from .triangle_solver import Step +from matplotlib import pyplot as plt +import numpy as np def visualise(step: Step): - pass + plt.figure(figsize=(8, 8)) + for triangle in step.initial_triangles: + triangle = np.append(triangle, [triangle[0]], axis=0) # Close the triangle + plt.plot(triangle[:, 0], triangle[:, 1], "o-") + + plt.xlabel("X") + plt.ylabel("Y") + plt.title(f"Step {step.number}") + plt.gca().set_aspect("equal", adjustable="box") + plt.show() diff --git a/test_autolens/point/triangles/conftest.py b/test_autolens/point/triangles/conftest.py index 321efc191..bafeafe95 100644 --- a/test_autolens/point/triangles/conftest.py +++ b/test_autolens/point/triangles/conftest.py @@ -5,6 +5,6 @@ @pytest.fixture def grid(): return al.Grid2D.uniform( - shape_native=(100, 100), - pixel_scales=0.05, + shape_native=(10, 10), + pixel_scales=1.0, ) diff --git a/test_autolens/point/triangles/test_solver.py b/test_autolens/point/triangles/test_solver.py index 55032fcbe..52fe497f1 100644 --- a/test_autolens/point/triangles/test_solver.py +++ b/test_autolens/point/triangles/test_solver.py @@ -6,6 +6,7 @@ import autolens as al import autogalaxy as ag from autolens.point.triangles.triangle_solver import TriangleSolver +from autolens.point.triangles.visualise import visualise @pytest.fixture @@ -51,11 +52,11 @@ def deflections_yx_2d_from(self, grid): "source_plane_coordinate", [ (0.0, 0.0), - (0.0, 1.0), - (1.0, 1.0), - (0.5, 0.5), - (0.1, 0.1), - (-1.0, -1.0), + # (0.0, 1.0), + # (1.0, 1.0), + # (0.5, 0.5), + # (0.1, 0.1), + # (-1.0, -1.0), ], ) def test_trivial( @@ -67,6 +68,8 @@ def test_trivial( grid=grid, pixel_scale_precision=0.01, ) + for step in solver.steps(source_plane_coordinate): + visualise(step) (coordinates,) = solver.solve( source_plane_coordinate=source_plane_coordinate, ) From d886fcb88746aed9748a22af9b3d5fff297c8a41 Mon Sep 17 00:00:00 2001 From: Richard Date: Mon, 15 Jul 2024 12:28:18 +0100 Subject: [PATCH 05/24] visualise whole upsampling procedure --- autolens/point/triangles/visualise.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/autolens/point/triangles/visualise.py b/autolens/point/triangles/visualise.py index 9c6fe9a21..87b7fabea 100644 --- a/autolens/point/triangles/visualise.py +++ b/autolens/point/triangles/visualise.py @@ -3,11 +3,18 @@ import numpy as np +def add_triangles(triangles, color): + for triangle in triangles: + triangle = np.append(triangle, [triangle[0]], axis=0) + plt.plot(triangle[:, 0], triangle[:, 1], "o-", color=color) + + def visualise(step: Step): plt.figure(figsize=(8, 8)) - for triangle in step.initial_triangles: - triangle = np.append(triangle, [triangle[0]], axis=0) # Close the triangle - plt.plot(triangle[:, 0], triangle[:, 1], "o-") + add_triangles(step.initial_triangles, color="black") + add_triangles(step.filtered_triangles, color="blue") + add_triangles(step.up_sampled, color="green") + add_triangles(step.neighbourhood, color="red") plt.xlabel("X") plt.ylabel("Y") From c54266d96742c487ec51e1e3e8f6c746e357e9d3 Mon Sep 17 00:00:00 2001 From: Richard Date: Mon, 15 Jul 2024 13:59:09 +0100 Subject: [PATCH 06/24] more testing for neighborhood --- test_autolens/point/triangles/test_solver.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/test_autolens/point/triangles/test_solver.py b/test_autolens/point/triangles/test_solver.py index 52fe497f1..7e1e9687b 100644 --- a/test_autolens/point/triangles/test_solver.py +++ b/test_autolens/point/triangles/test_solver.py @@ -51,8 +51,8 @@ def deflections_yx_2d_from(self, grid): @pytest.mark.parametrize( "source_plane_coordinate", [ - (0.0, 0.0), - # (0.0, 1.0), + # (0.0, 0.0), + (0.0, 1.0), # (1.0, 1.0), # (0.5, 0.5), # (0.1, 0.1), @@ -73,7 +73,7 @@ def test_trivial( (coordinates,) = solver.solve( source_plane_coordinate=source_plane_coordinate, ) - assert coordinates == pytest.approx(source_plane_coordinate, abs=1.0e-2) + assert coordinates == pytest.approx(source_plane_coordinate, abs=1.0e-1) def test_real_example(grid): @@ -99,5 +99,7 @@ def test_real_example(grid): lensing_obj=tracer, pixel_scale_precision=0.001, ) + for step in solver.steps((0.07, 0.07)): + visualise(step) result = solver.solve((0.07, 0.07)) assert len(result) == 4 From ff223971359b3057e963c146554589ccbeb59815 Mon Sep 17 00:00:00 2001 From: Richard Date: Mon, 15 Jul 2024 14:52:11 +0100 Subject: [PATCH 07/24] fixing tests... --- test_autolens/point/triangles/test_solver.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/test_autolens/point/triangles/test_solver.py b/test_autolens/point/triangles/test_solver.py index 7e1e9687b..27a1007e6 100644 --- a/test_autolens/point/triangles/test_solver.py +++ b/test_autolens/point/triangles/test_solver.py @@ -37,7 +37,7 @@ def test_solver(solver): def test_steps(solver): - assert solver.n_steps == 3 + assert solver.n_steps == 7 class NullTracer(al.Tracer): @@ -51,12 +51,13 @@ def deflections_yx_2d_from(self, grid): @pytest.mark.parametrize( "source_plane_coordinate", [ - # (0.0, 0.0), + (0.0, 0.0), (0.0, 1.0), - # (1.0, 1.0), - # (0.5, 0.5), - # (0.1, 0.1), - # (-1.0, -1.0), + (1.0, 0.0), + (1.0, 1.0), + (0.5, 0.5), + (0.1, 0.1), + (-1.0, -1.0), ], ) def test_trivial( From 354c2fe8e72b37e813a29ec5d6b87f4e7a8c6d3d Mon Sep 17 00:00:00 2001 From: Richard Date: Mon, 15 Jul 2024 14:53:09 +0100 Subject: [PATCH 08/24] remove visualisation from test --- test_autolens/point/triangles/test_solver.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/test_autolens/point/triangles/test_solver.py b/test_autolens/point/triangles/test_solver.py index 27a1007e6..ba07f7e66 100644 --- a/test_autolens/point/triangles/test_solver.py +++ b/test_autolens/point/triangles/test_solver.py @@ -69,8 +69,6 @@ def test_trivial( grid=grid, pixel_scale_precision=0.01, ) - for step in solver.steps(source_plane_coordinate): - visualise(step) (coordinates,) = solver.solve( source_plane_coordinate=source_plane_coordinate, ) From 5f312a2105a77e5e89b5c0ce839209987648c5df Mon Sep 17 00:00:00 2001 From: Richard Date: Mon, 15 Jul 2024 14:56:09 +0100 Subject: [PATCH 09/24] updated test --- test_autolens/point/triangles/test_solver.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test_autolens/point/triangles/test_solver.py b/test_autolens/point/triangles/test_solver.py index ba07f7e66..6ddde566a 100644 --- a/test_autolens/point/triangles/test_solver.py +++ b/test_autolens/point/triangles/test_solver.py @@ -101,4 +101,4 @@ def test_real_example(grid): for step in solver.steps((0.07, 0.07)): visualise(step) result = solver.solve((0.07, 0.07)) - assert len(result) == 4 + assert len(result) == 5 From e75e7ab5b31ce2affe20880902035764649f67e5 Mon Sep 17 00:00:00 2001 From: Richard Date: Mon, 15 Jul 2024 15:13:26 +0100 Subject: [PATCH 10/24] remove visualisation from tests --- test_autolens/point/triangles/test_solver.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/test_autolens/point/triangles/test_solver.py b/test_autolens/point/triangles/test_solver.py index 6ddde566a..201a4594e 100644 --- a/test_autolens/point/triangles/test_solver.py +++ b/test_autolens/point/triangles/test_solver.py @@ -6,7 +6,6 @@ import autolens as al import autogalaxy as ag from autolens.point.triangles.triangle_solver import TriangleSolver -from autolens.point.triangles.visualise import visualise @pytest.fixture @@ -98,7 +97,5 @@ def test_real_example(grid): lensing_obj=tracer, pixel_scale_precision=0.001, ) - for step in solver.steps((0.07, 0.07)): - visualise(step) result = solver.solve((0.07, 0.07)) assert len(result) == 5 From e79a320cf32be56b3ca567db14ee0eaccaec03fa Mon Sep 17 00:00:00 2001 From: Richard Date: Mon, 15 Jul 2024 15:15:23 +0100 Subject: [PATCH 11/24] docs --- autolens/point/triangles/triangle_solver.py | 34 ++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/autolens/point/triangles/triangle_solver.py b/autolens/point/triangles/triangle_solver.py index ff263b4ae..d869fa22f 100644 --- a/autolens/point/triangles/triangle_solver.py +++ b/autolens/point/triangles/triangle_solver.py @@ -13,6 +13,23 @@ @dataclass class Step: + """ + A step in the triangle solver algorithm. + + Attributes + ---------- + number + The number of the step. + initial_triangles + The triangles at the start of the step. + filtered_triangles + The triangles trace to triangles that contain the source plane coordinate. + neighbourhood + The neighbourhood of the filtered triangles. + up_sampled + The neighbourhood up-sampled to increase the resolution. + """ + number: int initial_triangles: ArrayTriangles filtered_triangles: ArrayTriangles @@ -171,7 +188,22 @@ def _filter_triangles( indexes = source_triangles.containing_indices(point=source_plane_coordinate) return triangles.for_indexes(indexes=indexes) - def steps(self, source_plane_coordinate: Tuple[float, float]) -> Iterator[Step]: + def steps( + self, + source_plane_coordinate: Tuple[float, float], + ) -> Iterator[Step]: + """ + Iterate over the steps of the triangle solver algorithm. + + Parameters + ---------- + source_plane_coordinate + The source plane coordinate to trace to the image plane. + + Returns + ------- + An iterator over the steps of the triangle solver algorithm. + """ initial_triangles = ArrayTriangles.for_grid(grid=self.grid) for number in range(self.n_steps): From 685c22e93b73225590d2915288ea9cb7a924e363 Mon Sep 17 00:00:00 2001 From: Richard Date: Mon, 15 Jul 2024 15:31:06 +0100 Subject: [PATCH 12/24] cast to tuple to fix test --- autolens/point/analysis.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/autolens/point/analysis.py b/autolens/point/analysis.py index 256fbbaf1..1c3553ca7 100644 --- a/autolens/point/analysis.py +++ b/autolens/point/analysis.py @@ -147,7 +147,7 @@ def _log_likelihood_for_coordinates( "The number of predicted coordinates must be equal to the number of observed coordinates." ) - predicted_coordinates = set(predicted_coordinates) + predicted_coordinates = set(map(tuple, predicted_coordinates)) observed_coordinates = set(self.observed_coordinates) log_likelihood = 0.0 From 533f996abd24d56c84f48775ffb0213000b01b9e Mon Sep 17 00:00:00 2001 From: Richard Date: Mon, 22 Jul 2024 09:28:20 +0100 Subject: [PATCH 13/24] using for_grid to avoid having to create and pass a grid object that is not yet properly jaxified --- autolens/point/triangles/triangle_solver.py | 76 +++++++++++++++---- .../point/triangles/test_regressions.py | 2 +- test_autolens/point/triangles/test_solver.py | 6 +- .../point/triangles/test_solver_jax.py | 11 +++ 4 files changed, 77 insertions(+), 18 deletions(-) create mode 100644 test_autolens/point/triangles/test_solver_jax.py diff --git a/autolens/point/triangles/triangle_solver.py b/autolens/point/triangles/triangle_solver.py index d869fa22f..9be9e431f 100644 --- a/autolens/point/triangles/triangle_solver.py +++ b/autolens/point/triangles/triangle_solver.py @@ -1,10 +1,10 @@ import logging import math from dataclasses import dataclass -from typing import Tuple, List, Iterator +from typing import Tuple, List, Iterator, Type from autoarray import Grid2D, Grid2DIrregular -from autoarray.structures.triangles.array import ArrayTriangles +from autoarray.structures.triangles import array from autoarray.type import Grid2DLike from autogalaxy import OperateDeflections @@ -31,19 +31,25 @@ class Step: """ number: int - initial_triangles: ArrayTriangles - filtered_triangles: ArrayTriangles - neighbourhood: ArrayTriangles - up_sampled: ArrayTriangles + initial_triangles: array.ArrayTriangles + filtered_triangles: array.ArrayTriangles + neighbourhood: array.ArrayTriangles + up_sampled: array.ArrayTriangles class TriangleSolver: + # noinspection PyPep8Naming def __init__( self, lensing_obj: OperateDeflections, - grid: Grid2D, + scale: float, + y_min: float, + y_max: float, + x_min: float, + x_max: float, pixel_scale_precision: float, magnification_threshold=0.1, + ArrayTriangles: Type[array.ArrayTriangles] = array.ArrayTriangles, ): """ Determine the image plane coordinates that are traced to be a source plane coordinate. @@ -56,22 +62,58 @@ def __init__( ---------- lensing_obj A tracer describing the lensing system. - grid - The grid of image plane coordinates. pixel_scale_precision The target pixel scale of the image grid. + ArrayTriangles + The class to use for the triangles. """ self.lensing_obj = lensing_obj - self.grid = grid + self.scale = scale + self.y_min = y_min + self.y_max = y_max + self.x_min = x_min + self.x_max = x_max self.pixel_scale_precision = pixel_scale_precision self.magnification_threshold = magnification_threshold + self.ArrayTriangles = ArrayTriangles + + @classmethod + def for_grid( + cls, + lensing_obj: OperateDeflections, + grid: Grid2D, + pixel_scale_precision: float, + magnification_threshold=0.1, + ArrayTriangles: Type[array.ArrayTriangles] = array.ArrayTriangles, + ): + scale = grid.pixel_scale + + y = grid[:, 0] + x = grid[:, 1] + + y_min = y.min() + y_max = y.max() + x_min = x.min() + x_max = x.max() + + return cls( + lensing_obj=lensing_obj, + scale=scale, + y_min=y_min, + y_max=y_max, + x_min=x_min, + x_max=x_max, + pixel_scale_precision=pixel_scale_precision, + magnification_threshold=magnification_threshold, + ArrayTriangles=ArrayTriangles, + ) @property def n_steps(self) -> int: """ How many times should triangles be subdivided? """ - return math.ceil(math.log2(self.grid.pixel_scale / self.pixel_scale_precision)) + return math.ceil(math.log2(self.scale / self.pixel_scale_precision)) def _source_plane_grid(self, grid: Grid2DLike) -> Grid2DLike: """ @@ -156,7 +198,7 @@ def _filter_low_magnification( points, self.lensing_obj.magnification_2d_via_hessian_from( grid=Grid2DIrregular(points), - buffer=self.grid.pixel_scale, + buffer=self.scale, ), ) if abs(magnification) > self.magnification_threshold @@ -164,7 +206,7 @@ def _filter_low_magnification( def _filter_triangles( self, - triangles: ArrayTriangles, + triangles: array.ArrayTriangles, source_plane_coordinate: Tuple[float, float], ): """ @@ -204,7 +246,13 @@ def steps( ------- An iterator over the steps of the triangle solver algorithm. """ - initial_triangles = ArrayTriangles.for_grid(grid=self.grid) + initial_triangles = self.ArrayTriangles.for_limits_and_scale( + y_min=self.y_min, + y_max=self.y_max, + x_min=self.x_min, + x_max=self.x_max, + scale=self.scale, + ) for number in range(self.n_steps): kept_triangles = self._filter_triangles( diff --git a/test_autolens/point/triangles/test_regressions.py b/test_autolens/point/triangles/test_regressions.py index 5c94adac4..c712b2e5b 100644 --- a/test_autolens/point/triangles/test_regressions.py +++ b/test_autolens/point/triangles/test_regressions.py @@ -66,7 +66,7 @@ def test_missing_multiple_image(grid): tracer = al.Tracer(galaxies=[instance.lens_galaxy, instance.source_galaxy]) - solver = TriangleSolver( + solver = TriangleSolver.for_grid( grid=grid, lensing_obj=tracer, pixel_scale_precision=0.001, diff --git a/test_autolens/point/triangles/test_solver.py b/test_autolens/point/triangles/test_solver.py index 201a4594e..c47e39a50 100644 --- a/test_autolens/point/triangles/test_solver.py +++ b/test_autolens/point/triangles/test_solver.py @@ -22,7 +22,7 @@ def solver(grid): ] ) - return TriangleSolver( + return TriangleSolver.for_grid( lensing_obj=tracer, grid=grid, pixel_scale_precision=0.01, @@ -63,7 +63,7 @@ def test_trivial( source_plane_coordinate: Tuple[float, float], grid, ): - solver = TriangleSolver( + solver = TriangleSolver.for_grid( lensing_obj=NullTracer(), grid=grid, pixel_scale_precision=0.01, @@ -92,7 +92,7 @@ def test_real_example(grid): tracer = al.Tracer(galaxies=[lens_galaxy, source_galaxy]) - solver = TriangleSolver( + solver = TriangleSolver.for_grid( grid=grid, lensing_obj=tracer, pixel_scale_precision=0.001, diff --git a/test_autolens/point/triangles/test_solver_jax.py b/test_autolens/point/triangles/test_solver_jax.py new file mode 100644 index 000000000..c2fe9ed14 --- /dev/null +++ b/test_autolens/point/triangles/test_solver_jax.py @@ -0,0 +1,11 @@ +import pytest + +import autolens as al +import autogalaxy as ag +from autolens.point.triangles.triangle_solver import TriangleSolver + + +def test_solver(solver): + assert solver.solve( + source_plane_coordinate=(0.0, 0.0), + ) From e13b5a2867ca7ae1e818f36c60245cfc60800199 Mon Sep 17 00:00:00 2001 From: Richard Date: Mon, 22 Jul 2024 10:08:17 +0100 Subject: [PATCH 14/24] fix trivial jax triangle test --- .../point/triangles/test_solver_jax.py | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/test_autolens/point/triangles/test_solver_jax.py b/test_autolens/point/triangles/test_solver_jax.py index c2fe9ed14..d992f9386 100644 --- a/test_autolens/point/triangles/test_solver_jax.py +++ b/test_autolens/point/triangles/test_solver_jax.py @@ -2,9 +2,32 @@ import autolens as al import autogalaxy as ag +from autoarray.structures.triangles.jax_array import ArrayTriangles from autolens.point.triangles.triangle_solver import TriangleSolver +@pytest.fixture +def solver(grid): + tracer = al.Tracer( + galaxies=[ + al.Galaxy( + redshift=0.5, + mass=ag.mp.Isothermal( + centre=(0.0, 0.0), + einstein_radius=1.0, + ), + ) + ] + ) + + return TriangleSolver.for_grid( + lensing_obj=tracer, + grid=grid, + pixel_scale_precision=0.01, + ArrayTriangles=ArrayTriangles, + ) + + def test_solver(solver): assert solver.solve( source_plane_coordinate=(0.0, 0.0), From cadedeb2e9f9e591ed4ffa7cd610fdc1a88569ac Mon Sep 17 00:00:00 2001 From: Richard Date: Mon, 22 Jul 2024 10:08:27 +0100 Subject: [PATCH 15/24] fix --- autolens/point/triangles/triangle_solver.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/autolens/point/triangles/triangle_solver.py b/autolens/point/triangles/triangle_solver.py index 9be9e431f..a950a709f 100644 --- a/autolens/point/triangles/triangle_solver.py +++ b/autolens/point/triangles/triangle_solver.py @@ -226,7 +226,7 @@ def _filter_triangles( source_plane_grid = self._source_plane_grid( grid=Grid2DIrregular(triangles.vertices) ) - source_triangles = triangles.with_vertices(source_plane_grid) + source_triangles = triangles.with_vertices(source_plane_grid.array) indexes = source_triangles.containing_indices(point=source_plane_coordinate) return triangles.for_indexes(indexes=indexes) From ffcbe67db05f0b0dcf7e280cd0ec19128fa5a93b Mon Sep 17 00:00:00 2001 From: Richard Date: Mon, 22 Jul 2024 10:23:50 +0100 Subject: [PATCH 16/24] set up trivial tests for jax triangles --- autolens/mock.py | 27 +++++++++++----- autolens/point/triangles/triangle_solver.py | 3 +- test_autolens/point/triangles/test_solver.py | 10 +----- .../point/triangles/test_solver_jax.py | 31 +++++++++++++++++++ 4 files changed, 53 insertions(+), 18 deletions(-) diff --git a/autolens/mock.py b/autolens/mock.py index 52f9ec62d..8b54b92b0 100644 --- a/autolens/mock.py +++ b/autolens/mock.py @@ -1,8 +1,19 @@ -from autofit.mock import * -from autoarray.mock import * -from autogalaxy.mock import * - -from autolens.imaging.mock.mock_fit_imaging import MockFitImaging -from autolens.lens.mock.mock_tracer import MockTracer -from autolens.lens.mock.mock_tracer import MockTracerPoint -from autolens.point.mock.mock_point_solver import MockPointSolver +import numpy as np + +from autofit.mock import * # noqa +from autoarray.mock import * # noqa +from autogalaxy.mock import * # noqa +from autolens import Tracer + +from autolens.imaging.mock.mock_fit_imaging import MockFitImaging # noqa +from autolens.lens.mock.mock_tracer import MockTracer # noqa +from autolens.lens.mock.mock_tracer import MockTracerPoint # noqa +from autolens.point.mock.mock_point_solver import MockPointSolver # noqa + + +class NullTracer(Tracer): + def __init__(self): + super().__init__([]) + + def deflections_yx_2d_from(self, grid): + return np.zeros_like(grid) diff --git a/autolens/point/triangles/triangle_solver.py b/autolens/point/triangles/triangle_solver.py index a950a709f..1708d5aa6 100644 --- a/autolens/point/triangles/triangle_solver.py +++ b/autolens/point/triangles/triangle_solver.py @@ -77,6 +77,7 @@ def __init__( self.magnification_threshold = magnification_threshold self.ArrayTriangles = ArrayTriangles + # noinspection PyPep8Naming @classmethod def for_grid( cls, @@ -84,7 +85,7 @@ def for_grid( grid: Grid2D, pixel_scale_precision: float, magnification_threshold=0.1, - ArrayTriangles: Type[array.ArrayTriangles] = array.ArrayTriangles, + ArrayTriangles: Type[array.AbstractTriangles] = array.ArrayTriangles, ): scale = grid.pixel_scale diff --git a/test_autolens/point/triangles/test_solver.py b/test_autolens/point/triangles/test_solver.py index c47e39a50..8aff0569b 100644 --- a/test_autolens/point/triangles/test_solver.py +++ b/test_autolens/point/triangles/test_solver.py @@ -1,10 +1,10 @@ from typing import Tuple -import numpy as np import pytest import autolens as al import autogalaxy as ag +from autolens.mock import NullTracer from autolens.point.triangles.triangle_solver import TriangleSolver @@ -39,14 +39,6 @@ def test_steps(solver): assert solver.n_steps == 7 -class NullTracer(al.Tracer): - def __init__(self): - super().__init__([]) - - def deflections_yx_2d_from(self, grid): - return np.zeros_like(grid) - - @pytest.mark.parametrize( "source_plane_coordinate", [ diff --git a/test_autolens/point/triangles/test_solver_jax.py b/test_autolens/point/triangles/test_solver_jax.py index d992f9386..78df1044c 100644 --- a/test_autolens/point/triangles/test_solver_jax.py +++ b/test_autolens/point/triangles/test_solver_jax.py @@ -1,8 +1,11 @@ +from typing import Tuple + import pytest import autolens as al import autogalaxy as ag from autoarray.structures.triangles.jax_array import ArrayTriangles +from autolens.mock import NullTracer from autolens.point.triangles.triangle_solver import TriangleSolver @@ -32,3 +35,31 @@ def test_solver(solver): assert solver.solve( source_plane_coordinate=(0.0, 0.0), ) + + +@pytest.mark.parametrize( + "source_plane_coordinate", + [ + (0.0, 0.0), + (0.0, 1.0), + (1.0, 0.0), + (1.0, 1.0), + (0.5, 0.5), + (0.1, 0.1), + (-1.0, -1.0), + ], +) +def test_trivial( + source_plane_coordinate: Tuple[float, float], + grid, +): + solver = TriangleSolver.for_grid( + lensing_obj=NullTracer(), + grid=grid, + pixel_scale_precision=0.01, + ArrayTriangles=ArrayTriangles, + ) + (coordinates,) = solver.solve( + source_plane_coordinate=source_plane_coordinate, + ) + assert coordinates == pytest.approx(source_plane_coordinate, abs=1.0e-1) From 99dafa3c78bfd9fb8b5f7a705a0dd838067c2b37 Mon Sep 17 00:00:00 2001 From: Richard Date: Mon, 22 Jul 2024 10:28:58 +0100 Subject: [PATCH 17/24] trivial example works but with repeating coordinates in result --- autolens/mock.py | 2 +- test_autolens/point/triangles/test_solver_jax.py | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/autolens/mock.py b/autolens/mock.py index 8b54b92b0..bef94bcbe 100644 --- a/autolens/mock.py +++ b/autolens/mock.py @@ -16,4 +16,4 @@ def __init__(self): super().__init__([]) def deflections_yx_2d_from(self, grid): - return np.zeros_like(grid) + return np.zeros_like(grid.array) diff --git a/test_autolens/point/triangles/test_solver_jax.py b/test_autolens/point/triangles/test_solver_jax.py index 78df1044c..eccf86f98 100644 --- a/test_autolens/point/triangles/test_solver_jax.py +++ b/test_autolens/point/triangles/test_solver_jax.py @@ -59,7 +59,8 @@ def test_trivial( pixel_scale_precision=0.01, ArrayTriangles=ArrayTriangles, ) - (coordinates,) = solver.solve( + coordinates = solver.solve( source_plane_coordinate=source_plane_coordinate, ) - assert coordinates == pytest.approx(source_plane_coordinate, abs=1.0e-1) + print(coordinates) + assert coordinates[0] == pytest.approx(source_plane_coordinate, abs=1.0e-1) From d19cbaf40f99b93d81fc9cefe68ecfce43ab0d3f Mon Sep 17 00:00:00 2001 From: Richard Date: Mon, 22 Jul 2024 10:43:42 +0100 Subject: [PATCH 18/24] type import reference --- autolens/point/triangles/triangle_solver.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/autolens/point/triangles/triangle_solver.py b/autolens/point/triangles/triangle_solver.py index 1708d5aa6..f3a7ce474 100644 --- a/autolens/point/triangles/triangle_solver.py +++ b/autolens/point/triangles/triangle_solver.py @@ -5,6 +5,7 @@ from autoarray import Grid2D, Grid2DIrregular from autoarray.structures.triangles import array +from autoarray.structures.triangles.abstract import AbstractTriangles from autoarray.type import Grid2DLike from autogalaxy import OperateDeflections @@ -49,7 +50,7 @@ def __init__( x_max: float, pixel_scale_precision: float, magnification_threshold=0.1, - ArrayTriangles: Type[array.ArrayTriangles] = array.ArrayTriangles, + ArrayTriangles: Type[AbstractTriangles] = array.ArrayTriangles, ): """ Determine the image plane coordinates that are traced to be a source plane coordinate. @@ -85,7 +86,7 @@ def for_grid( grid: Grid2D, pixel_scale_precision: float, magnification_threshold=0.1, - ArrayTriangles: Type[array.AbstractTriangles] = array.ArrayTriangles, + ArrayTriangles: Type[AbstractTriangles] = array.ArrayTriangles, ): scale = grid.pixel_scale From 1defcbc628751d3a2ca6e01115d731a2846662a2 Mon Sep 17 00:00:00 2001 From: Richard Date: Mon, 22 Jul 2024 10:57:49 +0100 Subject: [PATCH 19/24] simple real example gives same results with JAX --- autolens/point/triangles/triangle_solver.py | 2 +- test_autolens/point/triangles/test_solver.py | 1 + .../point/triangles/test_solver_jax.py | 29 +++++++++++++++++++ 3 files changed, 31 insertions(+), 1 deletion(-) diff --git a/autolens/point/triangles/triangle_solver.py b/autolens/point/triangles/triangle_solver.py index f3a7ce474..8cf0f30cd 100644 --- a/autolens/point/triangles/triangle_solver.py +++ b/autolens/point/triangles/triangle_solver.py @@ -208,7 +208,7 @@ def _filter_low_magnification( def _filter_triangles( self, - triangles: array.ArrayTriangles, + triangles: AbstractTriangles, source_plane_coordinate: Tuple[float, float], ): """ diff --git a/test_autolens/point/triangles/test_solver.py b/test_autolens/point/triangles/test_solver.py index 8aff0569b..d34b39689 100644 --- a/test_autolens/point/triangles/test_solver.py +++ b/test_autolens/point/triangles/test_solver.py @@ -90,4 +90,5 @@ def test_real_example(grid): pixel_scale_precision=0.001, ) result = solver.solve((0.07, 0.07)) + print(result) assert len(result) == 5 diff --git a/test_autolens/point/triangles/test_solver_jax.py b/test_autolens/point/triangles/test_solver_jax.py index eccf86f98..9039709da 100644 --- a/test_autolens/point/triangles/test_solver_jax.py +++ b/test_autolens/point/triangles/test_solver_jax.py @@ -64,3 +64,32 @@ def test_trivial( ) print(coordinates) assert coordinates[0] == pytest.approx(source_plane_coordinate, abs=1.0e-1) + + +def test_real_example(grid): + isothermal_mass_profile = al.mp.Isothermal( + centre=(0.0, 0.0), + einstein_radius=1.6, + ell_comps=al.convert.ell_comps_from(axis_ratio=0.9, angle=45.0), + ) + + lens_galaxy = al.Galaxy( + redshift=0.5, + mass=isothermal_mass_profile, + ) + + point_source = al.ps.PointSourceChi(centre=(0.07, 0.07)) + + source_galaxy = al.Galaxy(redshift=1.0, point_0=point_source) + + tracer = al.Tracer(galaxies=[lens_galaxy, source_galaxy]) + + solver = TriangleSolver.for_grid( + grid=grid, + lensing_obj=tracer, + pixel_scale_precision=0.001, + ArrayTriangles=ArrayTriangles, + ) + result = solver.solve((0.07, 0.07)) + print(result) + assert len(result) == 5 From 5b13a3d23debb91c8ff1f4768901d866fb543079 Mon Sep 17 00:00:00 2001 From: Richard Date: Mon, 22 Jul 2024 11:01:34 +0100 Subject: [PATCH 20/24] fix test --- autolens/point/analysis.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/autolens/point/analysis.py b/autolens/point/analysis.py index 1c3553ca7..002801638 100644 --- a/autolens/point/analysis.py +++ b/autolens/point/analysis.py @@ -56,7 +56,7 @@ def log_likelihood_function(self, instance): """ lens = instance.lens - solver = TriangleSolver( + solver = TriangleSolver.for_grid( lensing_obj=lens, grid=self.grid, pixel_scale_precision=self.pixel_scale_precision, From ac4f9cbda39ad6207d0d9434a89a6e5c6d76f3a6 Mon Sep 17 00:00:00 2001 From: Richard Date: Mon, 22 Jul 2024 11:03:49 +0100 Subject: [PATCH 21/24] extract fixture --- test_autolens/point/triangles/conftest.py | 20 +++++++++++++++++++ test_autolens/point/triangles/test_solver.py | 19 +----------------- .../point/triangles/test_solver_jax.py | 19 +----------------- 3 files changed, 22 insertions(+), 36 deletions(-) diff --git a/test_autolens/point/triangles/conftest.py b/test_autolens/point/triangles/conftest.py index bafeafe95..c596799ca 100644 --- a/test_autolens/point/triangles/conftest.py +++ b/test_autolens/point/triangles/conftest.py @@ -8,3 +8,23 @@ def grid(): shape_native=(10, 10), pixel_scales=1.0, ) + + +@pytest.fixture +def tracer(): + isothermal_mass_profile = al.mp.Isothermal( + centre=(0.0, 0.0), + einstein_radius=1.6, + ell_comps=al.convert.ell_comps_from(axis_ratio=0.9, angle=45.0), + ) + + lens_galaxy = al.Galaxy( + redshift=0.5, + mass=isothermal_mass_profile, + ) + + point_source = al.ps.PointSourceChi(centre=(0.07, 0.07)) + + source_galaxy = al.Galaxy(redshift=1.0, point_0=point_source) + + return al.Tracer(galaxies=[lens_galaxy, source_galaxy]) diff --git a/test_autolens/point/triangles/test_solver.py b/test_autolens/point/triangles/test_solver.py index d34b39689..d949b76a7 100644 --- a/test_autolens/point/triangles/test_solver.py +++ b/test_autolens/point/triangles/test_solver.py @@ -66,24 +66,7 @@ def test_trivial( assert coordinates == pytest.approx(source_plane_coordinate, abs=1.0e-1) -def test_real_example(grid): - isothermal_mass_profile = al.mp.Isothermal( - centre=(0.0, 0.0), - einstein_radius=1.6, - ell_comps=al.convert.ell_comps_from(axis_ratio=0.9, angle=45.0), - ) - - lens_galaxy = al.Galaxy( - redshift=0.5, - mass=isothermal_mass_profile, - ) - - point_source = al.ps.PointSourceChi(centre=(0.07, 0.07)) - - source_galaxy = al.Galaxy(redshift=1.0, point_0=point_source) - - tracer = al.Tracer(galaxies=[lens_galaxy, source_galaxy]) - +def test_real_example(grid, tracer): solver = TriangleSolver.for_grid( grid=grid, lensing_obj=tracer, diff --git a/test_autolens/point/triangles/test_solver_jax.py b/test_autolens/point/triangles/test_solver_jax.py index 9039709da..524994ce9 100644 --- a/test_autolens/point/triangles/test_solver_jax.py +++ b/test_autolens/point/triangles/test_solver_jax.py @@ -66,24 +66,7 @@ def test_trivial( assert coordinates[0] == pytest.approx(source_plane_coordinate, abs=1.0e-1) -def test_real_example(grid): - isothermal_mass_profile = al.mp.Isothermal( - centre=(0.0, 0.0), - einstein_radius=1.6, - ell_comps=al.convert.ell_comps_from(axis_ratio=0.9, angle=45.0), - ) - - lens_galaxy = al.Galaxy( - redshift=0.5, - mass=isothermal_mass_profile, - ) - - point_source = al.ps.PointSourceChi(centre=(0.07, 0.07)) - - source_galaxy = al.Galaxy(redshift=1.0, point_0=point_source) - - tracer = al.Tracer(galaxies=[lens_galaxy, source_galaxy]) - +def test_real_example(grid, tracer): solver = TriangleSolver.for_grid( grid=grid, lensing_obj=tracer, From 8b91c58767a69aed1ebeecc1db8fc3ad3bf66da9 Mon Sep 17 00:00:00 2001 From: Richard Date: Mon, 22 Jul 2024 11:17:48 +0100 Subject: [PATCH 22/24] better printing in tests --- test_autolens/point/triangles/test_solver.py | 3 ++- test_autolens/point/triangles/test_solver_jax.py | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/test_autolens/point/triangles/test_solver.py b/test_autolens/point/triangles/test_solver.py index d949b76a7..429c2631e 100644 --- a/test_autolens/point/triangles/test_solver.py +++ b/test_autolens/point/triangles/test_solver.py @@ -73,5 +73,6 @@ def test_real_example(grid, tracer): pixel_scale_precision=0.001, ) result = solver.solve((0.07, 0.07)) - print(result) + for r in result: + print(r) assert len(result) == 5 diff --git a/test_autolens/point/triangles/test_solver_jax.py b/test_autolens/point/triangles/test_solver_jax.py index 524994ce9..2f2dcd1f0 100644 --- a/test_autolens/point/triangles/test_solver_jax.py +++ b/test_autolens/point/triangles/test_solver_jax.py @@ -74,5 +74,6 @@ def test_real_example(grid, tracer): ArrayTriangles=ArrayTriangles, ) result = solver.solve((0.07, 0.07)) - print(result) + for pair in result: + print(pair) assert len(result) == 5 From 55dd74293092bc6fac53718a8b1e701b9ae7490b Mon Sep 17 00:00:00 2001 From: Richard Date: Mon, 22 Jul 2024 12:55:19 +0100 Subject: [PATCH 23/24] different order visualisation to show filtered triangles --- autolens/point/triangles/visualise.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/autolens/point/triangles/visualise.py b/autolens/point/triangles/visualise.py index 87b7fabea..3dd5ab402 100644 --- a/autolens/point/triangles/visualise.py +++ b/autolens/point/triangles/visualise.py @@ -12,9 +12,9 @@ def add_triangles(triangles, color): def visualise(step: Step): plt.figure(figsize=(8, 8)) add_triangles(step.initial_triangles, color="black") - add_triangles(step.filtered_triangles, color="blue") add_triangles(step.up_sampled, color="green") add_triangles(step.neighbourhood, color="red") + add_triangles(step.filtered_triangles, color="blue") plt.xlabel("X") plt.ylabel("Y") From 0c4af431acedb96c229d545d0e9b88096f222074 Mon Sep 17 00:00:00 2001 From: Richard Date: Mon, 22 Jul 2024 13:01:00 +0100 Subject: [PATCH 24/24] update type annotations to abstract class --- autolens/point/triangles/triangle_solver.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/autolens/point/triangles/triangle_solver.py b/autolens/point/triangles/triangle_solver.py index 8cf0f30cd..d26f429eb 100644 --- a/autolens/point/triangles/triangle_solver.py +++ b/autolens/point/triangles/triangle_solver.py @@ -32,10 +32,10 @@ class Step: """ number: int - initial_triangles: array.ArrayTriangles - filtered_triangles: array.ArrayTriangles - neighbourhood: array.ArrayTriangles - up_sampled: array.ArrayTriangles + initial_triangles: AbstractTriangles + filtered_triangles: AbstractTriangles + neighbourhood: AbstractTriangles + up_sampled: AbstractTriangles class TriangleSolver: