[Numpy-discussion] endianness ufuncs

Hugo numpy@hugo.doemaarwat...
Fri Apr 13 05:24:59 CDT 2007


Hi,

As as astronomer I work with big endian arrays (pyfits 1.1rc1 with numpy 
1.0) on little endian machines. When I try to make a ufunc (e.g. to 
convert from degrees to radians), it doesn't recognize the big endianness:

In [3]: big = numpy.array([83.4, 83.5, 83.9], dtype='>f8')
In [4]: uradians = numpy.frompyfunc(math.radians, 1, 1)
In [6]: uradians(big)
Out[6]: array([-2.6919063283e-182, 1.26773292198e-318, 
-2.69190632908e-182], dtype=object)

I cannot figure out whether this is the intended behavior but it sure is 
counterintuitive, since most of the time numpy handles the endianness 
transparently.

For now I'm happy with just converting everything to native (little) 
endian at the start of my calculations and convert them back in the end. 
(Although I'm not sure what's the best way to do that yet.)

Hugo


More information about the Numpy-discussion mailing list