def moving_window(array, nrows):
 count = num_windows_of_length_M_on_buffers_of_length_N(nrows, len(array))
 for i in range(count):
  (yield array[i:(i + nrows)])

def moving_window ( array , nrows ) : count = num_windows_of_length_M_on_buffers_of_length_N ( nrows , len ( array ) ) for i in range ( count ) : ( yield array [ i : ( i + nrows ) ] )
simple moving window generator over a 2d numpy array .