Skip to content

Commit 7790cab

Browse files
committed
FIX inconsistent attribute definitions across scikit-learn versions
1 parent 765aa0e commit 7790cab

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

mlresearch/active_learning/tests/test_active_learning_models.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,12 +98,15 @@ def test_augmentation_active_learning():
9898
)
9999
al_model.fit(iris.data, iris.target)
100100

101+
# Get steps in classifier - Required for compatibility purposes
102+
if hasattr(al_model.classifier_, "best_estimator_"):
103+
steps = al_model.classifier_.best_estimator_.steps
104+
else:
105+
steps = al_model.classifier_.steps
106+
101107
assert al_model.max_iter_ == 2
102108
assert al_model.random_state == RANDOM_STATE
103-
assert (
104-
dict(al_model.classifier_.best_estimator_.steps)["generator"].random_state
105-
== RANDOM_STATE
106-
)
109+
assert dict(steps)["generator"].random_state == RANDOM_STATE
107110

108111

109112
@pytest.mark.parametrize("name", ACTIVE_LEARNERS.keys())

0 commit comments

Comments
 (0)