From cdd40df85d4b897ce8bf8c76cbf761bdc0a3cac9 Mon Sep 17 00:00:00 2001 From: GStechschulte Date: Tue, 3 Oct 2023 06:28:54 +0200 Subject: [PATCH] sort values if conditional dict in plot_comparisons and plot_slopes --- bambi/interpret/plotting.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/bambi/interpret/plotting.py b/bambi/interpret/plotting.py index 544de3caf..3dfaaa572 100644 --- a/bambi/interpret/plotting.py +++ b/bambi/interpret/plotting.py @@ -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( @@ -473,6 +472,7 @@ 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: @@ -480,6 +480,8 @@ def plot_slopes( "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(