Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Drop extraneous columns that were appearing in MGPropertyGraph #3191

Merged
merged 2 commits into from
Jan 30, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions python/cugraph/cugraph/dask/structure/mg_property_graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -1105,6 +1105,8 @@ def extract_subgraph(
The name of the property whose values will be used as weights on
the returned Graph. If not specified, the returned Graph will be
unweighted.
default_edge_weight : float64, optional
Value that replaces empty weight property fields
check_multi_edges : bool (default is True)
When True and create_using argument is given and not a MultiGraph,
this will perform a check to verify that the edges in the edge
Expand Down Expand Up @@ -1217,10 +1219,11 @@ def edge_props_to_graph(
renumber_graph=True,
add_edge_data=True,
):

"""
Create and return a Graph from the edges in edge_prop_df.
"""
# Don't mutate input data
edge_prop_df = edge_prop_df.copy()
# FIXME: check default_edge_weight is valid
if edge_weight_property:
if (
Expand Down Expand Up @@ -1416,11 +1419,11 @@ def renumber_vertices_by_type(self, prev_id_column=None):
self.__edge_prop_dataframe
# map src_col_name IDs
.merge(mapper, left_on=self.src_col_name, right_on=self.vertex_col_name)
.drop(columns=[self.src_col_name])
.drop(columns=[self.src_col_name, self.vertex_col_name])
.rename(columns={new_name: self.src_col_name})
# map dst_col_name IDs
.merge(mapper, left_on=self.dst_col_name, right_on=self.vertex_col_name)
.drop(columns=[self.dst_col_name])
.drop(columns=[self.dst_col_name, self.vertex_col_name])
.rename(columns={new_name: self.dst_col_name})
)
self.__edge_prop_dataframe.index = self.__edge_prop_dataframe.index.astype(
Expand Down
6 changes: 6 additions & 0 deletions python/cugraph/cugraph/tests/mg/test_mg_property_graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -856,7 +856,13 @@ def test_renumber_vertices_by_type(dataset1_MGPropertyGraph, prev_id_column):
(pG, data) = dataset1_MGPropertyGraph
with pytest.raises(ValueError, match="existing column"):
pG.renumber_vertices_by_type("merchant_size")
vertex_property_names = set(pG.vertex_property_names)
edge_property_names = set(pG.edge_property_names)
df_id_ranges = pG.renumber_vertices_by_type(prev_id_column)
if prev_id_column is not None:
vertex_property_names.add(prev_id_column)
assert vertex_property_names == set(pG.vertex_property_names)
assert edge_property_names == set(pG.edge_property_names)
expected = {
"merchants": [0, 4], # stop is inclusive
"users": [5, 8],
Expand Down