Skip to content

Commit 3001645

Browse files
authored
Merge pull request #694 from Cadair/fix_init_stuff
Fix some issues in `NDCube.__init__`
2 parents ba1d208 + 3be8b27 commit 3001645

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

ndcube/ndcube.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -368,12 +368,8 @@ class NDCubeBase(NDCubeABC, astropy.nddata.NDData, NDCubeSlicingMixin):
368368
def __init__(self, data, wcs=None, uncertainty=None, mask=None, meta=None,
369369
unit=None, copy=False, **kwargs):
370370

371-
super().__init__(data, uncertainty=uncertainty, mask=mask,
371+
super().__init__(data, wcs=wcs, uncertainty=uncertainty, mask=mask,
372372
meta=meta, unit=unit, copy=copy, **kwargs)
373-
if not self.wcs:
374-
self.wcs = wcs # This line is required as a patch for an astropy bug.
375-
# Above line is in if statement to prevent WCS being overwritten with None
376-
# if we are instantiating from an NDCube.
377373

378374
# Enforce that the WCS object is not None
379375
if self.wcs is None:
@@ -1212,8 +1208,14 @@ def my_propagate(uncertainty, data, mask, **kwargs):
12121208
new_wcs = ResampledLowLevelWCS(self.wcs.low_level_wcs, bin_shape[::-1])
12131209

12141210
# Reform NDCube.
1215-
new_cube = type(self)(new_data, new_wcs, uncertainty=new_uncertainty, mask=new_mask,
1216-
meta=self.meta, unit=new_unit)
1211+
new_cube = type(self)(
1212+
data=new_data,
1213+
wcs=new_wcs,
1214+
uncertainty=new_uncertainty,
1215+
mask=new_mask,
1216+
meta=self.meta,
1217+
unit=new_unit
1218+
)
12171219
new_cube._global_coords = self._global_coords
12181220
# Reconstitute extra coords
12191221
if not self.extra_coords.is_empty:

0 commit comments

Comments
 (0)