TST Use _sklearn_version rather than version in pickle tests #27554
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.
Fix #27268.
This PR checks for
_sklearn_version
rather thanversion
since this is what we put in the pickle.I saw this test failing in Pyodide see build log
I can reproduce locally inside Pyodide with a failure that happens ~ 2 times out of 1000.
With this PR I can not reproduce the issue running 100,000 times inside Pyodide.
I looked a bit at it and there is some randomness in the pickle (even with normal Python, not Pyodide related). I guess this is due to uninitialized memory in C buffers inside the Cython tree code? The only explanation I can't think of, is that if you are unlucky this unitialized bytes combined to make
version
and the test fails.If this explanation is at least partially correct, checking for a longer string makes it less likely that that this test fail.
Full disclosure: this is not the complete story since even inside Pyodide I can not reproduce without using pytest for some reason ... let's just say that I have spent enough time on this already 😉.