[Numpy-discussion] Adding .abs() method to the array object

Benjamin Root ben.root@ou....
Sat Feb 23 20:34:34 CST 2013

On Sat, Feb 23, 2013 at 8:20 PM, <josef.pktd@gmail.com> wrote:

> On Sat, Feb 23, 2013 at 3:33 PM, Robert Kern <robert.kern@gmail.com>
> wrote:
> > On Sat, Feb 23, 2013 at 7:25 PM, Nathaniel Smith <njs@pobox.com> wrote:
> >> On Sat, Feb 23, 2013 at 3:38 PM, Till Stensitzki <mail.till@gmx.de>
> wrote:
> >>> Hello,
> >>> i know that the array object is already crowded, but i would like
> >>> to see the abs method added, especially doing work on the console.
> >>> Considering that many much less used functions are also implemented
> >>> as a method, i don't think adding one more would be problematic.
> >>
> >> My gut feeling is that we have too many methods on ndarray, not too
> >> few, but in any case, can you elaborate? What's the rationale for why
> >> np.abs(a) is so much harder than a.abs(), and why this function and
> >> not other unary functions?
> >
> > Or even abs(a).
> my reason is that I often use
> arr.max()
> but then decide I want to us abs and need
> np.max(np.abs(arr))
> instead of arr.abs().max() (and often I write that first to see the
> error message)
> I don't like
> np.abs(arr).max()
> because I have to concentrate to much on the braces, especially if arr
> is a calculation
> I wrote several times
> def maxabs(arr):
>     return np.max(np.abs(arr))
> silly, but I use it often and np.is_close is not useful (doesn't show how
> close)
> Just a small annoyance, but I think it's the method that I miss most often.
> Josef
My issue is having to remember which ones are methods and which ones are
functions.  There doesn't seem to be a rhyme or reason for the choices, and
I would rather like to see that a line is drawn, but I am not picky as to
where it is drawn.

Ben Root
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/numpy-discussion/attachments/20130223/e3b1b3ae/attachment-0001.html 

More information about the NumPy-Discussion mailing list