Skip to content

scipy/ckdtree

Pack Severity Fix Versions
SciPy info unsafe, with xpd check --fix --unsafe-fixes SciPy 1.6+

cKDTree is the same as KDTree, and SciPy keeps the name only for old code. Use KDTree unless the code must run on SciPy older than 1.6.

tree = cKDTree(points)
tree = KDTree(points)

The rule reports a call to cKDTree, whose docstring says it is functionally identical to KDTree and kept only for backward compatibility.

xpd check --fix --unsafe-fixes applies the fixes of this rule. Check the result, because an unsafe fix can change what the code does.

The unsafe fix writes KDTree for cKDTree, with the same arguments. The default leafsize differs, 16 against 10, so a query can return another one of two equally near points, and the tree's node classes differ. cKDTree imported by name is fixed only in a file that imports KDTree from scipy.spatial. Skipped on SciPy older than 1.6.

cKDTree is functionally identical to KDTree and SciPy keeps the name only for backward compatibility, as its docstring says. Write KDTree, unless the code must run on SciPy older than 1.6.

See all rules in the SciPy pack.