Skip to content

Commit a5e815e

Browse files
authored
Fix errors introduced by sklearn 1.5 PR #229
* 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
2 parents dd31493 + 4c50009 commit a5e815e

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

CHANGELOG

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ The rules for CHANGELOG file:
1515
------------------
1616
- Updating ``FPS`` to allow a numpy array of ints as an initialize parameter (#145)
1717
- Supported Python versions are now ranging from 3.9 - 3.12.
18+
- Updating ``skmatter.datasets`` submodule to support sklearn 1.5.0 (#229)
1819

1920
0.2.0 (2023/08/24)
2021
------------------

src/skmatter/datasets/_base.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,15 @@
11
from os.path import dirname, join
22

33
import numpy as np
4-
from sklearn.utils import Bunch, check_pandas_support
4+
import sklearn
5+
6+
7+
if sklearn.__version__ >= "1.5.0":
8+
from sklearn.utils._optional_dependencies import check_pandas_support
9+
else:
10+
from sklearn.utils import check_pandas_support
11+
12+
from sklearn.utils import Bunch
513

614

715
def load_nice_dataset():

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)