Skip to content

Commit cd3f0aa

Browse files
committed
Add tests fixed which I can fix
1 parent e8f3577 commit cd3f0aa

3 files changed

Lines changed: 14 additions & 10 deletions

File tree

autoarray/fit/masked_data.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from autoarray.structures import arrays, grids
1+
from autoarray.structures import arrays, grids, kernel
22
from autoarray.operators import convolution, fourier_transform
33

44
import numpy as np
@@ -101,7 +101,7 @@ def __init__(
101101
else:
102102
self.trimmed_psf_shape_2d = trimmed_psf_shape_2d
103103

104-
self.psf = imaging.psf.resized_from_new_shape(new_shape=self.trimmed_psf_shape_2d)
104+
self.psf = kernel.Kernel.manual_2d(array=imaging.psf.resized_from_new_shape(new_shape=self.trimmed_psf_shape_2d).in_2d)
105105

106106
self.convolver = convolution.Convolver(
107107
mask=mask,
@@ -228,7 +228,7 @@ def __init__(
228228
self.trimmed_primary_beam_shape_2d = trimmed_primary_beam_shape_2d
229229

230230
if self.trimmed_primary_beam_shape_2d is not None:
231-
self.primary_beam = interferometer.primary_beam.resized_from_new_shape(new_shape=self.trimmed_primary_beam_shape_2d)
231+
self.primary_beam = kernel.Kernel.manual_2d(array=interferometer.primary_beam.resized_from_new_shape(new_shape=self.trimmed_primary_beam_shape_2d).in_2d)
232232

233233
self.transformer = fourier_transform.Transformer(
234234
uv_wavelengths=interferometer.uv_wavelengths,

autoarray/structures/kernel.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,22 +56,22 @@ def full(cls, fill_value, shape_2d, pixel_scales=None, sub_size=1, origin=(0.0,
5656
if sub_size is not None:
5757
shape_2d = (shape_2d[0] * sub_size, shape_2d[1] * sub_size)
5858

59-
return cls.manual_2d(array=np.full(fill_value=fill_value, shape=shape_2d), pixel_scales=pixel_scales, origin=origin)
59+
return Kernel.manual_2d(array=np.full(fill_value=fill_value, shape=shape_2d), pixel_scales=pixel_scales, origin=origin)
6060

6161
@classmethod
6262
def ones(cls, shape_2d, pixel_scales=None, origin=(0.0, 0.0)):
63-
return cls.full(fill_value=1.0, shape_2d=shape_2d, pixel_scales=pixel_scales, origin=origin)
63+
return Kernel.full(fill_value=1.0, shape_2d=shape_2d, pixel_scales=pixel_scales, origin=origin)
6464

6565
@classmethod
6666
def zeros(cls, shape_2d, pixel_scales=None, origin=(0.0, 0.0)):
67-
return cls.full(fill_value=0.0, shape_2d=shape_2d, pixel_scales=pixel_scales, origin=origin)
67+
return Kernel.full(fill_value=0.0, shape_2d=shape_2d, pixel_scales=pixel_scales, origin=origin)
6868

6969
@classmethod
7070
def no_blur(cls, pixel_scales=None):
7171

7272
array = np.array([[0.0, 0.0, 0.0], [0.0, 1.0, 0.0], [0.0, 0.0, 0.0]])
7373

74-
return cls.manual_2d(array=array, pixel_scales=pixel_scales)
74+
return Kernel.manual_2d(array=array, pixel_scales=pixel_scales)
7575

7676
@classmethod
7777
def from_gaussian(
@@ -142,7 +142,7 @@ def from_fits(cls, file_path, hdu, pixel_scales=None, origin=(0.0, 0.0), renorma
142142
file_path=file_path, hdu=hdu,
143143
pixel_scales=pixel_scales, origin=origin)
144144

145-
return Kernel(array_1d=array, mask=array.mask, renormalize=renormalize)
145+
return Kernel(array_1d=array[:], mask=array.mask, renormalize=renormalize)
146146

147147
def rescaled_with_odd_dimensions_from_rescale_factor(
148148
self, rescale_factor, renormalize=False

test_autoarray/unit/fit/test_masked_data.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import autoarray as aa
2+
from autoarray.structures import kernel as kern
23
from autoarray.operators import convolution, fourier_transform
34
from autoarray.fit import masked_data as md
45
import numpy as np
@@ -73,6 +74,7 @@ def test__inversion_uses_border(self, sub_mask_7x7):
7374

7475
assert masked_imaging_7x7.inversion_uses_border == False
7576

77+
7678
class TestMaskedImaging(object):
7779
def test__masked_data(self, imaging_7x7, sub_mask_7x7):
7880

@@ -154,12 +156,13 @@ def test__pixel_scale_interpolation_grid_input__grids_include_interpolator_on_bl
154156
== new_blurring_grid.interpolator.wts
155157
).all()
156158

157-
def test__convolvers(self, imaging_7x7, sub_mask_7x7):
159+
def test__psf_and_convolvers(self, imaging_7x7, sub_mask_7x7):
158160

159161
masked_imaging_7x7 = aa.masked_imaging.manual(
160162
imaging=imaging_7x7,
161163
mask=sub_mask_7x7)
162164

165+
assert type(masked_imaging_7x7.psf) == kern.Kernel
163166
assert type(masked_imaging_7x7.convolver) == convolution.Convolver
164167

165168
def test__different_imaging_without_mock_objects__customize_constructor_inputs(
@@ -296,13 +299,14 @@ def test__masked_data(self, interferometer_7, sub_mask_7x7):
296299
).all()
297300
assert masked_interferometer_7.interferometer.uv_wavelengths[0, 0] == -55636.4609375
298301

299-
def test__transformer(self, interferometer_7, sub_mask_7x7):
302+
def test__primary_beam_and_transformer(self, interferometer_7, sub_mask_7x7):
300303

301304
masked_interferometer_7 = aa.masked_interferometer.manual(
302305
interferometer=interferometer_7,
303306
real_space_mask=sub_mask_7x7,
304307
)
305308

309+
assert type(masked_interferometer_7.primary_beam) == kern.Kernel
306310
assert type(masked_interferometer_7.transformer) == fourier_transform.Transformer
307311

308312
def test__different_interferometer_without_mock_objects__customize_constructor_inputs(

0 commit comments

Comments
 (0)