Skip to content

Commit

Permalink
Further sklearn version checks in compatibility test
Browse files Browse the repository at this point in the history
  • Loading branch information
opcode81 committed Aug 12, 2024
1 parent 834aee7 commit 47f0ea8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
7 changes: 6 additions & 1 deletion tests/backwardscompat/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,16 @@ def test_regression_model_backward_compatibility_v0_2_0(pickle_file, diabetesReg
Tests for compatibility with models created with v0.2.0 using create_test_models.py
"""
sklearn_version = Version(sklearn)

if not sklearn_version.is_at_most(1, 0, 2):
# NOTE: sklearn is breaking persisted objects with newer versions (e.g. OneHotEncoder),
# so we can only run this test with the correct sklearn version
pytest.skip("This test is only compatible with sklearn <= 1.0.2")

if "RandomForest" in pickle_file:
if not sklearn_version.is_equal(1, 0, 2):
pytest.skip("This test is only compatible with sklearn == 1.0.2")

d = load_pickle(pickle_file)
r2, model = d["R2"], d["model"]
diabetesRegressionTestCase.testMinR2(model, r2-0.02, fit=False)

4 changes: 2 additions & 2 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,10 @@ deps =
; and lead to non-ending builds (2.5h+) on github. This dependency should be installable with pip install sensai[torch] though...
pytorch-lightning>=1.1
; No pinned requirements included except sklearn, so relaxed versions created by setup.py apply.
; We use sklearn version 1.0.2, because it is the latest version that is still compatible with the lowest version we support.
; We use sklearn version 1.0.2, because it was used to persist the v0.2.0 compatibility test models.
scikit-learn==1.0.2
extras =
full
torch

[testenv:docs]
commands =
Expand Down

0 comments on commit 47f0ea8

Please sign in to comment.