[Numpy-discussion] numarray uses "rank" instead "ndim"
Travis Oliphant
oliphant at ee.byu.edu
Tue Jul 18 20:45:18 EDT 2006
Sebastian Haase wrote:
>Hi,
>(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
>arr.ndim
>
>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):
pass
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.
-Travis
More information about the NumPy-Discussion
mailing list