Skip to content

Fix for #3483: model_to_graphviz now works with shared variables #3490

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

Merged
merged 3 commits into from
May 23, 2019
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions pymc3/model_graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,8 @@ def make_graph(self):
'\tconda install -c conda-forge python-graphviz')
graph = graphviz.Digraph(self.model.name)
for shape, var_names in self.get_plates().items():
if isinstance(shape, SharedVariable):
shape = shape.eval()
label = ' x '.join(map('{:,d}'.format, shape))
if label:
# must be preceded by 'cluster' to get a box around it
Expand Down
2 changes: 2 additions & 0 deletions pymc3/tests/test_model_graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ def radon_model():
floor_measure = np.random.randint(0, 2, size=n_homes)
log_radon = np.random.normal(1, 1, size=n_homes)

floor_measure = th.shared(floor_measure)

d, r = divmod(919, 85)
county = np.hstack((
np.tile(np.arange(counties, dtype=int), d),
Expand Down