def subArray(data, offset, shape, stride):
 data = data[offset:]
 shape = tuple(shape)
 stride = tuple(stride)
 extraShape = data.shape[1:]
 for i in range(len(shape)):
  mask = (((slice(None),) * i) + (slice(None, (shape[i] * stride[i])),))
  newShape = shape[:(i + 1)]
  if (i < (len(shape) - 1)):
   newShape += (stride[i],)
  newShape += extraShape
  data = data[mask]
  data = data.reshape(newShape)
 return data

def subArray ( data , offset , shape , stride ) : data = data [ offset : ] shape = tuple ( shape ) stride = tuple ( stride ) extraShape = data . shape [ 1 : ] for i in range ( len ( shape ) ) : mask = ( ( ( slice ( None ) , ) * i ) + ( slice ( None , ( shape [ i ] * stride [ i ] ) ) , ) ) newShape = shape [ : ( i + 1 ) ] if ( i < ( len ( shape ) - 1 ) ) : newShape += ( stride [ i ] , ) newShape += extraShape data = data [ mask ] data = data . reshape ( newShape ) return data
unpack a sub-array from *data* using the specified offset .