def execOnSubArrays(arrs, fn, splitX, splitY):
if type(arrs) not in (tuple, list):<EOL><INDENT>arrs = (arrs,)<EOL><DEDENT>s0, s1 = arrs[<NUM_LIT:0>].shape<EOL>ss0 = s0 // splitX<EOL>ss1 = s1 // splitY<EOL>px, py = <NUM_LIT:0>, <NUM_LIT:0><EOL>out = None<EOL>for ix in range(splitX):<EOL><INDENT>if ix == splitX - <NUM_LIT:1>:<EOL><INDENT>ss0 = s0 - px<EOL><DEDENT>for iy in range(splitY):<EOL><INDENT>if iy == splitY - <NUM_LIT:1>:<EOL><INDENT>ss1 = s1 - py<EOL><DEDENT>sarrs = [a[px:px + ss0, py:py + ss1] for a in arrs]<EOL>sub = fn(*tuple(sarrs))<EOL>if out is None:<EOL><INDENT>out = np.empty(shape=(s0, s1), dtype=sub.dtype)<EOL><DEDENT>out[px:px + ss0, py:py + ss1] = sub<EOL>py += ss1<EOL><DEDENT>py = <NUM_LIT:0><EOL>px += ss0<EOL><DEDENT>return out<EOL>
execute a function(on or multiple arrays)
only on sub sections
works only on 2d arrays at the moment

>>> a1 = np.ones((1000,1000))
>>> a2 = np.ones((1000,1000))
>>> out = execOnSubArrays((a1,a2), lambda sa1,sa2: sa1+as2, splitX=10, splitY=10)