[Numpy-discussion] Conversion of heterogeneous arrays in numpy<-->numarray

Perry Greenfield perry at stsci.edu
Tue Jan 10 11:21:06 CST 2006


I think it would be a good thing, but right now we are more focused on  
seeing what is involved in porting some of our libraries first. I'll  
try to find out how much work it would be though.

Perry

On Jan 10, 2006, at 1:58 PM, Francesc Altet wrote:

> 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=numarray.records.array([(1,11,'a'),(2,22,'b')],  
> formats='u1,f4,a1')
>
> In [84]: a=numpy.array(r, dtype='u1,f4,a1')
>
> In [85]: numarray.records.array(a)
> ----------------------------------------------------------------------- 
> ----
> exceptions.ValueError                                Traceback (most  
> recent
> call last)
>
> /tmp/<console>
>
> /usr/lib/python2.3/site-packages/numarray-1.5.0-py2.3-linux-i686.egg/ 
> numarray/records.py
> in array(buffer, formats, shape, names, byteorder, aligned)
>     406                     byteorder=byteorder, aligned=aligned)
>     407     else:
> --> 408         raise ValueError("Unknown input type")
>     409
>     410 def _RecGetType(name):
>
> ValueError: Unknown input type
>
> In [86]: numpy.array(r)
> Out[86]: array([0Aa, °Ab], dtype=(void,6))
>
> However, if one specifies the format in for the numarray-->numpy it
> does seem to work:
>
> In [87]: numpy.array(r, dtype='u1,f4,a1')
> Out[87]: array([(1, 11.0, 'a'), (2, 22.0, 'b')], dtype=(void,6))
>
> But not in the sense numpy-->numarray:
>
> In [88]: numarray.records.array(a, formats='u1,f4,a1')
> ----------------------------------------------------------------------- 
> ----
> exceptions.ValueError                                Traceback (most  
> recent
> call last)
>
> /tmp/<console>
>
> /usr/lib/python2.3/site-packages/numarray-1.5.0-py2.3-linux-i686.egg/ 
> numarray/records.py
> in array(buffer, formats, shape, names, byteorder, aligned)
>     406                     byteorder=byteorder, aligned=aligned)
>     407     else:
> --> 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,
>
> -- 
>> 0,0<   Francesc Altet     http://www.carabos.com/
> V   V   Cárabos Coop. V.   Enjoy Data
>  "-"
>
>
>
> -------------------------------------------------------
> This SF.net email is sponsored by: Splunk Inc. Do you grep through log  
> files
> for problems?  Stop!  Download the new AJAX search engine that makes
> searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
> http://ads.osdn.com/?ad_idv37&alloc_id865&op=click
> _______________________________________________
> Numpy-discussion mailing list
> Numpy-discussion at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/numpy-discussion





More information about the Numpy-discussion mailing list