Skip to content

Commit a95464f

Browse files
Jammy2211Jammy2211
authored andcommitted
test_autoarray/inversion/pixelization/mappers/test_factory.py -> rectanguilar mapping matrix now has interpoltion
1 parent 0e1f23b commit a95464f

File tree

3 files changed

+30
-25
lines changed

3 files changed

+30
-25
lines changed

autoarray/inversion/pixelization/mappers/rectangular.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -98,14 +98,18 @@ def pix_sub_weights(self) -> PixSubWeights:
9898
are equal to 1.0.
9999
"""
100100

101-
mappings, weights = mapper_util.rectangular_mappings_weights_via_interpolation_from(
102-
shape_native=self.shape_native,
103-
source_plane_mesh_grid=self.source_plane_mesh_grid.array,
104-
source_plane_data_grid=Grid2DIrregular(self.source_plane_data_grid.over_sampled).array,
101+
mappings, weights = (
102+
mapper_util.rectangular_mappings_weights_via_interpolation_from(
103+
shape_native=self.shape_native,
104+
source_plane_mesh_grid=self.source_plane_mesh_grid.array,
105+
source_plane_data_grid=Grid2DIrregular(
106+
self.source_plane_data_grid.over_sampled
107+
).array,
108+
)
105109
)
106110

107111
return PixSubWeights(
108112
mappings=np.array(mappings),
109-
sizes=4*np.ones(len(mappings), dtype="int"),
113+
sizes=4 * np.ones(len(mappings), dtype="int"),
110114
weights=np.array(weights),
111115
)

test_autoarray/inversion/pixelization/mappers/test_factory.py

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -42,18 +42,19 @@ def test__rectangular_mapper():
4242
(5.0, 5.0), 1.0e-4
4343
)
4444
assert mapper.source_plane_mesh_grid.origin == pytest.approx((0.5, 0.5), 1.0e-4)
45-
assert (
46-
mapper.mapping_matrix
47-
== np.array(
45+
print(mapper.mapping_matrix)
46+
assert mapper.mapping_matrix == pytest.approx(
47+
np.array(
4848
[
49-
[0.0, 0.75, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.25],
50-
[0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0],
51-
[0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0],
52-
[0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0],
53-
[0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0],
49+
[0.0675, 0.5775, 0.18, 0.0075, -0.065, -0.1425, 0.0, 0.0375, 0.3375],
50+
[0.18, -0.03, 0.0, 0.84, -0.14, 0.0, 0.18, -0.03, 0.0],
51+
[0.0225, 0.105, 0.0225, 0.105, 0.49, 0.105, 0.0225, 0.105, 0.0225],
52+
[0.0, -0.03, 0.18, 0.0, -0.14, 0.84, 0.0, -0.03, 0.18],
53+
[0.0, 0.0, 0.0, -0.03, -0.14, -0.03, 0.18, 0.84, 0.18],
5454
]
55-
)
56-
).all()
55+
),
56+
1.0e-4,
57+
)
5758
assert mapper.shape_native == (3, 3)
5859

5960

test_autoarray/inversion/pixelization/mappers/test_rectangular.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -31,18 +31,18 @@ def test__pix_indexes_for_sub_slim_index__matches_util():
3131

3232
mapper = aa.Mapper(mapper_grids=mapper_grids, regularization=None)
3333

34-
mappings, weights = aa.util.mapper.rectangular_mappings_weights_via_interpolation_from(
35-
shape_native=(3,3),
36-
source_plane_mesh_grid=mesh_grid.array,
37-
source_plane_data_grid=aa.Grid2DIrregular(mapper_grids.source_plane_data_grid.over_sampled).array,
34+
mappings, weights = (
35+
aa.util.mapper.rectangular_mappings_weights_via_interpolation_from(
36+
shape_native=(3, 3),
37+
source_plane_mesh_grid=mesh_grid.array,
38+
source_plane_data_grid=aa.Grid2DIrregular(
39+
mapper_grids.source_plane_data_grid.over_sampled
40+
).array,
41+
)
3842
)
3943

40-
assert (
41-
mapper.pix_sub_weights.mappings == mappings
42-
).all()
43-
assert (
44-
mapper.pix_sub_weights.weights == weights
45-
).all()
44+
assert (mapper.pix_sub_weights.mappings == mappings).all()
45+
assert (mapper.pix_sub_weights.weights == weights).all()
4646

4747

4848
def test__pixel_signals_from__matches_util(grid_2d_sub_1_7x7, image_7x7):

0 commit comments

Comments
 (0)