[PYTHON MATRIX-SIG] max/min bug?

Perry Stoll pas@xis.xerox.com
Mon, 27 Jan 1997 15:36:10 PST


On 27 Jan, Brien Barton wrote:
> Is the following a bug or am I just confused??
>>>> min(a)
> 6 7 8
>>>> max(a)
> 0 1 2
>>>> 

Confused about a bug? No, not quite. It's something which I'm sure is
going to bite a lot of people.

> It seems that if a is a two-dimensional array, then min(a) returns the last
> row and max(a) returns the first row. 

Strange.

> that the min and max functions aren't mentioned in the doc.html file so
> maybe I shouldn't be using them.

Are you trying to find the maximum value in a?

Then try:

>>> max(Numeric.ravel(a))
8

Numeric.maximum returns an array whose entries are the maximum of 
it's inputs:

>>> Numeric.maximum(a,4)
4 4 4
4 4 5
6 7 8

Same with min/minimum.

I'll also add that there is no documentation in doc.html about the
attributes of arrays that one might want to use, e.g. shape. Jim, could
that get added?

-Perry



_______________
MATRIX-SIG  - SIG on Matrix Math for Python

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