Skip to content

Commit de27e61

Browse files
committed
Merge branch 'develop' of https://github.com/jammy2211/PyAutoArray into develop
2 parents 63ac5d3 + 3cac206 commit de27e61

8 files changed

Lines changed: 37 additions & 37 deletions

File tree

autoarray/operators/inversion/regularization.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -123,18 +123,18 @@ def __init__(self):
123123
"""
124124

125125

126-
class Constant(Regularization):
126+
class instance(Regularization):
127127
def __init__(self, coefficient=1.0):
128-
"""A constant-regularization scheme (regularization is described in the *Regularization* class above).
128+
"""A instance-regularization scheme (regularization is described in the *Regularization* class above).
129129
130-
For the constant regularization_matrix scheme, there is only 1 regularization coefficient that is applied to \
130+
For the instance regularization_matrix scheme, there is only 1 regularization coefficient that is applied to \
131131
all neighboring pixels. This means that we when write B, we only need to regularize pixels in one direction \
132132
(e.g. pixel 0 regularizes pixel 1, but NOT visa versa). For example:
133133
134134
B = [-1, 1] [0->1]
135135
[0, -1] 1 does not regularization with 0
136136
137-
A small numerical value of 1.0e-8 is added to all elements in a constant regularization matrix, to ensure that \
137+
A small numerical value of 1.0e-8 is added to all elements in a instance regularization matrix, to ensure that \
138138
it is positive definite.
139139
140140
Parameters
@@ -143,13 +143,13 @@ def __init__(self, coefficient=1.0):
143143
The regularization coefficient which controls the degree of smooth of the inversion reconstruction.
144144
"""
145145
self.coefficient = coefficient
146-
super(Constant, self).__init__()
146+
super(instance, self).__init__()
147147

148148
def regularization_weights_from_mapper(self, mapper):
149149
return self.coefficient * np.ones(mapper.pixelization_grid.pixels)
150150

151151
def regularization_matrix_from_mapper(self, mapper):
152-
return regularization_util.constant_regularization_matrix_from_pixel_neighbors(
152+
return regularization_util.instance_regularization_matrix_from_pixel_neighbors(
153153
coefficient=self.coefficient,
154154
pixel_neighbors=mapper.pixelization_grid.pixel_neighbors,
155155
pixel_neighbors_size=mapper.pixelization_grid.pixel_neighbors_size,
@@ -158,20 +158,20 @@ def regularization_matrix_from_mapper(self, mapper):
158158

159159
class AdaptiveBrightness(Regularization):
160160
def __init__(self, inner_coefficient=1.0, outer_coefficient=1.0, signal_scale=1.0):
161-
""" A constant-regularization scheme (regularization is described in the *Regularization* class above).
161+
""" A instance-regularization scheme (regularization is described in the *Regularization* class above).
162162
163163
For the weighted regularization scheme, each pixel is given an 'effective regularization weight', which is \
164164
applied when each set of pixel neighbors are regularized with one another. The motivation of this is that \
165165
different regions of a pixelization require different levels of regularization (e.g., high smoothing where the \
166166
no signal is present and less smoothing where it is, see (Nightingale, Dye and Massey 2018)).
167167
168-
Unlike the constant regularization_matrix scheme, neighboring pixels must now be regularized with one another \
168+
Unlike the instance regularization_matrix scheme, neighboring pixels must now be regularized with one another \
169169
in both directions (e.g. if pixel 0 regularizes pixel 1, pixel 1 must also regularize pixel 0). For example:
170170
171171
B = [-1, 1] [0->1]
172172
[-1, -1] 1 now also regularizes 0
173173
174-
For a constant regularization coefficient this would NOT produce a positive-definite matrix. However, for
174+
For a instance regularization coefficient this would NOT produce a positive-definite matrix. However, for
175175
the weighted scheme, it does!
176176
177177
The regularize weights change the B matrix as shown below - we simply multiply each pixel's effective \

autoarray/util/regularization_util.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33

44

55
@decorator_util.jit()
6-
def constant_regularization_matrix_from_pixel_neighbors(
6+
def instance_regularization_matrix_from_pixel_neighbors(
77
coefficient, pixel_neighbors, pixel_neighbors_size
88
):
9-
"""From the pixel-neighbors, setup the regularization matrix using the constant regularization scheme.
9+
"""From the pixel-neighbors, setup the regularization matrix using the instance regularization scheme.
1010
1111
Parameters
1212
----------

test_autoarray/unit/dataset/test_imaging.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ def test__image_and_exposure_times_range_of_values__background_has_value_9___noi
321321
def test__image_and_exposure_times_and_background_are_all_ranges_of_values__noise_estimates_correct(
322322
self
323323
):
324-
# Use same pattern as above, noting that we are now also using a variable background signal_to_noise_ratio map.
324+
# Use same pattern as above, noting that we are now also using a model background signal_to_noise_ratio map.
325325

326326
image = aa.array.manual_2d(array=[[5.0, 3.0], [10.0, 20.0]])
327327

@@ -2277,7 +2277,7 @@ def test__simulate_function__turns_exposure_time_and_sky_level_to_arrays(self):
22772277

22782278
background_sky_map = aa.array.full(fill_value=16.0, shape_2d=image.mask.shape)
22792279

2280-
imaging_variable = aa.imaging.simulate(
2280+
imaging_model = aa.imaging.simulate(
22812281
image=image,
22822282
exposure_time=1.0,
22832283
exposure_time_map=exposure_time_map,
@@ -2309,14 +2309,14 @@ def test__simulate_function__turns_exposure_time_and_sky_level_to_arrays(self):
23092309
)
23102310

23112311
assert (
2312-
imaging_variable.exposure_time_map.in_2d
2312+
imaging_model.exposure_time_map.in_2d
23132313
== imaging_simulated.exposure_time_map.in_2d
23142314
).all()
2315-
assert imaging_variable.image.in_2d == pytest.approx(
2315+
assert imaging_model.image.in_2d == pytest.approx(
23162316
imaging_simulated.image.in_2d, 1e-4
23172317
)
23182318
assert (
2319-
imaging_variable.background_noise_map.in_2d
2319+
imaging_model.background_noise_map.in_2d
23202320
== imaging_simulated.background_noise_map.in_2d
23212321
).all()
23222322

test_autoarray/unit/operators/inversion/test_integration.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ def test__5_simple_grid__no_sub_grid(self):
6262
assert mapper.shape_2d == (3, 3)
6363
assert (mapper.hyper_image == np.ones((2, 2))).all()
6464

65-
reg = aa.reg.Constant(coefficient=1.0)
65+
reg = aa.reg.instance(coefficient=1.0)
6666
regularization_matrix = reg.regularization_matrix_from_mapper(mapper=mapper)
6767

6868
assert (
@@ -175,7 +175,7 @@ def test__15_grid__no_sub_grid(self):
175175
).all()
176176
assert mapper.shape_2d == (3, 3)
177177

178-
reg = aa.reg.Constant(coefficient=1.0)
178+
reg = aa.reg.instance(coefficient=1.0)
179179
regularization_matrix = reg.regularization_matrix_from_mapper(mapper=mapper)
180180

181181
assert (
@@ -287,7 +287,7 @@ def test__5_simple_grid__include_sub_grid(self):
287287
).all()
288288
assert mapper.shape_2d == (3, 3)
289289

290-
reg = aa.reg.Constant(coefficient=1.0)
290+
reg = aa.reg.instance(coefficient=1.0)
291291
regularization_matrix = reg.regularization_matrix_from_mapper(mapper=mapper)
292292

293293
assert (
@@ -372,7 +372,7 @@ def test__grid__requires_border_relocation(self):
372372
).all()
373373
assert mapper.shape_2d == (3, 3)
374374

375-
reg = aa.reg.Constant(coefficient=1.0)
375+
reg = aa.reg.instance(coefficient=1.0)
376376
regularization_matrix = reg.regularization_matrix_from_mapper(mapper=mapper)
377377

378378
assert (
@@ -432,7 +432,7 @@ def test__interferometer(self):
432432
grid=grid, sparse_grid=None, inversion_uses_border=False
433433
)
434434

435-
reg = aa.reg.Constant(coefficient=0.0)
435+
reg = aa.reg.instance(coefficient=0.0)
436436

437437
visibilities = aa.visibilities.manual_1d(
438438
visibilities=[
@@ -547,7 +547,7 @@ def test__3x3_simple_grid(self):
547547
)
548548
).all()
549549

550-
reg = aa.reg.Constant(coefficient=1.0)
550+
reg = aa.reg.instance(coefficient=1.0)
551551
regularization_matrix = reg.regularization_matrix_from_mapper(mapper=mapper)
552552

553553
assert (
@@ -639,7 +639,7 @@ def test__3x3_simple_grid__include_mask(self):
639639
)
640640
).all()
641641

642-
reg = aa.reg.Constant(coefficient=1.0)
642+
reg = aa.reg.instance(coefficient=1.0)
643643
regularization_matrix = reg.regularization_matrix_from_mapper(mapper=mapper)
644644

645645
assert (
@@ -748,7 +748,7 @@ def test__3x3_simple_grid__include_mask_and_sub_grid(self):
748748
)
749749
).all()
750750

751-
reg = aa.reg.Constant(coefficient=1.0)
751+
reg = aa.reg.instance(coefficient=1.0)
752752
regularization_matrix = reg.regularization_matrix_from_mapper(mapper=mapper)
753753

754754
assert (
@@ -838,7 +838,7 @@ def test__3x3_simple_grid__include_mask_with_offset_centre(self):
838838
)
839839
).all()
840840

841-
reg = aa.reg.Constant(coefficient=1.0)
841+
reg = aa.reg.instance(coefficient=1.0)
842842
regularization_matrix = reg.regularization_matrix_from_mapper(mapper=mapper)
843843

844844
assert (
@@ -896,7 +896,7 @@ def test__interferometer(self):
896896
grid=grid, sparse_grid=sparse_grid, inversion_uses_border=False
897897
)
898898

899-
reg = aa.reg.Constant(coefficient=0.0)
899+
reg = aa.reg.instance(coefficient=0.0)
900900

901901
visibilities = aa.visibilities.manual_1d(
902902
visibilities=[

test_autoarray/unit/operators/inversion/test_regularization.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from test_autoarray.mock.mock_inversion import MockPixelizationGrid, MockRegMapper
55

66

7-
class TestRegularizationConstant:
7+
class TestRegularizationinstance:
88
def test__regularization_matrix__compare_to_regularization_util(self):
99

1010
pixel_neighbors = np.array(
@@ -29,10 +29,10 @@ def test__regularization_matrix__compare_to_regularization_util(self):
2929

3030
mapper = MockRegMapper(pixelization_grid=pixelization_grid)
3131

32-
reg = aa.reg.Constant(coefficient=1.0)
32+
reg = aa.reg.instance(coefficient=1.0)
3333
regularization_matrix = reg.regularization_matrix_from_mapper(mapper=mapper)
3434

35-
regularization_matrix_util = aa.util.regularization.constant_regularization_matrix_from_pixel_neighbors(
35+
regularization_matrix_util = aa.util.regularization.instance_regularization_matrix_from_pixel_neighbors(
3636
coefficient=1.0,
3737
pixel_neighbors=pixel_neighbors,
3838
pixel_neighbors_size=pixel_neighbors_size,

test_autoarray/unit/test_files/config/label.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,5 @@ HyperGalaxy = hg
3131
Rectangular = rect
3232
VoronoiMagnification = voro_mag
3333
VoronoiBrightnessImage = voro_image
34-
Constant = const
34+
instance = const
3535
AdaptiveBrightness = adapt_bright

test_autoarray/unit/test_files/config/priors/default/regularization.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
[Constant]
1+
[instance]
22
coefficient = u,0,1
33

44
[AdaptiveBrightness]

test_autoarray/unit/util/test_regularization_util.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import pytest
55

66

7-
class TestRegularizationConstantMatrix:
7+
class TestRegularizationinstanceMatrix:
88
def test__1_b_matrix_size_3x3__weights_all_1s__makes_correct_regularization_matrix(
99
self
1010
):
@@ -26,7 +26,7 @@ def test__1_b_matrix_size_3x3__weights_all_1s__makes_correct_regularization_matr
2626
test_b_matrix.T, test_b_matrix
2727
) + 1e-8 * np.identity(3)
2828

29-
regularization_matrix = aa.util.regularization.constant_regularization_matrix_from_pixel_neighbors(
29+
regularization_matrix = aa.util.regularization.instance_regularization_matrix_from_pixel_neighbors(
3030
coefficient=1.0,
3131
pixel_neighbors=pixel_neighbors,
3232
pixel_neighbors_size=pixel_neighbors_size,
@@ -53,7 +53,7 @@ def test__1_b_matrix_size_4x4__weights_all_1s__makes_correct_regularization_matr
5353

5454
pixel_neighbors_size = np.array([2, 2, 2, 2])
5555

56-
regularization_matrix = aa.util.regularization.constant_regularization_matrix_from_pixel_neighbors(
56+
regularization_matrix = aa.util.regularization.instance_regularization_matrix_from_pixel_neighbors(
5757
coefficient=1.0,
5858
pixel_neighbors=pixel_neighbors,
5959
pixel_neighbors_size=pixel_neighbors_size,
@@ -80,7 +80,7 @@ def test__1_b_matrix_size_4x4__coefficient_2__makes_correct_regularization_matri
8080
test_b_matrix.T, test_b_matrix
8181
) + 1e-8 * np.identity(4)
8282

83-
regularization_matrix = aa.util.regularization.constant_regularization_matrix_from_pixel_neighbors(
83+
regularization_matrix = aa.util.regularization.instance_regularization_matrix_from_pixel_neighbors(
8484
coefficient=2.0,
8585
pixel_neighbors=pixel_neighbors,
8686
pixel_neighbors_size=pixel_neighbors_size,
@@ -146,7 +146,7 @@ def test__1_b_matrix_size_9x9__coefficient_2__makes_correct_regularization_matri
146146
+ 1e-8 * np.identity(9)
147147
)
148148

149-
regularization_matrix = aa.util.regularization.constant_regularization_matrix_from_pixel_neighbors(
149+
regularization_matrix = aa.util.regularization.instance_regularization_matrix_from_pixel_neighbors(
150150
coefficient=1.0,
151151
pixel_neighbors=pixel_neighbors,
152152
pixel_neighbors_size=pixel_neighbors_size,
@@ -394,7 +394,7 @@ def test__4_b_matrices_size_6x6__weights_all_1s__makes_correct_regularization_ma
394394
test_regularization_matrix, 1.0e-4
395395
)
396396

397-
def test__2_b_matrices_size_4x4_variables_regularization_weights__makes_correct_regularization_matrix(
397+
def test__2_b_matrices_size_4x4_models_regularization_weights__makes_correct_regularization_matrix(
398398
self
399399
):
400400
# Simple case, where we have just one regularization direction, regularizing pixel 0 -> 1 and 1 -> 2.

0 commit comments

Comments
 (0)