- changed status to resolved
np.load fails because np.frombuffer is None
Issue #8
resolved
Using PyPy 2.3 installed via pyenv, np.load fails when trying to read data because it makes use of np.frombuffer which is None
. Setting np.frombuffer equal to np.fromstring is a workaround.
Numpy instaled via pip install git+https://bitbucket.org/pypy/numpy.git
.
Output of python --version:
$ python --version
Python 2.7.6 (394146e9bb67, May 08 2014, 17:08:54)
[PyPy 2.3.0 with GCC 4.6.3]
IPython log:
# IPython log file
get_ipython().magic(u'pinfo %save')
get_ipython().magic(u'quickref')
get_ipython().magic(u'pinfo %logstart')
import numpy as np
np.load('tests/lena.npz').keys()
#[Out]# ['lena']
np.load('tests/lena.npz')['lena']
repr(np.frombuffer)
#[Out]# 'None'
np.frombuffer = np.fromstring
np.load('tests/lena.npz')['lena']
#[Out]# array([[ 0.63529414, 0.63529414, 0.63529414, ..., 0.66666669,
#[Out]# 0.60784316, 0.50196081],
#[Out]# [ 0.63529414, 0.63529414, 0.63529414, ..., 0.66666669,
#[Out]# 0.60784316, 0.50196081],
#[Out]# [ 0.63529414, 0.63529414, 0.63529414, ..., 0.66666669,
#[Out]# 0.60784316, 0.50196081],
#[Out]# ...,
#[Out]# [ 0.16862746, 0.16862746, 0.19607843, ..., 0.40784314,
#[Out]# 0.39215687, 0.38431373],
#[Out]# [ 0.17254902, 0.17254902, 0.21568628, ..., 0.40784314,
#[Out]# 0.41176471, 0.42352942],
#[Out]# [ 0.17254902, 0.17254902, 0.21568628, ..., 0.40784314,
#[Out]# 0.41176471, 0.42352942]], dtype=float32)
get_ipython().magic(u'logstop')
Exception and traceback:
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-5-95e5d6d28212> in <module>()
----> 1 np.load('tests/lena.npz')['lena']
/users/rjw57/projects/dtcwt/venv-pypy/site-packages/numpy/lib/npyio.pyc in __getitem__(self, key)
248 if magic == format.MAGIC_PREFIX:
249 bytes = self.zip.open(key)
--> 250 return format.read_array(bytes)
251 else:
252 return self.zip.read(key)
/users/rjw57/projects/dtcwt/venv-pypy/site-packages/numpy/lib/format.pyc in read_array(fp)
466 data = _read_bytes(fp, read_size, "array data")
467 array[i:i+read_count] = numpy.frombuffer(data, dtype=dtype,
--> 468 count=read_count)
469
470 if fortran_order:
TypeError: 'NoneType' object is not callable
Comments (1)
-
- Log in to comment
frombuffer was fixed May 23, 2014 -- should work with any pypy newer than this.