Skip to content

Commit

Permalink
Check that the warning is being generated in the test.
Browse files Browse the repository at this point in the history
  • Loading branch information
Ddelval committed Oct 28, 2023
1 parent 9c032cc commit a7783e0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
2 changes: 1 addition & 1 deletion skfda/preprocessing/dim_reduction/_fpls.py
Original file line number Diff line number Diff line change
Expand Up @@ -654,7 +654,7 @@ def _perform_nipals(self) -> None: # noqa: WPS210
"one of the matrices is completely deflated. "
f"The algorithm will return {n_comp} components,"
f"instead of {self.n_components}.",
stacklevel=2,
stacklevel=3,
)
break

Expand Down
9 changes: 8 additions & 1 deletion skfda/tests/test_fpls.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,14 @@ def test_collinear_matrix(
fpls.fit(X, y)

fpls = FPLS(n_components=5)
fpls.fit(X, y)

# Check that a warning is raised when the rank is lower than the
# number of components
if rank < 5:
with pytest.warns(UserWarning):
fpls.fit(X, y)
else:
fpls.fit(X, y)

# Check that only as many components as rank are returned
assert fpls.x_weights_.shape == (n_features, rank)
Expand Down

0 comments on commit a7783e0

Please sign in to comment.