python - How do I fix the 'TypeError: hasattr(): attribute name must be string' error? -


i have following code:

import pymc pm matplotlib import pyplot plt pymc.matplot import plot mcplot import numpy np matplotlib import rc  res = [18.752, 12.450, 11.832]  v = pm.uniform('v', 0, 20)  errors = pm.uniform('errors', 0, 100, size = 3)  taus = 1/(errors ** 2)  mydist = pm.normal('mydist', mu = v, tau = taus, value = res, observed = true)  model=pm.model([mydist, errors, taus, v, res]) mcmc=pm.mcmc(model) # line 19 typeerror originates mcmc.sample(20000,10000)  mcplot(mcmc.trace('mydist')) 

for reason doesn't work, 'typeerror: hasattr(): attribute name must string' error, following trace:

 traceback (most recent call last):    file "<ipython-input-49-759ebaf4321c>", line 1, in <module> runfile('c:/users/paul/.spyder2-py3/temp.py', wdir='c:/users/paul/.spyder2-py3')    file "c:\users\paul\miniconda3\lib\site-packages\spyderlib\widgets\externalshell\sitecustomize.py", line 685, in runfile execfile(filename, namespace)    file "c:\users\paul\miniconda3\lib\site-packages\spyderlib\widgets\externalshell\sitecustomize.py", line 85, in execfile exec(compile(open(filename, 'rb').read(), filename, 'exec'), namespace)    file "c:/users/paul/.spyder2-py3/temp.py", line 19, in <module> mcmc=pm.mcmc(model)    file "c:\users\paul\miniconda3\lib\site-packages\pymc\mcmc.py", line 82, in __init__ **kwds)    file "c:\users\paul\miniconda3\lib\site-packages\pymc\model.py", line 197, in __init__ model.__init__(self, input, name, verbose)    file "c:\users\paul\miniconda3\lib\site-packages\pymc\model.py", line 99, in __init__ objectcontainer.__init__(self, input)    file "c:\users\paul\miniconda3\lib\site-packages\pymc\container.py", line 606, in __init__ conservative_update(self, input_to_file)    file "c:\users\paul\miniconda3\lib\site-packages\pymc\container.py", line 549, in conservative_update if not hasattr(obj, k):  typeerror: hasattr(): attribute name must string 

how make work , output "mydist"?

edit: posted wrong trace @ first accident.

edit2: must because res doesn't have name, because it's array, don't know how assign name it, it'll make work.

i must admit i'm not familiar pymc, changing following @ least made application run:

mydist = pm.normal('mydist', mu = v, tau = taus, value = res, observed = false)  mcmc=pm.mcmc([mydist, errors, taus, v, res]) 

this seems because wrapping in model extension of objectcontainer, since passed list, mcmc file_items in container.py tried assign index 4 in list using replace, since model objectcontainer assigned key 4 in it's __dict__ causing weird typeerror got. removing wrapping model caused mcmc correctly use listcontainer instead.

now, there's bug in model.py on line 543 observable stochastics aren't stored in database - expression for object in self.stochastics | self.deterministics: suspect should include self.observable_stochastics - needed change observable false or last line throw keyerror.

i'm not familiar enough pymc determine if it's or bug or desired behaviour leave submit issue it.


Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

jquery - javascript onscroll fade same class but with different div -