Skip to content
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

Broken str representation for Kronecker Normal distribution #4240

Closed
Sayam753 opened this issue Nov 21, 2020 · 1 comment · Fixed by #4243
Closed

Broken str representation for Kronecker Normal distribution #4240

Sayam753 opened this issue Nov 21, 2020 · 1 comment · Fixed by #4243
Assignees
Labels

Comments

@Sayam753
Copy link
Member

If you have questions about a specific use case, or you are not sure whether this is a bug or not, please post it to our discourse channel: https://discourse.pymc.io

Description of your problem

This issue popped out while I was in pdb debugger, figuring out the reason of failing test cases in #4207

Please provide a minimal, self-contained, and reproducible example.

>>> import numpy as np
>>> import pymc3 as pm
>>> K1 = np.array([[1., 0.5], [0.5, 2]])
>>> K2 = np.array([[1., 0.4, 0.2], [0.4, 2, 0.3], [0.2, 0.3, 1]])
>>> covs = [K1, K2]
>>> N = 6
>>> mu = np.zeros(N)
>>> with pm.Model() as model:
...     vals = pm.KroneckerNormal('vals', mu=mu, covs=covs, shape=N)
... 
>>> vals

Please provide the full traceback.

>>> vals
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/sayam/.local/lib/python3.8/site-packages/theano/gof/graph.py", line 449, in __repr__
    to_print = [str(self)]
  File "/home/sayam/Desktop/pymc/pymc3/pymc3/model.py", line 83, in __str__
    return self._str_repr(formatting="plain", **kwargs)
  File "/home/sayam/Desktop/pymc/pymc3/pymc3/model.py", line 77, in _str_repr
    return self.distribution._str_repr(name=name, dist=dist, formatting=formatting)
  File "/home/sayam/Desktop/pymc/pymc3/pymc3/distributions/distribution.py", line 176, in _str_repr
    param_values = [
  File "/home/sayam/Desktop/pymc/pymc3/pymc3/distributions/distribution.py", line 177, in <listcomp>
    get_repr_for_variable(getattr(dist, x), formatting=formatting) for x in param_names
  File "/home/sayam/Desktop/pymc/pymc3/pymc3/util.py", line 131, in get_repr_for_variable
    name = variable.name if variable is not None else None
AttributeError: 'list' object has no attribute 'name'

Please provide any additional information below.

https://github.com/pymc-devs/pymc3/blob/ad63b94342260ca21d385f2539e243aaf62d26aa/pymc3/util.py#L130-L131

I imagine to use getattr for variable. Pinging @Spaak, @AlexAndorra to help here.

Versions and main components

  • PyMC3 Version: master
  • Theano Version: 1.0.11
  • Python Version: 3.8.6
  • Operating system: Ubuntu 18.04 LTS
  • How did you install PyMC3: (conda/pip) pip
@Spaak
Copy link
Member

Spaak commented Nov 22, 2020

Thanks @Sayam753 for reporting and for the ping. Merging #4243 should fix this (and potential similar issues in the future, by falling back to a default str representation if needed).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants