Skip to content

Commit 980cc94

Browse files
committed
MAINT compatibility scikit-learn 1.5.2 and Numpy 2 (#1097)
1 parent 2b6269f commit 980cc94

File tree

5 files changed

+24
-3
lines changed

5 files changed

+24
-3
lines changed

azure-pipelines.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ jobs:
255255
- template: build_tools/azure/posix.yml
256256
parameters:
257257
name: macOS
258-
vmImage: macOS-11
258+
vmImage: macOS-12
259259
dependsOn: [linting, git_commit]
260260
condition: |
261261
and(

conftest.py

+7
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,14 @@
77

88
import os
99

10+
import numpy as np
1011
import pytest
12+
from sklearn.utils.fixes import parse_version
13+
14+
# use legacy numpy print options to avoid failures due to NumPy 2.+ scalar
15+
# representation
16+
if parse_version(np.__version__) > parse_version("2.0.0"):
17+
np.set_printoptions(legacy="1.25")
1118

1219

1320
def pytest_runtest_setup(item):

doc/whats_new/v0.12.rst

+14
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,19 @@
11
.. _changes_0_12:
22

3+
Version 0.12.4
4+
==============
5+
6+
**October 4, 2024**
7+
8+
Changelog
9+
---------
10+
11+
Compatibility
12+
.............
13+
14+
- Compatibility with NumPy 2.0+
15+
:pr:`1097` by :user:`Guillaume Lemaitre <glemaitre>`.
16+
317
Version 0.12.3
418
==============
519

imblearn/metrics/pairwise.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ def fit(self, X, y):
161161
f"elements in n_categories and {self.n_features_in_} in "
162162
f"X."
163163
)
164-
self.n_categories_ = np.array(self.n_categories, copy=False)
164+
self.n_categories_ = np.asarray(self.n_categories)
165165
classes = unique_labels(y)
166166

167167
# list of length n_features of ndarray (n_categories, n_classes)

imblearn/utils/estimator_checks.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ def check_samplers_sparse(name, sampler_orig):
309309
sampler = clone(sampler)
310310
X_res, y_res = sampler.fit_resample(X, y)
311311
assert sparse.issparse(X_res_sparse)
312-
assert_allclose(X_res_sparse.A, X_res, rtol=1e-5)
312+
assert_allclose(X_res_sparse.toarray(), X_res, rtol=1e-5)
313313
assert_allclose(y_res_sparse, y_res)
314314

315315

0 commit comments

Comments
 (0)