Skip to content

Commit

Permalink
Use public pandas and cudf APIs where possible (#4218)
Browse files Browse the repository at this point in the history
Avoiding `core` imports here as they tend to be "private"

Authors:
  - Matthew Roeschke (https://github.com/mroeschke)

Approvers:
  - Rick Ratzel (https://github.com/rlratzel)

URL: #4218
  • Loading branch information
mroeschke authored Mar 7, 2024
1 parent a9ec503 commit f202fa3
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 9 deletions.
6 changes: 3 additions & 3 deletions python/cugraph/cugraph/structure/graph_classes.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2021-2023, NVIDIA CORPORATION.
# Copyright (c) 2021-2024, NVIDIA CORPORATION.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
Expand Down Expand Up @@ -426,7 +426,7 @@ def from_pandas_edgelist(
... edge_attr='2', renumber=False)
"""
if not isinstance(pdf, pd.core.frame.DataFrame):
if not isinstance(pdf, pd.DataFrame):
raise TypeError("pdf input is not a Pandas DataFrame")

gdf = cudf.DataFrame.from_pandas(pdf)
Expand All @@ -450,7 +450,7 @@ def from_pandas_adjacency(self, pdf):
pdf : pandas.DataFrame
A DataFrame that contains adjacency information
"""
if not isinstance(pdf, pd.core.frame.DataFrame):
if not isinstance(pdf, pd.DataFrame):
raise TypeError("pdf input is not a Pandas DataFrame")

np_array = pdf.to_numpy()
Expand Down
6 changes: 2 additions & 4 deletions python/cugraph/cugraph/structure/hypergraph.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ def hypergraph(
events.reset_index(drop=True, inplace=True)

if EVENTID not in events.columns:
events[EVENTID] = cudf.core.index.RangeIndex(len(events))
events[EVENTID] = cudf.RangeIndex(len(events))

events[EVENTID] = _prepend_str(events[EVENTID], EVENTID + DELIM)
events[NODETYPE] = (
Expand Down Expand Up @@ -596,6 +596,4 @@ def _prepend_str(col, val):

# Make an empty categorical string dtype
def _empty_cat_dt():
return cudf.core.dtypes.CategoricalDtype(
categories=np.array([], dtype="str"), ordered=False
)
return cudf.CategoricalDtype(categories=np.array([], dtype="str"), ordered=False)
4 changes: 2 additions & 2 deletions python/cugraph/cugraph/tests/utils/test_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,14 +171,14 @@ def test_reader(dataset):
E = dataset.get_edgelist(download=True)

assert E is not None
assert isinstance(E, cudf.core.dataframe.DataFrame)
assert isinstance(E, cudf.DataFrame)
dataset.unload()

# using pandas
E_pd = dataset.get_edgelist(download=True, reader="pandas")

assert E_pd is not None
assert isinstance(E_pd, pandas.core.frame.DataFrame)
assert isinstance(E_pd, pandas.DataFrame)
dataset.unload()

with pytest.raises(ValueError):
Expand Down

0 comments on commit f202fa3

Please sign in to comment.