Skip to content

Commit b2dca8d

Browse files
committed
Make handling of extra and global coords by NDCube.to_nddata more general.
And docstring fix.
1 parent 361f887 commit b2dca8d

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

ndcube/ndcube.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1500,7 +1500,7 @@ def to_nddata(self,
15001500
Metadata object of new instance. Default is to use data of this instance.
15011501
psf: Any, optional
15021502
PSF object of new instance. Default is to use data of this instance.
1503-
extra_coords: `ndcubeextra_coords.ExtraCoordsABC`, optional
1503+
extra_coords: `ndcube.extra_coords.ExtraCoordsABC`, optional
15041504
Extra coords object of new instance. Default is to use data of this instance.
15051505
global_coords: `ndcube.global_coords.GlobalCoordsABC`, optional
15061506
WCS object of new instance. Default is to use data of this instance.
@@ -1545,9 +1545,11 @@ def to_nddata(self,
15451545
all_kwargs = {key.strip("_"): value for key, value in self.__dict__.items()}
15461546
all_kwargs.update(user_kwargs)
15471547
extra_coords, global_coords = None, None
1548-
if nddata_type is NDCube:
1549-
extra_coords = all_kwargs.pop("extra_coords")
1550-
global_coords = all_kwargs.pop("global_coords")
1548+
if issubclass(nddata_type, NDCubeBase):
1549+
if isinstance(all_kwargs["extra_coords"], ExtraCoordsABC):
1550+
extra_coords = all_kwargs.pop("extra_coords")
1551+
if isinstance(all_kwargs["global_coords"], GlobalCoordsABC):
1552+
global_coords = all_kwargs.pop("global_coords")
15511553
# Inspect call signature of new_nddata class and
15521554
# remove unsupported items from new_kwargs.
15531555
nddata_sig = inspect.signature(nddata_type).parameters.keys()

0 commit comments

Comments
 (0)