Skip to content

Commit

Permalink
[#167] Add a test for the unknown strategy error condition
Browse files Browse the repository at this point in the history
  • Loading branch information
riley-harper committed Dec 2, 2024
1 parent 0f99e1b commit 7fed016
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -788,7 +788,10 @@ def _get_model_parameters(training_config: dict[str, Any]) -> list[dict[str, Any

return return_parameters
else:
raise ValueError(f"Unknown model_parameter_search strategy '{strategy}'")
raise ValueError(
f"Unknown model_parameter_search strategy '{strategy}'. "
"Please choose one of 'explicit', 'grid', or 'randomized'."
)
elif use_param_grid:
return _custom_param_grid_builder(model_parameters)

Expand Down
14 changes: 14 additions & 0 deletions hlink/tests/model_exploration_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -548,6 +548,20 @@ def test_get_model_parameters_search_strategy_randomized_thresholds(training_con
assert parameter_choice["threshold_ratio"] == 1.2


def test_get_model_parameters_unknown_search_strategy(training_conf):
training_conf["training"]["model_parameter_search"] = {
"strategy": "something",
}
training_conf["training"]["model_parameters"] = [{"type": "probit"}]

with pytest.raises(
ValueError,
match="Unknown model_parameter_search strategy 'something'. "
"Please choose one of 'explicit', 'grid', or 'randomized'.",
):
_parameters = _get_model_parameters(training_conf["training"])


# -------------------------------------
# Tests that probably should be moved
# -------------------------------------
Expand Down

0 comments on commit 7fed016

Please sign in to comment.