adding an attribute to an nd-array
Travis Oliphant
oliphant at ee.byu.edu
Thu Oct 19 18:00:38 CDT 2006
Christopher Barker wrote:
>Travis Oliphant wrote:
>
>
>>Actually something as simple as
>>
>>class InfoArray(N.ndarray):
>> pass
>>
>>will allow you to add attributes to InfoArray.
>>
>>
>
>Well, sure, but how the heck do you initialize it?
>
>
You use the same constructor as ndarray has.
numpy.info(numpy.ndarray)
If you want an array-like function that produces the array, you do
array(obj).view(InfoArray)
or wrap that up in your own function.
There are many over-lapping ways to construct ndarray's. You can use
all of these ways to construct instances of your own type by getting the
ndarray and using the .view() method.
-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
More information about the Numpy-discussion
mailing list