Skip to content

Commit

Permalink
Fix errors introduced by sklearn 1.5 PR #229
Browse files Browse the repository at this point in the history
* Fix check_pandas_support import error introduced by sklearn 1.5.0
* Fix in test_dch.py failing test_selected_idx_and_scores due to sign flip(s) in PCA
  • Loading branch information
agoscinski authored May 26, 2024
2 parents dd31493 + 4c50009 commit a5e815e
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ The rules for CHANGELOG file:
------------------
- Updating ``FPS`` to allow a numpy array of ints as an initialize parameter (#145)
- Supported Python versions are now ranging from 3.9 - 3.12.
- Updating ``skmatter.datasets`` submodule to support sklearn 1.5.0 (#229)

0.2.0 (2023/08/24)
------------------
Expand Down
10 changes: 9 additions & 1 deletion src/skmatter/datasets/_base.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
from os.path import dirname, join

import numpy as np
from sklearn.utils import Bunch, check_pandas_support
import sklearn


if sklearn.__version__ >= "1.5.0":
from sklearn.utils._optional_dependencies import check_pandas_support
else:
from sklearn.utils import check_pandas_support

from sklearn.utils import Bunch


def load_nice_dataset():
Expand Down
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 a5e815e

Please sign in to comment.