[Numpy-discussion] Extensive use of methods instead of functions

Chris Barker Chris.Barker at noaa.gov
Tue Jan 28 11:02:04 EST 2003


Konrad Hinsen wrote:
> > M = array(l)
> > Mt = M.transpose()
> >
> > just isn't that much worse than:
> >
> > Mt = transpose(l)
> 
> No, but the automatic conversion enables me to write functions that
> accept any sequence type without even having to think about it.

I've used that to, but I also frequently use something like this:

def function(A):
	A = array(A)
	...

Which is pretty simple to. 

> Moreover, it is almost essential in many situations to accept scalars
> in place of arrays, because scalars fulfill the role of rank-0 arrays.

Yes, this is critical. Isn't there a plan to make the scalar -- rank-0
array dicotomy a little cleaner in NumArray ?
 
> > I also agree that the point is not subclassing per se, it's
> > polymorphism. It should be easy to write a class that acts like an array
> > in all the ways that you need it to. 
> 
> True, and that is a weak point of NumPy.

Is this getting any better with NumArray?
 

-Chris



-- 
Christopher Barker, Ph.D.
Oceanographer
                                    		
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 noaa.gov




More information about the NumPy-Discussion mailing list