Skip to content

CI Fix scipy-dev issues related to numpy 2.0 changes #27190

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
Aug 29, 2023
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
4 changes: 2 additions & 2 deletions sklearn/cluster/_hdbscan/_linkage.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ cpdef cnp.ndarray[MST_edge_t, ndim=1, mode='c'] mst_from_mutual_reachability(
mst = np.empty(n_samples - 1, dtype=MST_edge_dtype)
current_labels = np.arange(n_samples, dtype=np.int64)
current_node = 0
min_reachability = np.full(n_samples, fill_value=np.infty, dtype=np.float64)
min_reachability = np.full(n_samples, fill_value=np.inf, dtype=np.float64)
for i in range(0, n_samples - 1):
label_filter = current_labels != current_node
current_labels = current_labels[label_filter]
Expand Down Expand Up @@ -156,7 +156,7 @@ cpdef cnp.ndarray[MST_edge_t, ndim=1, mode='c'] mst_from_data_matrix(
mst = np.empty(n_samples - 1, dtype=MST_edge_dtype)

in_tree = np.zeros(n_samples, dtype=np.uint8)
min_reachability = np.full(n_samples, fill_value=np.infty, dtype=np.float64)
min_reachability = np.full(n_samples, fill_value=np.inf, dtype=np.float64)
current_sources = np.ones(n_samples, dtype=np.int64)

current_node = 0
Expand Down
4 changes: 2 additions & 2 deletions sklearn/impute/tests/test_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,9 +192,9 @@ def test_imputation_adds_missing_indicator_if_add_indicator_is_true(

Non-regression test for gh-26590.
"""
X_train = np.array([[0, np.NaN], [1, 2]])
X_train = np.array([[0, np.nan], [1, 2]])

# Test data where missing_value_test variable can be set to np.NaN or 1.
# Test data where missing_value_test variable can be set to np.nan or 1.
X_test = np.array([[0, missing_value_test], [1, 2]])

imputer.set_params(add_indicator=True)
Expand Down
2 changes: 1 addition & 1 deletion sklearn/preprocessing/tests/test_encoders.py
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,7 @@ def test_X_is_not_1D_pandas(method):
np.object_,
),
(np.array([["A", "cat"], ["B", "cat"]]), [["A", "B"], ["cat"]], np.str_),
(np.array([[1, 2], [np.nan, 2]]), [[1, np.nan], [2]], np.float_),
(np.array([[1, 2], [np.nan, 2]]), [[1, np.nan], [2]], np.float64),
(
np.array([["A", np.nan], [None, np.nan]], dtype=object),
[["A", None], [np.nan]],
Expand Down
4 changes: 2 additions & 2 deletions sklearn/utils/fixes.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,6 @@ def _contents(data_module):
# For +1.25 NumPy versions exceptions and warnings are being moved
# to a dedicated submodule.
if np_version >= parse_version("1.25.0"):
from numpy.exceptions import VisibleDeprecationWarning
from numpy.exceptions import ComplexWarning, VisibleDeprecationWarning
else:
from numpy import VisibleDeprecationWarning # type: ignore # noqa
from numpy import ComplexWarning, VisibleDeprecationWarning # type: ignore # noqa
2 changes: 1 addition & 1 deletion sklearn/utils/tests/test_validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -1586,7 +1586,7 @@ def test_check_pandas_sparse_invalid(ntype1, ntype2):
@pytest.mark.parametrize(
"ntype1, ntype2, expected_subtype",
[
("longfloat", "longdouble", np.floating),
("double", "longdouble", np.floating),
("float16", "half", np.floating),
("single", "float32", np.floating),
("double", "float64", np.floating),
Expand Down
4 changes: 1 addition & 3 deletions sklearn/utils/validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,10 @@
import numpy as np
import scipy.sparse as sp

# mypy error: Module 'numpy.core.numeric' has no attribute 'ComplexWarning'
from numpy.core.numeric import ComplexWarning # type: ignore

from .. import get_config as _get_config
from ..exceptions import DataConversionWarning, NotFittedError, PositiveSpectrumWarning
from ..utils._array_api import _asarray_with_order, _is_numpy_namespace, get_namespace
from ..utils.fixes import ComplexWarning
from ._isfinite import FiniteStatus, cy_isfinite
from .fixes import _object_dtype_isnan

Expand Down