Skip to content

Commit

Permalink
more coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
glemaitre committed Jan 6, 2025
1 parent 0df833d commit 4eee6ab
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion skore/src/skore/sklearn/_estimator.py
Original file line number Diff line number Diff line change
Expand Up @@ -892,7 +892,7 @@ def report_metrics(
metrics_kwargs["pos_label"] = pos_label
else:
raise ValueError(
f"Invalid type of metric: {type(metric)} for metric: {metric}"
f"Invalid type of metric: {type(metric)} for {metric!r}"
)

scores.append(
Expand Down
10 changes: 10 additions & 0 deletions skore/tests/unit/sklearn/test_estimator.py
Original file line number Diff line number Diff line change
Expand Up @@ -778,6 +778,16 @@ def custom_metric(y_true, y_pred, some_weights):
)


def test_estimator_report_report_metrics_invalid_metric_type(regression_data):
"""Check that we raise the expected error message if an invalid metric is passed."""
estimator, X_test, y_test = regression_data
report = EstimatorReport(estimator, X_test=X_test, y_test=y_test)

err_msg = re.escape("Invalid type of metric: <class 'int'> for 1")
with pytest.raises(ValueError, match=err_msg):
report.metrics.report_metrics(scoring=[1])


def test_estimator_report_get_X_y_and_data_source_hash_error():
"""Check that we raise the proper error in `get_X_y_and_use_cache`."""
X, y = make_classification(n_classes=2, random_state=42)
Expand Down

0 comments on commit 4eee6ab

Please sign in to comment.