[Numpy-discussion] numarray uses "rank" instead "ndim"

Travis Oliphant oliphant at ee.byu.edu
Tue Jul 18 19:45:18 CDT 2006

Sebastian Haase wrote:

>(Thanks to Travis and Todd for answering my last "dot"-question)
>I'm trying to adjust my numarray based code to also run with numpy.
>It seems that a (maybe the only left) problem is that numarray had
>arr.rank  giving the value of len(arr.shape)
>while in numpy this is now called 
>Is the "ndim" attribute already added in the CVS version (just now I could not 
>connect to the CVS server) ?  Or else, could it be added to numarray to ease 
>the transition !?
>Another way might be to go back to len(arr.shape)  - but that would be quite 
>ugly ...
>Also I noted that a numpy array object does not allow "sticking" a new 
>attribute into it: In numarray I could just say arr.xyz0='test'  like with 
>any (simple) Python object - in numpy I get an
>AttributeError: 'numpy.ndarray' object has no attribute 'xyz0'
Why don't you try using a simple sub-class of numpy's ndarray

class myarray(numpy.ndarray):

That way your new array can look like a numarray array object and have 
the same methods and attributes.  I've thought about even adding 
something like this to the numarray directory. 



More information about the Numpy-discussion mailing list