Lets say you have a Numpy 2d-array:
import numpy as np
big = np.zeros((4, 4))
>>> big
array([[0., 0., 0., 0.],
[0., 0., 0., 0.],
[0., 0., 0., 0.],
[0., 0., 0., 0.]])
Another 2d array, smaller or equal in length on both axis:
small = np.array([
[1, 2],
[3, 4]
])
You now want to override some values of big
with the values of small
, starting with the upper left corner of small
-> small[0][0]
on a starting point in big
.
e.g.:
import numpy as np
big = np.zeros((4, 4))
small = np.array([
[1, 2],
[3, 4]
])
def insert_at(big_arr, pos, to_insert_arr):
return [...]
result = insert_at(big, (1, 2), small)
>>> result
array([[0., 0., 0., 0.],
[0., 0., 1., 2.],
[0., 0., 3., 4.],
[0., 0., 0., 0.]])
I expected an numpy function for that but couldn't find one.