dedalus.tools.random_arrays

Tools for random array generation.

Module Contents

chunked_rng(seed, chunk_size, distribution, **kw)

RNG stream as a chunked generator.

rng_element(index, seed, chunk_size, distribution, **kw)

Get a specified element from a RNG stream.

rng_elements(indices, seed, chunk_size, distribution, **kw)

Get an array of elements from a RNG stream.

class IndexArray(shape, order='C')

mgrid-like object that returns an array of flat indices when sliced.

Parameters:
  • shape (tuple of ints) – Shape of array.

  • order ({‘C’, ‘F’}, optional) – Determines whether the returned flat indices should correspond to a row-major (C-style) or column-major (Fortran-style) order.

class ChunkedRandomArray(shape, seed=None, chunk_size=2**20, distribution='uniform', **kw)

Random array with elements that are deterministically produced when indexed. This allows robustly constructing and selecting from a random array without requiring enough local memory to hold the entire array.

Parameters:
  • shape (tuple of ints) – Shape of array.

  • seed (int, optional) – RNG seed. Default: None.

  • chunk_size (int, optional) – Chunk size for drawing from distribution. Should be less than locally available memory. Default: 2**20, corresponding to 8 MB of float64.

  • distribution (str, optional) – Distribution name, corresponding to numpy random Generator method. Default: ‘uniform’.

  • **kw (dict) – Other keywords passed to the distribution method.