Skip to content

MNT Common tests between KDTree and BallTree #16338

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

Merged
merged 1 commit into from
Feb 2, 2020

Conversation

VarIr
Copy link
Contributor

@VarIr VarIr commented Jan 31, 2020

Reference Issues/PRs

More common tests between KDTree and BallTree. See also #15148 and #16110 (comment).

What does this implement/fix? Explain your changes.

From the previous PR by @rth :

The API of KDTree and BallTree is almost identical, and yet they have separate test files probably because they were written when pytest parametization were not used.

This puts some of redundant tests from test_kd_tree.py and test_ball_tree.py into a common file test_neighbors_tree.py.

Any other comments?

There might also be some overlap with KernelDensity, which is not dealt with in this PR.
For example, compute_kernel_slow, test_kernel_density

@VarIr VarIr changed the title TST Common tests between KDTree and BallTree (2) [MRG] Common tests between KDTree and BallTree (2) Jan 31, 2020
Copy link
Member

@rth rth left a comment

Choose a reason for hiding this comment

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

Nice, thanks @VarIr !

@rth rth changed the title [MRG] Common tests between KDTree and BallTree (2) MNT Common tests between KDTree and BallTree (2) Jan 31, 2020
Comment on lines +72 to +78
@pytest.mark.parametrize('Cls', [KDTree, BallTree])
@pytest.mark.parametrize("kernel", ['gaussian', 'tophat', 'epanechnikov',
'exponential', 'linear', 'cosine'])
@pytest.mark.parametrize("h", [0.01, 0.1, 1])
@pytest.mark.parametrize("rtol", [0, 1E-5])
@pytest.mark.parametrize("atol", [1E-6, 1E-2])
@pytest.mark.parametrize("breadth_first", [True, False])
Copy link
Member

Choose a reason for hiding this comment

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

This actually runs 288 tests ! is it reasonably fast ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

On my local machine: 288 passed in 1.72s

Copy link
Contributor Author

Choose a reason for hiding this comment

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

For comparison: the old test_kd_tree_kde uses loops inside and results in 18 passed in 0.67s. Doubling for balltree, we have like 0.4s overhead.

Copy link
Member

Choose a reason for hiding this comment

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

It should be fine. Thanks for checking.

Copy link
Member

@thomasjpfan thomasjpfan left a comment

Choose a reason for hiding this comment

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

Thank you for the PR @VarIr !

@thomasjpfan thomasjpfan changed the title MNT Common tests between KDTree and BallTree (2) MNT Common tests between KDTree and BallTree Feb 2, 2020
@thomasjpfan thomasjpfan merged commit 8c8ea9e into scikit-learn:master Feb 2, 2020
@VarIr VarIr deleted the trees branch February 3, 2020 08:13
thomasjpfan pushed a commit to thomasjpfan/scikit-learn that referenced this pull request Feb 22, 2020
panpiort8 pushed a commit to panpiort8/scikit-learn that referenced this pull request Mar 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants