@@ -45,6 +45,19 @@ def __new__(
4545 obj .regions = regions .Regions (mask = obj )
4646 return obj
4747
48+ def __array_finalize__ (self , obj ):
49+
50+ if isinstance (obj , Mask ):
51+
52+ self .sub_size = obj .sub_size
53+ self .sub_length = obj .sub_length
54+ self .sub_fraction = obj .sub_fraction
55+ self .pixel_scales = obj .pixel_scales
56+ self .origin = obj .origin
57+ self .mapping = mapping .Mapping (mask = obj )
58+ self .geometry = geometry .Geometry (mask = obj )
59+ self .regions = regions .Regions (mask = obj )
60+
4861 @classmethod
4962 def manual (cls , mask_2d , pixel_scales = None , sub_size = 1 , origin = (0.0 , 0.0 ), invert = False ):
5063
@@ -127,8 +140,9 @@ def circular_annular(cls, shape_2d, inner_radius_arcsec, outer_radius_arcsec, pi
127140 The centre of the annulus used to mask pixels.
128141 """
129142
130- if type (pixel_scales ) is float :
131- pixel_scales = (pixel_scales , pixel_scales )
143+ if type (pixel_scales ) is not tuple :
144+ if type (pixel_scales ) is float or int :
145+ pixel_scales = (float (pixel_scales ), float (pixel_scales ))
132146
133147 mask_2d = mask_util .mask_2d_circular_annular_from_shape_2d_pixel_scales_and_radii (
134148 shape_2d = shape_2d ,
@@ -170,8 +184,9 @@ def circular_anti_annular(cls, shape_2d, inner_radius_arcsec, outer_radius_arcse
170184 The centre of the anti-annulus used to mask pixels.
171185 """
172186
173- if type (pixel_scales ) is float :
174- pixel_scales = (pixel_scales , pixel_scales )
187+ if type (pixel_scales ) is not tuple :
188+ if type (pixel_scales ) is float or int :
189+ pixel_scales = (float (pixel_scales ), float (pixel_scales ))
175190
176191 mask_2d = mask_util .mask_2d_circular_anti_annular_from_shape_2d_pixel_scales_and_radii (
177192 shape_2d = shape_2d ,
@@ -210,8 +225,9 @@ def elliptical(cls, shape_2d,
210225 The centre of the ellipse used to mask pixels.
211226 """
212227
213- if type (pixel_scales ) is float :
214- pixel_scales = (pixel_scales , pixel_scales )
228+ if type (pixel_scales ) is not tuple :
229+ if type (pixel_scales ) is float or int :
230+ pixel_scales = (float (pixel_scales ), float (pixel_scales ))
215231
216232 mask_2d = mask_util .mask_2d_elliptical_from_shape_2d_pixel_scales_and_radius (
217233 shape_2d = shape_2d ,
@@ -261,8 +277,9 @@ def elliptical_annular(cls, shape_2d,
261277 The centre of the elliptical annuli used to mask pixels.
262278 """
263279
264- if type (pixel_scales ) is float :
265- pixel_scales = (pixel_scales , pixel_scales )
280+ if type (pixel_scales ) is not tuple :
281+ if type (pixel_scales ) is float or int :
282+ pixel_scales = (float (pixel_scales ), float (pixel_scales ))
266283
267284 mask_2d = mask_util .mask_2d_elliptical_annular_from_shape_2d_pixel_scales_and_radius (
268285 shape_2d = shape_2d ,
@@ -295,8 +312,9 @@ def from_fits(cls, file_path, hdu, pixel_scales, sub_size, origin=(0.0, 0.0)):
295312 The arc-second to pixel conversion factor of each pixel.
296313 """
297314
298- if type (pixel_scales ) is float :
299- pixel_scales = (pixel_scales , pixel_scales )
315+ if type (pixel_scales ) is not tuple :
316+ if type (pixel_scales ) is float or int :
317+ pixel_scales = (float (pixel_scales ), float (pixel_scales ))
300318
301319 return cls (
302320 array_util .numpy_array_2d_from_fits (file_path = file_path , hdu = hdu ),
0 commit comments