[PYTHON MATRIX-SIG] Re: max/min bug
janko hauser
jhauser@ifm.uni-kiel.de
Tue, 28 Jan 1997 12:14:31 +0100
Two ways are possible, rename to mmax,mmin or ask in the function for
type of m and return the appropiate result, if it is something other
than an array. I think the second way is error prone, because of
possible other numerical objects. Or are there better indicators than
'type()'?
__Janko
Konrad Hinsen writes:
> > Anyway, here are my attempts:
> > (If there are mistakes, please shout loud!)
> >
> > def max(m,axis=0):
> > if axis == None:
> > return maximum.reduce(ravel(m))
> > else:
> > return maximum.reduce(m,axis)
> >
> > def min(m,axis=0):
> > if axis == None:
> > return minimum.reduce(ravel(m))
> > else:
> > return minimum.reduce(m,axis)
>
> The definitions are OK (and probably quite useful), but I would
> strongly recommend *not* to redefine min and max, which after all are
> built-in Python functions. If you import these definitions plus some
> code that needs the built-ins, you will get nasty surprises.
>
> Konrad.
> --
> -------------------------------------------------------------------------------
> Konrad Hinsen | E-Mail: hinsen@ibs.ibs.fr
> Laboratoire de Dynamique Moleculaire | Tel.: +33-4.76.88.99.28
> Institut de Biologie Structurale | Fax: +33-4.76.88.54.94
> 41, av. des Martyrs | Deutsch/Esperanto/English/
> 38027 Grenoble Cedex 1, France | Nederlands/Francais
> -------------------------------------------------------------------------------
>
> _______________
> MATRIX-SIG - SIG on Matrix Math for Python
>
> send messages to: matrix-sig@python.org
> administrivia to: matrix-sig-request@python.org
> _______________
_______________
MATRIX-SIG - SIG on Matrix Math for Python
send messages to: matrix-sig@python.org
administrivia to: matrix-sig-request@python.org
_______________