Alexander Schmolck wrote:
> Robert Kern <[EMAIL PROTECTED]> writes:
> 
>> If possible, I would prefer a way to pass a value to use and raise the error 
>> if
>> no such value is passed rather than hardcode an identity value for min() and 
>> max().
> 
> What's wrong with inf? I'm not sure integer reductions should have
> max/min-ints as identity values (because this could lead to nasty bugs when
> implicit dtype promotions are involved), but I can't see any problems
> resulting from +/-inf.

0 and 1 exist in both integer and floating point versions. +/-inf don't. A
hardcoded identity value should be consistent across all uses, not changing
depending on the type (and we shouldn't use +/-inf for integer arrays, either).
There are also times when I have constraints on the domain of the inputs. For
example, I might be dealing with arrays that should only have positive numbers.
If I call max() on the arrays, I might want the result for the empty one to be
0, not -inf.

Besides, being able to specify what value to use to start the reduction is a
generally useful feature regardless. There have been several times in the past
week, even, when I wished we had that capability.

-- 
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@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion

Reply via email to