[Numpy-discussion] Bug in resize of structured array (with initial size = 0)

Nicolas Rougier Nicolas.Rougier at inria.fr
Fri Jan 10 12:37:38 EST 2014


I've tried to resize a record array that was first empty (on purpose, I need it)
and I got the following error (while it's working for regular array).

Traceback (most recent call last):
  File "test_resize.py", line 10, in <module>
    print np.resize(V,2)
  File "/usr/locaL/Cellar/python/2.7.6/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/numpy/core/fromnumeric.py", line 1053, in resize
    if not Na: return mu.zeros(new_shape, a.dtype.char)
TypeError: Empty data-type

I'm using numpy 1.8.0, python 2.7.6, osx 10.9.1.
Can anyone confirm before I submit an issue ?

Here is the script:

V = np.zeros(0, dtype=np.float32)
print V.dtype
print np.resize(V,2)

V = np.zeros(0, dtype=[('a', np.float32, 1)])
print V.dtype
print np.resize(V,2)

More information about the NumPy-Discussion mailing list