adaptive.IntegratorLearner#

class adaptive.IntegratorLearner(function: Callable, bounds: tuple[int, int], tol: float)[source]#

Bases: BaseLearner

add_ival(ival: _Interval) None[source]#
property approximating_intervals: set[adaptive.learner.integrator_learner._Interval]#
ask(n: int, tell_pending: bool = True) tuple[list[float], list[float]][source]#

Choose points for learners.

done()[source]#
property err: float#
property igral: float#
load_dataframe(df: DataFrame, with_default_function_args: bool = True, function_prefix: str = 'function.', x_name: str = 'x', y_name: str = 'y') None[source]#

Load data from a pandas.DataFrame.

If with_default_function_args is True, then learner.function’s default arguments are set (using functools.partial) from the values in the pandas.DataFrame.

Parameters:
  • with_default_function_args (bool, optional) – Include the learner.function’s default arguments as a column, by default True

  • function_prefix (str, optional) – Prefix to the learner.function’s default arguments’ names, by default “function.”

  • x_name (str, optional) – Name of the input value, by default “x”

  • y_name (str, optional) – Name of the output value, by default “y”

loss(real=True)[source]#

Return the loss for the current state of the learner.

Parameters:

real (bool, default: True) – If False, return the “expected” loss, i.e. the loss including the as-yet unevaluated points (possibly by interpolation).

new() IntegratorLearner[source]#

Create a copy of Learner2D without the data.

property npoints: int#

Number of evaluated points.

plot()[source]#
pop_from_stack(n: int) tuple[list[float], list[float]][source]#
propagate_removed(ival: _Interval) None[source]#
remove_unfinished()[source]#

Remove uncomputed data from the learner.

tell(point: float, value: float) None[source]#

Tell the learner about a single value.

Parameters:
  • x (A value from the function domain) –

  • y (A value from the function image) –

tell_pending()[source]#

Tell the learner that ‘x’ has been requested such that it’s not suggested again.

to_dataframe(with_default_function_args: bool = True, function_prefix: str = 'function.', x_name: str = 'x', y_name: str = 'y') DataFrame[source]#

Return the data as a pandas.DataFrame.

Parameters:
  • with_default_function_args (bool, optional) – Include the learner.function’s default arguments as a column, by default True

  • function_prefix (str, optional) – Prefix to the learner.function’s default arguments’ names, by default “function.”

  • x_name (str, optional) – Name of the input value, by default “x”

  • y_name (str, optional) – Name of the output value, by default “y”

Return type:

pandas.DataFrame

Raises:

ImportError – If pandas is not installed.

to_numpy()[source]#

Data as NumPy array of size (npoints, 2).