diff --git a/src/xspline/xspl.py b/src/xspline/xspl.py index 991d48d..4888e61 100644 --- a/src/xspline/xspl.py +++ b/src/xspline/xspl.py @@ -1,20 +1,37 @@ from typing import Optional -from numpy.typing import NDArray - from xspline.bspl import clear_bspl_cache, get_bspl_funs from xspline.poly import get_poly_fun from xspline.xfunction import BasisXFunction +from xspline.typing import NDArray class XSpline(BasisXFunction): + """Main class for xspline functions. + + Parameters + ---------- + knots + Knots of the spline. + degree + Degree of the spline. + ldegree + Left extrapolation polynomial degree. + rdegree + Right extrapolation polynomial degree. + coefs + The coefficients for linear combining the spline basis. + + """ - def __init__(self, - knots: tuple[float, ...], - degree: int, - ldegree: Optional[int] = None, - rdegree: Optional[int] = None, - coefs: Optional[NDArray] = None) -> None: + def __init__( + self, + knots: tuple[float, ...], + degree: int, + ldegree: Optional[int] = None, + rdegree: Optional[int] = None, + coefs: Optional[NDArray] = None, + ) -> None: # validate inputs knots, degree = tuple(sorted(map(float, knots))), int(degree) if len(set(knots)) < 2: @@ -37,8 +54,26 @@ def __init__(self, self.ldegree, self.rdegree = ldegree, rdegree super().__init__(funs, coefs=coefs) - def get_design_mat(self, x: NDArray, - order: int = 0, check_args: bool = True) -> NDArray: + def get_design_mat( + self, x: NDArray, order: int = 0, check_args: bool = True + ) -> NDArray: + """Create design matrix from spline basis functions. + + Parameters + ---------- + x + Data points. + order + Order of differentiation/integration. + check_args + If ``True``, it will automatically check and parse the arguments. + + Returns + ------- + describe + Design matrix from spline basis functions. + + """ design_mat = super().get_design_mat(x, order, check_args) clear_bspl_cache() return design_mat