Skip to content

Commit

Permalink
First commit
Browse files Browse the repository at this point in the history
  • Loading branch information
gviejo committed Oct 2, 2024
1 parent a7659d5 commit c4f3c53
Showing 1 changed file with 32 additions and 3 deletions.
35 changes: 32 additions & 3 deletions src/nemos/basis.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ def _unpack_inputs(X: FeatureMatrix):
A tuple of each individual input.
"""

return (X[:, k] for k in range(X.shape[1]))

def fit(self, X: FeatureMatrix, y=None):
Expand Down Expand Up @@ -934,21 +935,41 @@ def __add__(self, other: Basis) -> AdditiveBasis:
"""
return AdditiveBasis(self, other)

def __mul__(self, other: Basis) -> MultiplicativeBasis:
def __len__(self) -> int:
"""
Returns
-------
: int
Number of basis functions.
"""
return self.n_basis_funcs

def __mul__(self, other: (Basis, int)) -> MultiplicativeBasis:
"""
Multiply two Basis objects together.
Parameters
----------
other
The other Basis object to multiply.
The other Basis object to multiply or integer
Returns
-------
:
The resulting Basis object.
"""
return MultiplicativeBasis(self, other)
if isinstance(other, Basis):
return MultiplicativeBasis(self, other)
elif isinstance(other, int):
if other <= 0:
raise ValueError("Multiplier should be a non-negative integer!")
result = self
for _ in range(other-1):
result = result + self
return result
else:
raise TypeError("Basis can only be multiplied with another basis or an integer!")

def __pow__(self, exponent: int) -> MultiplicativeBasis:
"""Exponentiation of a Basis object.
Expand Down Expand Up @@ -1044,6 +1065,14 @@ def __init__(self, basis1: Basis, basis2: Basis) -> None:
self._basis2 = basis2
return

@property
def basis1(self):
return self._basis1

@property
def basis2(self):
return self._basis2

def _check_n_basis_min(self) -> None:
pass

Expand Down

0 comments on commit c4f3c53

Please sign in to comment.