[PYTHON MATRIX-SIG] reduce methods
janko hauser
jhauser@ifm.uni-kiel.de
Wed, 29 Jan 1997 11:41:07 +0100
Yeah, I think this is the better way. But I wouldn't put this in
MLab.py officially, because it is not Matlab compatible. In the long
run I vote for a common file with standard definitions or to put more
definitions in Numeric.py.
__Janko
Brien Barton writes:
> Had an idea while trying out Janko's proposed new MLab.py functions. Right
> now:
>
> >>> a
> 3 6 2
> 4 9 5
> >>> minimum.reduce(a)
> 3 6 2
> >>> minimum.reduce(a,1)
> 2 4
>
> In the second case, we're finding the minimum value in each row, so the
> result I would expect is:
>
> 2
> 4
>
> In other words, I'd expect the axis that was "reduced" to change to a length
> of one instead of completely going away. Modifying Janko's min function to
> do this...
>
> def mmin(m,axis=0):
> if axis == None:
> return minimum.reduce(ravel(m))
> else:
> new_shape = list(m.shape)
> new_shape[axis] = 1
> return reshape(minimum.reduce(m,axis), new_shape)
>
> Opinions??
>
> -- Brien
>
>
> _______________
> 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
_______________