Skip to content

Commit

Permalink
removed bp
Browse files Browse the repository at this point in the history
  • Loading branch information
BalzaniEdoardo committed Oct 13, 2023
1 parent 290f223 commit 0a57674
Showing 1 changed file with 1 addition and 57 deletions.
58 changes: 1 addition & 57 deletions src/neurostatslib/basis.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"OrthExponentialBasis",
"AdditiveBasis",
"MultiplicativeBasis",
"FourierBasis"
"FourierBasis",
]


Expand Down Expand Up @@ -1092,62 +1092,6 @@ def _evaluate(self, sample_pts: NDArray) -> NDArray:
return np.concatenate([np.cos(angles), -np.sin(angles[:, 1:])], axis=1)


class BernsteinPolyBasis(Basis):
"""Set of 1D Bernstein Polynomial basis.
Parameters
----------
n_basis_funcs : int
Number of basis functions.
"""

def __init__(self, n_basis_funcs: int):
super().__init__(n_basis_funcs=n_basis_funcs)
self._n_input_dimensionality = 1

def _check_n_basis_min(self) -> None:
"""Check that the user required enough basis elements.
Checks that the number of basis is at least 1.
Raises
------
ValueError
If an insufficient number of basis element is requested for the basis type
"""
if self.n_basis_funcs < 1:
raise ValueError(
f"Object class {self.__class__.__name__} requires >= 1 basis elements. "
f"{self.n_basis_funcs} basis elements specified instead"
)

def _evaluate(self, sample_pts: NDArray) -> NDArray:
"""Generate basis functions with given spacing.
Parameters
----------
sample_pts
Spacing for basis functions.
Returns
-------
:
Evaluated Bernstein polynomial basis, shape (n_samples, n_basis_funcs).
Examples
--------
>>> import neurostatslib as nsl
>>> import numpy as np
>>> bernstein_basis = BernsteinPolyBasis(n_basis_funcs=5)
>>> sample_pts = np.linspace(0, 1, 10)
>>> basis_funcs = bernstein_basis._evaluate(sample_pts)
>>> basis_funcs.shape
(10, 5)
"""
return bernstein_poly(sample_pts, self.n_basis_funcs, der=0)


def mspline(x: NDArray, k: int, i: int, T: NDArray):
"""Compute M-spline basis function.
Expand Down

0 comments on commit 0a57674

Please sign in to comment.