更新时间:2023-02-13 20:58:01
Python的sqrt
操作不支持负整数.但是,numpy适用于复数.虚数$ i $由Python中的1j
给出.因此,您必须将方程式转换为:
Python's sqrt
operation doesn't support negative integers. However, numpy works with complex numbers. The imaginary number $i$ is given by 1j
in Python. So you will have to convert your equation to:
a=abs((np.exp( (g.node[i]['theta']*(1j)) for i in g.nodes_iter()))/g.number_of_nodes())