[Numpy-discussion] Questions about the array interface.

Scott Gilbert xscottg at yahoo.com
Thu Apr 7 20:05:48 CDT 2005


--- Andrew Straw <strawman at astraw.com> wrote:
>
> Here's a bit of weirdness which has prevented me from using '<' or '>' 
> in the past with the struct module.  I'm not guru enough to know what's 
> going on, but it has prevented me from being explicit rather than
> implicit.
> 
> In [1]:import struct
> 
> In [2]:from numarray.ieeespecial import nan
> 
> In [3]:nan
> Out[3]:nan
> 
> In [4]:struct.pack('<d',nan)
>
---------------------------------------------------------------------------
> exceptions.SystemError                               Traceback (most 
> recent call last)
> 
> /home/astraw/<console>
> 
> SystemError: frexp() result out of range
> 
> In [5]:struct.pack('d',nan)
> Out[5]:'\x00\x00\x00\x00\x00\x00\xf8\xff'
> 


No clue why that is, but it certainly looks like a bug in the struct
module.  It shouldn't make any difference about whether or not the array
protocol reports the endian though.  It's using a different notation for
typecodes.


Cheers,
    -Scott





More information about the Numpy-discussion mailing list