norlab-ulaval / libnabo

A fast K Nearest Neighbor library for low-dimensional spaces
http://norlab-ulaval.github.io/libnabo/
BSD 3-Clause "New" or "Revised" License
431 stars 142 forks source link

Python bindings #98

Open mikeagn opened 4 years ago

mikeagn commented 4 years ago

I am trying to use the python bindings of the library and run the simple example that is provided (libnabo/python/test.py). However, I cannot, since when the user defines the query point: q = np.array([[1.1, 2.]]) it there is a runtime error: RuntimeError: Query has less dimensions (1) than requested for cloud (2)

I guess that has something to do with the dimension of the query point. If I transpose the query point I get a correct answer but does this make sense?:

res = nns.knn(q.transpose(), 2, 0, SearchOptionFlags.ALLOW_SELF_MATCH) res (array([[1, 0]], dtype=int32), array([[0.01, 2.21]]))

Can you please help advise on how to use the python bindings, or maybe update the example with a working one? Many thanks in advance.