-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
fixed_ get_variable_name #2225
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fixed_ get_variable_name #2225
Conversation
bug fixed for issue #2224
Yes, that should do it. Should probably insert a repr test somewhere. |
@fonnesbeck I agree, I can't think of a good way to do it though. |
Yes, we should add it to We can test them by calling |
But that would mean we need to test them case by case? It would increase the code size quite a lot. |
I wouldnt test all of them, maybe just one per module to ensure that its imported and it works. Could even piggyback it on an existing test(s). |
@junpenglao do you want me to merge this and add a test separately? |
I am working on a test, something like: with pm.Model() as model:
x0 = pm.Binomial('Discrete', p=.5, n=10)
x1 = pm.Normal('Continuous', mu=0., sd=1.)
x2 = pm.GaussianRandomWalk('timeseries', mu=x1, sd=5., shape=10)
assert x0._repr_latex_(), '$Discrete \\sim \\text{Binomial}(\\mathit{n}=10, \\mathit{p}=0.5)$'
assert x1._repr_latex_(), '$Continuous \\sim \\text{Normal}(\\mathit{mu}=0.0, \\mathit{sd}=1.0)$' However while doing so i seems to find another bug: x2._repr_latex_()
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-17-3a78dd7af59c> in <module>()
3 x1 = pm.Normal('Continuous', mu=0., sd=1.)
4 x2 = pm.GaussianRandomWalk('timeseries', mu=x1, sd=5., shape=10)
----> 5 x2._repr_latex_()
/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/pymc3/model.py in _repr_latex_(self, name, dist)
830 if dist is None:
831 dist = self.distribution
--> 832 return self.distribution._repr_latex_(name=name, dist=dist)
833
834 @property
/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/pymc3/distributions/timeseries.py in _repr_latex_(self, name, dist)
100 sd = dist.sd
101 return r'${} \sim \text{{GaussianRandomWalk}}(\mathit{{mu}}={}, \mathit{{sd}}={})$'.format(name,
--> 102 get_variable_name(mu),
103 get_variable_name(sd))
104
/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/pymc3/util.py in get_variable_name(variable)
81 returns the argument name.
82 """
---> 83 name = variable.name
84 if name is None:
85 if hasattr(variable, 'get_parents'):
AttributeError: 'float' object has no attribute 'name' |
Good to know. We typically cast all constants passed to distributions into tensors, so apparently that's not happening in the GRW. |
@fonnesbeck OK, fixing that as well. |
Yes, it should be, for example:
|
cast constants to tensors
Good to merge once tests pass. |
Looks like a casting issue |
tidy up pm.timeseries and fixed *arg for `tau` fixed _repr_latex for Normalmixture
@fonnesbeck it's the int in LKJCorr, fixing now. |
Is this good to merge? |
@twiecki not yet, i am working on a test for |
with small bug fix in MvStudentT
bug fixed for issue #2224