numpy.save bug on solaris x86 w/ nans and objects

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

numpy.save bug on solaris x86 w/ nans and objects

John Hunter-4
I have a record array w/ dates (O4) and floats.  If some of these
floats are NaN, np.save crashes (on my solaris platform but not on a
linux machine I tested on).  Here is the code that produces the bug:

In [1]: pwd
Out[1]: '/home/titan/johnh/python/svn/matplotlib/matplotlib/examples/data'

In [2]: import matplotlib.mlab as mlab

In [3]: import numpy as np

In [4]: r = mlab.csv2rec('aapl.csv')

In [5]: r.dtype
Out[5]: dtype([('date', '|O4'), ('open', '<f8'), ('high', '<f8'),
('low', '<f8'), ('close', '<f8'), ('volume', '<i4'), ('adj_close',
'<f8')])

In [6]: r.close[100:] = np.nan

In [7]: r.close
Out[7]: array([ 124.63,  127.46,  129.4 , ...,     NaN,     NaN,     NaN])

In [8]: np.save('mydata.npy', r)
------------------------------------------------------------
Traceback (most recent call last):
 File "<ipython console>", line 1, in ?
 File "/home/titan/johnh/dev/lib/python2.4/site-packages/numpy/lib/io.py",
line 158, in save
   format.write_array(fid, arr)
 File "/home/titan/johnh/dev/lib/python2.4/site-packages/numpy/lib/format.py",
line 272, in write_array
   cPickle.dump(array, fp, protocol=2)
SystemError: frexp() result out of range


In [9]: np.__version__
Out[9]: '1.2.0.dev5136'

In [10]: !uname -a
SunOS flag 5.10 Generic_118855-15 i86pc i386 i86pc
_______________________________________________
Numpy-discussion mailing list
[hidden email]
http://projects.scipy.org/mailman/listinfo/numpy-discussion
Reply | Threaded
Open this post in threaded view
|

Re: numpy.save bug on solaris x86 w/ nans and objects

Charles R Harris


On Tue, May 20, 2008 at 10:57 AM, John Hunter <[hidden email]> wrote:
I have a record array w/ dates (O4) and floats.  If some of these
floats are NaN, np.save crashes (on my solaris platform but not on a
linux machine I tested on).  Here is the code that produces the bug:

In [1]: pwd
Out[1]: '/home/titan/johnh/python/svn/matplotlib/matplotlib/examples/data'

In [2]: import matplotlib.mlab as mlab

In [3]: import numpy as np

In [4]: r = mlab.csv2rec('aapl.csv')

In [5]: r.dtype
Out[5]: dtype([('date', '|O4'), ('open', '<f8'), ('high', '<f8'),
('low', '<f8'), ('close', '<f8'), ('volume', '<i4'), ('adj_close',
'<f8')])

In [6]: r.close[100:] = np.nan

In [7]: r.close
Out[7]: array([ 124.63,  127.46,  129.4 , ...,     NaN,     NaN,     NaN])

In [8]: np.save('mydata.npy', r)
------------------------------------------------------------
Traceback (most recent call last):
 File "<ipython console>", line 1, in ?
 File "/home/titan/johnh/dev/lib/python2.4/site-packages/numpy/lib/io.py",
line 158, in save
  format.write_array(fid, arr)
 File "/home/titan/johnh/dev/lib/python2.4/site-packages/numpy/lib/format.py",
line 272, in write_array
  cPickle.dump(array, fp, protocol=2)
SystemError: frexp() result out of range


In [9]: np.__version__
Out[9]: '1.2.0.dev5136'

In [10]: !uname -a
SunOS flag 5.10 Generic_118855-15 i86pc i386 i86pc

Looks like we need to add a test for this before release. But I'm off to work.

Chuck



_______________________________________________
Numpy-discussion mailing list
[hidden email]
http://projects.scipy.org/mailman/listinfo/numpy-discussion
Reply | Threaded
Open this post in threaded view
|

Re: numpy.save bug on solaris x86 w/ nans and objects

John Hunter-4
On Tue, May 20, 2008 at 12:13 PM, Charles R Harris
<[hidden email]> wrote:

> Looks like we need to add a test for this before release. But I'm off to
> work.

Here's a simpler example in case you want to wrap it in a test harness:

import datetime
import numpy as np

r = np.rec.fromarrays([
    [datetime.date(2007,1,1), datetime.date(2007,1,2), datetime.date(2007,1,2)],
    [.1, .2, np.nan],
    ], names='date,value')


np.save('mytest.npy', r)
_______________________________________________
Numpy-discussion mailing list
[hidden email]
http://projects.scipy.org/mailman/listinfo/numpy-discussion