adding an attribute to an nd-array

Christopher Barker Chris.Barker at
Thu Oct 19 15:59:49 CDT 2006

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?

 >>> class InfoArray(N.ndarray):
...          pass
 >>> InfoArray((1,2,3))
InfoArray([[[  6.61855173e-306,               nan,   4.94708449e+173],
         [  3.32457336e-309,   1.08825491e+175,   2.12468326e-314]]])

InfoArray([[[  2.17854722e-305,   1.90979621e-313,   1.90979621e-313],
         [  1.90979621e-313,   1.90979621e-313,   1.03977794e-312]]])

I, for one, would like a very easy to subclass version of ndarray, maybe 
one that had a default constructor like numpy.array().

oh, and:

Charles R Harris wrote:
> I'd be more inclined to worry about speed. One of the drawbacks of 
> numarray was the time it took to create arrays. Since I  often use many 
> small arrays, numpy was a big improvement in that area.


keep basic arrays simple and lean.

Wasn't there one a UserArray class or something?


Christopher Barker, Ph.D.
NOAA/OR&R/HAZMAT         (206) 526-6959   voice
7600 Sand Point Way NE   (206) 526-6329   fax
Seattle, WA  98115       (206) 526-6317   main reception

Chris.Barker at

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

More information about the Numpy-discussion mailing list