Fix numpy 2.5 incompatibility in Venn-Abers calibration - #170
Open
JayeshSuryavanshi wants to merge 1 commit into
Open
Fix numpy 2.5 incompatibility in Venn-Abers calibration#170JayeshSuryavanshi wants to merge 1 commit into
JayeshSuryavanshi wants to merge 1 commit into
Conversation
numpy 2.5 removed the 2-D form of np.cross, so the convex-hull orientation checks in _InductiveVennAbersCalibrator raised 'Both input arrays must be (arrays of) 3-dimensional vectors', which broke all Venn-Abers calibration (14 tests). Replace np.cross on the 2-D vectors with the explicit scalar cross product a[0] * b[1] - a[1] * b[0], which is identical to the previous behavior and version-independent. Add a direct test for the orientation helpers.
This was referenced Aug 2, 2026
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
hiclass is broken on numpy 2.5. numpy 2.5 removed the 2-D form of
np.cross(np.crossnow requires 3-dimensional vectors), and_InductiveVennAbersCalibratoruses it on 2-D points in its convex-hull orientation checks:On numpy 2.5 this raises:
which breaks all Venn-Abers calibration. On a clean checkout with numpy 2.5.1, 14 tests fail, every calibration test that exercises the
ivap/cvapmethods (acrosstest_calibration.py,test_LocalClassifierPerNode.py,test_LocalClassifierPerLevel.py,test_LocalClassifierPerParentNode.py).Fix
For 2-D vectors
a,b,np.cross(a, b)returns the scalara[0] * b[1] - a[1] * b[0](the signed area / orientation). Replace thenp.crosscall with that explicit expression, which is identical to the old behavior and works on every numpy version:Tests
With this change the full suite goes from 14 failed / 385 passed to 399 passed / 0 failed on numpy 2.5.1, with no regression. I also added
test_venn_abers_angle_turn_orientation, a small direct test of the two orientation helpers, so the sign convention is locked independently of the numpy version.black --checkandflake8are clean on the changed files.