Skip to content

MAINT compatibility scikit-learn 1.5.2 and Numpy 2 #1097

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Oct 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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