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

Utility function to create kdtrees #165

Merged
merged 1 commit into from
Dec 20, 2018
Merged

Utility function to create kdtrees #165

merged 1 commit into from
Dec 20, 2018

Conversation

leouieda
Copy link
Member

We support using pykdtree as a replacement for most kdtree operations
but the feature set is the not identical to the scipy implementation.
We had no way of dealing with this before and had some repeated
try...except code for importing the modules.

A new kdtree function in verde/utils.py centralizes the imports,
allows using the scipy kdtree even if pykdtree is installed, and
handles transposing the coordinate arrays before creating the tree.

Reminders

  • Run make format and make check to make sure the code follows the style guide.
  • Add tests for new features or tests that would have caught the bug that you're fixing.
  • Add new public functions/methods/classes to doc/api/index.rst and verde/__init__.py.
  • Write detailed docstrings for all functions/classes/methods.
  • If adding new functionality, add an example to the docstring, gallery, and/or tutorials.

We support using pykdtree as a replacement for most kdtree operations
but the feature set is the not identical to the scipy implementation.
We had no way of dealing with this before and had some repeated
`try...except` code for importing the modules.

A new `kdtree` function in `verde/utils.py` centralizes the imports,
allows using the scipy kdtree even if pykdtree is installed,  and
handles transposing the coordinate arrays before creating the tree.
@djhoese
Copy link
Contributor

djhoese commented Dec 20, 2018

Just curious, what features in the scipy kdtree are not supported in the pykdtree? Are there bugs in pykdtree that are making these things not work? Or did scipy add new features in the last year or two?

Edit: Also pykdtree now has a mask keyword argument you can provide to the query call to mark certain neighbors as bad. This lets you reuse the same KDTree even if your neighbor masks change.

@leouieda
Copy link
Member Author

@djhoese no bugs, just the other class methods besides query: https://docs.scipy.org/doc/scipy/reference/generated/scipy.spatial.cKDTree.html

I don't need them right now but I will need query_ball_point soon.

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

Successfully merging this pull request may close these issues.

2 participants