Skip to content

BUG: Arc_KDTree.query(pt, k=1) raises AttributeError #332

@schmidtc

Description

@schmidtc

Quering an Arc_KDTree with k = 1 results in AttributeError.
k=1 is the default.

>>> import libpysal
>>> pts = [(0,0), (1,0), (0,1), (1,1)]

>>> type(libpysal.cg.KDTree(pts))
<class 'scipy.spatial.ckdtree.cKDTree'>
>>> libpysal.cg.KDTree(pts).query((.5,.5), 1)
(0.7071067811865476, 0)

>>> type(libpysal.cg.KDTree(pts, distance_metric="Arc"))
<class 'libpysal.cg.kdtree.Arc_KDTree'>
>>> libpysal.cg.KDTree(pts, distance_metric="Arc").query((.5,.5))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/.../site-packages/libpysal/cg/kdtree.py", line 161, in query
    dims = len(d.shape)
AttributeError: 'float' object has no attribute 'shape'

>>> libpysal.cg.KDTree(pts, distance_metric="Arc").query((.5,.5), 2)
(array([78.62319385, 78.62319385]), array([2, 3]))


  • Platform information: posix darwin, posix.uname_result(sysname='Darwin', nodename='ZG04075', release='19.6.0', version='Darwin Kernel Version 19.6.0: Sun Jul 5 00:43:10 PDT 2020; root:xnu-6153.141.1~9/RELEASE_X86_64', machine='x86_64')
  • Python version: 3.7.7 (default, Mar 26 2020, 10:32:53) [Clang 4.0.1 (tags/RELEASE_401/final)]
  • SciPy version: 1.4.1
  • NumPy version: 1.19.1
  • LibPySAL version: 4.3.0

Metadata

Metadata

Assignees

Labels

bugfunctionality that: returns invalid, erroneous, or meaningless results; or doesn't work at all.weights

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions