Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

kdtree radius search not working #344

Open
tholzmann opened this issue Jan 2, 2023 · 1 comment
Open

kdtree radius search not working #344

tholzmann opened this issue Jan 2, 2023 · 1 comment

Comments

@tholzmann
Copy link

Describe the bug
When running radius search on my point cloud, I get an error:

File "D:\repos\scripts\venv\lib\site-packages\pyntcloud\core_class.py", line 590, in get_neighbors
return r_neighbors(kdtree, r)
File "D:\repos\scripts\venv\lib\site-packages\pyntcloud\neighbors\r_neighbors.py", line 21, in r_neighbors
return np.array(kdtree.query_ball_tree(kdtree, r))
ValueError: setting an array element with a sequence. The requested array has an inhomogeneous shape after 1 dimensions. The detected shape was (5342,) + inhomogeneous part.`

k-neighbor search works as expected.

To Reproduce
My code to reproduce the bug:

cloud = PyntCloud.from_file(pc_path)
kdtree_id = cloud.add_structure("kdtree")
r_neighbors = cloud.get_neighbors( r=5, kdtree=kdtree_id)

Desktop (please complete the following information):

  • OS: Win 10
  • pyntcloud: 0.3.1
  • python 3.9
@tholzmann
Copy link
Author

When reading some comments from this stackoverflow thread [1], I actually found out that it seems to be a Python 3.9 issue. The line 21 in neighbors/r_neighbors.py needs to be changed to:

return np.array(kdtree.query_ball_tree(kdtree, r), dtype=object)

so the argument dtype=object needs to be added.

[1] https://stackoverflow.com/questions/10346336/list-of-lists-into-numpy-array/26224619#26224619

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant