scipy/ckdtree
| Rule | ckdtree |
|---|---|
| Pack | SciPy |
| Severity | info |
| Fix | unsafe, with xpd check --fix --unsafe-fixes |
| Library versions | SciPy 1.6 and later |
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)What the rule reports
Section titled “What the rule reports”The rule reports a call to cKDTree, whose docstring says it is functionally identical to
KDTree and kept only for backward compatibility.
How to fix it
Section titled “How to fix it”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.
Message
Section titled “Message”xpd prints this message with the issue. A name that starts with $ stands for code from your file.
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.Browse the other rules of the SciPy pack.