tags:

views:

43

answers:

1

In other words, I want to do something like

A[[-1, 0, 1], [2, 3, 4]] += np.ones((3, 3))

instead of

A[-1:3, 2:5] += np.ones((1, 3))
A[0:2, 2:5] += np.ones((2, 3))
+2  A: 

If I understand correctly, you can do what you want to do with the following:

A[[[-1],[0],[1]],[2,3,4]] += np.ones((3, 3))

However, the numpy folks made a function, ix_, to make it a little bit easier:

A[np.ix_([-1,0,1],[2,3,4])] += np.ones((3, 3))

I hope that helps.

Justin Peel
This is AWESOME. Thanks!!!!
cheshire