You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When trying to deep copy a 0-d WCS, an obscure error occurs. We should either disallow 0-d WCSes from being created in .sub, or gracefully deep copy the 0-d WCS.
Expected behavior
The deep copy should work or the .sub call should fail because it results in a 0-d WCS.
How to Reproduce
In [1]: fromastropy.wcsimportWCS, WCSSUB_SPECTRALIn [2]: wcs=WCS(naxis=2)
In [3]: wcs_sub=wcs.sub([WCSSUB_SPECTRAL])
In [4]: wcs_sub.deepcopy()
---------------------------------------------------------------------------RuntimeErrorTraceback (mostrecentcalllast)
CellIn[4], line1---->1wcs_sub.deepcopy()
File~/python/dev/lib/python3.11/site-packages/astropy/wcs/wcs.py:653, inWCS.deepcopy(self)
646defdeepcopy(self):
647""" 648 Return a deep copy of the object. 649 650 Convenience method so user doesn't have to import the 651 :mod:`copy` stdlib module. 652 """-->653returncopy.deepcopy(self)
File/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/copy.py:153, indeepcopy(x, memo, _nil)
151copier=getattr(x, "__deepcopy__", None)
152ifcopierisnotNone:
-->153y=copier(memo)
154else:
155reductor=dispatch_table.get(cls)
File~/python/dev/lib/python3.11/site-packages/astropy/wcs/wcs.py:626, inWCS.__deepcopy__(self, memo)
620new_copy=self.__class__()
621new_copy.naxis=deepcopy(self.naxis, memo)
622WCSBase.__init__(
623new_copy,
624deepcopy(self.sip, memo),
625 (deepcopy(self.cpdis1, memo), deepcopy(self.cpdis2, memo)),
-->626deepcopy(self.wcs, memo),
627 (deepcopy(self.det2im1, memo), deepcopy(self.det2im2, memo)),
628 )
629forkey, valinself.__dict__.items():
630new_copy.__dict__[key] =deepcopy(val, memo)
File/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/copy.py:153, indeepcopy(x, memo, _nil)
151copier=getattr(x, "__deepcopy__", None)
152ifcopierisnotNone:
-->153y=copier(memo)
154else:
155reductor=dispatch_table.get(cls)
RuntimeError: NULLerrorobjectinwcslib
Description
When trying to deep copy a 0-d WCS, an obscure error occurs. We should either disallow 0-d WCSes from being created in
.sub
, or gracefully deep copy the 0-d WCS.Expected behavior
The deep copy should work or the
.sub
call should fail because it results in a 0-d WCS.How to Reproduce
Versions
The text was updated successfully, but these errors were encountered: