[Numpy-discussion] Questions about the array interface.

Robert Kern rkern at ucsd.edu
Thu Apr 7 20:24:38 CDT 2005


Scott Gilbert wrote:
> --- 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.

This behavior is expplained by Tim Peters:

http://groups-beta.google.com/group/comp.lang.python/msg/16dbf848c050405a

-- 
Robert Kern
rkern at ucsd.edu

"In the fields of hell where the grass grows high
  Are the graves of dreams allowed to die."
   -- Richard Harter




More information about the Numpy-discussion mailing list