[Numpy-discussion] tried to set void-array with object members using buffer error message

ctw lists.20.chth at xoxy.net
Sat Nov 8 19:35:41 EST 2008


Hi! Can someone here shed some light on this behavior:

> tst = np.zeros(2,[('a',np.int32),('b','S04')])
> np.random.shuffle(tst) # this works fine

> tst2 = np.zeros(2,[('a',np.int32),('b',list)])
> np.random.shuffle(tst2)
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)

/home/ctw/<ipython console> in <module>()

/home/ctw/mtrand.pyx in mtrand.RandomState.shuffle()

ValueError: tried to set void-array with object members using buffer.





I get the same error if I use np.ndarray instead of list. Also, when I
put in a class I locally define I get a "data type not understood"
error:

> class tstcls:
>    pass

> tst4 = np.zeros(2,[('a',np.int32),('b',tstcls)])
<class __main__.tstcls at
0x944a7dc>---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)

/home/ctw/<ipython console> in <module>()

TypeError: data type not understood



More information about the NumPy-Discussion mailing list