Skip to content

Commit

Permalink
fixed rendering docstrings
Browse files Browse the repository at this point in the history
  • Loading branch information
BalzaniEdoardo committed Dec 14, 2024
1 parent 15f547e commit 8c8c273
Showing 1 changed file with 48 additions and 84 deletions.
132 changes: 48 additions & 84 deletions src/nemos/basis/basis.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,26 +158,23 @@ def evaluate_on_grid(self, n_samples: int) -> Tuple[NDArray, NDArray]:
"""
return super().evaluate_on_grid(n_samples)

@add_docstring("set_input_shape", BSplineBasis)
@add_docstring("set_input_shape", AtomicBasisMixin)
def set_input_shape(self, xi: int | tuple[int, ...] | NDArray):
"""
Examples
--------
>>> import nemos as nmo
>>> import numpy as np
>>> basis = nmo.basis.BSplineEval(5)
Configure with an integer input:
>>> # Configure with an integer input:
>>> _ = basis.set_input_shape(3)
>>> basis.n_output_features
15
Configure with a tuple:
>>> # Configure with a tuple:
>>> _ = basis.set_input_shape((4, 5))
>>> basis.n_output_features
100
Configure with an array:
>>> # Configure with an array:
>>> x = np.ones((10, 4, 5))
>>> _ = basis.set_input_shape(x)
>>> basis.n_output_features
Expand Down Expand Up @@ -312,26 +309,23 @@ def evaluate_on_grid(self, n_samples: int) -> Tuple[NDArray, NDArray]:
"""
return super().evaluate_on_grid(n_samples)

@add_docstring("set_input_shape", BSplineBasis)
@add_docstring("set_input_shape", AtomicBasisMixin)
def set_input_shape(self, xi: int | tuple[int, ...] | NDArray):
"""
Examples
--------
>>> import nemos as nmo
>>> import numpy as np
>>> basis = nmo.basis.BSplineConv(5, 10)
Configure with an integer input:
>>> # Configure with an integer input:
>>> _ = basis.set_input_shape(3)
>>> basis.n_output_features
15
Configure with a tuple:
>>> # Configure with a tuple:
>>> _ = basis.set_input_shape((4, 5))
>>> basis.n_output_features
100
Configure with an array:
>>> # Configure with an array:
>>> x = np.ones((10, 4, 5))
>>> _ = basis.set_input_shape(x)
>>> basis.n_output_features
Expand Down Expand Up @@ -453,26 +447,23 @@ def evaluate_on_grid(self, n_samples: int) -> Tuple[NDArray, NDArray]:
"""
return super().evaluate_on_grid(n_samples)

@add_docstring("set_input_shape", CyclicBSplineBasis)
@add_docstring("set_input_shape", AtomicBasisMixin)
def set_input_shape(self, xi: int | tuple[int, ...] | NDArray):
"""
Examples
--------
>>> import nemos as nmo
>>> import numpy as np
>>> basis = nmo.basis.CyclicBSplineEval(5)
Configure with an integer input:
>>> # Configure with an integer input:
>>> _ = basis.set_input_shape(3)
>>> basis.n_output_features
15
Configure with a tuple:
>>> # Configure with a tuple:
>>> _ = basis.set_input_shape((4, 5))
>>> basis.n_output_features
100
Configure with an array:
>>> # Configure with an array:
>>> x = np.ones((10, 4, 5))
>>> _ = basis.set_input_shape(x)
>>> basis.n_output_features
Expand Down Expand Up @@ -599,26 +590,23 @@ def evaluate_on_grid(self, n_samples: int) -> Tuple[NDArray, NDArray]:
"""
return super().evaluate_on_grid(n_samples)

@add_docstring("set_input_shape", CyclicBSplineBasis)
@add_docstring("set_input_shape", AtomicBasisMixin)
def set_input_shape(self, xi: int | tuple[int, ...] | NDArray):
"""
Examples
--------
>>> import nemos as nmo
>>> import numpy as np
>>> basis = nmo.basis.CyclicBSplineConv(5, 10)
Configure with an integer input:
>>> # Configure with an integer input:
>>> _ = basis.set_input_shape(3)
>>> basis.n_output_features
15
Configure with a tuple:
>>> # Configure with a tuple:
>>> _ = basis.set_input_shape((4, 5))
>>> basis.n_output_features
100
Configure with an array:
>>> # Configure with an array:
>>> x = np.ones((10, 4, 5))
>>> _ = basis.set_input_shape(x)
>>> basis.n_output_features
Expand Down Expand Up @@ -764,26 +752,23 @@ def evaluate_on_grid(self, n_samples: int) -> Tuple[NDArray, NDArray]:
"""
return super().evaluate_on_grid(n_samples)

@add_docstring("set_input_shape", MSplineBasis)
@add_docstring("set_input_shape", AtomicBasisMixin)
def set_input_shape(self, xi: int | tuple[int, ...] | NDArray):
"""
Examples
--------
>>> import nemos as nmo
>>> import numpy as np
>>> basis = nmo.basis.MSplineEval(5)
Configure with an integer input:
>>> # Configure with an integer input:
>>> _ = basis.set_input_shape(3)
>>> basis.n_output_features
15
Configure with a tuple:
>>> # Configure with a tuple:
>>> _ = basis.set_input_shape((4, 5))
>>> basis.n_output_features
100
Configure with an array:
>>> # Configure with an array:
>>> x = np.ones((10, 4, 5))
>>> _ = basis.set_input_shape(x)
>>> basis.n_output_features
Expand Down Expand Up @@ -934,26 +919,23 @@ def evaluate_on_grid(self, n_samples: int) -> Tuple[NDArray, NDArray]:
"""
return super().evaluate_on_grid(n_samples)

@add_docstring("set_input_shape", MSplineBasis)
@add_docstring("set_input_shape", AtomicBasisMixin)
def set_input_shape(self, xi: int | tuple[int, ...] | NDArray):
"""
Examples
--------
>>> import nemos as nmo
>>> import numpy as np
>>> basis = nmo.basis.MSplineConv(5, 10)
Configure with an integer input:
>>> # Configure with an integer input:
>>> _ = basis.set_input_shape(3)
>>> basis.n_output_features
15
Configure with a tuple:
>>> # Configure with a tuple:
>>> _ = basis.set_input_shape((4, 5))
>>> basis.n_output_features
100
Configure with an array:
>>> # Configure with an array:
>>> x = np.ones((10, 4, 5))
>>> _ = basis.set_input_shape(x)
>>> basis.n_output_features
Expand Down Expand Up @@ -1076,26 +1058,23 @@ def split_by_feature(
"""
return super().split_by_feature(x, axis=axis)

@add_docstring("set_input_shape", RaisedCosineBasisLinear)
@add_docstring("set_input_shape", AtomicBasisMixin)
def set_input_shape(self, xi: int | tuple[int, ...] | NDArray):
"""
Examples
--------
>>> import nemos as nmo
>>> import numpy as np
>>> basis = nmo.basis.RaisedCosineLinearEval(5)
Configure with an integer input:
>>> # Configure with an integer input:
>>> _ = basis.set_input_shape(3)
>>> basis.n_output_features
15
Configure with a tuple:
>>> # Configure with a tuple:
>>> _ = basis.set_input_shape((4, 5))
>>> basis.n_output_features
100
Configure with an array:
>>> # Configure with an array:
>>> x = np.ones((10, 4, 5))
>>> _ = basis.set_input_shape(x)
>>> basis.n_output_features
Expand Down Expand Up @@ -1223,26 +1202,23 @@ def split_by_feature(
"""
return super().split_by_feature(x, axis=axis)

@add_docstring("set_input_shape", RaisedCosineBasisLinear)
@add_docstring("set_input_shape", AtomicBasisMixin)
def set_input_shape(self, xi: int | tuple[int, ...] | NDArray):
"""
Examples
--------
>>> import nemos as nmo
>>> import numpy as np
>>> basis = nmo.basis.RaisedCosineLinearConv(5, 10)
Configure with an integer input:
>>> # Configure with an integer input:
>>> _ = basis.set_input_shape(3)
>>> basis.n_output_features
15
Configure with a tuple:
>>> # Configure with a tuple:
>>> _ = basis.set_input_shape((4, 5))
>>> basis.n_output_features
100
Configure with an array:
>>> # Configure with an array:
>>> x = np.ones((10, 4, 5))
>>> _ = basis.set_input_shape(x)
>>> basis.n_output_features
Expand Down Expand Up @@ -1381,26 +1357,23 @@ def split_by_feature(
"""
return super().split_by_feature(x, axis=axis)

@add_docstring("set_input_shape", RaisedCosineBasisLog)
@add_docstring("set_input_shape", AtomicBasisMixin)
def set_input_shape(self, xi: int | tuple[int, ...] | NDArray):
"""
Examples
--------
>>> import nemos as nmo
>>> import numpy as np
>>> basis = nmo.basis.RaisedCosineLogEval(5)
Configure with an integer input:
>>> # Configure with an integer input:
>>> _ = basis.set_input_shape(3)
>>> basis.n_output_features
15
Configure with a tuple:
>>> # Configure with a tuple:
>>> _ = basis.set_input_shape((4, 5))
>>> basis.n_output_features
100
Configure with an array:
>>> # Configure with an array:
>>> x = np.ones((10, 4, 5))
>>> _ = basis.set_input_shape(x)
>>> basis.n_output_features
Expand Down Expand Up @@ -1540,26 +1513,23 @@ def split_by_feature(
"""
return super().split_by_feature(x, axis=axis)

@add_docstring("set_input_shape", RaisedCosineBasisLog)
@add_docstring("set_input_shape", AtomicBasisMixin)
def set_input_shape(self, xi: int | tuple[int, ...] | NDArray):
"""
Examples
--------
>>> import nemos as nmo
>>> import numpy as np
>>> basis = nmo.basis.RaisedCosineLogConv(5, 10)
Configure with an integer input:
>>> # Configure with an integer input:
>>> _ = basis.set_input_shape(3)
>>> basis.n_output_features
15
Configure with a tuple:
>>> # Configure with a tuple:
>>> _ = basis.set_input_shape((4, 5))
>>> basis.n_output_features
100
Configure with an array:
>>> # Configure with an array:
>>> x = np.ones((10, 4, 5))
>>> _ = basis.set_input_shape(x)
>>> basis.n_output_features
Expand Down Expand Up @@ -1680,26 +1650,23 @@ def split_by_feature(
"""
return super().split_by_feature(x, axis=axis)

@add_docstring("set_input_shape", OrthExponentialBasis)
@add_docstring("set_input_shape", AtomicBasisMixin)
def set_input_shape(self, xi: int | tuple[int, ...] | NDArray):
"""
Examples
--------
>>> import nemos as nmo
>>> import numpy as np
>>> basis = nmo.basis.OrthExponentialEval(5, decay_rates=np.arange(1, 6))
Configure with an integer input:
>>> # Configure with an integer input:
>>> _ = basis.set_input_shape(3)
>>> basis.n_output_features
15
Configure with a tuple:
>>> # Configure with a tuple:
>>> _ = basis.set_input_shape((4, 5))
>>> basis.n_output_features
100
Configure with an array:
>>> # Configure with an array:
>>> x = np.ones((10, 4, 5))
>>> _ = basis.set_input_shape(x)
>>> basis.n_output_features
Expand Down Expand Up @@ -1827,26 +1794,23 @@ def split_by_feature(
"""
return super().split_by_feature(x, axis=axis)

@add_docstring("set_input_shape", OrthExponentialBasis)
@add_docstring("set_input_shape", AtomicBasisMixin)
def set_input_shape(self, xi: int | tuple[int, ...] | NDArray):
"""
Examples
--------
>>> import nemos as nmo
>>> import numpy as np
>>> basis = nmo.basis.OrthExponentialConv(5, window_size=10, decay_rates=np.arange(1, 6))
Configure with an integer input:
>>> # Configure with an integer input:
>>> _ = basis.set_input_shape(3)
>>> basis.n_output_features
15
Configure with a tuple:
>>> # Configure with a tuple:
>>> _ = basis.set_input_shape((4, 5))
>>> basis.n_output_features
100
Configure with an array:
>>> # Configure with an array:
>>> x = np.ones((10, 4, 5))
>>> _ = basis.set_input_shape(x)
>>> basis.n_output_features
Expand Down

0 comments on commit 8c8c273

Please sign in to comment.