Skip to content

Commit 4ba02c4

Browse files
committed
fix unit test
1 parent c51f76b commit 4ba02c4

4 files changed

Lines changed: 27 additions & 15 deletions

File tree

autoarray/inversion/inversion/abstract.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -791,7 +791,7 @@ def reconstruction_noise_map(self):
791791
792792
The noise-map of the reconstruction is the RMS standard deviation of the noise in every pixel of the
793793
reconstruction. This definition is identical to the `noise_map` attributes of dataset objects.
794-
794+
795795
It is computed as the square root of the diagonal of the `reconstruction_noise_map_with_covariance` matrix,
796796
which is the same matrix used to solve for the reconstruction via the linear inversion.
797797
@@ -804,7 +804,9 @@ def reconstruction_noise_map(self):
804804

805805
@property
806806
def reconstruction_noise_map_dict(self) -> Dict[LinearObj, np.ndarray]:
807-
return self.source_quantity_dict_from(source_quantity=self.reconstruction_noise_map)
807+
return self.source_quantity_dict_from(
808+
source_quantity=self.reconstruction_noise_map
809+
)
808810

809811
def regularization_weights_from(self, index: int) -> np.ndarray:
810812
linear_obj = self.linear_obj_list[index]

autoarray/inversion/mock/mock_inversion.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@ def __init__(
5959
self._mapped_reconstructed_data_dict = mapped_reconstructed_data_dict
6060
self._mapped_reconstructed_image_dict = mapped_reconstructed_image_dict
6161

62-
self._errors = reconstruction_noise_map
63-
self._errors_dict = reconstruction_noise_map_dict
62+
self._reconstruction_noise_map = reconstruction_noise_map
63+
self._reconstruction_noise_map_dict = reconstruction_noise_map_dict
6464

6565
self._regularization_term = regularization_term
6666
self._log_det_curvature_reg_matrix_term = log_det_curvature_reg_matrix_term
@@ -172,15 +172,15 @@ def mapped_reconstructed_image_dict(self):
172172

173173
@property
174174
def reconstruction_noise_map(self):
175-
if self._errors is None:
175+
if self._reconstruction_noise_map is None:
176176
return super().reconstruction_noise_map
177-
return self._errors
177+
return self._reconstruction_noise_map
178178

179179
@property
180180
def reconstruction_noise_map_dict(self):
181-
if self._errors_dict is None:
181+
if self._reconstruction_noise_map_dict is None:
182182
return super().reconstruction_noise_map_dict
183-
return self._errors_dict
183+
return self._reconstruction_noise_map_dict
184184

185185
@property
186186
def regularization_term(self):

autoarray/inversion/plot/inversion_plotters.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -239,8 +239,12 @@ def figures_2d_of_pixelization(
239239
if reconstruction_noise_map:
240240
try:
241241
mapper_plotter.plot_source_from(
242-
pixel_values=self.inversion.reconstruction_noise_map_dict[mapper_plotter.mapper],
243-
auto_labels=AutoLabels(title="Noise Map", filename="reconstruction_noise_map"),
242+
pixel_values=self.inversion.reconstruction_noise_map_dict[
243+
mapper_plotter.mapper
244+
],
245+
auto_labels=AutoLabels(
246+
title="Noise Map", filename="reconstruction_noise_map"
247+
),
244248
)
245249

246250
except TypeError:
@@ -250,7 +254,9 @@ def figures_2d_of_pixelization(
250254
try:
251255
signal_to_noise_values = (
252256
self.inversion.reconstruction_dict[mapper_plotter.mapper]
253-
/ self.inversion.reconstruction_noise_map_dict[mapper_plotter.mapper]
257+
/ self.inversion.reconstruction_noise_map_dict[
258+
mapper_plotter.mapper
259+
]
254260
)
255261

256262
mapper_plotter.plot_source_from(
@@ -390,7 +396,9 @@ def subplot_of_mapper(
390396

391397
self.set_title(label="Noise-Map (Unzoomed)")
392398
self.figures_2d_of_pixelization(
393-
pixelization_index=mapper_index, reconstruction_noise_map=True, zoom_to_brightest=False
399+
pixelization_index=mapper_index,
400+
reconstruction_noise_map=True,
401+
zoom_to_brightest=False,
394402
)
395403

396404
self.set_title(label="Regularization Weights (Unzoomed)")

test_autoarray/inversion/inversion/test_abstract.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -636,7 +636,9 @@ def test__reconstruction_noise_map():
636636

637637
inversion = aa.m.MockInversion(curvature_reg_matrix=curvature_reg_matrix)
638638

639-
assert inversion.errors_with_covariance == pytest.approx(
640-
np.array([[2.5, -1.0, -0.5], [-1.0, 1.0, 0.0], [-0.5, 0.0, 0.5]]), 1.0e-2
639+
assert inversion.reconstruction_noise_map_with_covariance[0, 0] == pytest.approx(
640+
np.sqrt(2.5), 1.0e-2
641+
)
642+
assert inversion.reconstruction_noise_map == pytest.approx(
643+
np.sqrt(np.array([2.5, 1.0, 0.5])), 1.0e-3
641644
)
642-
assert inversion.reconstruction_noise_map == pytest.approx(np.array([2.5, 1.0, 0.5]), 1.0e-3)

0 commit comments

Comments
 (0)