-1

An error showed up recently on a new system I am using when I want to create simple BinTableHDU with astropy.

Here is the code I setup to isolate the problem :

import astropy.io.fits as pyfits 
ar = numpy.array(range(100))
col = pyfits.Column(name='TEST', array=ar, format='D')
cdef = pyfits.ColDefs([col])
hdu = pyfits.BinTableHDU.from_columns(cdef)
hdu.writeto("test.fits")
pyfits.getdata("test.fits")

I get this error :

AttributeError: 'record' object has no attribute '_coldefs'

I use astropy 2.0.2 with python 3.6.3.

Any idea to solve this problem ?

[EDIT:] when run in a script, an explicit access to the data is needed to trigger the error :

print(pyfits.getdata("test.fits"))
Iguananaut
  • 21,810
  • 5
  • 50
  • 63
akira
  • 31
  • 6

2 Answers2

2

This is a bug that was fixed in Astropy v2.0.3: https://github.com/astropy/astropy/pull/6955

There should also be newer Astropy releases available on conda.

Iguananaut
  • 21,810
  • 5
  • 50
  • 63
-1

I got a bit forward. My astropy is from an anaconda installation. When I use my regular python libs (no anaconda), I don't get any error reading the test.fits. So the problem was in reading the test.fits, not in writing it.

akira
  • 31
  • 6