From 0db443a5df013627a0ca573ea8be9e7ef591ecd2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Merlin=20Sch=C3=BCler?= Date: Thu, 18 Mar 2021 19:55:52 +0100 Subject: [PATCH] Removed underscore from affine_parameters method --- sksfa/_sfa.py | 10 ++++++---- sksfa/tests/test_sfa.py | 6 +++--- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/sksfa/_sfa.py b/sksfa/_sfa.py index efc88ec..dcc7e0b 100644 --- a/sksfa/_sfa.py +++ b/sksfa/_sfa.py @@ -433,12 +433,14 @@ def is_partially_fitted(self): except AttributeError: return False - def affine_parameters_(self): + def affine_parameters(self): """ - This function provides the parameters of a trained linear SFA model. - Only works if the standard fit method has been used (no partial_fit) and trivial dimensions are either not filled or only filled in 'fill_mode' == 'zero'. - Returns the parameters W, b so that the "np.dot(data, W.T) + b" should be equivalent to calling the 'transform' method. + This function provides the parameters of a trained linear SFA model. + Only works if the standard 'fit' method has been used (no 'partial_fit') and trivial dimensions are either not filled or only filled in 'fill_mode' == 'zero'. + Returns the parameters W, b so that the "np.dot(data, W.T) + b" is equivalent to calling the 'transform' method. """ + if not self.is_fitted: + raise AttributeError("Transformer has to be fitted to data before extracting parameters") out_dim = self.pca_diff_.components_.shape[0] n_missing_components = max(self.n_components_ - out_dim, 0) print(n_missing_components) diff --git a/sksfa/tests/test_sfa.py b/sksfa/tests/test_sfa.py index 6fdeb37..d6ce0cb 100644 --- a/sksfa/tests/test_sfa.py +++ b/sksfa/tests/test_sfa.py @@ -77,7 +77,7 @@ def test_sfa_parameter_computation(dimension, n_samples): current_data = mixed_trigonometric_functions(dimension, n_samples) sfa = SFA() slow_features = sfa.fit_transform(current_data) - W, b = sfa.affine_parameters_() + W, b = sfa.affine_parameters() affine_transformed = np.dot(current_data, W.T) + b assert np.allclose(slow_features, affine_transformed) @@ -87,7 +87,7 @@ def test_sfa_parameter_computation_rank_deficit_zero_fill(dimension, rank_defici current_data = mixed_trigonometric_functions(dimension, rank_deficit=rank_deficit) sfa = SFA(fill_mode="zero") slow_features = sfa.fit_transform(current_data) - W, b = sfa.affine_parameters_() + W, b = sfa.affine_parameters() affine_transformed = np.dot(current_data, W.T) + b assert np.allclose(slow_features, affine_transformed) @@ -98,4 +98,4 @@ def test_sfa_parameter_computation_rank_deficit_nonzero_fill(dimension, rank_def sfa = SFA(fill_mode="noise") slow_features = sfa.fit_transform(current_data) with pytest.raises(RuntimeError): - W, b = sfa.affine_parameters_() + W, b = sfa.affine_parameters()