Skip to content

Commit 411ded5

Browse files
Jammy2211Jammy2211
authored andcommitted
remove redunant methods from mapping
1 parent 456905c commit 411ded5

File tree

4 files changed

+3
-98
lines changed

4 files changed

+3
-98
lines changed

autoarray/inversion/inversion/imaging/abstract.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
import numpy as np
22
from typing import Dict, List, Union, Type
33

4-
from autoconf import cached_property
5-
64
from autoarray.dataset.imaging.dataset import Imaging
75
from autoarray.inversion.inversion.dataset_interface import DatasetInterface
86
from autoarray.inversion.linear_obj.func_list import AbstractLinearObjFuncList
@@ -97,6 +95,7 @@ def operated_mapping_matrix_list(self) -> List[np.ndarray]:
9795
self.psf.convolved_mapping_matrix_from(
9896
mapping_matrix=linear_obj.mapping_matrix,
9997
mask=self.mask,
98+
use_mixed_precision=self.settings.use_mixed_precision,
10099
xp=self._xp,
101100
)
102101
if linear_obj.operated_mapping_matrix_override is None
@@ -138,7 +137,6 @@ def linear_func_operated_mapping_matrix_dict(self) -> Dict:
138137
if linear_func.operated_mapping_matrix_override is not None:
139138
operated_mapping_matrix = linear_func.operated_mapping_matrix_override
140139
else:
141-
vvv
142140
operated_mapping_matrix = self.psf.convolved_mapping_matrix_from(
143141
mapping_matrix=linear_func.mapping_matrix,
144142
mask=self.mask,
@@ -203,7 +201,7 @@ def data_linear_func_matrix_dict(self):
203201

204202
return data_linear_func_matrix_dict
205203

206-
@cached_property
204+
@property
207205
def mapper_operated_mapping_matrix_dict(self) -> Dict:
208206
"""
209207
The `operated_mapping_matrix` of a `Mapper` object describes the mappings between the observed data's values

autoarray/inversion/inversion/imaging/mapping.py

Lines changed: 0 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -53,47 +53,6 @@ def __init__(
5353
xp=xp,
5454
)
5555

56-
@property
57-
def _data_vector_mapper(self) -> np.ndarray:
58-
"""
59-
Returns the `data_vector` of all mappers, a 1D vector whose values are solved for by the simultaneous
60-
linear equations constructed by this object. The object is described in full in the method `data_vector`.
61-
62-
This method is used to compute part of the `data_vector` if there are also linear function list objects
63-
in the inversion, and is separated into a separate method to enable preloading of the mapper `data_vector`.
64-
"""
65-
66-
if not self.has(cls=AbstractMapper):
67-
return
68-
69-
data_vector = np.zeros(self.total_params)
70-
71-
mapper_list = self.cls_list_from(cls=AbstractMapper)
72-
mapper_param_range_list = self.param_range_list_from(cls=AbstractMapper)
73-
74-
for i in range(len(mapper_list)):
75-
mapper = mapper_list[i]
76-
param_range = mapper_param_range_list[i]
77-
78-
operated_mapping_matrix = self.psf.convolved_mapping_matrix_from(
79-
mapping_matrix=mapper.mapping_matrix,
80-
mask=self.mask,
81-
use_mixed_precision=self.settings.use_mixed_precision,
82-
xp=self._xp
83-
)
84-
85-
data_vector_mapper = (
86-
inversion_imaging_util.data_vector_via_blurred_mapping_matrix_from(
87-
blurred_mapping_matrix=operated_mapping_matrix,
88-
image=self.data,
89-
noise_map=self.noise_map,
90-
)
91-
)
92-
93-
data_vector[param_range[0] : param_range[1],] = data_vector_mapper
94-
95-
return data_vector
96-
9756
@cached_property
9857
def data_vector(self) -> np.ndarray:
9958
"""
@@ -114,56 +73,6 @@ def data_vector(self) -> np.ndarray:
11473
noise_map=self.noise_map.array,
11574
)
11675

117-
@property
118-
def _curvature_matrix_mapper_diag(self) -> Optional[np.ndarray]:
119-
"""
120-
Returns the diagonal regions of the `curvature_matrix`, a 2D matrix which uses the mappings between the data
121-
and the linear objects to construct the simultaneous linear equations. The object is described in full in
122-
the method `curvature_matrix`.
123-
124-
This method computes the diagonal entries of all mapper objects in the `curvature_matrix`. It is separate from
125-
other calculations to enable preloading of this calculation.
126-
"""
127-
128-
if not self.has(cls=AbstractMapper):
129-
return None
130-
131-
curvature_matrix = np.zeros((self.total_params, self.total_params))
132-
133-
mapper_list = self.cls_list_from(cls=AbstractMapper)
134-
mapper_param_range_list = self.param_range_list_from(cls=AbstractMapper)
135-
136-
for i in range(len(mapper_list)):
137-
mapper_i = mapper_list[i]
138-
mapper_param_range_i = mapper_param_range_list[i]
139-
140-
operated_mapping_matrix = self.psf.convolved_mapping_matrix_from(
141-
mapping_matrix=mapper_i.mapping_matrix,
142-
mask=self.mask,
143-
use_mixed_precision=self.settings.use_mixed_precision,
144-
xp=self._xp
145-
)
146-
147-
diag = inversion_util.curvature_matrix_via_mapping_matrix_from(
148-
mapping_matrix=operated_mapping_matrix,
149-
noise_map=self.noise_map,
150-
settings=self.settings,
151-
add_to_curvature_diag=True,
152-
no_regularization_index_list=self.no_regularization_index_list,
153-
xp=self._xp,
154-
)
155-
156-
curvature_matrix[
157-
mapper_param_range_i[0] : mapper_param_range_i[1],
158-
mapper_param_range_i[0] : mapper_param_range_i[1],
159-
] = diag
160-
161-
curvature_matrix = inversion_util.curvature_matrix_mirrored_from(
162-
curvature_matrix=curvature_matrix, xp=self._xp
163-
)
164-
165-
return curvature_matrix
166-
16776
@cached_property
16877
def curvature_matrix(self):
16978
"""

autoarray/inversion/inversion/settings.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ def __init__(
4848
For an interferometer inversion using the linear operators method, sets the maximum number of iterations
4949
of the solver (this input does nothing for dataset data and other interferometer methods).
5050
"""
51+
self.use_mixed_precision = use_mixed_precision
5152
self._use_positive_only_solver = use_positive_only_solver
5253
self._positive_only_uses_p_initial = positive_only_uses_p_initial
5354
self._use_border_relocator = use_border_relocator

test_autoarray/inversion/inversion/test_factory.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -290,9 +290,6 @@ def test__inversion_imaging__compare_mapping_and_sparse_operator_values(
290290
settings=aa.SettingsInversion(),
291291
)
292292

293-
assert inversion_sparse_operator._curvature_matrix_mapper_diag == pytest.approx(
294-
inversion_mapping._curvature_matrix_mapper_diag, 1.0e-4
295-
)
296293
assert inversion_sparse_operator.reconstruction == pytest.approx(
297294
inversion_mapping.reconstruction, 1.0e-4
298295
)

0 commit comments

Comments
 (0)