def _get_chunks(shape, ncpu):
 chunks = []
 nchunks_per_dim = int(ceil((ncpu ** (1.0 / len(shape)))))
 used_chunks = 1
 for i in shape:
  if (used_chunks < ncpu):
   regular_chunk = (i // nchunks_per_dim)
   remainder_chunk = (regular_chunk + (i % nchunks_per_dim))
   if (regular_chunk == 0):
    chunk_lens = (remainder_chunk,)
   else:
    chunk_lens = (((regular_chunk,) * (nchunks_per_dim - 1)) + (remainder_chunk,))
  else:
   chunk_lens = (i,)
  chunks.append(chunk_lens)
  used_chunks *= nchunks_per_dim
 return tuple(chunks)

def _get_chunks ( shape , ncpu ) : chunks = [ ] nchunks_per_dim = int ( ceil ( ( ncpu ** ( 1.0 / len ( shape ) ) ) ) ) used_chunks = 1 for i in shape : if ( used_chunks < ncpu ) : regular_chunk = ( i // nchunks_per_dim ) remainder_chunk = ( regular_chunk + ( i % nchunks_per_dim ) ) if ( regular_chunk == 0 ) : chunk_lens = ( remainder_chunk , ) else : chunk_lens = ( ( ( regular_chunk , ) * ( nchunks_per_dim - 1 ) ) + ( remainder_chunk , ) ) else : chunk_lens = ( i , ) chunks . append ( chunk_lens ) used_chunks *= nchunks_per_dim return tuple ( chunks )
split the array into equal sized chunks based on the number of available processors .