[Numpy-discussion] Load numarray with specific shape cause error

Vincent Picavet Vincent.Picavet at inria.fr
Fri Feb 4 01:38:59 CST 2005


Hi,
Here is what I launch in the Python interpreter :
----
import numarray
simulation_file = "/path/to/my/file.bin"
a = numarray.fromfile(simulation_file, 'Float32',(3144, 33, 65))
a.sum() 
----

And here I get the following error :

----
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
  File
"/nfs/data2/picavet/workspace/softs/python/lib/python2.4/site-packages/
numarray/numarraycore.py", line 1133, in sum    return
ufunc.add.reduce(ufunc.add.areduce(self, type=type).flat, type=type)
libnumarray.error: add_Float64_reduce: access beyond buffer.
offset=25151 buffersize=17160
----

Just after that, I execute :
----
a.sum()
588108255.50844395
a.mean()
87.206215933326803
----

... and as you can see I got no error the second time.
The binary file I try to load is a raw file of 3144*33*64
4-Bytes float elements.

In fact I just saw that if I use the shape (65,33,3144) when calling
fromfile(), everything works just fine. And after having called a.sum()
the first time, the shape of the array has been changed.

----
>>> a.getshape()
(3144, 65, 33)
>>> a.sum()
Traceback (most recent call last):
[snip, same as above]
>>> a.getshape()
(33, 65, 3144)
----

Any idea why I can't load an array with such a shape ?

I use Python 2.4 and the latest version of numarray.
Python 2.4 (#1, Jan 27 2005, 15:21:15)
[GCC 3.2.2 20030222 (Red Hat Linux 3.2.2-5)] on linux2

Thanks,
Vincent



-- 
Vincent Picavet,		Tel : +33 (0) 1 39 63 52 14	
INRIA Rocquencourt,		E-mail : vincent.picavet at inria.fr
Projet CLIME			http://www-rocq.inria.fr/clime	




More information about the Numpy-discussion mailing list