|
From: Francesc A. <fa...@ca...> - 2006-01-25 12:15:08
|
Hi,
This exposes a weird behaviour when building heterogeneous arrays in
numpy:
In [85]: xcol =3D numpy.ones((3,2), 'int32')
In [86]: numpy.array([(xcol[0],)], dtype=3D[('x','i4', (2,))])
Out[86]: array([(array([1, 1]),)], dtype=3D(void,8))
So far so good. Now:
In [89]: numpy.array([xcol], dtype=3D[('x','i4', (2,))])
<ERROR: expected a readable buffer object>
array([[[(array([-1208633192, -1208633192]),), (array([15, 15]),)],
[(array([ 0, 185]),), (array([ 18, -1208633016]),)],
[(array([480, 21]),), (array([21, 21]),)]]], dtype=3D(void,8))
While I'd expect:
In [89]: numpy.array([xcol], dtype=3D[('x','i4', (2,))])
Out[89]: array([(array([1, 1]),
(array([1, 1]),
(array([1, 1]))], dtype=3D(void,8))
Also, for the whishlist: It would be nice if one can specify the shape
of the array to be built in the factory itself. I mean, allowing
something like:
In [90]: numpy.array([xcol], dtype=3D[('x','i4', (2,))], shape=3D2)
Out[90]: array([(array([1, 1]),
(array([1, 1]))], dtype=3D(void,8))
Cheers,
=2D-=20
>0,0< Francesc Altet =A0 =A0 http://www.carabos.com/
V V C=E1rabos Coop. V. =A0=A0Enjoy Data
"-"
|