2017-02-21 44 views
1

这里是我的代码:图形工具ValueError异常与graph_union用于过滤图

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有旧vmask.a = not vmask.a。任何人都可以确认这是一个错误还是我做错了什么?

回答

0

是的,这是一个bug,并已在git中修复。

顺便说一下,最好向https://graph-tool.skewed.de/issues或图形工具邮件列表的问题跟踪器报告这样的问题,而不是堆栈溢出,以保证更快的操作。