diff --git a/evalml/pipelines/utils.py b/evalml/pipelines/utils.py index 4f1d9846d6..1034ccb6fc 100644 --- a/evalml/pipelines/utils.py +++ b/evalml/pipelines/utils.py @@ -25,6 +25,8 @@ def get_pipelines(problem_type, model_types=None): pipelines, list of all pipeline """ + if model_types is not None and not isinstance(model_types, list): + raise TypeError("model_types parameter is not a list.") problem_pipelines = [] @@ -39,7 +41,7 @@ def get_pipelines(problem_type, model_types=None): all_model_types = list_model_types(problem_type) for model_type in model_types: if model_type not in all_model_types: - raise RuntimeError("Unrecognized model type for problem type %s: %s f" % (problem_type, model_type)) + raise RuntimeError("Unrecognized model type for problem type %s: %s" % (problem_type, model_type)) pipelines = [] diff --git a/evalml/tests/automl_tests/test_autoclassifier.py b/evalml/tests/automl_tests/test_autoclassifier.py index 1247b982a1..8710676ba1 100644 --- a/evalml/tests/automl_tests/test_autoclassifier.py +++ b/evalml/tests/automl_tests/test_autoclassifier.py @@ -1,5 +1,6 @@ import numpy as np import pandas as pd +import pytest from sklearn.model_selection import StratifiedKFold, TimeSeriesSplit from evalml import AutoClassifier @@ -216,4 +217,10 @@ def test_describe_pipeline_objective_ordered(X_y, capsys): assert err == '' assert expected_objective_order in out_stripped + +def test_model_types_as_list(): + with pytest.raises(TypeError, match="model_types parameter is not a list."): + AutoClassifier(objective='AUC', model_types='linear_model', max_pipelines=2) + + # def test_serialization(trained_model) diff --git a/evalml/tests/pipeline_tests/test_pipelines.py b/evalml/tests/pipeline_tests/test_pipelines.py index b549a1fdb9..c0bfe1044b 100644 --- a/evalml/tests/pipeline_tests/test_pipelines.py +++ b/evalml/tests/pipeline_tests/test_pipelines.py @@ -24,6 +24,8 @@ def test_get_pipelines(): assert len(get_pipelines(problem_type=ProblemTypes.BINARY)) == 3 assert len(get_pipelines(problem_type=ProblemTypes.BINARY, model_types=["linear_model"])) == 1 assert len(get_pipelines(problem_type=ProblemTypes.REGRESSION)) == 1 + with pytest.raises(RuntimeError, match="Unrecognized model type for problem type"): + get_pipelines(problem_type=ProblemTypes.REGRESSION, model_types=["random_forest", "xgboost"]) @pytest.fixture