Skip to content

Commit e01ea7d

Browse files
Jammy2211Jammy2211
authored andcommitted
refactor complete
1 parent 2283b47 commit e01ea7d

File tree

19 files changed

+90
-110
lines changed

19 files changed

+90
-110
lines changed

autogalaxy/__init__.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,13 @@
1414
from autoarray.inversion import regularization as reg # noqa
1515
from autoarray.inversion.pixelization import image_mesh
1616
from autoarray.inversion.pixelization.mappers.abstract import AbstractMapper # noqa
17-
from autoarray.inversion.inversion.settings import SettingsInversion # noqa
17+
from autoarray.settings import Settings # noqa
1818
from autoarray.inversion.inversion.factory import inversion_from as Inversion # noqa
1919
from autoarray.inversion.pixelization.image_mesh.abstract import AbstractImageMesh
2020
from autoarray.inversion.pixelization.mesh.abstract import AbstractMesh
2121
from autoarray.inversion.regularization.abstract import AbstractRegularization
2222
from autoarray.inversion.pixelization.pixelization import Pixelization # noqa
2323
from autoarray.inversion.pixelization.mappers.abstract import AbstractMapper
24-
from autoarray.inversion.pixelization.mappers.mapper_grids import MapperGrids # noqa
25-
from autoarray.inversion.pixelization.mappers.factory import (
26-
mapper_from as Mapper,
27-
) # noqa
2824
from autoarray.inversion.pixelization.border_relocator import BorderRelocator
2925
from autoarray.preloads import Preloads
3026
from autoarray.preloads import mapper_indices_from
@@ -43,8 +39,8 @@
4339
from autoarray.structures.grids.uniform_2d import Grid2D # noqa
4440
from autoarray.structures.grids.irregular_2d import Grid2DIrregular # noqa
4541
from autoarray.operators.over_sampling.over_sampler import OverSampler # noqa
46-
from autoarray.inversion.pixelization.mesh_grid.rectangular_2d import Mesh2DRectangular # noqa
47-
from autoarray.inversion.pixelization.mesh_grid.delaunay_2d import Mesh2DDelaunay # noqa
42+
from autoarray.inversion.pixelization.mesh_grid.rectangular import Mesh2DRectangular # noqa
43+
from autoarray.inversion.pixelization.mesh_grid.delaunay import Mesh2DDelaunay # noqa
4844
from autoarray.structures.vectors.uniform import VectorYX2D # noqa
4945
from autoarray.structures.vectors.irregular import VectorYX2DIrregular # noqa
5046
from autoarray.layout.region import Region1D # noqa

autogalaxy/abstract_fit.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616

1717
class AbstractFitInversion:
18-
def __init__(self, model_obj, settings_inversion: aa.SettingsInversion, xp=np):
18+
def __init__(self, model_obj, settings: aa.Settings, xp=np):
1919
"""
2020
An abstract fit object which fits to datasets (e.g. imaging, interferometer) inherit from.
2121
@@ -28,11 +28,11 @@ def __init__(self, model_obj, settings_inversion: aa.SettingsInversion, xp=np):
2828
The object which contains the model components (e.g. light profiles, galaxies, etc) which are used to
2929
create the model-data that fits the data. In PyAutoGalaxy this is a list of galaxies and PyAutoLens
3030
it is a `Tracer`.
31-
settings_inversion
31+
settings
3232
Settings controlling how an inversion is fitted for example which linear algebra formalism is used.
3333
"""
3434
self.model_obj = model_obj
35-
self.settings_inversion = settings_inversion
35+
self.settings = settings or aa.Settings()
3636
self.use_jax = xp is not np
3737

3838
@property
@@ -75,7 +75,7 @@ def perform_inversion(self) -> bool:
7575
def sparse_operator(self) -> Optional[aa.ImagingSparseOperator]:
7676
"""
7777
Only call the `sparse_operator` property of a dataset used to perform efficient linear algebra calculations if
78-
the SettingsInversion()` object has `use_sparse_operator=True`, to avoid unnecessary computation.
78+
the Settings()` object has `use_sparse_operator=True`, to avoid unnecessary computation.
7979
8080
Returns
8181
-------

autogalaxy/aggregator/ellipse/fit_ellipse.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ def _fit_ellipse_from(
3333
is instead used to load lists of the data, noise-map, PSF and mask and combine them into a list of
3434
`FitEllipse` objects.
3535
36-
The settings of an inversion can be overwritten by inputting a `settings_inversion` object, for example
36+
The settings of an inversion can be overwritten by inputting a `settings` object, for example
3737
if you want to use a grid with a different inversion solver.
3838
3939
Parameters

autogalaxy/aggregator/imaging/fit_imaging.py

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
def _fit_imaging_from(
1717
fit: af.Fit,
1818
instance: Optional[af.ModelInstance] = None,
19-
settings_inversion: aa.SettingsInversion = None,
19+
settings: aa.Settings = None,
2020
) -> List[FitImaging]:
2121
"""
2222
Returns a list of `FitImaging` objects from a `PyAutoFit` loaded directory `Fit` or sqlite database `Fit` object.
@@ -26,7 +26,7 @@ def _fit_imaging_from(
2626
2727
- The imaging data, noise-map, PSF and settings as .fits files (e.g. `dataset/data.fits`).
2828
- The mask used to mask the `Imaging` data structure in the fit (`dataset.fits[hdu=0]`).
29-
- The settings of inversions used by the fit (`dataset/settings_inversion.json`).
29+
- The settings of inversions used by the fit (`dataset/settings.json`).
3030
3131
Each individual attribute can be loaded from the database via the `fit.value()` method.
3232
@@ -37,7 +37,7 @@ def _fit_imaging_from(
3737
is instead used to load lists of the data, noise-map, PSF and mask and combine them into a list of
3838
`FitImaging` objects.
3939
40-
The settings of an inversion can be overwritten by inputting a `settings_inversion` object, for example
40+
The settings of an inversion can be overwritten by inputting a `settings` object, for example
4141
if you want to use a grid with a different inversion solver.
4242
4343
Parameters
@@ -48,8 +48,8 @@ def _fit_imaging_from(
4848
instance
4949
A manual instance that overwrites the max log likelihood instance in fit (e.g. for drawing the instance
5050
randomly from the PDF).
51-
settings_inversion
52-
Optionally overwrite the `SettingsInversion` of the `Inversion` object that is created from the fit.
51+
settings
52+
Optionally overwrite the `Settings` of the `Inversion` object that is created from the fit.
5353
"""
5454

5555
from autogalaxy.imaging.fit_imaging import FitImaging
@@ -62,7 +62,7 @@ def _fit_imaging_from(
6262

6363
adapt_images_list = agg_util.adapt_images_from(fit=fit)
6464

65-
settings_inversion = settings_inversion or fit.value(name="settings_inversion")
65+
settings = settings or fit.value(name="settings")
6666

6767
fit_dataset_list = []
6868

@@ -79,7 +79,7 @@ def _fit_imaging_from(
7979
galaxies=galaxies,
8080
dataset_model=dataset_model,
8181
adapt_images=adapt_images,
82-
settings_inversion=settings_inversion,
82+
settings=settings,
8383
)
8484
)
8585

@@ -90,7 +90,7 @@ class FitImagingAgg(af.AggBase):
9090
def __init__(
9191
self,
9292
aggregator: af.Aggregator,
93-
settings_inversion: Optional[aa.SettingsInversion] = None,
93+
settings: Optional[aa.Settings] = None,
9494
):
9595
"""
9696
Interfaces with an `PyAutoFit` aggregator object to create instances of `FitImaging` objects from the results
@@ -101,7 +101,7 @@ def __init__(
101101
102102
- The imaging data, noise-map, PSF and settings as .fits files (e.g. `dataset/data.fits`).
103103
- The mask used to mask the `Imaging` data structure in the fit (`dataset.fits[hdu=0]`).
104-
- The settings of inversions used by the fit (`dataset/settings_inversion.json`).
104+
- The settings of inversions used by the fit (`dataset/settings.json`).
105105
106106
The `aggregator` contains the path to each of these files, and they can be loaded individually. This class
107107
can load them all at once and create an `FitImaging` object via the `_fit_imaging_from` method.
@@ -123,19 +123,19 @@ def __init__(
123123
----------
124124
aggregator
125125
A `PyAutoFit` aggregator object which can load the results of model-fits.
126-
settings_inversion
127-
Optionally overwrite the `SettingsInversion` of the `Inversion` object that is created from the fit.
126+
settings
127+
Optionally overwrite the `Settings` of the `Inversion` object that is created from the fit.
128128
129129
Parameters
130130
----------
131131
aggregator
132132
A `PyAutoFit` aggregator object which can load the results of model-fits.
133-
settings_inversion
134-
Optionally overwrite the `SettingsInversion` of the `Inversion` object that is created from the fit.
133+
settings
134+
Optionally overwrite the `Settings` of the `Inversion` object that is created from the fit.
135135
"""
136136
super().__init__(aggregator=aggregator)
137137

138-
self.settings_inversion = settings_inversion
138+
self.settings = settings
139139

140140
def object_via_gen_from(
141141
self, fit, instance: Optional[af.ModelInstance] = None
@@ -157,5 +157,5 @@ def object_via_gen_from(
157157
return _fit_imaging_from(
158158
fit=fit,
159159
instance=instance,
160-
settings_inversion=self.settings_inversion,
160+
settings=self.settings,
161161
)

autogalaxy/aggregator/interferometer/fit_interferometer.py

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
def _fit_interferometer_from(
1717
fit: af.Fit,
1818
instance: Optional[af.ModelInstance] = None,
19-
settings_inversion: aa.SettingsInversion = None,
19+
settings: aa.Settings = None,
2020
) -> List[FitInterferometer]:
2121
"""
2222
Returns a list of `FitInterferometer` objects from a `PyAutoFit` loaded directory `Fit` or sqlite database `Fit` object.
@@ -26,7 +26,7 @@ def _fit_interferometer_from(
2626
2727
- The interferometer data, noise-map, uv-wavelengths and settings as .fits files (e.g. `dataset/data.fits`).
2828
- The real space mask defining the grid of the interferometer for the FFT (`dataset/real_space_mask.fits`).
29-
- The settings of inversions used by the fit (`dataset/settings_inversion.json`).
29+
- The settings of inversions used by the fit (`dataset/settings.json`).
3030
3131
Each individual attribute can be loaded from the database via the `fit.value()` method.
3232
@@ -38,7 +38,7 @@ def _fit_interferometer_from(
3838
method is instead used to load lists of the data, noise-map, PSF and mask and combine them into a list of
3939
`FitInterferometer` objects.
4040
41-
The settings of an inversion can be overwritten by inputting a `settings_inversion` object, for
41+
The settings of an inversion can be overwritten by inputting a `settings` object, for
4242
example if you want to use a grid with a different inversion solver.
4343
4444
Parameters
@@ -49,8 +49,8 @@ def _fit_interferometer_from(
4949
instance
5050
A manual instance that overwrites the max log likelihood instance in fit (e.g. for drawing the instance
5151
randomly from the PDF).
52-
settings_inversion
53-
Optionally overwrite the `SettingsInversion` of the `Inversion` object that is created from the fit.
52+
settings
53+
Optionally overwrite the `Settings` of the `Inversion` object that is created from the fit.
5454
"""
5555
from autogalaxy.interferometer.fit_interferometer import FitInterferometer
5656

@@ -64,7 +64,7 @@ def _fit_interferometer_from(
6464

6565
adapt_images_list = agg_util.adapt_images_from(fit=fit)
6666

67-
settings_inversion = settings_inversion or fit.value(name="settings_inversion")
67+
settings = settings or fit.value(name="settings")
6868

6969
fit_dataset_list = []
7070

@@ -81,7 +81,7 @@ def _fit_interferometer_from(
8181
galaxies=galaxies,
8282
dataset_model=dataset_model,
8383
adapt_images=adapt_images,
84-
settings_inversion=settings_inversion,
84+
settings=settings,
8585
)
8686
)
8787

@@ -92,7 +92,7 @@ class FitInterferometerAgg(af.AggBase):
9292
def __init__(
9393
self,
9494
aggregator: af.Aggregator,
95-
settings_inversion: Optional[aa.SettingsInversion] = None,
95+
settings: Optional[aa.Settings] = None,
9696
):
9797
"""
9898
Interfaces with an `PyAutoFit` aggregator object to create instances of `FitInterferometer` objects from the
@@ -103,7 +103,7 @@ def __init__(
103103
104104
- The interferometer data, noise-map, uv-wavelengths and settings as .fits files (e.g. `dataset/data.fits`).
105105
- The real space mask defining the grid of the interferometer for the FFT (`dataset/real_space_mask.fits`).
106-
- The settings of inversions used by the fit (`dataset/settings_inversion.json`).
106+
- The settings of inversions used by the fit (`dataset/settings.json`).
107107
108108
The `aggregator` contains the path to each of these files, and they can be loaded individually. This class
109109
can load them all at once and create an `FitInterferometer` object via the `_fit_interferometer_from` method.
@@ -125,19 +125,19 @@ def __init__(
125125
----------
126126
aggregator
127127
A `PyAutoFit` aggregator object which can load the results of model-fits.
128-
settings_inversion
129-
Optionally overwrite the `SettingsInversion` of the `Inversion` object that is created from the fit.
128+
settings
129+
Optionally overwrite the `Settings` of the `Inversion` object that is created from the fit.
130130
131131
Parameters
132132
----------
133133
aggregator
134134
A `PyAutoFit` aggregator object which can load the results of model-fits.
135-
settings_inversion
136-
Optionally overwrite the `SettingsInversion` of the `Inversion` object that is created from the fit.
135+
settings
136+
Optionally overwrite the `Settings` of the `Inversion` object that is created from the fit.
137137
"""
138138
super().__init__(aggregator=aggregator)
139139

140-
self.settings_inversion = settings_inversion
140+
self.settings = settings
141141

142142
def object_via_gen_from(
143143
self, fit, instance: Optional[af.ModelInstance] = None
@@ -159,5 +159,5 @@ def object_via_gen_from(
159159
return _fit_interferometer_from(
160160
fit=fit,
161161
instance=instance,
162-
settings_inversion=self.settings_inversion,
162+
settings=self.settings,
163163
)

autogalaxy/analysis/analysis/dataset.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def __init__(
2323
dataset: Union[aa.Imaging, aa.Interferometer],
2424
adapt_images: Optional[AdaptImages] = None,
2525
cosmology: LensingCosmology = None,
26-
settings_inversion: aa.SettingsInversion = None,
26+
settings: aa.Settings = None,
2727
preloads: aa.Preloads = None,
2828
title_prefix: str = None,
2929
use_jax: bool = True,
@@ -45,7 +45,7 @@ def __init__(
4545
used by certain classes for adapting the analysis to the properties of the dataset.
4646
cosmology
4747
The Cosmology assumed for this analysis.
48-
settings_inversion
48+
settings
4949
Settings controlling how an inversion is fitted during the model-fit, for example which linear algebra
5050
formalism is used.
5151
title_prefix
@@ -62,7 +62,7 @@ def __init__(
6262
self.dataset = dataset
6363
self.adapt_images = adapt_images
6464

65-
self.settings_inversion = settings_inversion or aa.SettingsInversion()
65+
self.settings = settings or aa.Settings()
6666

6767
self.title_prefix = title_prefix
6868

@@ -138,8 +138,8 @@ def save_attributes(self, paths: af.DirectoryPaths):
138138
visualization, and the pickled objects used by the aggregator output by this function.
139139
"""
140140
paths.save_json(
141-
name="settings_inversion",
142-
object_dict=to_dict(self.settings_inversion),
141+
name="settings",
142+
object_dict=to_dict(self.settings),
143143
)
144144
paths.save_json(
145145
name="cosmology",

autogalaxy/analysis/plotter_interface.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -227,8 +227,8 @@ def should_plot(name):
227227
mapper_list = inversion.cls_list_from(cls=aa.AbstractMapper)
228228

229229
for i, mapper in enumerate(mapper_list):
230-
y = mapper.mapper_grids.source_plane_mesh_grid[:, 0]
231-
x = mapper.mapper_grids.source_plane_mesh_grid[:, 1]
230+
y = mapper.source_plane_mesh_grid[:, 0]
231+
x = mapper.source_plane_mesh_grid[:, 1]
232232
reconstruction = inversion.reconstruction_dict[mapper]
233233
noise_map = inversion.reconstruction_noise_map_dict[mapper]
234234

0 commit comments

Comments
 (0)