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 ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys -- and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV _______________________________________________ Numpy-discussion mailing list Numpy-discussion@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/numpy-discussion