Skip to content

Commit

Permalink
Remove cupy.array_equal, since it's not compatible with cuPy 7.8 (dml…
Browse files Browse the repository at this point in the history
  • Loading branch information
hcho3 authored and trivialfis committed Dec 20, 2020
1 parent bce7ca3 commit d5c5de5
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions python-package/xgboost/sklearn.py
Expand Up @@ -841,14 +841,18 @@ def fit(self, X, y, *, sample_weight=None, base_margin=None,
self.classes_ = cp.unique(y.values)
self.n_classes_ = len(self.classes_)
can_use_label_encoder = False
if not cp.array_equal(self.classes_, cp.arange(self.n_classes_)):
expected_classes = cp.arange(self.n_classes_)
if (self.classes_.shape != expected_classes.shape or
not (self.classes_ == expected_classes).all()):
raise ValueError(label_encoding_check_error)
elif _is_cupy_array(y):
import cupy as cp # pylint: disable=E0401
self.classes_ = cp.unique(y)
self.n_classes_ = len(self.classes_)
can_use_label_encoder = False
if not cp.array_equal(self.classes_, cp.arange(self.n_classes_)):
expected_classes = cp.arange(self.n_classes_)
if (self.classes_.shape != expected_classes.shape or
not (self.classes_ == expected_classes).all()):
raise ValueError(label_encoding_check_error)
else:
self.classes_ = np.unique(y)
Expand Down

0 comments on commit d5c5de5

Please sign in to comment.