From 9c998750f710f0265489e5a65dbc127ca3a0d14d Mon Sep 17 00:00:00 2001
From: Matthew Pitkin <matthew.pitkin@ligo.org>
Date: Tue, 21 Aug 2018 22:35:23 +0100
Subject: [PATCH] Minor fixes

---
 .../linear_regression_pymc3_custom_likelihood.py       |  3 ---
 tupak/core/sampler.py                                  | 10 +++++-----
 2 files changed, 5 insertions(+), 8 deletions(-)

diff --git a/examples/other_examples/linear_regression_pymc3_custom_likelihood.py b/examples/other_examples/linear_regression_pymc3_custom_likelihood.py
index 181f721ab..4d87b8110 100644
--- a/examples/other_examples/linear_regression_pymc3_custom_likelihood.py
+++ b/examples/other_examples/linear_regression_pymc3_custom_likelihood.py
@@ -89,7 +89,6 @@ class GaussianLikelihoodPyMC3(tupak.Likelihood):
         """
 
         from tupak.core.sampler import Pymc3
-        import theano.tensor as tt
 
         if not isinstance(sampler, Pymc3):
             raise ValueError("Sampler is not a tupak Pymc3 sampler object")
@@ -97,8 +96,6 @@ class GaussianLikelihoodPyMC3(tupak.Likelihood):
         if not hasattr(sampler, 'pymc3_model'):
             raise AttributeError("Sampler has not PyMC3 model attribute")
 
-        pymc3 = sampler.external_sampler
-
         with sampler.pymc3_model:
             mdist = sampler.pymc3_priors['m']
             cdist = sampler.pymc3_priors['c']
diff --git a/tupak/core/sampler.py b/tupak/core/sampler.py
index 5bde459a8..30690954c 100644
--- a/tupak/core/sampler.py
+++ b/tupak/core/sampler.py
@@ -1404,7 +1404,9 @@ class Pymc3(Sampler):
         def like_(values):
             for i, key in enumerate(pymc3_parameters):
                 pymc3_log_like.parameters[key] = values[i]
-            return pymc3_log_like.loglikelihood()
+            return pymc3_log_like.log_likelihood()
+
+        pymc3 = self.external_sampler
 
         with self.pymc3_model:
             #  check if it is a predefined likelhood function
@@ -1497,16 +1499,14 @@ class Pymc3(Sampler):
                 parameters = OrderedDict()
                 for key in self.pymc3_priors:
                     try:
-                        #self.likelihood.parameters[key] = tt.cast(self.pymc3_priors[key], 'float64')
-                        #self.likelihood.parameters[key] = self.pymc3_priors[key]
                         parameters[key] = self.pymc3_priors[key]
                     except KeyError:
                         raise KeyError("Unknown key '{}' when setting GravitationalWaveTransient likelihood".format(key))
 
-                values = tt.as_tensor_variable(parameters.values())
+                values = tt.as_tensor_variable(list(parameters.values()))
                 pymc3_log_like = self.likelihood
                 pymc3_parameters = parameters.keys()
-                pymc3.DensityDist('likelihood', _like, observed={'values': values})
+                pymc3.DensityDist('likelihood', lambda v: like_(v), observed={'values': values})
             else:
                 raise ValueError("Unknown likelihood has been provided")
 
-- 
GitLab