From f17f7d0ff6dae58d0084f5920eeaf23bce84cdee Mon Sep 17 00:00:00 2001 From: Connor Bevington Date: Tue, 26 Jul 2016 16:06:35 -0400 Subject: [PATCH] Allow functionality for single expparams value Attribute error arises for the case of a single expparams value (N, number of coin flips, in this case) if not converted to a numpy array. Fixed with with np.asarray --- introduction_to_bayes_smc.ipynb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/introduction_to_bayes_smc.ipynb b/introduction_to_bayes_smc.ipynb index c87e14d..314d292 100644 --- a/introduction_to_bayes_smc.ipynb +++ b/introduction_to_bayes_smc.ipynb @@ -296,6 +296,9 @@ " def likelihood(self, outcomes, modelparams, expparams):\n", " # Finally, we calculate the likelihood function\n", " # Again, call some necessary internal functions.\n", + " expparams = np.asarray(expparams,dtype=self.expparams_dtype)\n", + " if len(expparams.shape) == 0:\n", + " expparams = expparams.reshape(-1)\n", " super(CoinFlipsModel,self).likelihood(outcomes, modelparams, expparams)\n", " \n", " # The tensor storing the values of the likelihood has the following expected shape.\n",