[Numpy-discussion] numpy.asum ?

Robert Kern robert.kern@gmail....
Mon Oct 5 14:58:47 CDT 2009


On Mon, Oct 5, 2009 at 14:55, Sebastian Haase <seb.haase@gmail.com> wrote:
> On Mon, Oct 5, 2009 at 8:43 PM, Robert Kern <robert.kern@gmail.com> wrote:
>> On Mon, Oct 5, 2009 at 13:37, Sebastian Haase <seb.haase@gmail.com> wrote:
>>> Thanks for the reply.
>>> I thought one reason for amax was that
>>> from numpy import *
>>> would not not import max but only amax.
>>
>> I have my timelines confused. Numeric has neither amax() nor max(). I
>> don't actually recall the sequence of events, then.
>>
>>> How about sum ?
>>> Does "from numpy import *"
>>> overwrite the builtin sum ?
>>
>> Try it.
>>
>>>> sum
> <built-in function sum>
>>>> from numpy import *
>>>> sum
> <function sum at 0x0334E2B0>
>>>> asum
> Traceback (most recent call last):
>  File "<input>", line 1, in <module>
> NameError: name 'asum' is not defined
>>>> N.__version__
> '1.3.0'
>>>>
>
>>> not to mention the "symmetry" / consistency argument for having "asum" ?
>>
>> At this point, I don't care to cater to "from numpy import *" use
>> case. Too much code uses numpy.sum() remove it, or even deprecate it.
>>
>
> I did not mean to suggest to remove or deprecate it. I only remember
> that there was a discussion - long time ago - that "from numpy import
> *" (still common in many places, like interactive sessions) - should
> not overwrite builtins ....

We are not removing sum from numpy.__all__ at this point in time. It's too late.

> Personally, I would prefer to write np.amax and np.asum ... do you see
> my argument for consistency here ?

Yes, but it's not important enough to me to want to introduce more aliases.

-- 
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