autoray.lazy.random

Lazy random array creation.

Classes

LazyGenerator

A lazy random generator, whose draws are lazy arrays that depend on a

Functions

default_rng([seed, backend, _like])

Create a lazy random generator.

array(shape[, rng, backend, _like])

Create lazy random samples.

Module Contents

class autoray.lazy.random.LazyGenerator(node, like)[source]

A lazy random generator, whose draws are lazy arrays that depend on a single generator node. The concrete generator is created when that node is computed.

Parameters:
  • node (LazyArray) – The node that creates the concrete generator.

  • like (str or LazyArray) – The backend name or lazy array that draws take like from.

__slots__ = ('_node', '_like')
_node
_like
property backend
_draw(size, **kwargs)[source]
normal(loc=0.0, scale=1.0, size=None, **kwargs)[source]
standard_normal(size=None, **kwargs)[source]
uniform(low=0.0, high=1.0, size=None, **kwargs)[source]
random(size=None, **kwargs)[source]
__repr__()[source]
autoray.lazy.random.default_rng(seed=None, backend='numpy', _like=None, **kwargs)[source]

Create a lazy random generator.

Parameters:
  • seed (None, int, LazyGenerator or backend seed, optional) – Seed passed to the concrete random.default_rng when computed. A LazyGenerator is returned unchanged.

  • backend (str, optional) – Backend used when _like is None. Defaults to "numpy".

  • _like (LazyArray or None, optional) – Lazy array that supplies the backend, dtype and device at execution.

  • **kwargs – Options passed to random.default_rng when computed.

Return type:

LazyGenerator

autoray.lazy.random.array(shape, rng=None, backend='numpy', _like=None, **kwargs)[source]

Create lazy random samples.

Extra options, such as dist, dtype and device, are passed to random_array() when the array is computed.

Parameters:
  • shape (tuple[int]) – Shape of the output array.

  • rng (None, int, LazyGenerator or backend generator, optional) – Passed to random.array when computed. A LazyGenerator also supplies the backend when _like is None.

  • backend (str, optional) – Backend used when _like and rng give none. Defaults to "numpy".

  • _like (LazyArray or None, optional) – Lazy array that supplies the backend, dtype and device at execution.

  • **kwargs – Options passed to random.array when computed.

Returns:

Random samples as a lazy array.

Return type:

LazyArray