[PYTHON MATRIX-SIG] max/min bug?

Geoffrey Furnish furnish@laura.llnl.gov
Wed, 29 Jan 1997 11:01:12 -0800


Jim Crotinger writes:
 > Konrad Hinsen writes:
 >  > Short answer: use minimum.reduce(a) and maximum.reduce(a) to get what you
 >  > expect.
 >  > 
 >  > Long answer: min() and max() are built-in Python functions that predate
 >  > NumPy. If they are called with a single argument which is a sequence
 >  > (e.g. an array), they return the smallest/largest element of that
 >  > sequence. Sounds fine, but isn't: what is the smallest of three arrays?
 >  > 
 > 
 >   That's what I thought.  This violates the principle of least
 > astonishment and really ought to be reconsidered somehow. Either it
 > should do what everyone (or at least most people) expects (which is to
 > return the largest/smallest element of the multidimensional array),
 > or it should throw an exception and complain.

I agree.  This non intuitive behavior of min/max in NumPy has been the
source of much consternation for users here.

-- 
Geoffrey Furnish		email: furnish@llnl.gov
LLNL X/ICF			phone: 510-424-4227	fax: 510-423-0925

_______________
MATRIX-SIG  - SIG on Matrix Math for Python

send messages to: matrix-sig@python.org
administrivia to: matrix-sig-request@python.org
_______________