{"action":"created","issue":{"url":"https://api.github.com/repos/pymc-devs/pymc3/issues/894","labels_url":"https://api.github.com/repos/pymc-devs/pymc3/issues/894/labels{/name}","comments_url":"https://api.github.com/repos/pymc-devs/pymc3/issues/894/comments","events_url":"https://api.github.com/repos/pymc-devs/pymc3/issues/894/events","html_url":"https://github.com/pymc-devs/pymc3/issues/894","id":122741119,"number":894,"title":"Error with categorical variables","user":{"login":"carolfs","id":55320,"avatar_url":"https://avatars.githubusercontent.com/u/55320?v=3","gravatar_id":"","url":"https://api.github.com/users/carolfs","html_url":"https://github.com/carolfs","followers_url":"https://api.github.com/users/carolfs/followers","following_url":"https://api.github.com/users/carolfs/following{/other_user}","gists_url":"https://api.github.com/users/carolfs/gists{/gist_id}","starred_url":"https://api.github.com/users/carolfs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/carolfs/subscriptions","organizations_url":"https://api.github.com/users/carolfs/orgs","repos_url":"https://api.github.com/users/carolfs/repos","events_url":"https://api.github.com/users/carolfs/events{/privacy}","received_events_url":"https://api.github.com/users/carolfs/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2015-12-17T14:07:11Z","updated_at":"2016-01-08T18:01:23Z","closed_at":null,"body":"The following code runs fine sometimes, but sometimes it generates an error. Not sure about what's going on. I've just updated all packages with pip.\r\n\r\n```python\r\nimport numpy as np\r\nimport pymc3\r\n\r\nwith pymc3.Model() as model:\r\n    category = pymc3.Categorical(name='category', p=[0.25,0.25,0.25,0.25])\r\n    trace = pymc3.sample(20)\r\nprint(trace['category'])\r\n```\r\n\r\nWhen it doesn't, I get the following error:\r\n\r\n```\r\nAssigned Metropolis to category\r\nTraceback (most recent call last):\r\n  File \"/usr/lib/python3.5/site-packages/theano/compile/function_module.py\", line 859, in __call__\r\n    outputs = self.fn()\r\nIndexError: index out of bounds\r\n\r\nDuring handling of the above exception, another exception occurred:\r\n\r\nTraceback (most recent call last):\r\n  File \"mpl_bfit.py\", line 8, in <module>\r\n    trace = pymc3.sample(20)\r\n  File \"/usr/lib/python3.5/site-packages/pymc3/sampling.py\", line 156, in sample\r\n    return sample_func(*sample_args)\r\n  File \"/usr/lib/python3.5/site-packages/pymc3/sampling.py\", line 165, in _sample\r\n    for i, strace in enumerate(sampling):\r\n  File \"/usr/lib/python3.5/site-packages/pymc3/sampling.py\", line 247, in _iter_sample\r\n    point = step.step(point)\r\n  File \"/usr/lib/python3.5/site-packages/pymc3/step_methods/arraystep.py\", line 118, in step\r\n    apoint = self.astep(bij.map(point))\r\n  File \"/usr/lib/python3.5/site-packages/pymc3/step_methods/metropolis.py\", line 125, in astep\r\n    q_new = metrop_select(self.delta_logp(q,q0), q, q0)\r\n  File \"/usr/lib/python3.5/site-packages/theano/compile/function_module.py\", line 871, in __call__\r\n    storage_map=getattr(self.fn, 'storage_map', None))\r\n  File \"/usr/lib/python3.5/site-packages/theano/gof/link.py\", line 314, in raise_with_op\r\n    reraise(exc_type, exc_value, exc_trace)\r\n  File \"/usr/lib/python3.5/site-packages/six.py\", line 685, in reraise\r\n    raise value.with_traceback(tb)\r\n  File \"/usr/lib/python3.5/site-packages/theano/compile/function_module.py\", line 859, in __call__\r\n    outputs = self.fn()\r\nIndexError: index out of bounds\r\nApply node that caused the error: Subtensor{int64}(TensorConstant{(4,) of 0.25}, ScalarFromTensor.0)\r\nToposort index: 5\r\nInputs types: [TensorType(float64, vector), Scalar(int64)]\r\nInputs shapes: [(4,), ()]\r\nInputs strides: [(8,), ()]\r\nInputs values: [array([ 0.25,  0.25,  0.25,  0.25]), 4]\r\nOutputs clients: [[Elemwise{Composite{(Switch((GE(i0, i1) * LE(i0, i2)), log(i3), i4) - Switch((GE(i5, i1) * LE(i5, i2)), log(i6), i4))}}(Subtensor{int64}.0, TensorConstant{0}, TensorConstant{3}, Subtensor{int64}.0, TensorConstant{-inf}, Subtensor{int64}.0, Subtensor{int64}.0)]]\r\n\r\nBacktrace when the node is created:\r\n  File \"/usr/lib/python3.5/site-packages/pymc3/distributions/discrete.py\", line 367, in logp\r\n    return bound(log(p[value]),\r\n\r\nHINT: Use the Theano flag 'exception_verbosity=high' for a debugprint and storage map footprint of this apply node.\r\n```"},"comment":{"url":"https://api.github.com/repos/pymc-devs/pymc3/issues/comments/170075374","html_url":"https://github.com/pymc-devs/pymc3/issues/894#issuecomment-170075374","issue_url":"https://api.github.com/repos/pymc-devs/pymc3/issues/894","id":170075374,"user":{"login":"twiecki","id":674200,"avatar_url":"https://avatars.githubusercontent.com/u/674200?v=3","gravatar_id":"","url":"https://api.github.com/users/twiecki","html_url":"https://github.com/twiecki","followers_url":"https://api.github.com/users/twiecki/followers","following_url":"https://api.github.com/users/twiecki/following{/other_user}","gists_url":"https://api.github.com/users/twiecki/gists{/gist_id}","starred_url":"https://api.github.com/users/twiecki/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/twiecki/subscriptions","organizations_url":"https://api.github.com/users/twiecki/orgs","repos_url":"https://api.github.com/users/twiecki/repos","events_url":"https://api.github.com/users/twiecki/events{/privacy}","received_events_url":"https://api.github.com/users/twiecki/received_events","type":"User","site_admin":false},"created_at":"2016-01-08T18:01:23Z","updated_at":"2016-01-08T18:01:23Z","body":"@carolfs did you try with pymc3.ElemwiseCategoricalStep(var=a, values=[0,1,2,3])?"}}