cranmer / play

Fun little projects
4 stars 5 forks source link

Visualisation of Model input not possible #1

Open Kecksdose opened 8 years ago

Kecksdose commented 8 years ago

Hi,

while copy/pasting your RooFit Notebook, I got some Errors on the nx.draw_graphvix() method. It says

0.5  [color=red,
  ^
Expected "}" (at char 200), (line:10, col:3)

Could me tell me which specific versions of Pydot, Networkx and Graphviz you are using? Mine are

pydot==1.0.2
networlx==1.10
graphviz==2.38.0

Regards, Timon

cranmer commented 8 years ago

Hi Timon,

I recently updated my system. Currently I'm having all sorts of problems with pygraphviz, pydot, networks. I just spent a couple of hours on it. I'll try again later.

you might try replacing G = nx.DiGraph(nx.read_dot('expressionTree.dot')) with G =nx.drawing.nx_agraph.read_dot('expressionTree.dot') (seems the networkx api has changed a bit)

Also, maybe issue is with the dot file created by RooFit. Check to see if you can run dot directly on the expressionTree.dot file. Or comment the line pdf.graphVizTree('expressionTree.dot') and use the one in the repository.

Kecksdose commented 8 years ago

Hi Kyle,

I found a solution without using nx.draw_graphviz (which is some kind of broken, I think). Here is the code:

import networkx as nx
import pydot
from IPython.display import Image

model.graphVizTree('SimpleModel.dot')
G = nx.drawing.nx_agraph.read_dot('SimpleModel.dot')
model_dot = nx.to_pydot(G)

model_png = model_dot.create_png(prog='dot')
Image(model_png)

Anyway, thanks for your quick response! Timon