Skip to content

Commit

Permalink
Removed underscore from affine_parameters method
Browse files Browse the repository at this point in the history
  • Loading branch information
mrschue committed Mar 18, 2021
1 parent 54fa7e0 commit 0db443a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
10 changes: 6 additions & 4 deletions sksfa/_sfa.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions sksfa/tests/test_sfa.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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)

Expand All @@ -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()

0 comments on commit 0db443a

Please sign in to comment.