Skip to content
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

Rejecting parameter 'positions' for boxplot(), refs #3566 #3576

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

leoluecken
Copy link

Hi, this is a first attempt for the boxplot position rejection (#3566). I'm not sure about the style. Please review and let me know if something should be changed.
Cheers

Copy link
Owner

@mwaskom mwaskom left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, I think raising an error here makes sense; it looks like positions errored on <=0.12 anyway since seaborn was already passing positions directly. (In 0.13, there was an effort to allow users to override more of the matplotlib params that seaborn sets defaults for, though as you discovered in the original issue, there's no guarantee that the overridden behavior will be correct).

@@ -1577,6 +1577,10 @@ def boxplot(
fliersize=None, hue_norm=None, native_scale=False, log_scale=None, formatter=None,
legend="auto", ax=None, **kwargs
):

if "positions" in kwargs:
msg = "boxplot() does not support parameter 'positions'. Consider to use native_scale=True and specify positions via parameter 'x'."
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
msg = "boxplot() does not support parameter 'positions'. Consider to use native_scale=True and specify positions via parameter 'x'."
msg = "boxplot does not support parameter `positions`. Consider using `native_scale=True`.

Nit: For a horizontal boxplot you'd specify the positions with y so let's make the suggestion less specific. Note that I've also tweaked the formatting.


if "positions" in kwargs:
msg = "boxplot() does not support parameter 'positions'. Consider to use native_scale=True and specify positions via parameter 'x'."
raise ValueError(msg)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small thing but TypeError is probably a better error class here, that is what you get if you passed an undefined parameter. Alternatively, RuntimeError since positions is technically valid but produces incorrect behavior.

Comment on lines 1181 to 1187
try:
boxplot(**kwargs, positions=positions)
err = None
except ValueError as e:
err = e

assert(err is not None)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be slightly more idiomatic I think to use pytest.raises here, ideally with the match parameter to make sure we're getting the error we expect.

Copy link

codecov bot commented Nov 30, 2023

Codecov Report

Attention: 1 lines in your changes are missing coverage. Please review.

Comparison is base (b95d6d1) 98.58% compared to head (e4f6186) 98.34%.

❗ Current head e4f6186 differs from pull request most recent head 56aced5. Consider uploading reports for the commit 56aced5 to get more accurate results

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #3576      +/-   ##
==========================================
- Coverage   98.58%   98.34%   -0.25%     
==========================================
  Files          75       75              
  Lines       24706    24641      -65     
==========================================
- Hits        24357    24233     -124     
- Misses        349      408      +59     
Files Coverage Δ
seaborn/categorical.py 98.91% <100.00%> (-0.01%) ⬇️
tests/test_categorical.py 99.21% <88.88%> (-0.06%) ⬇️

... and 24 files with indirect coverage changes

@leoluecken
Copy link
Author

Hi, I came back to this now and updated my branch. How do I proceed? Should I open a new PR or can this be updated somehow? Sorry, I'm not very familiar with this process... :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants