Skip to content

Commit

Permalink
TEST: account for changed exception raised by PipelineDF in sklearn>=1.1
Browse files Browse the repository at this point in the history
  • Loading branch information
j-ittner committed Sep 5, 2022
1 parent 0c5ae56 commit 1f2cbab
Showing 1 changed file with 21 additions and 8 deletions.
29 changes: 21 additions & 8 deletions test/test/sklearndf/pipeline/test_pipeline_df.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import numpy as np
import numpy.typing as npt
import pandas as pd
import pytest
from numpy.testing import (
assert_array_equal,
assert_no_warnings,
Expand All @@ -23,6 +24,7 @@
from sklearn.base import BaseEstimator, TransformerMixin, is_classifier, is_regressor
from sklearn.feature_selection import f_classif

from sklearndf import __sklearn_1_1__, __sklearn_version__
from sklearndf.classification import SVCDF, LogisticRegressionDF
from sklearndf.pipeline import PipelineDF
from sklearndf.regression import DummyRegressorDF, LassoDF, LinearRegressionDF
Expand Down Expand Up @@ -220,14 +222,25 @@ def test_pipeline_df__init() -> None:
assert_raises(TypeError, PipelineDF)
# Check that we can't instantiate pipelines with objects without fit
# method
assert_raises_regex(
TypeError,
"Last step of Pipeline should implement fit "
"or be the string 'passthrough'"
".*NoFit.*",
PipelineDF,
[("clf", NoFit())],
)
if __sklearn_version__ < __sklearn_1_1__:
with pytest.raises(
TypeError,
match=(
"Last step of Pipeline should implement fit "
"or be the string 'passthrough'"
".*NoFit.*"
),
):
PipelineDF([("clf", NoFit())])
else:
with pytest.raises(
ValueError,
match=(
'expected final step "clf" to contain a EstimatorDF, '
"but found an instance of NoFit"
),
):
PipelineDF([("clf", NoFit())])

# Smoke test with only an estimator
clf = NoTransformerDF()
Expand Down

0 comments on commit 1f2cbab

Please # to comment.