Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
def14ce
added all functionality and KNNInterpolator class
Feb 13, 2026
6477976
added MapperKNNInterpolator
Feb 13, 2026
10c2ec4
mapper now comes from factory as required
Feb 13, 2026
f5de839
JAX integration test complete
Feb 13, 2026
b9e0920
knn without batch fully working with factory fixes
Feb 16, 2026
ca18104
split regularization update
Feb 16, 2026
fa80a50
Merge branch 'feature/psf_centering_fix' into feature/knn_mesh
Feb 17, 2026
2af5688
renaming and structuring stuff
Feb 17, 2026
8c5827f
refactor renaming unit tested
Feb 17, 2026
19df324
knn works and tested
Feb 18, 2026
a5977bd
save any changes
Feb 18, 2026
e329615
lots of refatoring to work out if its gonna work..
Feb 18, 2026
ae0221e
delaunay unitt est
Feb 18, 2026
6406167
more unit test fixes going through pixelization module
Feb 18, 2026
4a42584
all unit tests pass
Feb 18, 2026
add6bf3
reinstate .array in mesh_grid_xy
Feb 18, 2026
f72c771
remove all mapper grids and fix lots of unit tests
Feb 19, 2026
61213c1
fix mapper factory tests
Feb 19, 2026
e6228f6
fix most unit tests
Feb 19, 2026
10399e9
urgh
Feb 19, 2026
1cea025
bug
Feb 19, 2026
d2649e4
border check
Feb 19, 2026
8485f69
sign
Feb 19, 2026
f9b220c
unit test fixed
Feb 19, 2026
c916c52
all unit tests fixed
Feb 19, 2026
a03a6b4
remove mesh_tuil
Feb 19, 2026
fca22ce
refactor and simplify SettingsInversion
Feb 19, 2026
9d7963b
all unit tests pass
Feb 19, 2026
fb539ef
split into interpolator module and move more stuff for separation
Feb 20, 2026
e7b999f
many unit tests fixed
Feb 20, 2026
cab9a6c
all unit tests pass following mesh geometry spit
Feb 20, 2026
b9ca4c7
unit test added but fails
Feb 20, 2026
3fe3ce0
fix interpolator mappings
Feb 20, 2026
94697aa
half neoghbors
Feb 20, 2026
ba7d637
remove PixSubWeights
Feb 20, 2026
3d99660
remove use_voronoi_areas for delaunay
Feb 20, 2026
f60bb2f
remove use_voronoi_area
Feb 20, 2026
723111c
move areas factor
Feb 20, 2026
4cc87d4
refactor going well bout to do one final change on new branch
Feb 20, 2026
07b0447
mega refactor done
Feb 20, 2026
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
31 changes: 14 additions & 17 deletions autoarray/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,25 +23,21 @@
from .fit.fit_imaging import FitImaging
from .fit.fit_interferometer import FitInterferometer
from .geometry.geometry_2d import Geometry2D
from .inversion.pixelization.mappers.abstract import AbstractMapper
from .inversion.pixelization import mesh
from .inversion.pixelization import image_mesh
from .inversion.mesh import mesh
from .inversion.mesh import image_mesh
from .inversion import regularization as reg
from .inversion.inversion.settings import SettingsInversion
from .settings import Settings
from .inversion.inversion.abstract import AbstractInversion
from .inversion.regularization.abstract import AbstractRegularization
from .inversion.inversion.factory import inversion_from as Inversion
from .inversion.inversion.dataset_interface import DatasetInterface
from .inversion.pixelization.border_relocator import BorderRelocator
from .inversion.pixelization.pixelization import Pixelization
from .inversion.pixelization.mappers.abstract import AbstractMapper
from .inversion.pixelization.mappers.mapper_grids import MapperGrids
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.rectangular_uniform import MapperRectangularUniform
from .inversion.pixelization.image_mesh.abstract import AbstractImageMesh
from .inversion.pixelization.mesh.abstract import AbstractMesh
from .inversion.mesh.border_relocator import BorderRelocator
from .inversion.pixelization import Pixelization
from .inversion.mappers.abstract import Mapper
from .inversion.mesh.image_mesh.abstract import AbstractImageMesh
from .inversion.mesh.mesh.abstract import AbstractMesh
from .inversion.mesh.interpolator.rectangular import InterpolatorRectangular
from .inversion.mesh.interpolator.delaunay import InterpolatorDelaunay
from .inversion.inversion.imaging.mapping import InversionImagingMapping
from .inversion.inversion.imaging.sparse import InversionImagingSparse
from .inversion.inversion.imaging.inversion_imaging_util import ImagingSparseOperator
Expand Down Expand Up @@ -77,9 +73,10 @@
from .structures.grids.uniform_2d import Grid2D
from .operators.over_sampling.over_sampler import OverSampler
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.delaunay_2d import Mesh2DDelaunay
from .inversion.mesh.mesh_geometry.rectangular import MeshGeometryRectangular
from .inversion.mesh.mesh_geometry.delaunay import MeshGeometryDelaunay
from .inversion.mesh.interpolator.rectangular import InterpolatorRectangular
from .inversion.mesh.interpolator.delaunay import InterpolatorDelaunay
from .structures.arrays.kernel_2d import Kernel2D
from .structures.vectors.uniform import VectorYX2D
from .structures.vectors.irregular import VectorYX2DIrregular
Expand Down
1 change: 0 additions & 1 deletion autoarray/config/general.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ inversion:
check_reconstruction: true # If True, the inversion's reconstruction is checked to ensure the solution of a meshs's mapper is not an invalid solution where the values are all the same.
use_positive_only_solver: true # If True, inversion's use a positive-only linear algebra solver by default, which is slower but prevents unphysical negative values in the reconstructed solutuion.
no_regularization_add_to_curvature_diag_value : 1.0e-3 # The default value added to the curvature matrix's diagonal when regularization is not applied to a linear object, which prevents inversion's failing due to the matrix being singular.
positive_only_uses_p_initial: true # If True, the positive-only solver of an inversion's uses an initial guess of the reconstructed data's values as which values should be positive, speeding up the solver.
use_border_relocator: false # If True, by default a pixelization's border is used to relocate all pixels outside its border to the border.
reconstruction_vmax_factor: 0.5 # Plots of an Inversion's reconstruction use the reconstructed data's bright value multiplied by this factor.
numba:
Expand Down
2 changes: 1 addition & 1 deletion autoarray/dataset/grids.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from autoarray.structures.arrays.kernel_2d import Kernel2D
from autoarray.structures.grids.uniform_2d import Grid2D

from autoarray.inversion.pixelization.border_relocator import BorderRelocator
from autoarray.inversion.mesh.border_relocator import BorderRelocator

from autoarray import exc

Expand Down
107 changes: 68 additions & 39 deletions autoarray/fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -332,13 +332,11 @@ def make_regularization_constant_split():


def make_regularization_adaptive_brightness():
return aa.reg.AdaptiveBrightness(
inner_coefficient=0.1, outer_coefficient=10.0, signal_scale=0.5
)
return aa.reg.Adapt(inner_coefficient=0.1, outer_coefficient=10.0, signal_scale=0.5)


def make_regularization_adaptive_brightness_split():
return aa.reg.AdaptiveBrightnessSplit(
return aa.reg.AdaptSplit(
inner_coefficient=0.1, outer_coefficient=10.0, signal_scale=0.5
)

Expand All @@ -355,13 +353,44 @@ def make_regularization_matern_kernel():
return aa.reg.MaternKernel(coefficient=1.0, scale=0.5, nu=0.7)


def make_rectangular_mesh_grid_3x3():
return aa.Mesh2DRectangular.overlay_grid(
grid=make_grid_2d_sub_2_7x7().over_sampled, shape_native=(3, 3)
def make_over_sampler_2d_7x7():
return aa.OverSampler(mask=make_mask_2d_7x7(), sub_size=2)


def make_border_relocator_2d_7x7():
return aa.BorderRelocator(
mask=make_mask_2d_7x7(), sub_size=np.array([2, 2, 2, 2, 2, 2, 2, 2, 2])
)


def make_rectangular_mapper_7x7_3x3():

from autoarray.inversion.mesh.mesh.rectangular_adapt_density import (
overlay_grid_from,
)

shape_native = (3, 3)

source_plane_mesh_grid = overlay_grid_from(
shape_native=shape_native, grid=make_grid_2d_sub_2_7x7().over_sampled
)

mesh = aa.mesh.RectangularUniform(shape=shape_native)

interpolator = mesh.interpolator_from(
source_plane_data_grid=make_grid_2d_sub_2_7x7(),
source_plane_mesh_grid=aa.Grid2DIrregular(source_plane_mesh_grid),
adapt_data=aa.Array2D.ones(shape_native, pixel_scales=0.1),
)

return aa.Mapper(
interpolator=interpolator,
regularization=make_regularization_constant(),
)


def make_delaunay_mapper_9_3x3():

def make_delaunay_mesh_grid_9():
grid_9 = aa.Grid2D.no_mask(
values=[
[0.6, -0.3],
Expand All @@ -378,51 +407,51 @@ def make_delaunay_mesh_grid_9():
pixel_scales=1.0,
)

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


def make_over_sampler_2d_7x7():
return aa.OverSampler(mask=make_mask_2d_7x7(), sub_size=2)
mesh = aa.mesh.Delaunay()


def make_border_relocator_2d_7x7():
return aa.BorderRelocator(
mask=make_mask_2d_7x7(), sub_size=np.array([2, 2, 2, 2, 2, 2, 2, 2, 2])
)


def make_rectangular_mapper_7x7_3x3():
mapper_grids = aa.MapperGrids(
mask=make_mask_2d_7x7(),
interpolator = mesh.interpolator_from(
source_plane_data_grid=make_grid_2d_sub_2_7x7(),
source_plane_mesh_grid=make_rectangular_mesh_grid_3x3(),
image_plane_mesh_grid=None,
source_plane_mesh_grid=grid_9,
adapt_data=aa.Array2D.ones(shape_native=(3, 3), pixel_scales=0.1),
)

return aa.MapperRectangularUniform(
mapper_grids=mapper_grids,
border_relocator=make_border_relocator_2d_7x7(),
return aa.Mapper(
interpolator=interpolator,
regularization=make_regularization_constant(),
image_plane_mesh_grid=aa.Grid2D.uniform(shape_native=(3, 3), pixel_scales=0.1),
)


def make_delaunay_mapper_9_3x3():
mapper_grids = aa.MapperGrids(
mask=make_mask_2d_7x7(),
def make_knn_mapper_9_3x3():

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,
)

mesh = aa.mesh.KNearestNeighbor(split_neighbor_division=1)

interpolator = mesh.interpolator_from(
source_plane_data_grid=make_grid_2d_sub_2_7x7(),
source_plane_mesh_grid=make_delaunay_mesh_grid_9(),
image_plane_mesh_grid=aa.Grid2D.uniform(shape_native=(3, 3), pixel_scales=0.1),
source_plane_mesh_grid=grid_9,
adapt_data=aa.Array2D.ones(shape_native=(3, 3), pixel_scales=0.1),
)

return aa.MapperDelaunay(
mapper_grids=mapper_grids,
border_relocator=make_border_relocator_2d_7x7(),
return aa.Mapper(
interpolator=interpolator,
regularization=make_regularization_constant(),
image_plane_mesh_grid=aa.Grid2D.uniform(shape_native=(3, 3), pixel_scales=0.1),
)


Expand Down
18 changes: 9 additions & 9 deletions autoarray/inversion/inversion/abstract.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
from autoarray.dataset.interferometer.dataset import Interferometer
from autoarray.inversion.inversion.dataset_interface import DatasetInterface
from autoarray.inversion.linear_obj.linear_obj import LinearObj
from autoarray.inversion.pixelization.mappers.abstract import AbstractMapper
from autoarray.inversion.mappers.abstract import Mapper
from autoarray.inversion.regularization.abstract import AbstractRegularization
from autoarray.inversion.inversion.settings import SettingsInversion
from autoarray.settings import Settings
from autoarray.preloads import Preloads
from autoarray.structures.arrays.uniform_2d import Array2D
from autoarray.structures.grids.irregular_2d import Grid2DIrregular
Expand All @@ -26,7 +26,7 @@ def __init__(
self,
dataset: Union[Imaging, Interferometer, DatasetInterface],
linear_obj_list: List[LinearObj],
settings: SettingsInversion = SettingsInversion(),
settings: Settings = None,
preloads: Preloads = None,
xp=np,
):
Expand Down Expand Up @@ -72,7 +72,7 @@ def __init__(

self.linear_obj_list = linear_obj_list

self.settings = settings
self.settings = settings or Settings()

self.preloads = preloads or Preloads()

Expand Down Expand Up @@ -143,7 +143,7 @@ def param_range_list_from(self, cls: Type) -> List[List[int]]:
- The first `Mapper` values are in the entries `[3:103]`.
- The second `Mapper` values are in the entries `[103:303]

For this example, `param_range_list_from(cls=AbstractMapper)` therefore returns the
For this example, `param_range_list_from(cls=Mapper)` therefore returns the
list `[[3, 103], [103, 303]]`.

Parameters
Expand Down Expand Up @@ -239,7 +239,7 @@ def mapper_indices(self) -> np.ndarray:

mapper_indices = []

param_range_list = self.param_range_list_from(cls=AbstractMapper)
param_range_list = self.param_range_list_from(cls=Mapper)

for param_range in param_range_list:

Expand Down Expand Up @@ -713,7 +713,7 @@ def regularization_weights_from(self, index: int) -> np.ndarray:
def regularization_weights_mapper_dict(self) -> Dict[LinearObj, np.ndarray]:
regularization_weights_dict = {}

for index, mapper in enumerate(self.cls_list_from(cls=AbstractMapper)):
for index, mapper in enumerate(self.cls_list_from(cls=Mapper)):
regularization_weights_dict[mapper] = self.regularization_weights_from(
index=index,
)
Expand Down Expand Up @@ -773,7 +773,7 @@ def max_pixel_list_from(
-------

"""
mapper = self.cls_list_from(cls=AbstractMapper)[mapper_index]
mapper = self.cls_list_from(cls=Mapper)[mapper_index]
reconstruction = self.reconstruction_dict[mapper]

max_pixel_list = []
Expand Down Expand Up @@ -818,7 +818,7 @@ def max_pixel_centre(self, mapper_index: int = 0) -> Grid2DIrregular:
-------
The centre of the brightest pixel in the mapper values.
"""
mapper = self.cls_list_from(cls=AbstractMapper)[mapper_index]
mapper = self.cls_list_from(cls=Mapper)[mapper_index]
reconstruction = self.reconstruction_dict[mapper]

max_pixel = np.argmax(reconstruction)
Expand Down
8 changes: 4 additions & 4 deletions autoarray/inversion/inversion/factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@
from autoarray.inversion.inversion.imaging.sparse import (
InversionImagingSparse,
)
from autoarray.inversion.inversion.settings import SettingsInversion
from autoarray.settings import Settings
from autoarray.preloads import Preloads
from autoarray.structures.arrays.uniform_2d import Array2D


def inversion_from(
dataset: Union[Imaging, Interferometer, DatasetInterface],
linear_obj_list: List[LinearObj],
settings: SettingsInversion = SettingsInversion(),
settings: Settings = None,
preloads: Preloads = None,
xp=np,
):
Expand Down Expand Up @@ -80,7 +80,7 @@ def inversion_from(
def inversion_imaging_from(
dataset,
linear_obj_list: List[LinearObj],
settings: SettingsInversion = SettingsInversion(),
settings: Settings = None,
preloads: Preloads = None,
xp=np,
):
Expand Down Expand Up @@ -157,7 +157,7 @@ def inversion_imaging_from(
def inversion_interferometer_from(
dataset: Union[Interferometer, DatasetInterface],
linear_obj_list: List[LinearObj],
settings: SettingsInversion = SettingsInversion(),
settings: Settings = None,
xp=np,
):
"""
Expand Down
8 changes: 4 additions & 4 deletions autoarray/inversion/inversion/imaging/abstract.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
from autoarray.dataset.imaging.dataset import Imaging
from autoarray.inversion.inversion.dataset_interface import DatasetInterface
from autoarray.inversion.linear_obj.func_list import AbstractLinearObjFuncList
from autoarray.inversion.pixelization.mappers.abstract import AbstractMapper
from autoarray.inversion.mappers.abstract import Mapper
from autoarray.inversion.inversion.abstract import AbstractInversion
from autoarray.inversion.linear_obj.linear_obj import LinearObj
from autoarray.inversion.inversion.settings import SettingsInversion
from autoarray.settings import Settings
from autoarray.preloads import Preloads

from autoarray.inversion.inversion.imaging import inversion_imaging_util
Expand All @@ -18,7 +18,7 @@ def __init__(
self,
dataset: Union[Imaging, DatasetInterface],
linear_obj_list: List[LinearObj],
settings: SettingsInversion = SettingsInversion(),
settings: Settings = None,
preloads: Preloads = None,
xp=np,
):
Expand Down Expand Up @@ -255,7 +255,7 @@ def mapper_operated_mapping_matrix_dict(self) -> Dict:
"""
mapper_operated_mapping_matrix_dict = {}

for mapper in self.cls_list_from(cls=AbstractMapper):
for mapper in self.cls_list_from(cls=Mapper):
operated_mapping_matrix = self.psf.convolved_mapping_matrix_from(
mapping_matrix=mapper.mapping_matrix, mask=self.mask, xp=self._xp
)
Expand Down
6 changes: 3 additions & 3 deletions autoarray/inversion/inversion/imaging/mapping.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
from autoarray.inversion.inversion.dataset_interface import DatasetInterface
from autoarray.inversion.inversion.imaging.abstract import AbstractInversionImaging
from autoarray.inversion.linear_obj.linear_obj import LinearObj
from autoarray.inversion.pixelization.mappers.abstract import AbstractMapper
from autoarray.inversion.inversion.settings import SettingsInversion
from autoarray.inversion.mappers.abstract import Mapper
from autoarray.settings import Settings
from autoarray.preloads import Preloads
from autoarray.structures.arrays.uniform_2d import Array2D

Expand All @@ -21,7 +21,7 @@ def __init__(
self,
dataset: Union[Imaging, DatasetInterface],
linear_obj_list: List[LinearObj],
settings: SettingsInversion = SettingsInversion(),
settings: Settings = None,
preloads: Preloads = None,
xp=np,
):
Expand Down
Loading
Loading