@@ -33,7 +33,7 @@ def make_test_data_path():
3333 return test_data_path
3434
3535
36- def test__grid__uses_mask_and_settings (
36+ def test__grid__uses_mask_and_settings__lp_grid_matches_grid_2d_7x7 (
3737 image_7x7 ,
3838 noise_map_7x7 ,
3939 mask_2d_7x7 ,
@@ -57,7 +57,7 @@ def test__grid__uses_mask_and_settings(
5757 assert (masked_imaging_7x7 .grids .lp .slim == grid_2d_7x7 ).all ()
5858
5959
60- def test__grids_pixelization__uses_mask_and_settings (
60+ def test__grids_pixelization__uses_mask_and_settings__default_over_sample__matches_grid_2d_7x7 (
6161 image_7x7 ,
6262 noise_map_7x7 ,
6363 mask_2d_7x7 ,
@@ -75,6 +75,17 @@ def test__grids_pixelization__uses_mask_and_settings(
7575 assert (masked_imaging_7x7 .grids .pixelization == grid_2d_7x7 ).all ()
7676 assert (masked_imaging_7x7 .grids .pixelization .slim == grid_2d_7x7 ).all ()
7777
78+
79+ def test__grids_pixelization__uses_mask_and_settings__custom_over_sample__returns_grid2d_with_correct_size (
80+ image_7x7 ,
81+ noise_map_7x7 ,
82+ mask_2d_7x7 ,
83+ grid_2d_7x7 ,
84+ ):
85+ masked_image_7x7 = aa .Array2D (values = image_7x7 .native , mask = mask_2d_7x7 )
86+
87+ masked_noise_map_7x7 = aa .Array2D (values = noise_map_7x7 .native , mask = mask_2d_7x7 )
88+
7889 masked_imaging_7x7 = aa .Imaging (
7990 data = masked_image_7x7 ,
8091 noise_map = masked_noise_map_7x7 ,
@@ -86,7 +97,9 @@ def test__grids_pixelization__uses_mask_and_settings(
8697 assert masked_imaging_7x7 .grids .over_sample_size_pixelization [0 ] == 4
8798
8899
89- def test__grid_settings__sub_size (image_7x7 , noise_map_7x7 ):
100+ def test__grid_settings__sub_size__returns_correct_over_sample_sizes (
101+ image_7x7 , noise_map_7x7
102+ ):
90103 dataset_7x7 = aa .Imaging (
91104 data = image_7x7 ,
92105 noise_map = noise_map_7x7 ,
@@ -116,7 +129,7 @@ def test__no_noise_map__raises_exception():
116129 aa .Imaging (data = image )
117130
118131
119- def test__from_fits ():
132+ def test__from_fits__separate_fits_files__loads_data_psf_noise_map_correctly ():
120133 dataset = aa .Imaging .from_fits (
121134 pixel_scales = 0.1 ,
122135 data_path = path .join (test_data_path , "3x3_ones.fits" ),
@@ -134,6 +147,8 @@ def test__from_fits():
134147 assert dataset .psf .kernel .mask .pixel_scales == (0.1 , 0.1 )
135148 assert dataset .noise_map .mask .pixel_scales == (0.1 , 0.1 )
136149
150+
151+ def test__from_fits__all_data_in_one_fits_file_multiple_hdus__loads_data_psf_noise_map_correctly ():
137152 dataset = aa .Imaging .from_fits (
138153 pixel_scales = 0.1 ,
139154 data_path = path .join (test_data_path , "3x3_multiple_hdu.fits" ),
@@ -155,7 +170,9 @@ def test__from_fits():
155170 assert dataset .noise_map .mask .pixel_scales == (0.1 , 0.1 )
156171
157172
158- def test__output_to_fits (imaging_7x7 , test_data_path ):
173+ def test__output_to_fits__round_trips_data_psf_noise_map_correctly (
174+ imaging_7x7 , test_data_path
175+ ):
159176
160177 imaging_7x7 .output_to_fits (
161178 data_path = path .join (test_data_path , "data.fits" ),
@@ -176,7 +193,9 @@ def test__output_to_fits(imaging_7x7, test_data_path):
176193 assert dataset .pixel_scales == (0.1 , 0.1 )
177194
178195
179- def test__apply_mask (imaging_7x7 , mask_2d_7x7 , psf_3x3 ):
196+ def test__apply_mask__data_noise_map_psf_correctly_masked (
197+ imaging_7x7 , mask_2d_7x7 , psf_3x3
198+ ):
180199 masked_imaging_7x7 = imaging_7x7 .apply_mask (mask = mask_2d_7x7 )
181200
182201 assert (masked_imaging_7x7 .data .slim == np .ones (9 )).all ()
@@ -198,7 +217,9 @@ def test__apply_mask(imaging_7x7, mask_2d_7x7, psf_3x3):
198217 assert type (masked_imaging_7x7 .psf ) == aa .Convolver
199218
200219
201- def test__apply_noise_scaling (imaging_7x7 , mask_2d_7x7 ):
220+ def test__apply_noise_scaling__masked_pixel_data_zeroed_and_noise_set_to_noise_value (
221+ imaging_7x7 , mask_2d_7x7
222+ ):
202223 masked_imaging_7x7 = imaging_7x7 .apply_noise_scaling (
203224 mask = mask_2d_7x7 , noise_value = 1e5
204225 )
@@ -207,7 +228,7 @@ def test__apply_noise_scaling(imaging_7x7, mask_2d_7x7):
207228 assert masked_imaging_7x7 .noise_map .native [4 , 4 ] == 1e5
208229
209230
210- def test__apply_noise_scaling__use_signal_to_noise_value (
231+ def test__apply_noise_scaling__use_signal_to_noise_value__noise_map_scaled_to_match_snr (
211232 image_7x7 , psf_3x3 , noise_map_7x7 , mask_2d_7x7
212233):
213234
@@ -233,7 +254,7 @@ def test__apply_noise_scaling__use_signal_to_noise_value(
233254 assert masked_imaging_7x7 .noise_map .native [3 , 3 ] == 10.0
234255
235256
236- def test__apply_mask__noise_covariance_matrix ():
257+ def test__apply_mask__noise_covariance_matrix__submatrix_extracted_for_unmasked_pixels ():
237258 image = aa .Array2D .ones (shape_native = (2 , 2 ), pixel_scales = (1.0 , 1.0 ))
238259
239260 noise_covariance_matrix = np .array (
@@ -263,7 +284,7 @@ def test__apply_mask__noise_covariance_matrix():
263284 )
264285
265286
266- def test__different_imaging_without_mock_objects__customize_constructor_inputs ():
287+ def test__different_imaging_without_mock_objects__customize_constructor_inputs__single_unmasked_pixel_correct ():
267288
268289 kernel = aa .Array2D .ones (shape_native = (7 , 7 ), pixel_scales = 3.0 )
269290 psf = aa .Convolver (kernel = kernel )
@@ -291,14 +312,18 @@ def test__different_imaging_without_mock_objects__customize_constructor_inputs()
291312 assert (masked_dataset .noise_map == np .array ([2.0 ])).all ()
292313
293314
294- def test__noise_map_unmasked_has_zeros_or_negative__raises_exception ():
315+ def test__noise_map_unmasked_has_zeros__raises_exception ():
295316 array = aa .Array2D .no_mask ([[1.0 , 2.0 ]], pixel_scales = 1.0 )
296317
297318 noise_map = aa .Array2D .no_mask ([[0.0 , 3.0 ]], pixel_scales = 1.0 )
298319
299320 with pytest .raises (aa .exc .DatasetException ):
300321 aa .Imaging (data = array , noise_map = noise_map )
301322
323+
324+ def test__noise_map_unmasked_has_negative_values__raises_exception ():
325+ array = aa .Array2D .no_mask ([[1.0 , 2.0 ]], pixel_scales = 1.0 )
326+
302327 noise_map = aa .Array2D .no_mask ([[- 1.0 , 3.0 ]], pixel_scales = 1.0 )
303328
304329 with pytest .raises (aa .exc .DatasetException ):
0 commit comments