Skip to content

Commit

Permalink
sort values if conditional dict in plot_comparisons and plot_slopes
Browse files Browse the repository at this point in the history
  • Loading branch information
GStechschulte committed Oct 3, 2023
1 parent 7ca9762 commit cdd40df
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions bambi/interpret/plotting.py
Original file line number Diff line number Diff line change
Expand Up @@ -323,8 +323,7 @@ def plot_comparisons(
"passed to 'conditional' is greater than 3."
)
if isinstance(conditional, dict):
for key, value in conditional.items():
conditional[key] = sorted(value)
conditional = {key: sorted(value) for key, value in conditional.items()}

if average_by is True:
raise ValueError(
Expand Down Expand Up @@ -473,13 +472,16 @@ def plot_slopes(

if conditional is None and average_by is None:
raise ValueError("Must specify at least one of 'conditional' or 'average_by'.")

if conditional is not None:
if not isinstance(conditional, str):
if len(conditional) > 3 and average_by is None:
raise ValueError(
"Must specify a covariate to 'average_by' when number of covariates"
"passed to 'conditional' is greater than 3."
)
if isinstance(conditional, dict):
conditional = {key: sorted(value) for key, value in conditional.items()}

if average_by is True:
raise ValueError(
Expand Down

0 comments on commit cdd40df

Please sign in to comment.