Skip to content

Commit 05524b9

Browse files
committed
Moved mock_inversion to autoarray from automodel
1 parent 0f1e22a commit 05524b9

4 files changed

Lines changed: 91 additions & 3 deletions

File tree

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
import numpy as np
2+
3+
4+
class MockGeometry(object):
5+
def __init__(
6+
self,
7+
pixel_centres=None,
8+
pixel_neighbors=np.array([1]),
9+
pixel_neighbors_size=np.array([1]),
10+
):
11+
12+
self.pixel_scales = (1.0, 1.0)
13+
self.origin = (0.0, 0.0)
14+
self.pixel_centres = pixel_centres
15+
16+
self.pixel_neighbors = pixel_neighbors.astype("int")
17+
self.pixel_neighbors_size = pixel_neighbors_size.astype("int")
18+
19+
20+
class MockPixelization(object):
21+
def __init__(self, value, grid=None):
22+
self.value = value
23+
self.grid = grid
24+
25+
# noinspection PyUnusedLocal,PyShadowingNames
26+
def mapper_from_grid_and_pixelization_grid(
27+
self, grid, pixelization_grid, inversion_uses_border, hyper_image=None
28+
):
29+
return self.value
30+
31+
def pixelization_grid_from_grid(self, grid, cluster_grid, hyper_image):
32+
if hyper_image is None:
33+
return self.grid
34+
else:
35+
return self.grid * hyper_image
36+
37+
38+
class MockRegularization(object):
39+
def __init__(self, matrix_shape):
40+
self.shape = matrix_shape
41+
42+
def regularization_matrix_from_pixel_neighbors(
43+
self, pixel_neighbors, pixel_neighbors_size
44+
):
45+
return np.array([[1.0, 0.0, 0.0], [0.0, 1.0, 0.0], [0.0, 0.0, 1.0]])
46+
47+
def regularization_matrix_from_mapper(self, mapper):
48+
return np.array([[1.0, 0.0, 0.0], [0.0, 1.0, 0.0], [0.0, 0.0, 1.0]])
49+
50+
51+
class MockRegMapper(object):
52+
53+
def __init__(self, pixel_neighbors=None, pixel_neighbors_size=None, pixel_signals=None):
54+
self.pixel_neighbors = pixel_neighbors
55+
self.pixel_neighbors_size = pixel_neighbors_size
56+
self.pixel_signals = pixel_signals
57+
58+
def pixel_signals_from_signal_scale(self, signal_scale):
59+
return self.pixel_signals
60+
61+
62+
class MockMapper(object):
63+
def __init__(self, matrix_shape, grid=None):
64+
65+
self.grid = grid
66+
self.mapping_matrix = np.ones(matrix_shape)
67+
self.geometry = MockGeometry()
68+
69+
70+
class MockConvolver(object):
71+
def __init__(self, matrix_shape):
72+
self.shape = matrix_shape
73+
74+
def convolve_mapping_matrix(self, mapping_matrix):
75+
return np.ones(self.shape)
76+
77+
78+
class MockInversion(object):
79+
def __init__(self):
80+
self.blurred_mapping_matrix = np.zeros((1, 1))
81+
self.regularization_matrix = np.zeros((1, 1))
82+
self.curvature_matrix = np.zeros((1, 1))
83+
self.curvature_reg_matrix = np.zeros((1, 1))
84+
self.solution_vector = np.zeros((1))
85+
86+
@property
87+
def reconstructed_image(self):
88+
return np.zeros((1, 1))

test_autoarray/unit/operators/inversion/test_inversions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import numpy as np
44
import pytest
55

6-
from test_automodel.mock import mock_inversion
6+
from test_autoarray.mock import mock_inversion
77

88

99
class TestRegularizationTerm:

test_autoarray/unit/operators/inversion/test_mappers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
import autoarray as aa
55
from test_autoarray.mock.mock_grids import MockPixelizationGrid
6-
from test_automodel.mock.mock_inversion import MockGeometry
6+
from test_autoarray.mock.mock_inversion import MockGeometry
77

88

99
def grid_to_pixel_pixels_via_nearest_neighbour(grid, pixel_centers):

test_autoarray/unit/operators/inversion/test_regularization.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import autoarray as aa
22
import numpy as np
33

4-
from test_automodel.mock.mock_inversion import MockRegMapper
4+
from test_autoarray.mock.mock_inversion import MockRegMapper
55

66
class TestRegularizationConstant:
77
def test__regularization_matrix__compare_to_regularization_util(self):

0 commit comments

Comments
 (0)