Support scikit-learn 1.9 (DTYPE removed from sklearn.tree._tree)#152
Merged
Conversation
scikit-learn 1.9 no longer re-exports DTYPE from sklearn.tree._tree, so `import quantile_forest` raises ImportError on sklearn>=1.9. DTYPE has always been np.float32 (it is used here only as the coercion dtype for check_X_y at the two validate_data calls), so guard the import with a fallback to np.float32 — identical value, backward compatible with older scikit-learn, forward compatible with 1.9+.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #152 +/- ##
==========================================
- Coverage 98.72% 98.55% -0.17%
==========================================
Files 5 5
Lines 1175 1178 +3
==========================================
+ Hits 1160 1161 +1
- Misses 15 17 +2 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Member
|
LGTM. Thank you for the contribution, @MaxGhenis! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
import quantile_forestraisesImportErroron scikit-learn 1.9:scikit-learn 1.9 no longer re-exports
DTYPEfromsklearn.tree._tree.quantile_forest/_quantile_forest.pyimports it at module load, so the whole package fails to import under scikit-learn ≥ 1.9.Fix
DTYPEhas always beennp.float32, and it is used here only as the coercion dtype passed tovalidate_data/check_X_y(the two"dtype": DTYPEcall sites). So guard the import with a fallback tonp.float32:import quantile_forest-equivalent against scikit-learn 1.9.0: the old import raises, the fallback yieldsnp.float32.numpy as npis already imported in this module.Verification
Happy to add a CI entry pinning the newest scikit-learn if that's useful.