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
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
9 hdu = fits.GroupsHDU(x)
10 hdu.writeto(tempfile.TemporaryFile(mode='wb'))
---> 11 hdu.data[:2]
\astropy\io\fits\hdu\groups.py in __getitem__(self, key)
210
211 def __getitem__(self, key):
--> 212 out = super().__getitem__(key)
213 if isinstance(out, GroupData):
214 out.parnames = self.parnames
\astropy\io\fits\fitsrec.py in __getitem__(self, key)
494 # Store the new arrays for the _coldefs object
495 #
--> 496 arrays.append(self._coldefs._arrays[idx][key])
497
498 # Ensure that the sliced FITS_rec will view the same scaled
TypeError: 'NoneType' object is not subscriptable
But it works if one writes it to a file and then slices the read file:
hdu.writeto('tmp_groups.fits')
with fits.open('tmp_groups.fits') as hdul:
hdul[0].data[:2]
Looks like a bug to me. Also, when I append hdu to a HDUList without writing to a file, the info() is different from the one read in from a file:
Filename: (No file associated with this HDUList)
No. Name Ver Type Cards Dimensions Format
0 PRIMARY 1 GroupsHDU 15 (5, 3, 1, 1) float32 1 Groups 0 Parameters
Filename: tmp_groups.fits
No. Name Ver Type Cards Dimensions Format
0 PRIMARY 1 GroupsHDU 15 (5, 3, 1, 1) float32 10 Groups 3 Parameters
Yep, looks real, the code probably needs to be updated to cope with the ColDefs -> _arrays references and follow what has been done for hdu/table.py.
In [26]: hdu.data.columns
Out[26]:
ColDefs(
name = 'abc'; format = 'E'
name = 'xyz'; format = 'E'
name = '_xyz'; format = 'E'
name = 'DATA'; format = 'E'
)
In [27]: hdu.data.columns._arrays
Out[27]: [None, None, None, None]
In [28]: hdu.data.columns[0]
Out[28]: name = 'abc'; format = 'E'
In [29]: hdu.data.columns[0].array
In [30]: hdu.data.columns[0].array is None
Out[30]: True
Activity
pllim commentedon Oct 9, 2017
Looks like a bug to me. Also, when I append
hduto aHDUListwithout writing to a file, theinfo()is different from the one read in from a file:saimn commentedon Dec 12, 2017
Yep, looks real, the code probably needs to be updated to cope with the
ColDefs->_arraysreferences and follow what has been done forhdu/table.py.