{ } Raw JSON

bundles / scipy latest / scipy / _lib / _util / _apply_over_batch

function

scipy._lib._util:_apply_over_batch

source: /scipy/_lib/_util.py :1118

Signature

def   _apply_over_batch ( * argdefs )

Summary

Factory for decorator that applies a function over batched arguments.

Extended Summary

Array arguments may have any number of core dimensions (typically 0, 1, or 2) and any broadcastable batch shapes. There may be any number of array outputs of any number of dimensions. Assumptions right now - which are satisfied by all functions of interest in linalg - are that all array inputs are consecutive keyword or positional arguments, and that the wrapped function returns either a single array or a tuple of arrays. It's only as general as it needs to be right now - it can be extended.

Parameters

*argdefs : tuple of (str, int)

Definitions of array arguments: the keyword name of the argument, and the number of core dimensions.

Examples

`linalg.eig` accepts two matrices as the first two arguments `a` and `b`, where `b` is optional, and returns one array or a tuple of arrays, depending on the values of other positional or keyword arguments. To generate a wrapper that applies the function over batches of `a` and optionally `b` :
_apply_over_batch(('a', 2), ('b', 2))

Aliases

  • scipy.linalg._basic._apply_over_batch