sampling_function

odl.discr.discr_utils.sampling_function(func_or_arr, domain, out_dtype=None)[source]

Return a function that can be used for sampling.

For examples on this function’s usage, see point_collocation.

Parameters
func_or_arrcallable or array-like

Either a single callable object (possibly with multiple output components), or an array or callables and constants. A callable (or each callable) must take a single input and may accept one output parameter called out, and should return its result.

domainIntervalProd

Set in which inputs to the function are assumed to lie. It is used to determine the type of input (point/meshgrid/array) based on domain.ndim, and (unless switched off) to check whether all inputs are in bounds.

out_dtypeoptional

Data type of a single output of func_or_arr, i.e., when called with a single point as input. In particular:

  • If func_or_arr is a scalar-valued function, out_dtype is expected to be a basic dtype with empty shape.

  • If func_or_arr is a vector- or tensor-valued function, out_dtype should be a shaped data type, e.g., (float, (3,)) for a vector-valued function with 3 components.

  • If func_or_arr is an array-like, out_dtype should be a shaped dtype whose shape matches that of func_or_arr. It can also be None, in which case the shape is inferred, and the scalar data type is set to float.

Returns
funcfunction

Wrapper function that has an optional out argument.