derivkit.utils.sandbox module

Sandbox utilities for experimentation and testing.

derivkit.utils.sandbox.generate_test_function(name: str = 'sin')

Return (f, f’, f’’) tuple for a named test function.

Parameters:

name – One of {“sin”}; more may be added.

Returns:

Tuple of callables (f, df, d2f) for testing.

derivkit.utils.sandbox.get_partial_function(full_function: Callable, variable_index: int, fixed_values: list | ndarray) Callable

Returns a single-variable version of a multivariate function.

A single parameter must be specified by index. All others parameters are held fixed.

Parameters:
  • full_function (callable) – A function that takes a list of n_parameters parameters and returns a vector of n_observables observables.

  • variable_index (int) – The index of the parameter to treat as the variable.

  • fixed_values (list or np.ndarray) – The list of parameter values to use as fixed inputs for all parameters except the one being varied.

Returns:

A function of a single variable, suitable for use in

differentiation.

Return type:

callable

Raises:
  • ValueError – If fixed_values is not 1D or if variable_index` is out of bounds.

  • TypeError – If variable_index is not an integer.

  • IndexError – If variable_index is out of bounds for the size of fixed_values.