[Numpy-discussion] numpy.asum ?

Sebastian Haase seb.haase at gmail.com
Mon Oct 5 14:37:16 EDT 2009


Thanks for the reply.
I thought one reason for amax was that
from numpy import *
would not not import max but only amax.
How about sum ?
Does "from numpy import *"
overwrite the builtin sum ?
not to mention the "symmetry" / consistency argument for having "asum" ?

More comments ??

--Sebastian Haase


On Mon, Oct 5, 2009 at 6:04 PM, Robert Kern <robert.kern at gmail.com> wrote:
> On Mon, Oct 5, 2009 at 10:56, Sebastian Haase <seb.haase at gmail.com> wrote:
>> Hi,
>>
>> Is this a dumb question ?
>> Why is there no np.asum() equivalent to np.sum()  - like amax() to max() ?
>
> Back when Numeric was being written, max() and min() existed as
> builtins, but sum() did not. In order to support "from Numeric import
> *", the amax() aliases were added. sum() was added to the builtins
> later, but no one went back to add an asum() alias.
>
>> Another question: what does it mean that amax() (and max()) is a
>> "function" while maximum() is a ufunc !?
>>
>>>>> N.max
>> <function amax at 0x14071b8>
>>>>> N.maximum
>> <ufunc 'maximum'>
>>>>> N.amax
>> <function amax at 0x14071b8>
>>
>> Is there a performance difference connected to this ?
>
> No. maximum(x,y) is a binary ufunc that takes two arrays and returns
> an array with the element-wise maximum from between the two inputs.
> amax(x) is an unary function that returns the maximum value in the
> array. amax(x) is a convenience for maximum.reduce(x.flat).
>
> --
> Robert Kern
>
> "I have come to believe that the whole world is an enigma, a harmless
> enigma that is made terrible by our own mad attempt to interpret it as
> though it had an underlying truth."
>  -- Umberto Eco
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion at scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion
>



More information about the NumPy-Discussion mailing list