Skip to content

Make the check for single precision data insensitive to byte-order.

Martin Shepherd requested to merge fix_64bit_conversion into master

When astropy.fitsio.fits reads a single-precision floating-point data array from a FITS extension, it returns it in a numpy.ndarray of dtype np.dtype(">f4") (big-endian 32-bit float) rather than np.float32, which is little-endian. For this reason, the check that tested whether the data needed to be converted to np.float64, failed, because it was comparing dtype to np.float32. The data array thus remained 32-bit, and subsequent calculations on this array were all being performed in single precision. This patch changes the test to make it independent of byte order. It now detects when fitsio returns either little-endian or big-endian arrays of 32-bit floats, and converts both of them to np.float64.

Merge request reports