On Mon, Feb 25, 2013 at 7:49 PM, <josef.p...@gmail.com> wrote: > On Mon, Feb 25, 2013 at 7:11 PM, Charles R Harris > <charlesr.har...@gmail.com> wrote: >> >> >> On Sat, Feb 23, 2013 at 1:33 PM, Robert Kern <robert.k...@gmail.com> wrote: >>> >>> On Sat, Feb 23, 2013 at 7:25 PM, Nathaniel Smith <n...@pobox.com> wrote: >>> > On Sat, Feb 23, 2013 at 3:38 PM, Till Stensitzki <mail.t...@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). >> >> >> Well, that just calls a method: >> >> In [1]: ones(3).__abs__() >> Out[1]: array([ 1., 1., 1.]) >> >> Which shows the advantage of methods, they provide universal function hooks. > > Maybe we should start to advertise magic methods. > I only recently discovered I can use divmod instead of the numpy functions: > >>>> divmod(np.array([1.4]), 1) > (array([ 1.]), array([ 0.4])) >>>> np.array([1.4]).__divmod__(1) > (array([ 1.]), array([ 0.4]))
Thanks for the hint. my new favorite :) >>> (freq - nobs * probs).__abs__().max() 132.0 Josef > > Josef > > >> >> Chuck >> >> _______________________________________________ >> NumPy-Discussion mailing list >> NumPy-Discussion@scipy.org >> http://mail.scipy.org/mailman/listinfo/numpy-discussion >> _______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion