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

fixed sklearn sanity checks for valid_metrics #925

Conversation

stamate
Copy link
Contributor

@stamate stamate commented Nov 2, 2023

Description

This PR aims to fix the sklearn.neighbors.KDTree.valid_metrics() sanity check which has been introduced in skearn.version 1.3.0 (and also in 1.3.0rc1), but has afterward been reverted due to compatibility issues with other libraries. More about this can be found here:

scikit-learn/scikit-learn#26742
scikit-learn/scikit-learn#26754

Proposed Changes

I changed the if sklearn_version >= version.parse("1.3.0"): condition to if sklearn_version in [version.parse("1.3.0"), version.parse("1.3.0rc1")]: so we can only cover the two cases in which sklearn.neighbors.KDTree.valid_metrics is not an attribute and is instead a method.

Copy link

welcome bot commented Nov 2, 2023

Thanks for opening this pull request! We'll make sure it's perfect before merging 🤗 force
Make sure to read the contributing guide. Also, if you think that your contribution is worthy of it, you can consider adding yourself to the Contributors list (feel free to ask us if you have any doubts).

@@ -111,7 +111,7 @@ def _get_count(
# -------------------
# Sanity checks
sklearn_version = version.parse(sklearn.__version__)
if sklearn_version >= version.parse("1.3.0"):
if sklearn_version in [version.parse("1.3.0"), version.parse("1.3.0rc1")]:
Copy link
Member

Choose a reason for hiding this comment

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

shouldn't this be:

if sklearn_version >= version.parse("1.3.0") or sklearn_version == version.parse("1.3.0rc1"):

Copy link
Contributor Author

@stamate stamate Nov 2, 2023

Choose a reason for hiding this comment

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

I tested and we only have the method in versions 1.3.0 and 1.3.0rc1. Versions greater than 1.3.0 reverted back to the attribute style. So the method is only available in those two versions.

Copy link
Member

Choose a reason for hiding this comment

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

I see, makes sense then thanks!

@codecov-commenter
Copy link

codecov-commenter commented Nov 2, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (323929f) 54.86% compared to head (76a1efa) 54.87%.

Additional details and impacted files
@@           Coverage Diff           @@
##              dev     #925   +/-   ##
=======================================
  Coverage   54.86%   54.87%           
=======================================
  Files         303      303           
  Lines       14255    14255           
=======================================
+ Hits         7821     7822    +1     
+ Misses       6434     6433    -1     
Files Coverage Δ
neurokit2/complexity/utils_entropy.py 81.03% <100.00%> (ø)

... and 1 file with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@DominiqueMakowski DominiqueMakowski merged commit c1e38e1 into neuropsychology:dev Nov 2, 2023
8 checks passed
Copy link

welcome bot commented Nov 2, 2023

landing
Congrats on merging your first pull request! 🎉🍾 We're looking forward to your next one!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants