From 8c8c273c4ab6e388f231ee10a70c670fd4ee8180 Mon Sep 17 00:00:00 2001 From: BalzaniEdoardo Date: Fri, 13 Dec 2024 21:31:17 -0500 Subject: [PATCH] fixed rendering docstrings --- src/nemos/basis/basis.py | 132 ++++++++++++++------------------------- 1 file changed, 48 insertions(+), 84 deletions(-) diff --git a/src/nemos/basis/basis.py b/src/nemos/basis/basis.py index 758e1f6d..2ea0bd86 100644 --- a/src/nemos/basis/basis.py +++ b/src/nemos/basis/basis.py @@ -158,7 +158,7 @@ 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 @@ -166,18 +166,15 @@ def set_input_shape(self, xi: int | tuple[int, ...] | NDArray): >>> 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 @@ -312,7 +309,7 @@ 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 @@ -320,18 +317,15 @@ def set_input_shape(self, xi: int | tuple[int, ...] | NDArray): >>> 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 @@ -453,7 +447,7 @@ 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 @@ -461,18 +455,15 @@ def set_input_shape(self, xi: int | tuple[int, ...] | NDArray): >>> 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 @@ -599,7 +590,7 @@ 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 @@ -607,18 +598,15 @@ def set_input_shape(self, xi: int | tuple[int, ...] | NDArray): >>> 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 @@ -764,7 +752,7 @@ 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 @@ -772,18 +760,15 @@ def set_input_shape(self, xi: int | tuple[int, ...] | NDArray): >>> 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 @@ -934,7 +919,7 @@ 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 @@ -942,18 +927,15 @@ def set_input_shape(self, xi: int | tuple[int, ...] | NDArray): >>> 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 @@ -1076,7 +1058,7 @@ 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 @@ -1084,18 +1066,15 @@ def set_input_shape(self, xi: int | tuple[int, ...] | NDArray): >>> 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 @@ -1223,7 +1202,7 @@ 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 @@ -1231,18 +1210,15 @@ def set_input_shape(self, xi: int | tuple[int, ...] | NDArray): >>> 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 @@ -1381,7 +1357,7 @@ 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 @@ -1389,18 +1365,15 @@ def set_input_shape(self, xi: int | tuple[int, ...] | NDArray): >>> 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 @@ -1540,7 +1513,7 @@ 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 @@ -1548,18 +1521,15 @@ def set_input_shape(self, xi: int | tuple[int, ...] | NDArray): >>> 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 @@ -1680,7 +1650,7 @@ 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 @@ -1688,18 +1658,15 @@ def set_input_shape(self, xi: int | tuple[int, ...] | NDArray): >>> 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 @@ -1827,7 +1794,7 @@ 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 @@ -1835,18 +1802,15 @@ def set_input_shape(self, xi: int | tuple[int, ...] | NDArray): >>> 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