From bf1da205c9bb43497e7a71d4bceff6d74f3becb0 Mon Sep 17 00:00:00 2001 From: Andrei Ivanov Date: Fri, 8 Nov 2024 10:27:39 -0800 Subject: [PATCH] Resolving warning: conversion of an array with ndim > 0 to a scalar. --- python/dgl/data/tu.py | 2 +- python/dgl/utils/data.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/python/dgl/data/tu.py b/python/dgl/data/tu.py index 56cf63d0d57f..b871923f9e0e 100644 --- a/python/dgl/data/tu.py +++ b/python/dgl/data/tu.py @@ -406,7 +406,7 @@ def process(self): int ) ) - self.num_labels = int(max(DS_graph_labels) + 1) + self.num_labels = int(max(DS_graph_labels)[0] + 1) self.graph_labels = F.tensor(DS_graph_labels) elif os.path.exists(self._file_path("graph_attributes")): DS_graph_labels = loadtxt( diff --git a/python/dgl/utils/data.py b/python/dgl/utils/data.py index 5083cefc5038..9d3e9bf0ca7f 100644 --- a/python/dgl/utils/data.py +++ b/python/dgl/utils/data.py @@ -94,7 +94,7 @@ def networkx2tensor(nx_graph, idtype, edge_id_attr_name=None): src = [0] * num_edges dst = [0] * num_edges for u, v, attr in nx_graph.edges(data=True): - eid = int(attr[edge_id_attr_name]) + eid = int(attr[edge_id_attr_name][0]) if eid < 0 or eid >= nx_graph.number_of_edges(): raise DGLError( "Expect edge IDs to be a non-negative integer smaller than {:d}, " @@ -278,7 +278,7 @@ def networkxbipartite2tensors( "Expect the node {} to have attribute bipartite=1 " "with edge {}".format(v, (u, v)) ) - eid = int(attr[edge_id_attr_name]) + eid = int(attr[edge_id_attr_name][0]) if eid < 0 or eid >= nx_graph.number_of_edges(): raise DGLError( "Expect edge IDs to be a non-negative integer smaller than {:d}, "