[Numpy-discussion] Please chime in on proposed methods for arrays

Colin J. Williams cjw at sympatico.ca
Thu Mar 17 04:10:16 EST 2005

Travis Oliphant wrote:

> One item I have not received a lot of feedback on is the new proposal 
> for a greatly increased number of methods on the ndarray.
> The current PEP has a listing of all the proposed methods and 
> attributes (some more were added after consulting current numarray in 
> more detail and looking at all the functions in current Numeric.py)
> If a function call essentially involved an arrayobject with some other 
> parameters then it was turned into a method.  

This seems a good idea.  I would suggest going a step further.  If a 
method has no parameters then make it a property and adopt the naming 
convention that the property names start with an upper case character, 
eg. Cos.  In other words, drop the redundant parentheses.

> If it involved two "equal" arrays then it was left as a function.  
> This is a somewhat arbitrary convention, and so I am asking for 
> suggestions as to what should be methods.

Why change from the above proposal?

> Should all the ufuncs be methods as well?  I think Konrad suggested 
> this.  What is the opinion of others?
Yes, modified as suggested above.

> The move from functions to methods will mean that some of the function 
> calls currently in Numeric.py will be redundant, but I think they 
> should stay there for backwards compatibility, (perhaps with a 
> deprecation warning...)

Yes, the same for numarray.  Deprecation, with dropping from some future 

> A final question:
> I think we need to think carefully about multidimensional indexing so 
> that it replaces current usage of take, put, putmask.
> For example, how, in numarray would you replace 
> take(a,[1,5,10],axis=-2)  if a is a 10x20x30 array? 
> Note that in this case take returns a 10x3x30 array  (call it g) with
> g[:,0,:] = a[:,1,:]
> g[:,1,:] = a[:,5,:]
> g[:,2,:] = a[:,10,:]
> I submit that a[...,[1,5,10],:] would be an appropriate syntax.    
> This would mean changing the current PEP a bit.

What is the benefit of the ellipsis here?  It seems to serve the same 
purpose as the colon.

Colin W.

> -Travis
> -------------------------------------------------------
> SF email is sponsored by - The IT Product Guide
> Read honest & candid reviews on hundreds of IT Products from real users.
> Discover which products truly live up to the hype. Start reading now.
> http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
> _______________________________________________
> Numpy-discussion mailing list
> Numpy-discussion at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/numpy-discussion

More information about the NumPy-Discussion mailing list