我对 Scipy
的 cKDTree 的 query_pairs
和 query_ball_tree
方法之间的差异/相似性有点困惑。
阅读docs我们可以看到它们有相同的描述:
query_ball_tree(self, other, r[, p, eps]) - Find all pairs of points whose distance is at most r query_pairs(self, r[, p, eps]) - Find all pairs of points whose distance is at most r.
它们甚至需要相同的强制参数,除了 query_ball_tree
需要other
(来自 docs ):>“包含要搜索的点的树。”。
那么,这两种方法之间有实际区别吗?是否更愿意使用其中一种? 我目前使用 query_pairs
来实现我的目的,但我正在考虑替代方案。
我见过人们使用前者,例如 tree1.query_ball_tree(tree2, ...)
,这表明您可以在不同的树之间进行查询...但我猜 em> 如果我们执行诸如 tree1.query_ball_tree(tree1, ...)
之类的操作,它将相当于 query_pairs
。非常感谢任何指导。
最佳答案
query_ball_tree
查找 self
和 other
之间距离最大为 r 的所有点对。
query_pairs
查找 self
中距离最大为 r 的所有点对。
这些新的官方文档可能会帮助您:
scipy.spatial.cKDTree.query_ball_tree — SciPy v1.6.0.dev 引用指南 http://scipy.github.io/devdocs/generated/scipy.spatial.cKDTree.query_ball_tree.html#scipy.spatial.cKDTree.query_ball_tree
scipy.spatial.cKDTree.query_pairs — SciPy v1.6.0.dev 引用指南 http://scipy.github.io/devdocs/generated/scipy.spatial.cKDTree.query_pairs.html#scipy.spatial.cKDTree.query_pairs
关于python - Scipy cKDTree query_pairs 与 query_ball_tree,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47763534/