On Fri, Oct 9, 2015 at 10:32 PM, Phillip Feldman <
phillip.m.feld...@gmail.com> wrote:

> Hello Nathaniel,
>
> It is hard to say what is normative practice with NumPy, because there are
> at least three paradigms:
>
> (1) Some operations are implemented as methods of the `ndarray` class.
> `sum` and `mean` are examples.
>
> (2) Some operations are implemented via functions that invoke a private
> method of the class.  `abs` is an example of this:
>
> In [8]: x= array([1+1J])
> In [9]: x.__abs__()
> Out[9]: array([ 1.41421356])
>
> (3) Some operations are implemented as functions that operate directly on
> the array, e.g., RMS (root-mean-square).
>
> Because calculating the square of the magnitude is such a widely-used
> operation, and is often done in a grossly inefficient manner (e.g., by
> taking the absolute value, which involves a square-root, and then
> squaring), I believe that there is a strong argument for doing either (1)
> or (2).  I'd prefer (1).
>
>
We tend to avoid adding methods. 2) would be a very easy enhancement, just
a slight modification of sqr.

Chuck
_______________________________________________
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
https://mail.scipy.org/mailman/listinfo/numpy-discussion

Reply via email to