BSplineBasis.derivatives_factory()   A
last analyzed

Complexity

Conditions 1

Size

Total Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
c 1
b 0
f 0
dl 0
loc 7
rs 9.4285
1
"""
2
Class for approximating the solution to two-point boundary value problems using
3
B-splines as basis functions.
4
5
@author: davidrpugh
6
7
"""
8
import functools
9
10
from scipy import interpolate
11
12
from . import basis_functions
13
14
15
class BSplineBasis(basis_functions.BasisFunctionLike):
16
17
    @staticmethod
18
    def _basis_spline_factory(coef, degree, knots, der, ext):
19
        """Return a B-Spline given some coefficients."""
20
        return functools.partial(interpolate.splev, tck=(knots, coef, degree), der=der, ext=ext)
21
22
    @classmethod
23
    def derivatives_factory(cls, coef, degree, knots, ext, **kwargs):
24
        """
25
        Given some coefficients, return a the derivative of a B-spline.
26
27
        """
28
        return cls._basis_spline_factory(coef, degree, knots, 1, ext)
29
30
    @classmethod
31
    def fit(cls, *args, **kwargs):
32
        """Possibly just wrap interpolate.splprep?"""
33
        return interpolate.splprep(*args, **kwargs)
34
35
    @classmethod
36
    def functions_factory(cls, coef, degree, knots, ext, **kwargs):
37
        """
38
        Given some coefficients, return a B-spline.
39
40
        """
41
        return cls._basis_spline_factory(coef, degree, knots, 0, ext)
42