Skip to content

Commit

Permalink
Rejecting parameter 'positions' for boxplot(), refs #3566
Browse files Browse the repository at this point in the history
  • Loading branch information
leoluecken committed Nov 29, 2023
1 parent 9a2196d commit e4f6186
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
4 changes: 4 additions & 0 deletions seaborn/categorical.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'."
raise ValueError(msg)

p = _CategoricalPlotter(
data=data,
Expand Down
20 changes: 19 additions & 1 deletion tests/test_categorical.py
Original file line number Diff line number Diff line change
Expand Up @@ -1168,7 +1168,25 @@ def test_vs_catplot(self, long_df, wide_df, null_df, flat_series, kwargs):
g = catplot(**kwargs, kind="box")

assert_plots_equal(ax, g.ax)



@pytest.mark.parametrize("positions", [None, [1, 2, 3, 4]])
def test_reject_boxpositions(self, positions):

kwargs = {
"x":[1, 2, 3, 4],
"y":[1, 1, 2, 2]
}

try:
boxplot(**kwargs, positions=positions)
err = None

Check warning on line 1183 in tests/test_categorical.py

View check run for this annotation

Codecov / codecov/patch

tests/test_categorical.py#L1183

Added line #L1183 was not covered by tests
except ValueError as e:
err = e

assert(err is not None)



class TestBoxenPlot(SharedAxesLevelTests, SharedPatchArtistTests):

Expand Down

0 comments on commit e4f6186

Please sign in to comment.