I face a problem with Numpy, I try to use the values of each row (of B) as the indexes of another multidimensional array (A):
>>> A
array([[0, 1, 2],
[3, 4, 5],
[6, 7, 8]])
>>> B
array([[ 0, 1, 2, 3],
[ 1, 5, 6, 7],
[ 8, 9, 10, 11]])
>>> np.clip(B, 0, 2)
array([[0, 1, 2, 2],
[1, 2, 2, 2],
[2, 2, 2, 2]])
Here is the expected result:
array([[0, 1, 2, 2],
[4, 5, 5, 5],
[8, 8, 8, 8]])
Any idea ? Thanks a lot for your help.