def add_array(array_large, array_small, position):
 if all(((large_shape > small_shape) for (large_shape, small_shape) in zip(array_large.shape, array_small.shape))):
  (large_slices, small_slices) = overlap_slices(array_large.shape, array_small.shape, position)
  array_large[large_slices] += array_small[small_slices]
  return array_large
 else:
  raise ValueError(u"Can't add array. Small array too large.")

def add_array ( array_large , array_small , position ) : if all ( ( ( large_shape > small_shape ) for ( large_shape , small_shape ) in zip ( array_large . shape , array_small . shape ) ) ) : ( large_slices , small_slices ) = overlap_slices ( array_large . shape , array_small . shape , position ) array_large [ large_slices ] += array_small [ small_slices ] return array_large else : raise ValueError ( u"Can't add array. Small array too large." )
add a smaller array at a given position in a larger array .