payload: {"action":"closed","issue":{"url":"https://api.github.com/repos/pymc-devs/pymc3/issues/3714","repository_url":"https://api.github.com/repos/pymc-devs/pymc3","labels_url":"https://api.github.com/repos/pymc-devs/pymc3/issues/3714/labels{/name}","comments_url":"https://api.github.com/repos/pymc-devs/pymc3/issues/3714/comments","events_url":"https://api.github.com/repos/pymc-devs/pymc3/issues/3714/events","html_url":"https://github.com/pymc-devs/pymc3/issues/3714","id":535060435,"node_id":"MDU6SXNzdWU1MzUwNjA0MzU=","number":3714,"title":"Bounded prior causes Value Error in sample_smc(kernel='ABC')","user":{"login":"aakhmetz","id":2173206,"node_id":"MDQ6VXNlcjIxNzMyMDY=","avatar_url":"https://avatars3.githubusercontent.com/u/2173206?v=4","gravatar_id":"","url":"https://api.github.com/users/aakhmetz","html_url":"https://github.com/aakhmetz","followers_url":"https://api.github.com/users/aakhmetz/followers","following_url":"https://api.github.com/users/aakhmetz/following{/other_user}","gists_url":"https://api.github.com/users/aakhmetz/gists{/gist_id}","starred_url":"https://api.github.com/users/aakhmetz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aakhmetz/subscriptions","organizations_url":"https://api.github.com/users/aakhmetz/orgs","repos_url":"https://api.github.com/users/aakhmetz/repos","events_url":"https://api.github.com/users/aakhmetz/events{/privacy}","received_events_url":"https://api.github.com/users/aakhmetz/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2019-12-09T16:59:04Z","updated_at":"2019-12-10T14:07:26Z","closed_at":"2019-12-10T14:07:25Z","author_association":"NONE","body":"Doing ```sample_smc(kernel='ABC')``` and setting one particular prior from ```Normal``` to the bounded ```Uniform``` causes an error ```setting an array element with a sequence.```\r\n\r\n**Please provide a minimal, self-contained, and reproducible example.**\r\nThe gist is here: https://gist.github.com/aakhmetz/372d0bb18ea89882437d6c63053f45b8\r\n```python\r\ndef _sim(gtmean, gtsd, σ1, ρ, w):\r\n    weights = np.random.dirichlet(w, 1)[0]\r\n    draws = np.random.multinomial(len(ds), weights, size=1)[0]\r\n    # generation time\r\n    α = (gtmean/gtsd)**2\r\n    β = gtsd**2/gtmean\r\n    gt = ss.gamma(α, scale = β)\r\n    # incubation period\r\n    incmean = 12.3; incvar = 12.1\r\n    incα = (incmean**2)/incvar\r\n    incβ = incvar/incmean\r\n    ht = ss.gamma(incα, scale = incβ)\r\n    # Mechanism 1\r\n    res = np.random.normal(0, σ1, draws[0])\r\n    # Mechanism 2\r\n    μ2 = abs(np.random.gamma(α, β, draws[1]) - np.random.gamma(α, β, draws[1]))\r\n    res = np.r_[res,np.random.normal(μ2, 0.5, size=draws[1])]\r\n    # Mechanism 3\r\n    ## incorporating copulas\r\n    ### see https://twiecki.io/blog/2018/05/03/copulas/ for details\r\n    if (draws[2]>=1):\r\n        x = np.random.multivariate_normal([0, 0], [[1., ρ], [ρ, 1.]], draws[2])\r\n        norm = ss.distributions.norm()\r\n        x_unif = norm.cdf(x)\r\n        τ = ht.ppf(x_unif[:, 0]) \r\n        u = gt.ppf(x_unif[:, 1])\r\n        μ3 = abs(gt.rvs(draws[2]) + u - τ)\r\n        res = np.r_[res, np.random.normal(μ3, 0.5, size=draws[2])]\r\n    # output\r\n    return np.sort(res)\r\n\r\nwith pm.Model():\r\n    # Generation time interval\r\n    gtmean = pm.HalfNormal('gtmean', sd=20) \r\n    gtsd = pm.HalfNormal('gtsd', sd=5)\r\n    # for Mechanism 1\r\n    σ1 = pm.HalfNormal('σ1', sd=5, testval=5)\r\n    # corr.coeff. b/w incubation period and serial interval\r\n    ρ = pm.Uniform('ρ', 0, 1, testval=0) ## <- does not work\r\n    ## ρ = pm.Bound(pm.Normal,lower=-1,upper=1)('ρ', 0, 1, testval=0) ## <- does not work\r\n    ## ρ = pm.Normal('ρ', 0, .1, testval=-.5) <- previous variant\r\n    \r\n    w = pm.Dirichlet('w', a=np.array([1, 5, 1]))\r\n    s = pm.Simulator('s', _sim, observed=np.sort([x+0.5 for x in ds]))\r\n    trace = pm.sample_smc(1000, kernel=\"ABC\", epsilon=0.1, parallel=True)\r\n```\r\n\r\n**Please provide the full traceback.**\r\n```python\r\nSample initial stage: ...\r\n---------------------------------------------------------------------------\r\nRemoteTraceback                           Traceback (most recent call last)\r\nRemoteTraceback: \r\n\"\"\"\r\nTraceback (most recent call last):\r\n  File \"/home/aakhmetz/anaconda3/lib/python3.6/multiprocessing/pool.py\", line 119, in worker\r\n    result = (True, func(*args, **kwds))\r\n  File \"/home/aakhmetz/anaconda3/lib/python3.6/multiprocessing/pool.py\", line 47, in starmapstar\r\n    return list(itertools.starmap(args[0], args[1]))\r\n  File \"/home/aakhmetz/anaconda3/lib/python3.6/site-packages/pymc3/smc/smc.py\", line 438, in __call__\r\n    sim_data = self.function(**func_parameters)\r\n  File \"<ipython-input-16-1302d6d723b0>\", line 22, in _sim\r\n    x = np.random.multivariate_normal([0, 0], [[1., ρ], [ρ, 1.]], draws[2])\r\n  File \"mtrand.pyx\", line 3758, in numpy.random.mtrand.RandomState.multivariate_normal\r\nValueError: setting an array element with a sequence.\r\n\"\"\"\r\n\r\nThe above exception was the direct cause of the following exception:\r\n\r\nValueError                                Traceback (most recent call last)\r\n<timed exec> in <module>\r\n\r\n~/anaconda3/lib/python3.6/site-packages/pymc3/smc/sample_smc.py in sample_smc(draws, kernel, n_steps, parallel, start, cores, tune_steps, p_acc_rate, threshold, epsilon, dist_func, sum_stat, progressbar, model, random_seed)\r\n    136     smc.initialize_population()\r\n    137     smc.setup_kernel()\r\n--> 138     smc.initialize_logp()\r\n    139 \r\n    140     while smc.beta < 1:\r\n\r\n~/anaconda3/lib/python3.6/site-packages/pymc3/smc/smc.py in initialize_logp(self)\r\n    142             priors = self.pool.starmap(self.prior_logp, [(sample,) for sample in self.posterior])\r\n    143             likelihoods = self.pool.starmap(\r\n--> 144                 self.likelihood_logp, [(sample,) for sample in self.posterior]\r\n    145             )\r\n    146         else:\r\n\r\n~/anaconda3/lib/python3.6/multiprocessing/pool.py in starmap(self, func, iterable, chunksize)\r\n    272         `func` and (a, b) becomes func(a, b).\r\n    273         '''\r\n--> 274         return self._map_async(func, iterable, starmapstar, chunksize).get()\r\n    275 \r\n    276     def starmap_async(self, func, iterable, chunksize=None, callback=None,\r\n\r\n~/anaconda3/lib/python3.6/multiprocessing/pool.py in get(self, timeout)\r\n    642             return self._value\r\n    643         else:\r\n--> 644             raise self._value\r\n    645 \r\n    646     def _set(self, i, obj):\r\n\r\nValueError: setting an array element with a sequence.\r\n```\r\n\r\n**Please provide any additional information below.**\r\nBecause I am new in SMC-ABC, I maybe be wrong in something. Although it seems to me that my code is legit.\r\n\r\n## Versions and main components\r\n\r\n* PyMC3 Version: 3.8\r\n* Theano Version: 1.0.4\r\n* Python Version: 3.6.9\r\n* Operating system: ubuntu\r\n* How did you install PyMC3: (conda/pip) latest master version from github\r\n"}}
other: {"actor":{"display_login":"aakhmetz"}}