|
From: Francesc A. <fa...@ca...> - 2006-01-10 18:58:42
|
Hi,
Is there any plan to provide a conversion between recarrays in numpy
and numarray?. For the moment it does not seem to work:
In [83]: r=3Dnumarray.records.array([(1,11,'a'),(2,22,'b')], formats=3D'u1,=
f4,a1')
In [84]: a=3Dnumpy.array(r, dtype=3D'u1,f4,a1')
In [85]: numarray.records.array(a)
=2D------------------------------------------------------------------------=
=2D-
exceptions.ValueError Traceback (most recent=
=20
call last)
/tmp/<console>
/usr/lib/python2.3/site-packages/numarray-1.5.0-py2.3-linux-i686.egg/numarr=
ay/records.py=20
in array(buffer, formats, shape, names, byteorder, aligned)
406 byteorder=3Dbyteorder, aligned=3Daligned)
407 else:
=2D-> 408 raise ValueError("Unknown input type")
409
410 def _RecGetType(name):
ValueError: Unknown input type
In [86]: numpy.array(r)
Out[86]: array([0Aa, =B0Ab], dtype=3D(void,6))
However, if one specifies the format in for the numarray-->numpy it
does seem to work:
In [87]: numpy.array(r, dtype=3D'u1,f4,a1')
Out[87]: array([(1, 11.0, 'a'), (2, 22.0, 'b')], dtype=3D(void,6))
But not in the sense numpy-->numarray:
In [88]: numarray.records.array(a, formats=3D'u1,f4,a1')
=2D------------------------------------------------------------------------=
=2D-
exceptions.ValueError Traceback (most recent=
=20
call last)
/tmp/<console>
/usr/lib/python2.3/site-packages/numarray-1.5.0-py2.3-linux-i686.egg/numarr=
ay/records.py=20
in array(buffer, formats, shape, names, byteorder, aligned)
406 byteorder=3Dbyteorder, aligned=3Daligned)
407 else:
=2D-> 408 raise ValueError("Unknown input type")
409
410 def _RecGetType(name):
ValueError: Unknown input type
Having this would be great for supporting heterogeneous arrays in
PyTables.
Regards,
=2D-=20
>0,0< Francesc Altet =A0 =A0 http://www.carabos.com/
V V C=E1rabos Coop. V. =A0=A0Enjoy Data
"-"
|