-
-
Notifications
You must be signed in to change notification settings - Fork 25.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
FIX EmptyRequest.get
defaults to Bunch
of METHODS
#28371
Changes from 4 commits
5e94bd1
e56b4d8
6da316e
2aa6c16
940e53d
8ed5630
4bcaab6
6610d7b
d32ca3a
d500ae5
974c559
adf4eff
2ca2aa7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -1490,3 +1490,20 @@ def test_make_scorer_deprecation(deprecated_params, new_params, warn_msg): | |||||||||||||||
assert deprecated_roc_auc_scorer(classifier, X, y) == pytest.approx( | ||||||||||||||||
roc_auc_scorer(classifier, X, y) | ||||||||||||||||
) | ||||||||||||||||
|
||||||||||||||||
|
||||||||||||||||
def test_metadata_routing_multimetric_without_metadata_works_with_and_without_routing(): | ||||||||||||||||
"""Test multimetric scorer works with and without metadata routing enabled when | ||||||||||||||||
there is no actual metadata to pass. | ||||||||||||||||
|
||||||||||||||||
Non-regression test for https://github.com/scikit-learn/scikit-learn/issues/28256 | ||||||||||||||||
""" | ||||||||||||||||
X, y = make_classification(n_samples=50, n_features=10, random_state=0) | ||||||||||||||||
estimator = EstimatorWithFitAndPredict().fit(X, y) | ||||||||||||||||
|
||||||||||||||||
multimetric_scorer = _MultimetricScorer(scorers={"acc": get_scorer("accuracy")}) | ||||||||||||||||
with config_context(enable_metadata_routing=True): | ||||||||||||||||
multimetric_scorer(estimator, X, y) | ||||||||||||||||
|
||||||||||||||||
with config_context(enable_metadata_routing=False): | ||||||||||||||||
multimetric_scorer(estimator, X, y) | ||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
eddiebergman marked this conversation as resolved.
Show resolved
Hide resolved
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1530,7 +1530,10 @@ | |
# an empty dict on routed_params.ANYTHING.ANY_METHOD. | ||
class EmptyRequest: | ||
def get(self, name, default=None): | ||
return default if default else {} | ||
if not default: | ||
return Bunch(**{method: dict() for method in METHODS}) | ||
|
||
return default | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. codecov is not happy here. I need to figure out when is it the case that There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @adrinjalali I assume that we should be able to cover this one because it would be equivalent to call e.g. routed_params = _process_routing(self, "score", **kwargs)
routed_params.get("score", default="default") I don't where is the best place to test this. This looks like a metadata routing test to me. |
||
|
||
def __getitem__(self, name): | ||
return Bunch(**{method: dict() for method in METHODS}) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.