graph-tools ValueError with graph_union for filtered graphs

graph-tools ValueError with graph_union for filtered graphs

这是我的代码:

import graph_tool.all as gt
print gt.__version__
g1 = gt.Graph()
g1.add_vertex(5)
g1.add_edge_list([(0,1),(1,2),(2,3),(3,4)])
g2 = gt.Graph()
#g2.add_vertex(3)
#g2.add_edge_list([(0,1),(1,2)])
g1.vp['prop'] = g1.new_vp('int', 1)
g1.ep['eprop'] = g1.new_ep('bool', False)
g1.ep['eprop'][list(g1.edges())[0]]=True

g1.set_edge_filter(g1.ep['eprop'], inverted=True)
#g2.vp['prop'] = g2.new_vp('int', 2)
ug = gt.graph_union(g1, g2, intersection = None, include = True, internal_props=True)
print ug
ug.list_properties()
for e in ug.edges():
    print e, ug.ep['eprop'][e]

我得到以下输出:

2.20 (commit f6ef9990, Fri Jan 27 16:40:08 2017 +0000)
Traceback (most recent call last):
File "Untitled.py", line 17, in
ug = gt.graph_union(g1, g2, intersection = None, include = True, internal_props=True)
File "/usr/local/lib/python2.7/site-packages/graph_tool/generation/init.py", line 1192, in graph_union vmask.a = not vmask.a
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()

我认为这可能是一个类似于 this bug 的错误,特别是因为在 gt.generation__init__.py 中,第 1185 行修复了错误:emask.a = numpy.logical_not(emask.a),而第 1192 行有旧的 [=14] =].任何人都可以确认这是错误还是我做错了什么?

是的,这是一个错误,已在 git 中修复。

顺便说一句,最好将此类问题报告给 https://graph-tool.skewed.de/issues 的问题跟踪器或图形工具邮件列表,而不是堆栈溢出,以保证更快的行动。