[Numpy-discussion] new __wrap_array__ magic method

Sebastien.deMentendeHorne at electrabel.com Sebastien.deMentendeHorne at electrabel.com
Fri Aug 12 02:03:05 EDT 2005


> 
> > __wrap_array__(self, ufunc): # all unary operators like 
> __neg__, __abs__, __invert__
> > __lwrap_array__(self, other, ufunc): # all binary operators 
> called with self on the lhs like __add__, __mul__, __pow__
> > __rwrap_array__(self, other, ufunc): # all binary operators 
> called with self on the rhs like __radd__, __rmul__, __rpow__
> 
> The term "wrap_array" doesn't seem very descriptive of
> what these are for. Wrapping of arrays may come into the
> implementations of them, but it's not the main point.
> The point is to apply a ufunc to the object and get
> an appropriate result.
> 
> Maybe just __ufunc__, __lufunc__, __rufunc__?

Definitely ! I came first with a function that was more similar to __array__ and so __wrap_array__ seemed a plausible name for this function.
Afterward, I changed a bit the role of this function to propose the alternative way and your names are way more adequate (it may be useful to add the unary/binary word in the function like:

__unary_ufunc__
__binary_lufunc__
__binary_rufunc__

as it does not map exactly to __add__, __radd__ and people could mix __ufunc__ and __rufunc__ without understanding the __lufunc__...


> 
> -- 
> Greg Ewing, Computer Science Dept, 
> +--------------------------------------+
> University of Canterbury,	   | A citizen of 
> NewZealandCorp, a	  |
> Christchurch, New Zealand	   | wholly-owned subsidiary of 
> USA Inc.  |
> greg.ewing at canterbury.ac.nz	   
+--------------------------------------+
> 
> 
> -------------------------------------------------------
> SF.Net email is Sponsored by the Better Software Conference & EXPO
> September 19-22, 2005 * San Francisco, CA * Development 
> Lifecycle Practices
> Agile & Plan-Driven Development * Managing Projects & Teams * 
> Testing & QA
> Security * Process Improvement & Measurement * 
> http://www.sqe.com/bsce5sf
> _______________________________________________
> Numpy-discussion mailing list
> Numpy-discussion at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/numpy-discussion
> 


=======================================================
This message is confidential. It may also be privileged or otherwise protected by work product immunity or other legal rules. If you have received it by mistake please let us know by reply and then delete it from your system; you should not copy it or disclose its contents to anyone. All messages sent to and from Electrabel may be monitored to ensure compliance with internal policies and to protect our business. Emails are not secure and cannot be guaranteed to be error free as they can be intercepted, amended, lost or destroyed, or contain viruses. Anyone who communicates with us by email is taken to accept these risks.

http://www.electrabel.be/homepage/general/disclaimer_EN.asp
=======================================================





More information about the NumPy-Discussion mailing list