This is a pre-release version (latest).Go to latest (1.18.0)
{ } Raw JSON

bundles / scipy latest / scipy / _lib / _elementwise_iterative_method / _initialize

function

scipy._lib._elementwise_iterative_method:_initialize

source: build-install/usr/lib/python3.14/site-packages/scipy/_lib/_elementwise_iterative_method.py:29

Signature

def _initialize(func, xs, args, kwargs = None, complex_ok = False, multi_output_ok = False, preserve_shape = False, xp = None)

Summary

Initialize abscissa, function, and args arrays for elementwise function

Parameters

func : callable

An elementwise function with signature

func(x: ndarray, *args) -> ndarray

where each element of x is a finite real and args is a tuple, which may contain an arbitrary number of arrays that are broadcastable with x.

xs : tuple of arrays

Finite real abscissa arrays. Must be broadcastable.

args : tuple, optional

Additional positional arguments to be passed to func.

kwargs : tuple, optional

Additional keyword arguments to be passed to func.

complex_ok : bool, default: False

Whether complex dtypes are allowed; e.g., True for tanhsinh, False for _chandrupatla.

multi_output_ok : bool, default: False

Whether the user callable may return multiple outputs as a single array with shape to which xs and args are broadcastable to.

preserve_shape : bool, default: False

When preserve_shape=False (default), func may be passed arguments of any shape; _scalar_optimization_loop is permitted to reshape and compress arguments at will. When preserve_shape=True, arguments passed to func must have shape shape + (n,), where n is any integer.

xp : namespace

Namespace of array arguments in xs.

Returns

xs, fs, args : tuple of arrays

Broadcasted, writeable, 1D abscissa and function value arrays (or NumPy floats, if appropriate). The dtypes of the xs and fs are xfat; the dtype of the args are unchanged.

shape : tuple of ints

Original shape of broadcasted arrays.

xfat : NumPy dtype

Result dtype of abscissae, function values, and args determined using np.result_type, except integer types are promoted to np.float64.

Raises

: ValueError

If the result dtype is not that of a real scalar

Notes

Useful for initializing the input of SciPy functions that accept an elementwise callable, abscissae, and arguments; e.g. scipy.optimize._chandrupatla.

Aliases

  • scipy.differentiate.eim._initialize