pyppin.math.functions¶
Create real-valued functions by interpolating data.
Utilities like plot_ascii take a real-valued function, i.e. a Callable[[float], float]
, as their
argument. This library lets you turn a set of data points into an (interpolated) function that you
can use there.
Classes
|
Base class for functions built out of a set of (x, y) data pairs. |
|
Build a function by linearly interpolating (i.e. |
|
Build a piecewise constant function, i.e. one that gives constant values between one given x-value and the next. |
- class pyppin.math.functions.FunctionFromSortedData(data: Union[List[Tuple[float, float]], Dict[float, float]])[source]¶
Bases:
ABC
Base class for functions built out of a set of (x, y) data pairs.
All the subclasses of this are callable objects that behave like a function from float to float, and are constructed from a collection of (x, y) data pairs, either as a list or a dict. If provided as a list, no more than one y-value should be given per x-value!
- class pyppin.math.functions.Interpolate(data: Union[List[Tuple[float, float]], Dict[float, float]])[source]¶
Bases:
FunctionFromSortedData
Build a function by linearly interpolating (i.e. drawing straight lines) between the given data points.
- class pyppin.math.functions.PiecewiseConstant(data: Union[List[Tuple[float, float]], Dict[float, float]])[source]¶
Bases:
FunctionFromSortedData
Build a piecewise constant function, i.e. one that gives constant values between one given x-value and the next.