[Numpy-discussion] Deprecate np.max/np.min ?

Pauli Virtanen pav@iki...
Fri Nov 6 12:22:59 CST 2009


pe, 2009-11-06 kello 12:57 -0500, josef.pktd@gmail.com kirjoitti:
[clip]
> It follows the same pattern for missing brackets as many of the other
> functions, where I often have typos.
> 
> >>> np.min(3,2)
> 3
> >>> np.sum(3,2)
> 3
> >>> np.ones(3,2)
[clip]

I think you are thinking about Matlab now...

The issue here is that Numpy's `min` and `max`, if used like their
Python counterparts, give surprising results. `sum`, `ones`, `round`,
etc. don't have this problem. The prepended `a` in the beginning is IMO
not a big price to pay for reduced overloading.

OTOH, one can ask, why is

	np.min(3, 2)

allowed when

	np.min([3], 2)

gives "ValueError: axis(=2) out of bounds". It seems to me that
0-dimensional objects should accept only None as the axis? (Fixing this
would also make misuse of np.min and np.max more difficult.)

-- 
Pauli Virtanen





More information about the NumPy-Discussion mailing list