Erin Sheldon wrote:
> Just tested the lastest SVN and it works as advertised. Thanks
> Travis.
>
> An unrelated question: why does this work for arrays but not recarrays?
>
>
> In [24]: mydescriptor =
> [('age',float64),('Nchildren',int8),('weight',float32)]
>
> In [25]: a = array([(64,2,75.0),(25,0,60.0)], dtype=mydescriptor)
>
> In [26]: a = recarray([(64,2,75.0),(25,0,60.0)], dtype=mydescriptor)
> ---------------------------------------------------------------------------
> exceptions.TypeError Traceback (most recent
> call last)
>
> /Users/esheldon/<ipython console>
>
> TypeError: __new__() got an unexpected keyword argument 'dtype'
>
> I understand that I could use the formats and names keywords, but
> this seems a little inconsistent.
>
>
Well there are a couple of reasons this doesn't work.
1) the recarray constructor is similar to the ndarray constructor.
Neither of these take list arguments as inputs. So, while I've added
dtype as the
keyword for the formats input of the recarray constructor, the second
example will still fail.
2) Even were you to use the rec.array function (which is analagous to
the numpy.array function) to produce the error, it does not take a dtype
keyword.
This is inconsistent. But, the interface for the record array class
came from numarray. I tried to stay compatible with those functions so
the numarray people would have an easier time adapting.
Perhaps we should add a dtype keyword argument to all the
constructors in numpy/core/records.py which over-rides the formats,
names, and titles keywords so that you could do
a = rec.array([...], dtype=mine)
analgously to
a = array([...], dtype=mine)
-Travis
-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Numpy-discussion mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/numpy-discussion