I want to mark all maxima along a given axis of an array (which shape may be n-dimensional), this works fine along the first one, but for the rest I can’t figure it out. I don’t want to iterate over axis, because there can be arbritarily many of them.
>>> A = range(5)*3
>>> A = array(a).reshape([3,5], order='F')
>>> A
array([[0, 3, 1, 4, 2],
[1, 4, 2, 0, 3],
[2, 0, 3, 1, 4]])
>>> B = amax(A, axis= 0)
>>> C = amax(A, axis= 1)
>>> B == A
array([[False, False, False, True, False],
[False, True, False, False, False],
[ True, False, True, False, True]], dtype=bool)
This is what I want it to do for:
>>> C == A
False
but (of course) it does not.
How to get this working?
I finally came up with: