From 4345e592a1868866d0c1efd4386116537bcb00de Mon Sep 17 00:00:00 2001 From: GStechschulte Date: Mon, 9 Oct 2023 20:52:55 +0200 Subject: [PATCH] if-else logic for response_dim --- bambi/interpret/effects.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/bambi/interpret/effects.py b/bambi/interpret/effects.py index 4b1b940e5..2ad4c331c 100644 --- a/bambi/interpret/effects.py +++ b/bambi/interpret/effects.py @@ -670,7 +670,11 @@ def comparisons( ) # returns empty list if model predictions do not have multiple dimensions - response_dim = idata.posterior.coords.get(response.name + "_dim", []).values + response_dim_key = response.name + "_dim" + if response_dim_key in idata.posterior.coords: + response_dim = idata.posterior.coords[response_dim_key].values + else: + response_dim = [] predictive_difference = PredictiveDifferences( model, @@ -820,7 +824,11 @@ def slopes( ) # returns empty list if model predictions do not have multiple dimensions - response_dim = idata.posterior.coords.get(response.name + "_dim", []).values + response_dim_key = response.name + "_dim" + if response_dim_key in idata.posterior.coords: + response_dim = idata.posterior.coords[response_dim_key].values + else: + response_dim = [] predictive_difference = PredictiveDifferences( model, slopes_data, wrt_info, conditional_info, response, use_hdi, effect_type