From 01575b9febd59c39e07e7dfac4c6327590ace69a Mon Sep 17 00:00:00 2001 From: Colm Talbot <colm.talbot@ligo.org> Date: Wed, 3 Apr 2024 20:37:05 +0000 Subject: [PATCH] BUG: fix Pymc sampler import --- .../linear_regression_pymc_custom_likelihood.py | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/examples/core_examples/alternative_samplers/linear_regression_pymc_custom_likelihood.py b/examples/core_examples/alternative_samplers/linear_regression_pymc_custom_likelihood.py index ae6c58a27..1fccbcde6 100644 --- a/examples/core_examples/alternative_samplers/linear_regression_pymc_custom_likelihood.py +++ b/examples/core_examples/alternative_samplers/linear_regression_pymc_custom_likelihood.py @@ -12,6 +12,7 @@ import bilby import matplotlib.pyplot as plt import numpy as np import pymc as pm +from bilby.core.sampler.pymc import Pymc # A few simple setup steps label = "linear_regression_pymc_custom_likelihood" @@ -76,13 +77,11 @@ class GaussianLikelihoodPyMC(bilby.core.likelihood.GaussianLikelihood): ---------- sampler: :class:`bilby.core.sampler.Pymc` A Sampler object must be passed containing the prior distributions - and PyMC3 :class:`~pymc3.Model` to use as a context manager. + and PyMC :class:`~pymc.Model` to use as a context manager. If this is not passed, the super class is called and the regular likelihood is evaluated. """ - from bilby.core.sampler.pymc import Pymc - if not isinstance(sampler, Pymc): return super(GaussianLikelihoodPyMC, self).log_likelihood() @@ -116,15 +115,12 @@ class PyMCUniformPrior(bilby.core.prior.Uniform): def ln_prob(self, sampler=None): """ - Change ln_prob method to take in a Sampler and return a PyMC3 + Change ln_prob method to take in a Sampler and return a PyMC distribution. - If the passed argument is not a `Pymc3` sampler, assume that it is a + If the passed argument is not a `Pymc` sampler, assume that it is a float or array to be passed to the superclass. """ - - from bilby.core.sampler import Pymc - if not isinstance(sampler, Pymc): return super(PyMCUniformPrior, self).ln_prob(sampler) -- GitLab