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

ENH: Make sorting optional for cKDTree.query_ball_point() #8908

Merged
merged 3 commits into from
Nov 6, 2018

Conversation

JesseLivezey
Copy link
Contributor

@JesseLivezey JesseLivezey commented Jun 5, 2018

Previously, cKDTree.query_ball_point() would not sort the returned indices for single point queries, but did sort them for multi-point queries.

For multi-point queries with large numbers of returned indices, sorting slowed down query_ball_point() significantly.

The PR adds a new optional kwarg which allows the returned indices to be explicitly sorted or not. The default (None) has the same inconsistent behavior as before.

Closes #8838

Copy link
Contributor

@tylerjereddy tylerjereddy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As noted in the linked PR, it seems your editor is automatically adjusting whitespace quite a lot; this made the diff a bit tedious to parse.

That said, the github diff setting that allows for ignoring whitespace changes is helpful to narrow down the pertinent changes here.

I suspect that magnitude of whitespace adjustment is a bit out of scope for this PR, but the actual content changes seem to be reasonably small & you've added some unit tests, which looks promising at first glance (haven't check this in detail yet).

Might be worth considering addition of an asv benchmark test for the performance of the no-sorting approach with a multi-point query?

@JesseLivezey JesseLivezey force-pushed the optional_sort branch 3 times, most recently from 3872858 to 2c08cbb Compare June 28, 2018 16:54
@JesseLivezey
Copy link
Contributor Author

@tylerjereddy removed all of the white-space changes. I also think I added an asv benchmark correctly.

@rgommers
Copy link
Member

rgommers commented Jul 1, 2018

Seems to agree with @sturlamolden's opinion in gh-8838. Sturla, does this look fine to you?

@sturlamolden
Copy link
Contributor

I haven't tested this code, but from the looks of it yes. @rgommers

@JesseLivezey
Copy link
Contributor Author

@sturlamolden @rgommers Anything I can do to push this along? Does scipy require a rebase on master to merge?

@rgommers
Copy link
Member

rgommers commented Aug 1, 2018

Anything I can do to push this along?

You just did, pinging us. We have a bit of a review backlog; the list of open PRs never seems to grow shorter.

Does scipy require a rebase on master to merge?

No, if the PR can be merged (which it can currently) then it's all good.

@rgommers rgommers added this to the 1.2.0 milestone Aug 1, 2018
@tylerjereddy
Copy link
Contributor

@JesseLivezey If you could rebase / force push that would be helpful to flush through CI since it has been a few months for this PR.

Apart from that, seems like I can merge before the version 1.2.x branching very soon.

Sorts returned indicies if True and does not sort them if False. If
None, does not sort single point queries, but does sort
multi-point queries which was the behavior before this option
was added.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This probably warrants a .. versionadded:: directive.

@@ -1330,3 +1330,28 @@ def test_short_knn():
[0., 0.01, np.inf, np.inf],
[0., 0.01, np.inf, np.inf],
[0., np.inf, np.inf, np.inf]])

class Test_sorted_query_ball_point:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We still support python 2.7, where this is an old-style class. Please inherit from object explicitly.

@JesseLivezey
Copy link
Contributor Author

@tylerjereddy I rebased and pushed and I think I addressed @ev-br's changes.

@tylerjereddy tylerjereddy changed the title Make sorting optional for cKDTree.query_ball_point() ENH: Make sorting optional for cKDTree.query_ball_point() Nov 6, 2018
Copy link
Contributor

@tylerjereddy tylerjereddy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewer comments addressed and CI is all green so merging, thanks @JesseLivezey.

If you could add a concise note to the release notes, that would be helpful.

@tylerjereddy tylerjereddy merged commit 592fb03 into scipy:master Nov 6, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement A new feature or improvement scipy.spatial
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants