gpt4 book ai didi

python - 使用 ValueError : A 2-dimensional array must be passed 定义复数列表中的最短对

转载 作者:太空宇宙 更新时间:2023-11-03 22:14:49 25 4
gpt4 key购买 nike

我需要你的帮助。我不得不计算点之间的距离来定义最短对,为了实现它,我使用了 scipy.spatial.distance.pdist(我的轮廓点很复杂,z=x+1j*y)

last_points = np.array([contour.last_point_on_contour() for contour in reached])
print last_points
last_points_2d=np.array([last_points.real, last_points.imag])
dm = pdist(last_points_2d, 'euclidean')

并采取跟随误差

ValueError: A 2-dimensional array must be passed.

最后的点是(点的坐标)

[-501.54525930+9.54332241j -496.00082683+7.88953715j
-494.40471685+2.72497522j -492.63174757-1.58916156j
-494.39724167-6.69815202j -499.57661541-9.11793037j]

我将不胜感激任何帮助。谢谢

最佳答案

当你这样做时:

one_point_2d=np.array([last_points.real, last_points.imag])

last_points 实际上是一个点(for 循环中的最后一个点)。您希望它包括所有点。

关于python - 使用 ValueError : A 2-dimensional array must be passed 定义复数列表中的最短对,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17487606/

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