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

Attribute Error using graphviz: MvGaussianRandomWalk #5303

Closed
ltoniazzi opened this issue Jan 2, 2022 · 2 comments
Closed

Attribute Error using graphviz: MvGaussianRandomWalk #5303

ltoniazzi opened this issue Jan 2, 2022 · 2 comments
Labels
Milestone

Comments

@ltoniazzi
Copy link
Member

Description of your problem

When I try to plot a model with pm.model_to_graphviz that features a distribution pm.MvGaussianRandomWalk, I get the Attribute Error 'MvGaussianRandomWalk' object has no attribute 'mu'.

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

import numpy as np
import pymc3 as pm
shape = (3,2)
chol = np.array([[1,0],[1,1]])
mu = np.zeros(2)
with pm.Model() as model:
    RW = pm.MvGaussianRandomWalk("RW", mu=mu, chol=chol, shape=shape)
pm.model_to_graphviz(model)

Please provide the full traceback.

Complete error traceback
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
/tmp/ipykernel_7565/1959954546.py in <module>
      6 with pm.Model() as model:
      7     RW = pm.MvGaussianRandomWalk("RW", mu=mu, chol=chol, shape=shape)
----> 8 pm.model_to_graphviz(model)

~/miniconda3/envs/pymc/lib/python3.9/site-packages/pymc3/model_graph.py in model_to_graphviz(model, formatting)
    241         raise ValueError(f"Unsupported formatting for graph nodes: '{formatting}'. See docstring.")
    242     model = pm.modelcontext(model)
--> 243     return ModelGraph(model).make_graph(formatting=formatting)

~/miniconda3/envs/pymc/lib/python3.9/site-packages/pymc3/model_graph.py in make_graph(self, formatting)
    207                 with graph.subgraph(name="cluster" + label) as sub:
    208                     for var_name in var_names:
--> 209                         self._make_node(var_name, sub, formatting=formatting)
    210                     # plate label goes bottom right
    211                     sub.attr(label=label, labeljust="r", labelloc="b", style="rounded")

~/miniconda3/envs/pymc/lib/python3.9/site-packages/pymc3/model_graph.py in _make_node(self, var_name, graph, formatting)
    148             label = f"{var_name}\n~\nData"
    149         else:
--> 150             label = v._str_repr(formatting=formatting).replace(" ~ ", "\n~\n")
    151 
    152         graph.node(var_name.replace(":", "&"), label, **attrs)

~/miniconda3/envs/pymc/lib/python3.9/site-packages/pymc3/model.py in _str_repr(self, name, dist, formatting)
     78         if dist is None and hasattr(self, "distribution"):
     79             dist = self.distribution
---> 80         return self.distribution._str_repr(name=name, dist=dist, formatting=formatting)
     81 
     82     def _repr_latex_(self, *, formatting="latex_with_params", **kwargs):

~/miniconda3/envs/pymc/lib/python3.9/site-packages/pymc3/distributions/distribution.py in _str_repr(self, name, dist, formatting)
    211 
    212         param_names = self._distr_parameters_for_repr()
--> 213         param_values = [
    214             get_repr_for_variable(getattr(dist, x), formatting=formatting) for x in param_names
    215         ]

~/miniconda3/envs/pymc/lib/python3.9/site-packages/pymc3/distributions/distribution.py in <listcomp>(.0)
    212         param_names = self._distr_parameters_for_repr()
    213         param_values = [
--> 214             get_repr_for_variable(getattr(dist, x), formatting=formatting) for x in param_names
    215         ]
    216 

AttributeError: 'MvGaussianRandomWalk' object has no attribute 'mu'

Please provide any additional information below.
This error is briefly discussed on discourse. A related issue might be 4391 with corresponding PR 4403.

Versions and main components

  • PyMC3 Version: 3.11.2
  • Theano Version: 1.1.2
  • Python Version: 3.9.6
  • Operating system: Ubuntu Linux
  • How did you install PyMC3: conda
@michaelosthege
Copy link
Member

For v3 we'll probably consider it as a "wontfix", but for v4 it should be dealt with as part of #4642.

@michaelosthege michaelosthege added this to the v4.0.0b3 milestone Jan 13, 2022
@ricardoV94 ricardoV94 modified the milestones: v4.0.0b3, v4.0.0 Feb 3, 2022
@ricardoV94 ricardoV94 modified the milestones: v4.0.0, v4.1.0 Apr 1, 2022
@michaelosthege michaelosthege modified the milestones: v4.1.0, v4.2.0 Jul 2, 2022
@ricardoV94 ricardoV94 modified the milestones: v4.2.0, v4.3.0 Sep 14, 2022
@ricardoV94
Copy link
Member

Closing this as it's not an issue in V4

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

No branches or pull requests

3 participants