gpt4 book ai didi

python - 尝试使用图形工具进行 block 分区时出现 AttributeError

转载 作者:太空宇宙 更新时间:2023-11-04 06:05:12 26 4
gpt4 key购买 nike

我收到这个错误:

AttributeError: 'list' object has no attribute 'clear'

尝试在 this page 处执行示例时

block partition example

例子是:

>>> g = gt.collection.data["power"]
>>> bstack, mdl = gt.minimize_nested_blockmodel_dl(g, deg_corr=True)
>>> t = gt.get_hierarchy_tree(bstack)[0]
>>> tpos = pos = gt.radial_tree_layout(t, t.vertex(t.num_vertices() - 1), weighted=True)
>>> cts = gt.get_hierarchy_control_points(g, t, tpos)
>>> pos = g.own_property(tpos)
>>> b = bstack[0].vp["b"]
>>> gt.graph_draw(g, pos=pos, vertex_fill_color=b, vertex_shape=b, edge_control_points=cts,
... edge_color=[0, 0, 0, 0.3], vertex_anchor=0, output="power_nested_mdl.pdf")
<...>

它在运行该行时给了我异常:

>>> bstack, mdl = gt.minimize_nested_blockmodel_dl(g, deg_corr=True)

有什么线索吗?

谢谢

最佳答案

list.clear() 不在 Python 2 中,只在 Python 3 中。该示例在 Python 3 中运行没有问题。

无论如何,graph-tool 应该在 Python 2.7 及更高版本上工作,所以这也可能被报告为一个错误。

关于python - 尝试使用图形工具进行 block 分区时出现 AttributeError,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22527108/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com