8000 [WIP] Draft: Precompute feature for PairwiseDistancesReductions by kyrajeep · Pull Request #29391 · scikit-learn/scikit-learn · GitHub
[go: up one dir, main page]

Skip to content

[WIP] Draft: Precompute feature for PairwiseDistancesReductions #29391

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

kyrajeep
Copy link
@kyrajeep kyrajeep commented Jul 2, 2024

See #25888

What does this implement/fix? Explain your changes.

Starting with modifying sklearn/neighbors/test_ball_tree.py, this pull request seeks to eventually implement the 'precomputed' option for PairwiseDistancesReductions.

Copy link
github-actions bot commented Jul 2, 2024

❌ Linting issues

This PR is introducing linting issues. Here's a summary of the issues. Note that you can avoid having linting issues by enabling pre-commit hooks. Instructions to enable them can be found here.

You can see the details of the linting issues under the lint job here


black

black detected issues. Please run black . locally and push the changes. Here you can see the detected issues. Note that running black might also fix some of the issues which might be detected by ruff. Note that the installed black version is black=24.3.0.


--- /home/runner/work/scikit-learn/scikit-learn/sklearn/neighbors/tests/test_ball_tree.py	2024-07-02 20:35:25.947523+00:00
+++ /home/runner/work/scikit-learn/scikit-learn/sklearn/neighbors/tests/test_ball_tree.py	2024-07-02 20:35:53.578192+00:00
@@ -40,11 +40,11 @@
 ]
 
 
 def brute_force_neighbors(X, Y, k, metric, **kwargs):
     from sklearn.metrics import DistanceMetric
-    
+
     if metric == "precomputed":
         return Y, np.argsort(Y, axis=1)[:, :k]
 
     X, Y = check_array(X), check_array(Y)
     D = DistanceMetric.get_metric(metric, **kwargs).pairwise(Y, X)
@@ -75,12 +75,11 @@
 
     bt = BallTreeImplementation(X, leaf_size=1, metric=metric)
     dist1, ind1 = bt.query(Y, k)
     dist2, ind2 = brute_force_neighbors(X, Y, k, metric)
     assert_array_almost_equal(dist1, dist2)
-    
-    
+
 
 @pytest.mark.parametrize(
     "BallTreeImplementation, decimal_tol", zip(BALL_TREE_CLASSES, [6, 5])
 )
 def test_query_haversine(BallTreeImplementation, decimal_tol):
would reformat /home/runner/work/scikit-learn/scikit-learn/sklearn/neighbors/tests/test_ball_tree.py

Oh no! 💥 💔 💥
1 file would be reformatted, 926 files would be left unchanged.

ruff

ruff detected issues. Please run ruff check --fix --output-format=full . locally, fix the remaining issues, and push the changes. Here you can see the detected issues. Note that the installed ruff version is ruff=0.2.1.


sklearn/neighbors/tests/test_ball_tree.py:45:1: W293 [*] Blank line contains whitespace
   |
43 | def brute_force_neighbors(X, Y, k, metric, **kwargs):
44 |     from sklearn.metrics import DistanceMetric
45 |     
   | ^^^^ W293
46 |     if metric == "precomputed":
47 |         return Y, np.argsort(Y, axis=1)[:, :k]
   |
   = help: Remove whitespace from blank line

sklearn/neighbors/tests/test_ball_tree.py:80:1: W293 [*] Blank line contains whitespace
   |
78 |     dist2, ind2 = brute_force_neighbors(X, Y, k, metric)
79 |     assert_array_almost_equal(dist1, dist2)
80 |     
   | ^^^^ W293
   |
   = help: Remove whitespace from blank line

sklearn/neighbors/tests/test_ball_tree.py:81:1: W293 [*] Blank line contains whitespace
   |
79 |     assert_array_almost_equal(dist1, dist2)
80 |     
81 |     
   | ^^^^ W293
82 | 
83 | @pytest.mark.parametrize(
   |
   = help: Remove whitespace from blank line

Found 3 errors.
[*] 3 fixable with the `--fix` option.

Generated for commit: a912954. Link to the linter CI: here

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.

1 participant
0