Indexing#

Like NumPy, Aesara distinguishes between basic and advanced indexing. Aesara fully supports basic indexing (see NumPy’s indexing) and integer advanced indexing.

Index-assignment is not supported. If you want to do something like a[5] = b or a[5]+=b, see aesara.tensor.subtensor.set_subtensor() and aesara.tensor.subtensor.inc_subtensor() below.

Generating index tensors#

where

if cond then ift else iff Generalizes a scalar Op to tensors.

ogrid

Create a dense n-dimensional 'meshgrid' with equally spaced points.

ravel_multi_index(multi_index, dims[, mode, ...])

Converts a tuple of index arrays into an array of flat indices, applying boundary modes to the multi-index.

unravel_index(indices, dims[, order])

Converts a flat index or array of flat indices into a tuple of coordinate arrays.

tril_indices_from(a[, k])

Return the indices for the lower-triangle of arr.

tril_indices(n[, k, m])

Return the indices for the lower-triangle of an (n, m) array.

triu_indices(n[, k, m])

Return the indices for the upper-triangle of an (n, m) array.

triu_indices_from(a[, k])

Return the indices for the upper-triangle of arr.

Indexing-like operations#

take(a, indices[, axis, mode])

Take elements from an array along an axis.

take_along_axis(arr, indices[, axis])

Take values from the input array by matching 1d index and data slices.

choose(a, choices[, mode])

Construct an array from an index array and a set of arrays to choose from.

compress(condition, x[, axis])

Return selected slices of an array along given axis.

diag(v[, k])

A helper function for two ops: ExtractDiag and AllocDiag.

diagonal(a[, offset, axis1, axis2])

A helper function for ExtractDiag.

Inserting data into tensors#

set_subtensor(x, y[, inplace, ...])

Return x with the given subtensor overwritten by y.

inc_subtensor(x, y[, inplace, ...])

Update the value of an indexed array by a given amount.