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

Axis out of bounds #2

Open
jsevo opened this issue Nov 4, 2013 · 2 comments
Open

Axis out of bounds #2

jsevo opened this issue Nov 4, 2013 · 2 comments

Comments

@jsevo
Copy link

jsevo commented Nov 4, 2013

Hi there,

I tried using your code on my own data and encountered several issues. It appears to boil down to an axis out of bounds issue.

Running your sample code (using python 2.7.3 on linux) returns the following error:
"""
d, i = T.query([45.0, 10.0, 10.0], k=4)
File "/usr/local/lib/python2.7/dist-packages/periodic_kdtree.py", line 306, in query
hits = self.__query(x, k=k, eps=eps, p=p, distance_upper_bound=distance_upper_bound)
File "/usr/local/lib/python2.7/dist-packages/periodic_kdtree.py", line 217, in __query
self.max_distance_upper_bound)
File "/usr/lib/python2.7/dist-packages/numpy/core/fromnumeric.py", line 1894, in amin
return _wrapit(a, 'min', axis, out)
File "/usr/lib/python2.7/dist-packages/numpy/core/fromnumeric.py", line 37, in _wrapit
result = getattr(asarray(obj),method)(_args, *_kwds)
ValueError: axis(=15) out of bounds

"""

@jsevo
Copy link
Author

jsevo commented Nov 4, 2013

I found the bit that caused the bug but I am unsure how to proceed:

Line 216-217 of periodic_kdtree.py

It appears that the following (class PeriodiccKDTree(KDTree)):

distance_upper_bound = np.min(distance_upper_bound, self.max_distance_upper_bound)

needs to be changed to (note the square brackets)

distance_upper_bound = np.min([distance_upper_bound, self.max_distance_upper_bound])

EDIT:

The same applies for Line 131 (class PeriodicKDTree(KDTree)):

r = np.min(r, self.max_distance_upper_bound)

has to be changed to

r = np.min([r, self.max_distance_upper_bound])

@pdebuyl
Copy link
Contributor

pdebuyl commented May 22, 2014

Hi,

I have the exact same issue. From np.min docstring, it is clear that the second argument is axis and not an item to be compared.

Using NumPy 1.7.1

I'd be happy to make this a pull request if @patvarilly is ok with submissions.

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

2 participants