Skip to content

Commit b3f8832

Browse files
authored
Merge pull request #199 from Jammy2211/feature/delaunay_primitive
Feature/delaunay primitive
2 parents 6fbb976 + 9f9cf1e commit b3f8832

File tree

165 files changed

+1378
-104274
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

165 files changed

+1378
-104274
lines changed

.github/workflows/main.yml

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,6 @@ jobs:
4040
pip install ./PyAutoArray
4141
pip install ./PyAutoArray[optional]
4242
43-
cd PyAutoArray/autoarray/util/nn/src/nn
44-
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/runner/work/PyAutoArray/PyAutoArray/PyAutoArray/autoarray/util/nn/src/nn
45-
bash ./configure
46-
cp makefile_autolens makefile
47-
make
48-
cd /home/runner/work/PyAutoArray/PyAutoArray
49-
5043
- name: Extract branch name
5144
shell: bash
5245
run: |
@@ -75,7 +68,6 @@ jobs:
7568
export ROOT_DIR=`pwd`
7669
export PYTHONPATH=$PYTHONPATH:$ROOT_DIR/PyAutoConf
7770
export PYTHONPATH=$PYTHONPATH:$ROOT_DIR/PyAutoArray
78-
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/runner/work/PyAutoArray/PyAutoArray/PyAutoArray/autoarray/util/nn/src/nn
7971
pushd PyAutoArray
8072
python3 -m pytest --cov autoarray --cov-report xml:coverage.xml
8173
- name: Slack send

.gitignore

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,3 @@ test_autoarray/unit/structures/files/array.fits
3333
test_autoarray/unit/structures/files/frame.fits
3434
test_autoarray/unit/structures/files/kernel.fits
3535
test_autoarray/unit/structures/grids/files/grid/grid.fits
36-
37-
# Ignoring all files in autoarray/util/nn/src/.
38-
autoarray/util/nn/src/*

autoarray/__init__.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@
4242
from .inversion.pixelization.mappers.factory import mapper_from as Mapper
4343
from .inversion.pixelization.mappers.rectangular import MapperRectangular
4444
from .inversion.pixelization.mappers.delaunay import MapperDelaunay
45-
from .inversion.pixelization.mappers.voronoi import MapperVoronoi
4645
from .inversion.pixelization.mappers.rectangular_uniform import MapperRectangularUniform
4746
from .inversion.pixelization.image_mesh.abstract import AbstractImageMesh
4847
from .inversion.pixelization.mesh.abstract import AbstractMesh
@@ -77,7 +76,6 @@
7776
from .structures.grids.irregular_2d import Grid2DIrregular
7877
from .structures.mesh.rectangular_2d import Mesh2DRectangular
7978
from .structures.mesh.rectangular_2d_uniform import Mesh2DRectangularUniform
80-
from .structures.mesh.voronoi_2d import Mesh2DVoronoi
8179
from .structures.mesh.delaunay_2d import Mesh2DDelaunay
8280
from .structures.arrays.kernel_2d import Kernel2D
8381
from .structures.vectors.uniform import VectorYX2D

autoarray/abstract_ndarray.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -73,15 +73,6 @@ def __init__(self, array, xp=np):
7373
while isinstance(array, AbstractNDArray):
7474
array = array.array
7575
self._array = array
76-
# try:
77-
# register_pytree_node(
78-
# type(self),
79-
# self.instance_flatten,
80-
# self.instance_unflatten,
81-
# )
82-
# except ValueError:
83-
# pass
84-
8576
self._xp = xp
8677

8778
def invert(self):

autoarray/config/general.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,5 @@ numba:
1414
cache: true
1515
nopython: true
1616
parallel: false
17-
pixelization:
18-
voronoi_nn_max_interpolation_neighbors: 300
1917
structures:
2018
native_binned_only: false # If True, data structures are only stored in their native and binned format. This is used to reduce memory usage in autocti.

autoarray/config/visualize/mat_wrap_2d.yaml

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -155,15 +155,6 @@ DelaunayDrawer: # wrapper for `plt.fill()`: customize the appearance of De
155155
alpha: 0.7
156156
edgecolor: k
157157
linewidth: 0.0
158-
VoronoiDrawer: # wrapper for `plt.fill()`: customize the appearance of Voronoi mesh's.
159-
figure:
160-
alpha: 0.7
161-
edgecolor: k
162-
linewidth: 0.3
163-
subplot:
164-
alpha: 0.7
165-
edgecolor: k
166-
linewidth: 0.3
167158
ParallelOverscanPlot:
168159
figure:
169160
c: k

autoarray/fixtures.py

Lines changed: 2 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -378,28 +378,9 @@ def make_delaunay_mesh_grid_9():
378378
pixel_scales=1.0,
379379
)
380380

381-
return aa.Mesh2DDelaunay(values=grid_9)
382-
383-
384-
def make_voronoi_mesh_grid_9():
385-
grid_9 = aa.Grid2D.no_mask(
386-
values=[
387-
[0.6, -0.3],
388-
[0.5, -0.8],
389-
[0.2, 0.1],
390-
[0.0, 0.5],
391-
[-0.3, -0.8],
392-
[-0.6, -0.5],
393-
[-0.4, -1.1],
394-
[-1.2, 0.8],
395-
[-1.5, 0.9],
396-
],
397-
shape_native=(3, 3),
398-
pixel_scales=1.0,
399-
)
400-
401-
return aa.Mesh2DVoronoi(
381+
return aa.Mesh2DDelaunay(
402382
values=grid_9,
383+
source_plane_data_grid_over_sampled=make_grid_2d_sub_2_7x7().over_sampled,
403384
)
404385

405386

@@ -445,22 +426,6 @@ def make_delaunay_mapper_9_3x3():
445426
)
446427

447428

448-
def make_voronoi_mapper_9_3x3():
449-
mapper_grids = aa.MapperGrids(
450-
mask=make_mask_2d_7x7(),
451-
source_plane_data_grid=make_grid_2d_sub_2_7x7(),
452-
source_plane_mesh_grid=make_voronoi_mesh_grid_9(),
453-
image_plane_mesh_grid=aa.Grid2D.uniform(shape_native=(3, 3), pixel_scales=0.1),
454-
adapt_data=aa.Array2D.ones(shape_native=(3, 3), pixel_scales=0.1),
455-
)
456-
457-
return aa.MapperVoronoi(
458-
mapper_grids=mapper_grids,
459-
border_relocator=make_border_relocator_2d_7x7(),
460-
regularization=make_regularization_constant(),
461-
)
462-
463-
464429
def make_rectangular_inversion_7x7_3x3():
465430
return aa.Inversion(
466431
dataset=make_masked_imaging_7x7(),
@@ -475,12 +440,6 @@ def make_delaunay_inversion_9_3x3():
475440
)
476441

477442

478-
def make_voronoi_inversion_9_3x3():
479-
return aa.Inversion(
480-
dataset=make_masked_imaging_7x7(), linear_obj_list=[make_voronoi_mapper_9_3x3()]
481-
)
482-
483-
484443
### EUCLID DATA ####
485444

486445

autoarray/inversion/inversion/abstract.py

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -200,33 +200,6 @@ def all_linear_obj_have_regularization(self) -> bool:
200200
list(filter(None, self.regularization_list))
201201
)
202202

203-
@property
204-
def mapper_edge_pixel_list(self) -> List[int]:
205-
"""
206-
Returns the edge pixels of all mappers in the inversion.
207-
208-
This uses the `edge_pixel_list` property of the `Mesh` of the `Mapper` class, and updates their values to
209-
correspond to the indexing of the overall inversion's `curvature_matrix`.
210-
211-
This is used to regulareze the edge pixels of the inversion's `reconstruction` or remove them from the
212-
inversion procedure entirely (e.g. make these values of these edge pixels zero).
213-
214-
Returns
215-
-------
216-
A list of the edge pixels of all mappers in the inversion, where the values are updated to correspond to the
217-
indexing of the overall inversion's `curvature_matrix`.
218-
"""
219-
mapper_edge_pixel_list = []
220-
221-
param_range_list = self.param_range_list_from(cls=LinearObj)
222-
223-
for param_range, linear_obj in zip(param_range_list, self.linear_obj_list):
224-
if isinstance(linear_obj, AbstractMapper):
225-
for edge_pixel in linear_obj.edge_pixel_list:
226-
mapper_edge_pixel_list.append(edge_pixel + param_range[0])
227-
228-
return mapper_edge_pixel_list
229-
230203
@property
231204
def total_regularizations(self) -> int:
232205
return sum(

autoarray/inversion/inversion/mapper_valued.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ def __init__(self, mapper, values, mesh_pixel_mask: Optional[np.ndarray] = None)
1616
mapper pixel) in order to perform calculations which use both the `Mapper` and these values.
1717
1818
For example, a common use case is to interpolate the reconstruction of values on a mapper from the
19-
mesh of the mapper (e.g. a Voronoi mesh) to a uniform Cartesian grid of values, because the irregular mesh
19+
mesh of the mapper (e.g. a Delaunay mesh) to a uniform Cartesian grid of values, because the irregular mesh
2020
is difficult to plot and analyze.
2121
2222
This class also provides functionality to compute the magnification of the reconstruction, by comparing the
@@ -26,7 +26,7 @@ def __init__(self, mapper, values, mesh_pixel_mask: Optional[np.ndarray] = None)
2626
Parameters
2727
----------
2828
mapper
29-
The `Mapper` object which pairs with the values, for example a `MapperVoronoi` object.
29+
The `Mapper` object which pairs with the values, for example a `MapperDelaunay` object.
3030
values
3131
The values of each pixel of the mapper, which could be the `reconstruction` values of an `Inversion`,
3232
but alternatively could be other quantities such as the noise-map of these values.
@@ -71,7 +71,7 @@ def interpolated_array_from(
7171
extent: Optional[Tuple[float, float, float, float]] = None,
7272
) -> Array2D:
7373
"""
74-
The values of a mapper can be on an irregular pixelization (e.g. a Delaunay triangulation, Voronoi mesh).
74+
The values of a mapper can be on an irregular pixelization (e.g. a Delaunay triangulation).
7575
7676
Analysing the reconstruction can therefore be difficult and require specific functionality tailored to using
7777
this irregular grid.
@@ -166,7 +166,7 @@ def max_pixel_centre(self) -> Grid2DIrregular:
166166
max_pixel = np.argmax(self.values_masked)
167167

168168
max_pixel_centre = Grid2DIrregular(
169-
values=[self.mapper.source_plane_mesh_grid[max_pixel]]
169+
values=[self.mapper.source_plane_mesh_grid.array[max_pixel]]
170170
)
171171

172172
return max_pixel_centre
@@ -218,7 +218,8 @@ def magnification_via_mesh_from(
218218
PSF, as the source plane reconstruction is a non-convolved image.
219219
220220
In the source-plane, this is computed by summing the reconstruction values multiplied by the area of each
221-
mesh pixel, for example if the source-plane is a `Voronoi` mesh this is the area of each Voronoi pixel.
221+
mesh pixel, for example if the source-plane is a `Delaunay` mesh this is the area of each corresponding
222+
Delaunay pixel.
222223
223224
This calculatiion is generally more robust that using an interpolated
224225
image (see `magnification_via_interpolation_from`), because it uses the exact the source-plane reconstruction
@@ -244,7 +245,7 @@ def magnification_via_mesh_from(
244245
245246
To compute the magnification of a `Delaunay` mesh, use the method `magnification_via_interpolation_from`.
246247
247-
This method only supports a `RectangularMagnification` or `Voronoi` mesh.
248+
This method only supports a `RectangularMagnification`.
248249
"""
249250
)
250251

@@ -257,8 +258,7 @@ def magnification_via_mesh_from(
257258
"""
258259
The magnification cannot be computed because the areas of the source-plane mesh pixels are all zero.
259260
260-
This probably means you have specified an invalid source-plane mesh, for example a `Voronoi` mesh
261-
where all pixels are on the edge of the source-plane and therefore have an infinite border.
261+
This probably means you have specified an invalid source-plane mesh.
262262
"""
263263
)
264264

autoarray/inversion/linear_obj/neighbors.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@
44
class Neighbors(np.ndarray):
55
def __new__(cls, arr: np.ndarray, sizes: np.ndarray):
66
"""
7-
Class packaging ndarrays describing the neighbors of every pixel in a mesh (e.g. `RectangularMagnification`,
8-
`Voronoi`).
7+
Class packaging ndarrays describing the neighbors of every pixel in a mesh (e.g. `RectangularMagnification`).
98
109
The array `arr` contains the pixel indexes of the neighbors of every pixel. Its has shape [total_pixels,
1110
max_neighbors_in_single_pixel].
@@ -28,7 +27,7 @@ def __new__(cls, arr: np.ndarray, sizes: np.ndarray):
2827
2928
- For pixel 4, the central pixel, neighbors[4,:] = [1, 3, 5, 7] and neighbors_sizes[4] = 4.
3029
31-
The same arrays can be generalized for other pixelizations, for example a `Voronoi` grid.
30+
The same arrays can be generalized for other pixelizations, for example a `Delaunay` grid.
3231
3332
Parameters
3433
----------

0 commit comments

Comments
 (0)