我如何清除此警告,它是什么意思?

How do I clear this warning, and what does it mean?

代码运行并生成所需的图形。但是,我的控制台显示以下消息:

FutureWarning:要堆栈的数组必须作为 "sequence" 类型传递,例如列表或元组。从 NumPy 1.16 开始,不推荐使用对生成器等非序列可迭代对象的支持,将来会引发错误。 pos = np.row_stack((pos[x] for x in node_list))

我的问题是这是什么意思?我应该如何更改代码来修复此警告?

这是我第一次询问代码,所以如果我犯了错误,请告诉我。

import matplotlib.pyplot as plt
import networkx as nx
import numpy as np

G = nx.Graph()
G.add_nodes_from([0, 1, 2, 3])
G.add_edges_from([(0, 1), (1, 2)])
G.adjacency()
pos = nx.planar_layout(G)

# nodes
options = {"node_size": 500, "alpha": 0.8}
nx.draw_networkx_nodes(G, pos, nodelist=[0, 1, 2, 3], node_color="r", **options)

# edges
nx.draw_networkx_edges(G, pos, width=1.0, alpha=0.5)
nx.draw_networkx_edges(
    G,
    pos,
    edgelist=[(0, 1), (1, 2)],
    width=8,
    alpha=0.5,
    edge_color="r",
)

plt.show()

My question is what does this mean?

表达式 (pos[x] for x in node_list) 产生一个 class 'generator' 的对象;表达式 [pos[x] for x in node_list] 会产生一个对象 class 'list'.

How should I change the code to fix this warning?

您必须将括号更改为 e。 G。库代码中显示的表达式中的括号,但是,正如 Joel 指出的那样,这可能会由库维护人员完成。