[Numpy-discussion] numpy.asum ?
Robert Kern
robert.kern@gmail....
Mon Oct 5 11:04:21 CDT 2009
On Mon, Oct 5, 2009 at 10:56, Sebastian Haase <seb.haase@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
More information about the NumPy-Discussion
mailing list