From 2e824d8ee0fb738855b7c2a95f92b9714a5a3668 Mon Sep 17 00:00:00 2001 From: GStechschulte Date: Thu, 4 Jul 2024 18:57:22 +0200 Subject: [PATCH 1/3] early return None and add logic for bayeux methods --- bambi/backend/inference_methods.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/bambi/backend/inference_methods.py b/bambi/backend/inference_methods.py index 900d9c26..dee510e7 100644 --- a/bambi/backend/inference_methods.py +++ b/bambi/backend/inference_methods.py @@ -17,6 +17,9 @@ def __init__(self): self.pymc_methods = self._pymc_methods() def _get_bayeux_methods(self, model): + # If bayeux is not installed, return an empty MCMC list. + if model is None: + return {"mcmc": []} # Bambi only supports bayeux MCMC methods mcmc_methods = model.methods.get("mcmc") return {"mcmc": mcmc_methods} @@ -85,7 +88,7 @@ def bayeux_model(): A dummy model with a simple quadratic likelihood function. """ if importlib.util.find_spec("bayeux") is None: - return {"mcmc": []} + return None import bayeux as bx # pylint: disable=import-outside-toplevel From 70532fc2744830145ae005d0530c4f143542d621 Mon Sep 17 00:00:00 2001 From: GStechschulte Date: Thu, 4 Jul 2024 19:08:08 +0200 Subject: [PATCH 2/3] return only pymc key-value pair --- bambi/backend/inference_methods.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/bambi/backend/inference_methods.py b/bambi/backend/inference_methods.py index dee510e7..51a51d61 100644 --- a/bambi/backend/inference_methods.py +++ b/bambi/backend/inference_methods.py @@ -72,6 +72,8 @@ def get_kwargs(self, method): @property def names(self): + if self.bayeux_model is None: + return {"pymc": self.pymc_methods} return {"pymc": self.pymc_methods, "bayeux": self.bayeux_methods} From 6fcfbc218904f32fcd8bcd638cb7bd972a0a09ad Mon Sep 17 00:00:00 2001 From: GStechschulte Date: Thu, 4 Jul 2024 19:36:36 +0200 Subject: [PATCH 3/3] return empty bayeux list if not installed --- bambi/backend/inference_methods.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/bambi/backend/inference_methods.py b/bambi/backend/inference_methods.py index 51a51d61..dee510e7 100644 --- a/bambi/backend/inference_methods.py +++ b/bambi/backend/inference_methods.py @@ -72,8 +72,6 @@ def get_kwargs(self, method): @property def names(self): - if self.bayeux_model is None: - return {"pymc": self.pymc_methods} return {"pymc": self.pymc_methods, "bayeux": self.bayeux_methods}