-
-
Notifications
You must be signed in to change notification settings - Fork 25.8k
FIX potentially redundant marker argument #27043
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
Conversation
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.
Thank you for the PR!
sklearn/calibration.py
Outdated
@@ -1190,12 +1190,13 @@ def plot(self, *, ax=None, name=None, ref_line=True, **kwargs): | |||
if name is not None: | |||
line_kwargs["label"] = name | |||
line_kwargs.update(**kwargs) | |||
line_kwargs.setdefault("marker", "s") |
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.
Can the default value be placed during the initiation of line_kwargs
?
line_kwargs = {"marker": "s"}
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.
You are right! And that's probably cleaner 😅.
I addressed your comment in my latest commit.
Co-authored-by: Thomas J. Fan <thomasjpfan@gmail.com>
Co-authored-by: Thomas J. Fan <thomasjpfan@gmail.com>
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.
LGTM, thanks!
Co-authored-by: ArturoAmorQ <arturo.amor-quiroz@polytechnique.edu> Co-authored-by: Thomas J. Fan <thomasjpfan@gmail.com>
Co-authored-by: ArturoAmorQ <arturo.amor-quiroz@polytechnique.edu> Co-authored-by: Thomas J. Fan <thomasjpfan@gmail.com>
Co-authored-by: ArturoAmorQ <arturo.amor-quiroz@polytechnique.edu> Co-authored-by: Thomas J. Fan <thomasjpfan@gmail.com>
Co-authored-by: ArturoAmorQ <arturo.amor-quiroz@polytechnique.edu> Co-authored-by: Thomas J. Fan <thomasjpfan@gmail.com>
Reference Issues/PRs
What does this implement/fix? Explain your changes.
The Comparison of Calibration of Classifiers example is raising a
UserWarning: marker is redundantly defined by the 'marker' keyword argument and the fmt string "s-" (-> marker='s'). The keyword argument will take precedence.
As users may want to customize the marker as done in this example, this PR uses the
setdefault
method to check if'marker'
is already a key inline_kwargs
. If it's not present, it adds the key with the value's'
. If it's already present, it does nothing, avoiding the redundancy.Any other comments?