[Numpy-discussion] maximmum.reduce and nans

Sasha ndarray at mac.com
Wed Jun 14 12:39:23 EDT 2006


On 6/14/06, Martin Wiechert <martin.wiechert at gmx.de> wrote:
>...
> does anybody know, why
>
> maximum.reduce (())
>
> does not return -inf?
>

Technically, because

>>> maximum.identity is None
True

It is theoretically feasible to change maximum.identity to -inf, but
that would be inconsistent with the default dtype being int.  For
example

>>> add.identity, type(add.identity)
(0, <type 'int'>)

Another reason is that IEEE special values are not universally supported yet.

I would suggest to add 'initial' keyword to reduce.  If this is done,
the type of 'initial' may also supply the default for 'dtype' argument
of reduce that was added in numpy.

Another suggestion in this area is to change identity attribute of
ufuncs from a scalar to dtype:scalar dictionary.

Finally, a bug report:
>>> add.identity = None
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
SystemError: error return without exception set




More information about the NumPy-Discussion mailing list