Skip to content

Commit 8cf02e1

Browse files
committed
fix: remove spurious nodes in dot files.
1 parent 0d9b1d7 commit 8cf02e1

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

causal_testing/specification/causal_dag.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,9 @@ class CausalDAG(nx.DiGraph):
133133
def __init__(self, dot_path: str = None, **attr):
134134
super().__init__(**attr)
135135
if dot_path:
136-
pydot_graph = pydot.graph_from_dot_file(dot_path)
136+
with open(dot_path, 'r') as file:
137+
dot_content = file.read().replace('\n', '')
138+
pydot_graph = pydot.graph_from_dot_data(dot_content)
137139
self.graph = nx.DiGraph(nx.drawing.nx_pydot.from_pydot(pydot_graph[0]))
138140
else:
139141
self.graph = nx.DiGraph()

0 commit comments

Comments
 (0)