Skip to content

Commit 2447d0f

Browse files
ceriottmagoscinski
authored andcommitted
Fix in test_dch.py failing test_selected_idx_and_scores due to sign flip(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.
1 parent 18bca5f commit 2447d0f

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

tests/test_dch.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ def test_selected_idx_and_scores(self):
3030
selector.fit(self.T, self.y)
3131
self.assertTrue(np.allclose(selector.selected_idx_, self.idx))
3232

33-
feature_residuals = selector.score_feature_matrix(self.T)
33+
# takes abs to avoid numerical noise changing the sign of PCA projections
34+
feature_residuals = np.abs(selector.score_feature_matrix(self.T))
3435
val = np.max(
3536
np.abs(
3637
(self.feature_residuals_100 - feature_residuals[100])

0 commit comments

Comments
 (0)