Skip to content

Commit 181fe51

Browse files
authored
Fix compatibility with NumPy v1.24 (#3323)
* Fix * More fixes * Use latest scikit-learn
1 parent 194021c commit 181fe51

File tree

6 files changed

+10
-29
lines changed

6 files changed

+10
-29
lines changed

.github/workflows/platform-ci.yml

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ jobs:
7272
7373
source ./ci/rewrite-cov-config.sh
7474
75-
pip install numpy scipy cython "scikit-learn<1.2.0"
75+
pip install numpy scipy cython
7676
7777
pip install -e ".[dev,extra]"
7878
@@ -104,11 +104,6 @@ jobs:
104104
fi
105105
if [ -n "$WITH_RAY" ] || [ -n "$WITH_RAY_DAG" ] || [ -n "$WITH_RAY_DEPLOY" ]; then
106106
pip install "xgboost_ray" "protobuf<4"
107-
# Future PR will Unpin numpy.
108-
pip install "numpy<1.24"
109-
# Use standard ray releases when ownership bug is fixed
110-
# pip uninstall -y ray
111-
# pip install https://s3-us-west-2.amazonaws.com/ray-wheels/master/c03d0432f3bb40f3c597b7fc450870ba5e34ad56/ray-3.0.0.dev0-cp38-cp38-manylinux2014_x86_64.whl
112107
# Ray Datasets need pyarrow>=6.0.1
113108
pip install "pyarrow>=6.0.1"
114109
fi

azure-pipelines.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ jobs:
6060
source ./ci/rewrite-cov-config.sh
6161
6262
if [[ "$(mars.test.module)" == "learn" ]]; then
63-
pip install numpy\<1.20.0 scipy cython scikit-learn\<1.2.0
63+
pip install numpy\<1.20.0 scipy cython
6464
else
6565
pip install numpy scipy cython
6666
fi

mars/learn/datasets/tests/test_samples_generator.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ def test_make_classification_informative_features(setup):
110110
(2, [1 / 2] * 2, 2),
111111
(2, [3 / 4, 1 / 4], 2),
112112
(10, [1 / 3] * 3, 10),
113-
(np.int(64), [1], 1),
113+
(np.int_(64), [1], 1),
114114
]:
115115
n_classes = len(weights)
116116
n_clusters = n_classes * n_clusters_per_class

mars/learn/utils/tests/test_multiclass.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@
117117
[()],
118118
# sequence of sequences that weren't supported even before deprecation
119119
np.array([np.array([]), np.array([1, 2, 3])], dtype=object),
120-
[np.array([]), np.array([1, 2, 3])],
120+
# [np.array([]), np.array([1, 2, 3])], # deprecated in numpy v1.24
121121
[{1, 2, 3}, {1, 2}],
122122
[frozenset([1, 2, 3]), frozenset([1, 2])],
123123
# and also confusable as sequences of sequences
@@ -222,7 +222,7 @@ def test_is_multilabel(setup):
222222
raws = [
223223
[[1, 2]],
224224
[0, 1, 0, 1],
225-
[[1], [0, 2], []],
225+
# [[1], [0, 2], []], # deprecated in numpy v1.24
226226
np.array([[1, 0], [0, 0]]),
227227
np.array([[1], [0], [0]]),
228228
np.array([[1, 0, 0]]),

mars/tensor/__init__.py

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -334,14 +334,14 @@
334334
character,
335335
generic,
336336
flexible,
337-
int_,
338-
bool_,
339-
float_,
337+
int_ as int,
338+
bool_ as bool,
339+
float_ as float,
340340
cfloat,
341341
bytes_,
342342
unicode_,
343343
void,
344-
object_,
344+
object_ as object,
345345
intc,
346346
intp,
347347
int8,
@@ -371,20 +371,6 @@
371371
from .fetch import TensorFetch, TensorFetchShuffle
372372
from . import ufunc
373373

374-
try:
375-
import warnings
376-
377-
# suppress numpy warnings on types
378-
with warnings.catch_warnings():
379-
warnings.simplefilter("ignore", DeprecationWarning)
380-
warnings.simplefilter("ignore", FutureWarning)
381-
# noinspection PyUnresolvedReferences
382-
from numpy import object, int, bool, float
383-
except ImportError: # pragma: no cover
384-
pass
385-
finally:
386-
del warnings
387-
388374
del (
389375
TensorFuseChunk,
390376
TensorCpFuseChunk,

mars/tests/test_session.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ def test_array_protocol(setup):
188188

189189
arr2 = mt.ones((10, 20))
190190

191-
result = np.asarray(arr2, mt.bool_)
191+
result = np.asarray(arr2, mt.bool)
192192
np.testing.assert_array_equal(result, np.ones((10, 20), dtype=np.bool_))
193193

194194
arr3 = mt.ones((10, 20)).sum()

0 commit comments

Comments
 (0)