np.put 1d np.take:
In [1270]: A=np.arange(10)
In [1271]: np.take(A,[8,9,10,11],mode='wrapped')
Out[1271]: array([8, 9, 0, 1])
In [1272]: np.put(A,[8,9,10,11],[10,11,12,13],mode='wrapped')
In [1273]: A
Out[1273]: array([12, 13, 2, 3, 4, 5, 6, 7, 10, 11])
In [1274]: np.take(A,[8,9,10,11],mode='wrapped')
Out[1274]: array([10, 11, 12, 13])
np.place np.putmask ( np.copyto). , B, .
=================
place:
In [1313]: A=np.arange(24).reshape(4,6)
In [1314]: mask=np.zeros(A.shape,bool)
In [1315]: mask[:3,:4]=True
In [1316]: B=-np.arange(12).reshape(3,4)
, mask , A, "" B.
mask, B place A wrapped.
In [1317]: np.place(A, np.roll(mask,-2,0), np.roll(B,1,0).flat)
In [1318]: A
Out[1318]:
array([[ -8, -9, -10, -11, 4, 5],
[ 6, 7, 8, 9, 10, 11],
[ 0, -1, -2, -3, 16, 17],
[ -4, -5, -6, -7, 22, 23]])
2d
In [1332]: m=np.roll(np.roll(mask,-2,0),-1,1)
In [1333]: m
Out[1333]:
array([[ True, True, True, False, False, True],
[False, False, False, False, False, False],
[ True, True, True, False, False, True],
[ True, True, True, False, False, True]], dtype=bool)
In [1334]: b=np.roll(np.roll(B,1,0),-1,1)
In [1335]: b
Out[1335]:
array([[ -9, -10, -11, -8],
[ -1, -2, -3, 0],
[ -5, -6, -7, -4]])
In [1336]: A=np.zeros((4,6),int)
In [1337]: np.place(A, m, b.flat)
In [1338]: A
Out[1338]:
array([[ -9, -10, -11, 0, 0, -8],
[ 0, 0, 0, 0, 0, 0],
[ -1, -2, -3, 0, 0, 0],
[ -5, -6, -7, 0, 0, -4]])