Skip to content

Commit

Permalink
MAINT compatibility scikit-learn 1.5.2 and Numpy 2 (#1097)
Browse files Browse the repository at this point in the history
  • Loading branch information
glemaitre committed Oct 4, 2024
1 parent 5f0ef2d commit 0a0cb92
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 3 deletions.
2 changes: 1 addition & 1 deletion azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ jobs:
- template: build_tools/azure/posix.yml
parameters:
name: macOS
vmImage: macOS-11
vmImage: macOS-12
dependsOn: [linting, git_commit]
condition: |
and(
Expand Down
7 changes: 7 additions & 0 deletions conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,14 @@

import os

import numpy as np
import pytest
from sklearn.utils.fixes import parse_version

# use legacy numpy print options to avoid failures due to NumPy 2.+ scalar
# representation
if parse_version(np.__version__) > parse_version("2.0.0"):
np.set_printoptions(legacy="1.25")


def pytest_runtest_setup(item):
Expand Down
14 changes: 14 additions & 0 deletions doc/whats_new/v0.12.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
.. _changes_0_12:

Version 0.12.4
==============

**October 4, 2024**

Changelog
---------

Compatibility
.............

- Compatibility with NumPy 2.0+
:pr:`1097` by :user:`Guillaume Lemaitre <glemaitre>`.

Version 0.12.3
==============

Expand Down
2 changes: 1 addition & 1 deletion imblearn/metrics/pairwise.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ def fit(self, X, y):
f"elements in n_categories and {self.n_features_in_} in "
f"X."
)
self.n_categories_ = np.array(self.n_categories, copy=False)
self.n_categories_ = np.asarray(self.n_categories)
classes = unique_labels(y)

# list of length n_features of ndarray (n_categories, n_classes)
Expand Down
2 changes: 1 addition & 1 deletion imblearn/utils/estimator_checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ def check_samplers_sparse(name, sampler_orig):
sampler = clone(sampler)
X_res, y_res = sampler.fit_resample(X, y)
assert sparse.issparse(X_res_sparse)
assert_allclose(X_res_sparse.A, X_res, rtol=1e-5)
assert_allclose(X_res_sparse.toarray(), X_res, rtol=1e-5)
assert_allclose(y_res_sparse, y_res)


Expand Down

0 comments on commit 0a0cb92

Please sign in to comment.