Skip to content

Commit

Permalink
Fix in test_dch.py failing test_selected_idx_and_scores due to sign f…
Browse files Browse the repository at this point in the history
…lip(s) in PCA

With version changes of the of sklearn the PCA output can have sign
flips of the principal components. Now we only compare the absolute
value to make the test invariant to such sign changes.
  • Loading branch information
ceriottm authored and agoscinski committed May 24, 2024
1 parent a54a4b2 commit 6affcc2
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion tests/test_dch.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ def test_selected_idx_and_scores(self):
selector.fit(self.T, self.y)
self.assertTrue(np.allclose(selector.selected_idx_, self.idx))

feature_residuals = selector.score_feature_matrix(self.T)
# takes abs to avoid numerical noise changing the sign of PCA projections
feature_residuals = np.abs(selector.score_feature_matrix(self.T))
val = np.max(
np.abs(
(self.feature_residuals_100 - feature_residuals[100])
Expand Down

0 comments on commit 6affcc2

Please sign in to comment.