Skip to content

Commit

Permalink
Use cupy.ndarray (without core) (#8114)
Browse files Browse the repository at this point in the history
`core` is internal to `cupy` and renamed to reflect that in CuPy 9. However that shouldn't be needed to access `ndarray` as it is `import`ed at the top-level. So just use `cupy.ndarray`.

cc @kkraus14 @rjzamora

Authors:
  - https://github.com/jakirkham

Approvers:
  - Keith Kraus (https://github.com/kkraus14)
  - GALI PREM SAGAR (https://github.com/galipremsagar)

URL: #8114
  • Loading branch information
jakirkham authored Apr 29, 2021
1 parent 04d6e5a commit cea6c20
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion python/cudf/cudf/core/algorithms.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def factorize(values, sort=False, na_sentinel=-1, size_hint=None):
if size_hint:
warn("size_hint is not applicable for cudf.factorize")

return_cupy_array = isinstance(values, cp.core.core.ndarray)
return_cupy_array = isinstance(values, cp.ndarray)

values = Series(values)

Expand Down
2 changes: 1 addition & 1 deletion python/cudf/cudf/tests/test_dataframe.py
Original file line number Diff line number Diff line change
Expand Up @@ -6069,7 +6069,7 @@ def test_dataframe_init_1d_list(data, columns):
def test_dataframe_init_from_arrays_cols(data, cols, index):

gd_data = data
if isinstance(data, cupy.core.ndarray):
if isinstance(data, cupy.ndarray):
# pandas can't handle cupy arrays in general
pd_data = data.get()

Expand Down
12 changes: 6 additions & 6 deletions python/cudf/cudf/tests/test_factorize.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def test_factorize_series_obj(ncats, nelem):

uvals, labels = df["cats"].factorize()
np.testing.assert_array_equal(labels.to_array(), sorted(set(arr)))
assert isinstance(uvals, cp.core.core.ndarray)
assert isinstance(uvals, cp.ndarray)
assert isinstance(labels, Index)

encoder = dict((labels[idx], idx) for idx in range(len(labels)))
Expand All @@ -39,7 +39,7 @@ def test_factorize_index_obj(ncats, nelem):

uvals, labels = df.index.factorize()
np.testing.assert_array_equal(labels.values.get(), sorted(set(arr)))
assert isinstance(uvals, cp.core.core.ndarray)
assert isinstance(uvals, cp.ndarray)
assert isinstance(labels, Index)

encoder = dict((labels[idx], idx) for idx in range(len(labels)))
Expand Down Expand Up @@ -127,15 +127,15 @@ def test_factorize_result_classes():

labels, cats = cudf.factorize(cudf.Series(data))

assert isinstance(labels, cp.core.core.ndarray)
assert isinstance(labels, cp.ndarray)
assert isinstance(cats, cudf.Index)

labels, cats = cudf.factorize(cudf.Index(data))

assert isinstance(labels, cp.core.core.ndarray)
assert isinstance(labels, cp.ndarray)
assert isinstance(cats, cudf.Index)

labels, cats = cudf.factorize(cp.array(data))

assert isinstance(labels, cp.core.core.ndarray)
assert isinstance(cats, cp.core.core.ndarray)
assert isinstance(labels, cp.ndarray)
assert isinstance(cats, cp.ndarray)

0 comments on commit cea6c20

Please sign in to comment.