Skip to content

Commit

Permalink
Remove cupy.array_equal, since it's not compatible with cuPy 7.8 (#6528)
Browse files Browse the repository at this point in the history
  • Loading branch information
hcho3 committed Dec 18, 2020
1 parent ca3da55 commit 380f6f4
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions python-package/xgboost/sklearn.py
Expand Up @@ -852,14 +852,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 380f6f4

Please sign in to comment.