From 0c0db1c345a6ea76cf55146d7f885b1d7da56c3d Mon Sep 17 00:00:00 2001 From: Yelrose <270018958@qq.com> Date: Mon, 31 Aug 2020 14:11:33 +0800 Subject: [PATCH] fixed subgraph edge_feat --- pgl/graph.py | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/pgl/graph.py b/pgl/graph.py index 85ec406..68d7db3 100644 --- a/pgl/graph.py +++ b/pgl/graph.py @@ -589,26 +589,25 @@ class Graph(object): if eid is None and edges is None: raise ValueError("Eid and edges can't be None at the same time.") + sub_edge_feat = {} if edges is None: edges = self._edges[eid] else: edges = np.array(edges, dtype="int64") + + if with_edge_feat: + for key, value in self._edge_feat.items(): + if eid is None: + raise ValueError( + "Eid can not be None with edge features.") + sub_edge_feat[key] = value[eid] + else: + sub_edge_feat = edge_feats sub_edges = graph_kernel.map_edges( np.arange( len(edges), dtype="int64"), edges, reindex) - sub_edge_feat = {} - if edges is None: - if with_edge_feat: - for key, value in self._edge_feat.items(): - if eid is None: - raise ValueError( - "Eid can not be None with edge features.") - sub_edge_feat[key] = value[eid] - else: - sub_edge_feat = edge_feats - sub_node_feat = {} if with_node_feat: for key, value in self._node_feat.items(): -- GitLab