Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
67 commits
Select commit Hold shift + click to select a range
29065b6
delaunay in triangulation_2d
Dec 2, 2025
6275efa
find simplices jax function works
Dec 3, 2025
30c6cbe
pix_indexes_for_sub_slim_index_delaunay_from now does not use numba
Dec 3, 2025
be48f5f
fix xp stuff
Dec 3, 2025
8041d63
fix vertex_neighbor_vertices in interface
Dec 3, 2025
a47ca03
more delaunay functions now run in jax
Dec 3, 2025
74268fd
explcit unit tests for split to aid JAX dev
Dec 3, 2025
f427fff
test__reg_split_from converted to JAX, thank you CHATGPT!
Dec 3, 2025
5e8acfe
reg split from now support numpy
Dec 3, 2025
7b031ea
all regularization code converted
Dec 3, 2025
5c38d02
working JAX LH Function
Dec 3, 2025
ee0ccf3
fix ploting bug
Dec 3, 2025
e1ee5d3
black
Dec 3, 2025
bb5bc27
fix numpy interface to vertex areas
Dec 3, 2025
8d6089e
test__voronoi_areas_via_delaunay_from
Dec 3, 2025
e39d991
restore old split_cross
Dec 3, 2025
d155be6
areas improved
Dec 3, 2025
5d9a629
reduce max cells to 32
Dec 3, 2025
5fc944d
vectorized jax?
Dec 3, 2025
1d88968
revert to simpler
Dec 3, 2025
75c0bc7
area hack
Dec 3, 2025
84cd539
area hack undo
Dec 3, 2025
7ef7104
black
Dec 4, 2025
9a255a5
Voronoi in primiitive
Dec 4, 2025
0d6e2a2
another fix
Dec 4, 2025
799be12
fix horror bug
Dec 5, 2025
d0a90b4
fix visualization bug
Dec 5, 2025
b20d6b1
remove all Voronoi support
Dec 5, 2025
3448545
plotting bug?
Dec 8, 2025
006bbee
fit subplot log10 plot
Dec 8, 2025
6ec06c0
Merge branch 'feature/delaunay_primitive' of https://github.com/Jammy…
Dec 8, 2025
532d855
fix test__voronoi_areas_via_delaunay_from
Dec 9, 2025
795989a
test__voronoi_pixel_areas_for_split
Dec 9, 2025
aa4fb96
fix mesh delaunay
Dec 9, 2025
8041c48
fix mapper util test weights
Dec 9, 2025
76856ce
fix areas for magnification
Dec 9, 2025
c635031
more experitmental changes
Dec 10, 2025
5d07361
more hacks
Dec 10, 2025
92b6bb9
seems to work fast without crazy memory use, time to integration test
Dec 10, 2025
2121b1e
fix log 10 plot
Dec 10, 2025
131ebd9
profiling runs are clear
Dec 11, 2025
12be2c1
pure callback now starting to look readable
Dec 11, 2025
ec5ed6f
remove edge_pixel_list throughotu soruce code
Dec 11, 2025
bc5b857
cleaning up to retain Voronoi functionality
Dec 11, 2025
2a44512
clean up looks good
Dec 11, 2025
1bb2ffd
merge with barycentric areas
Dec 11, 2025
4547f14
edge area diff code
Dec 11, 2025
123c13f
revert to original voro
Dec 11, 2025
3ce518b
bary areas
Dec 11, 2025
051b8ed
voro areas include zeros
Dec 11, 2025
5247b7b
add mapper_pixels_zeroed_indices
Dec 11, 2025
ba91658
boolean for voro vs bary areas
Dec 11, 2025
048751c
black
Dec 11, 2025
567edb2
fix position bug
Dec 12, 2025
98b0112
test__scipy_delaunay__simplices
Dec 12, 2025
b2dd80d
test__scipy_delaunay__split
Dec 12, 2025
915eb02
test on barycentric dual area use
Dec 12, 2025
9449191
neighbors unit test up for old code
Dec 12, 2025
f1431e5
delaunay neighbors now implemented in JAX
Dec 12, 2025
2e02b55
fix neighbors
Dec 12, 2025
f12f863
unit test does not care for order
Dec 12, 2025
2efec76
fix aa.Mesh2DDelaunay(values=mesh_grid) not having over sample
Dec 12, 2025
e601aaf
remove dge pixel list
Dec 12, 2025
408c8dd
fix test__pix_indexes_for_sub_slim_index__matches_util
Dec 12, 2025
f89364f
all unit tests pass
Dec 12, 2025
f118f67
github build
Dec 12, 2025
9f9cf1e
constant split xp fix
Dec 12, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,6 @@ jobs:
pip install ./PyAutoArray
pip install ./PyAutoArray[optional]

cd PyAutoArray/autoarray/util/nn/src/nn
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/runner/work/PyAutoArray/PyAutoArray/PyAutoArray/autoarray/util/nn/src/nn
bash ./configure
cp makefile_autolens makefile
make
cd /home/runner/work/PyAutoArray/PyAutoArray

- name: Extract branch name
shell: bash
run: |
Expand Down Expand Up @@ -75,7 +68,6 @@ jobs:
export ROOT_DIR=`pwd`
export PYTHONPATH=$PYTHONPATH:$ROOT_DIR/PyAutoConf
export PYTHONPATH=$PYTHONPATH:$ROOT_DIR/PyAutoArray
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/runner/work/PyAutoArray/PyAutoArray/PyAutoArray/autoarray/util/nn/src/nn
pushd PyAutoArray
python3 -m pytest --cov autoarray --cov-report xml:coverage.xml
- name: Slack send
Expand Down
3 changes: 0 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,3 @@ test_autoarray/unit/structures/files/array.fits
test_autoarray/unit/structures/files/frame.fits
test_autoarray/unit/structures/files/kernel.fits
test_autoarray/unit/structures/grids/files/grid/grid.fits

# Ignoring all files in autoarray/util/nn/src/.
autoarray/util/nn/src/*
2 changes: 0 additions & 2 deletions autoarray/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
from .inversion.pixelization.mappers.factory import mapper_from as Mapper
from .inversion.pixelization.mappers.rectangular import MapperRectangular
from .inversion.pixelization.mappers.delaunay import MapperDelaunay
from .inversion.pixelization.mappers.voronoi import MapperVoronoi
from .inversion.pixelization.mappers.rectangular_uniform import MapperRectangularUniform
from .inversion.pixelization.image_mesh.abstract import AbstractImageMesh
from .inversion.pixelization.mesh.abstract import AbstractMesh
Expand Down Expand Up @@ -77,7 +76,6 @@
from .structures.grids.irregular_2d import Grid2DIrregular
from .structures.mesh.rectangular_2d import Mesh2DRectangular
from .structures.mesh.rectangular_2d_uniform import Mesh2DRectangularUniform
from .structures.mesh.voronoi_2d import Mesh2DVoronoi
from .structures.mesh.delaunay_2d import Mesh2DDelaunay
from .structures.arrays.kernel_2d import Kernel2D
from .structures.vectors.uniform import VectorYX2D
Expand Down
9 changes: 0 additions & 9 deletions autoarray/abstract_ndarray.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,15 +73,6 @@ def __init__(self, array, xp=np):
while isinstance(array, AbstractNDArray):
array = array.array
self._array = array
# try:
# register_pytree_node(
# type(self),
# self.instance_flatten,
# self.instance_unflatten,
# )
# except ValueError:
# pass

self._xp = xp

def invert(self):
Expand Down
2 changes: 0 additions & 2 deletions autoarray/config/general.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,5 @@ numba:
cache: true
nopython: true
parallel: false
pixelization:
voronoi_nn_max_interpolation_neighbors: 300
structures:
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.
9 changes: 0 additions & 9 deletions autoarray/config/visualize/mat_wrap_2d.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -155,15 +155,6 @@ DelaunayDrawer: # wrapper for `plt.fill()`: customize the appearance of De
alpha: 0.7
edgecolor: k
linewidth: 0.0
VoronoiDrawer: # wrapper for `plt.fill()`: customize the appearance of Voronoi mesh's.
figure:
alpha: 0.7
edgecolor: k
linewidth: 0.3
subplot:
alpha: 0.7
edgecolor: k
linewidth: 0.3
ParallelOverscanPlot:
figure:
c: k
Expand Down
45 changes: 2 additions & 43 deletions autoarray/fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -378,28 +378,9 @@ def make_delaunay_mesh_grid_9():
pixel_scales=1.0,
)

return aa.Mesh2DDelaunay(values=grid_9)


def make_voronoi_mesh_grid_9():
grid_9 = aa.Grid2D.no_mask(
values=[
[0.6, -0.3],
[0.5, -0.8],
[0.2, 0.1],
[0.0, 0.5],
[-0.3, -0.8],
[-0.6, -0.5],
[-0.4, -1.1],
[-1.2, 0.8],
[-1.5, 0.9],
],
shape_native=(3, 3),
pixel_scales=1.0,
)

return aa.Mesh2DVoronoi(
return aa.Mesh2DDelaunay(
values=grid_9,
source_plane_data_grid_over_sampled=make_grid_2d_sub_2_7x7().over_sampled,
)


Expand Down Expand Up @@ -445,22 +426,6 @@ def make_delaunay_mapper_9_3x3():
)


def make_voronoi_mapper_9_3x3():
mapper_grids = aa.MapperGrids(
mask=make_mask_2d_7x7(),
source_plane_data_grid=make_grid_2d_sub_2_7x7(),
source_plane_mesh_grid=make_voronoi_mesh_grid_9(),
image_plane_mesh_grid=aa.Grid2D.uniform(shape_native=(3, 3), pixel_scales=0.1),
adapt_data=aa.Array2D.ones(shape_native=(3, 3), pixel_scales=0.1),
)

return aa.MapperVoronoi(
mapper_grids=mapper_grids,
border_relocator=make_border_relocator_2d_7x7(),
regularization=make_regularization_constant(),
)


def make_rectangular_inversion_7x7_3x3():
return aa.Inversion(
dataset=make_masked_imaging_7x7(),
Expand All @@ -475,12 +440,6 @@ def make_delaunay_inversion_9_3x3():
)


def make_voronoi_inversion_9_3x3():
return aa.Inversion(
dataset=make_masked_imaging_7x7(), linear_obj_list=[make_voronoi_mapper_9_3x3()]
)


### EUCLID DATA ####


Expand Down
27 changes: 0 additions & 27 deletions autoarray/inversion/inversion/abstract.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,33 +200,6 @@ def all_linear_obj_have_regularization(self) -> bool:
list(filter(None, self.regularization_list))
)

@property
def mapper_edge_pixel_list(self) -> List[int]:
"""
Returns the edge pixels of all mappers in the inversion.

This uses the `edge_pixel_list` property of the `Mesh` of the `Mapper` class, and updates their values to
correspond to the indexing of the overall inversion's `curvature_matrix`.

This is used to regulareze the edge pixels of the inversion's `reconstruction` or remove them from the
inversion procedure entirely (e.g. make these values of these edge pixels zero).

Returns
-------
A list of the edge pixels of all mappers in the inversion, where the values are updated to correspond to the
indexing of the overall inversion's `curvature_matrix`.
"""
mapper_edge_pixel_list = []

param_range_list = self.param_range_list_from(cls=LinearObj)

for param_range, linear_obj in zip(param_range_list, self.linear_obj_list):
if isinstance(linear_obj, AbstractMapper):
for edge_pixel in linear_obj.edge_pixel_list:
mapper_edge_pixel_list.append(edge_pixel + param_range[0])

return mapper_edge_pixel_list

@property
def total_regularizations(self) -> int:
return sum(
Expand Down
16 changes: 8 additions & 8 deletions autoarray/inversion/inversion/mapper_valued.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def __init__(self, mapper, values, mesh_pixel_mask: Optional[np.ndarray] = None)
mapper pixel) in order to perform calculations which use both the `Mapper` and these values.

For example, a common use case is to interpolate the reconstruction of values on a mapper from the
mesh of the mapper (e.g. a Voronoi mesh) to a uniform Cartesian grid of values, because the irregular mesh
mesh of the mapper (e.g. a Delaunay mesh) to a uniform Cartesian grid of values, because the irregular mesh
is difficult to plot and analyze.

This class also provides functionality to compute the magnification of the reconstruction, by comparing the
Expand All @@ -26,7 +26,7 @@ def __init__(self, mapper, values, mesh_pixel_mask: Optional[np.ndarray] = None)
Parameters
----------
mapper
The `Mapper` object which pairs with the values, for example a `MapperVoronoi` object.
The `Mapper` object which pairs with the values, for example a `MapperDelaunay` object.
values
The values of each pixel of the mapper, which could be the `reconstruction` values of an `Inversion`,
but alternatively could be other quantities such as the noise-map of these values.
Expand Down Expand Up @@ -71,7 +71,7 @@ def interpolated_array_from(
extent: Optional[Tuple[float, float, float, float]] = None,
) -> Array2D:
"""
The values of a mapper can be on an irregular pixelization (e.g. a Delaunay triangulation, Voronoi mesh).
The values of a mapper can be on an irregular pixelization (e.g. a Delaunay triangulation).

Analysing the reconstruction can therefore be difficult and require specific functionality tailored to using
this irregular grid.
Expand Down Expand Up @@ -166,7 +166,7 @@ def max_pixel_centre(self) -> Grid2DIrregular:
max_pixel = np.argmax(self.values_masked)

max_pixel_centre = Grid2DIrregular(
values=[self.mapper.source_plane_mesh_grid[max_pixel]]
values=[self.mapper.source_plane_mesh_grid.array[max_pixel]]
)

return max_pixel_centre
Expand Down Expand Up @@ -218,7 +218,8 @@ def magnification_via_mesh_from(
PSF, as the source plane reconstruction is a non-convolved image.

In the source-plane, this is computed by summing the reconstruction values multiplied by the area of each
mesh pixel, for example if the source-plane is a `Voronoi` mesh this is the area of each Voronoi pixel.
mesh pixel, for example if the source-plane is a `Delaunay` mesh this is the area of each corresponding
Delaunay pixel.

This calculatiion is generally more robust that using an interpolated
image (see `magnification_via_interpolation_from`), because it uses the exact the source-plane reconstruction
Expand All @@ -244,7 +245,7 @@ def magnification_via_mesh_from(

To compute the magnification of a `Delaunay` mesh, use the method `magnification_via_interpolation_from`.

This method only supports a `RectangularMagnification` or `Voronoi` mesh.
This method only supports a `RectangularMagnification`.
"""
)

Expand All @@ -257,8 +258,7 @@ def magnification_via_mesh_from(
"""
The magnification cannot be computed because the areas of the source-plane mesh pixels are all zero.

This probably means you have specified an invalid source-plane mesh, for example a `Voronoi` mesh
where all pixels are on the edge of the source-plane and therefore have an infinite border.
This probably means you have specified an invalid source-plane mesh.
"""
)

Expand Down
5 changes: 2 additions & 3 deletions autoarray/inversion/linear_obj/neighbors.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
class Neighbors(np.ndarray):
def __new__(cls, arr: np.ndarray, sizes: np.ndarray):
"""
Class packaging ndarrays describing the neighbors of every pixel in a mesh (e.g. `RectangularMagnification`,
`Voronoi`).
Class packaging ndarrays describing the neighbors of every pixel in a mesh (e.g. `RectangularMagnification`).

The array `arr` contains the pixel indexes of the neighbors of every pixel. Its has shape [total_pixels,
max_neighbors_in_single_pixel].
Expand All @@ -28,7 +27,7 @@ def __new__(cls, arr: np.ndarray, sizes: np.ndarray):

- For pixel 4, the central pixel, neighbors[4,:] = [1, 3, 5, 7] and neighbors_sizes[4] = 4.

The same arrays can be generalized for other pixelizations, for example a `Voronoi` grid.
The same arrays can be generalized for other pixelizations, for example a `Delaunay` grid.

Parameters
----------
Expand Down
14 changes: 4 additions & 10 deletions autoarray/inversion/mock/mock_mapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,9 @@ def __init__(
over_sampler=None,
border_relocator=None,
adapt_data=None,
edge_pixel_list=None,
regularization=None,
pix_sub_weights=None,
pix_sub_weights_split_cross=None,
pix_sub_weights_split_points=None,
mapping_matrix=None,
pixel_signals=None,
parameters=None,
Expand All @@ -37,9 +36,8 @@ def __init__(
)

self._over_sampler = over_sampler
self._edge_pixel_list = edge_pixel_list
self._pix_sub_weights = pix_sub_weights
self._pix_sub_weights_split_cross = pix_sub_weights_split_cross
self._pix_sub_weights_split_points = pix_sub_weights_split_points
self._mapping_matrix = mapping_matrix
self._parameters = parameters
self._pixel_signals = pixel_signals
Expand All @@ -62,17 +60,13 @@ def over_sampler(self):
return super().over_sampler
return self._over_sampler

@property
def edge_pixel_list(self):
return self._edge_pixel_list

@property
def pix_sub_weights(self):
return self._pix_sub_weights

@property
def pix_sub_weights_split_cross(self):
return self._pix_sub_weights_split_cross
def pix_sub_weights_split_points(self):
return self._pix_sub_weights_split_points

@property
def mapping_matrix(self):
Expand Down
2 changes: 1 addition & 1 deletion autoarray/inversion/pixelization/border_relocator.py
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ def relocated_mesh_grid_from(

relocated_grid = relocated_grid_from(
grid=mesh_grid.array,
border_grid=grid[self.border_slim],
border_grid=grid[self.sub_border_slim],
xp=xp,
)

Expand Down
1 change: 0 additions & 1 deletion autoarray/inversion/pixelization/image_mesh/overlay.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,6 @@ def image_plane_mesh_grid_from(
adapt_data
Not used by this image mesh.
"""

pixel_scales = mask.pixel_scales

grid = mask.derive_grid.unmasked
Expand Down
10 changes: 4 additions & 6 deletions autoarray/inversion/pixelization/mappers/abstract.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ def __init__(
mapper_grids: MapperGrids,
regularization: Optional[AbstractRegularization],
border_relocator: BorderRelocator,
preloads=None,
xp=np,
):
"""
Expand Down Expand Up @@ -88,6 +89,7 @@ def __init__(

self.border_relocator = border_relocator
self.mapper_grids = mapper_grids
self.preloads = preloads

@property
def params(self) -> int:
Expand All @@ -113,10 +115,6 @@ def image_plane_mesh_grid(self) -> Grid2D:
def over_sampler(self):
return self.mapper_grids.source_plane_data_grid.over_sampler

@property
def edge_pixel_list(self) -> List[int]:
return self.source_plane_mesh_grid.edge_pixel_list

@property
def adapt_data(self) -> np.ndarray:
return self.mapper_grids.adapt_data
Expand Down Expand Up @@ -420,7 +418,7 @@ def interpolated_array_from(
) -> Array2D:
"""
The reconstructed values of a mapper (e.g. the `reconstruction` of an `Inversion` may be on an irregular
pixelization (e.g. a Delaunay triangulation, Voronoi mesh).
pixelization (e.g. a Delaunay triangulation).

Analysing the reconstruction can therefore be difficult and require specific functionality tailored to using
this irregular grid.
Expand All @@ -437,7 +435,7 @@ def interpolated_array_from(
----------
values
The value corresponding to the reconstructed value of every pixelization pixel (e.g. Delaunay triangle
vertexes, Voronoi mesh cells).
vertexes).
shape_native
The 2D shape in pixels of the interpolated reconstruction, which is always returned using square pixels.
extent
Expand Down
Loading
Loading