Skip to content

Commit

Permalink
if-else logic for response_dim
Browse files Browse the repository at this point in the history
  • Loading branch information
GStechschulte committed Oct 9, 2023
1 parent f53c337 commit 4345e59
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions bambi/interpret/effects.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 4345e59

Please sign in to comment.