Skip to content

Commit

Permalink
Fix compatibility with NumPy v1.24 (#3323)
Browse files Browse the repository at this point in the history
* Fix

* More fixes

* Use latest scikit-learn
  • Loading branch information
vcfgv committed Jan 16, 2023
1 parent 194021c commit 181fe51
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 29 deletions.
7 changes: 1 addition & 6 deletions .github/workflows/platform-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ jobs:
source ./ci/rewrite-cov-config.sh
pip install numpy scipy cython "scikit-learn<1.2.0"
pip install numpy scipy cython
pip install -e ".[dev,extra]"
Expand Down Expand Up @@ -104,11 +104,6 @@ jobs:
fi
if [ -n "$WITH_RAY" ] || [ -n "$WITH_RAY_DAG" ] || [ -n "$WITH_RAY_DEPLOY" ]; then
pip install "xgboost_ray" "protobuf<4"
# Future PR will Unpin numpy.
pip install "numpy<1.24"
# Use standard ray releases when ownership bug is fixed
# pip uninstall -y ray
# pip install https://s3-us-west-2.amazonaws.com/ray-wheels/master/c03d0432f3bb40f3c597b7fc450870ba5e34ad56/ray-3.0.0.dev0-cp38-cp38-manylinux2014_x86_64.whl
# Ray Datasets need pyarrow>=6.0.1
pip install "pyarrow>=6.0.1"
fi
Expand Down
2 changes: 1 addition & 1 deletion azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ jobs:
source ./ci/rewrite-cov-config.sh
if [[ "$(mars.test.module)" == "learn" ]]; then
pip install numpy\<1.20.0 scipy cython scikit-learn\<1.2.0
pip install numpy\<1.20.0 scipy cython
else
pip install numpy scipy cython
fi
Expand Down
2 changes: 1 addition & 1 deletion mars/learn/datasets/tests/test_samples_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ def test_make_classification_informative_features(setup):
(2, [1 / 2] * 2, 2),
(2, [3 / 4, 1 / 4], 2),
(10, [1 / 3] * 3, 10),
(np.int(64), [1], 1),
(np.int_(64), [1], 1),
]:
n_classes = len(weights)
n_clusters = n_classes * n_clusters_per_class
Expand Down
4 changes: 2 additions & 2 deletions mars/learn/utils/tests/test_multiclass.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@
[()],
# sequence of sequences that weren't supported even before deprecation
np.array([np.array([]), np.array([1, 2, 3])], dtype=object),
[np.array([]), np.array([1, 2, 3])],
# [np.array([]), np.array([1, 2, 3])], # deprecated in numpy v1.24
[{1, 2, 3}, {1, 2}],
[frozenset([1, 2, 3]), frozenset([1, 2])],
# and also confusable as sequences of sequences
Expand Down Expand Up @@ -222,7 +222,7 @@ def test_is_multilabel(setup):
raws = [
[[1, 2]],
[0, 1, 0, 1],
[[1], [0, 2], []],
# [[1], [0, 2], []], # deprecated in numpy v1.24
np.array([[1, 0], [0, 0]]),
np.array([[1], [0], [0]]),
np.array([[1, 0, 0]]),
Expand Down
22 changes: 4 additions & 18 deletions mars/tensor/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -334,14 +334,14 @@
character,
generic,
flexible,
int_,
bool_,
float_,
int_ as int,
bool_ as bool,
float_ as float,
cfloat,
bytes_,
unicode_,
void,
object_,
object_ as object,
intc,
intp,
int8,
Expand Down Expand Up @@ -371,20 +371,6 @@
from .fetch import TensorFetch, TensorFetchShuffle
from . import ufunc

try:
import warnings

# suppress numpy warnings on types
with warnings.catch_warnings():
warnings.simplefilter("ignore", DeprecationWarning)
warnings.simplefilter("ignore", FutureWarning)
# noinspection PyUnresolvedReferences
from numpy import object, int, bool, float
except ImportError: # pragma: no cover
pass
finally:
del warnings

del (
TensorFuseChunk,
TensorCpFuseChunk,
Expand Down
2 changes: 1 addition & 1 deletion mars/tests/test_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ def test_array_protocol(setup):

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

result = np.asarray(arr2, mt.bool_)
result = np.asarray(arr2, mt.bool)
np.testing.assert_array_equal(result, np.ones((10, 20), dtype=np.bool_))

arr3 = mt.ones((10, 20)).sum()
Expand Down

0 comments on commit 181fe51

Please sign in to comment.