BasisFunction#
- class splinebox.basis_functions.BasisFunction(multigenerator, support)#
Base class for all basis functions. This class should not be used directly, but instead classes for specific basis functions should inherit from this class.
An example of how to implement your own basis function using inheriting from this class is given below.
- Parameters:
- multigeneratorboolean
Indicates whether the basis function generates multiple outputs. This is used to distinguish basis functions designed for Hermite splines, which return two values instead of one.
- supportfloat
The support of the function, i.e. the size of the area being mapped to non-zero values.
Methods
__call__(t[, derivative])Evaluate the function at position(s) t.
Returns a filtered version of the input s, used to convert knots into control points for a closed spline.
Returns a filtered version of the input s, used to convert knots into control points for an open spline.
This function is needed for local refinement (see [Badoual2016]).
Examples
This example shows how to implement a new basis function.
>>> class MyBasis(splinebox.BasisFunction): ... def __init__(self): ... super().__init__(multigenerator=False, support=2) ... ... def __str__(self): ... return "MyBasis" ... ... def __repr__(self): ... # Change this if your new basis function is not in splinebox.basis_functions ... return "splinebox.basis_functions.MyBasis()" ... ... def _func(self, t): ... # Implement your function here ... return val ... ... def _derivative_1(self, t): ... # Implement the first derivative of your function here ... return val ... ... def _derivative_2(self, t): ... # Implement the second derivative of your function here ... # or raise an error if not differentiable ... raise RuntimeError("MyBasis isn't twice differentiable.") ... ... def filter_symmetric(self, s): ... # Implement the function that can turn knots into control points ... # for an open spline ... return s.astype(float) ... ... def filter_periodic(self, s): ... # Implement the function that can turn knots into control points ... # for a closed spline ... return s.astype(float)
Comparison splinebox and scipy: contour approximation