Skip to content

Commit

Permalink
docs: set default graphviz background to transparent (#141)
Browse files Browse the repository at this point in the history
  • Loading branch information
redeboer authored Jan 26, 2022
1 parent 11c420b commit 8ea1be2
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion docs/usage/visualize.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,7 @@
" reaction.transitions[0],\n",
" render_node=True,\n",
" size=12,\n",
" bgcolor=\"transparent\",\n",
" bgcolor=\"white\",\n",
" edge_style={\n",
" \"color\": \"red\",\n",
" \"arrowhead\": \"open\",\n",
Expand Down
2 changes: 2 additions & 0 deletions src/qrules/io/_dot.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ def wrapper(*args: Any, **kwargs: Any) -> str:


def insert_graphviz_styling(dot: str, graphviz_attrs: Dict[str, Any]) -> str:
if "bgcolor" not in graphviz_attrs:
graphviz_attrs["bgcolor"] = None
header = __dot_kwargs_to_header(graphviz_attrs)
return dot.replace(_DOT_HEAD, _DOT_HEAD + header)

Expand Down
3 changes: 3 additions & 0 deletions tests/unit/io/test_dot.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ def test_asdot_exact_format(reaction: ReactionInfo):
rankdir=LR;
node [shape=point, width=0];
edge [arrowhead=none];
bgcolor=none;
"edge0" [shape=none, label="0: gamma[-1]"];
"edge1" [shape=none, label="1: pi0[0]"];
"edge2" [shape=none, label="2: pi0[0]"];
Expand All @@ -61,6 +62,7 @@ def test_asdot_exact_format(reaction: ReactionInfo):
rankdir=LR;
node [shape=point, width=0];
edge [arrowhead=none];
bgcolor=none;
"edge0" [shape=none, label="0: gamma[-1]"];
"edge1" [shape=none, label="1: pi0[0]"];
"edge2" [shape=none, label="2: pi0[0]"];
Expand All @@ -86,6 +88,7 @@ def test_asdot_graphviz_attrs(reaction: ReactionInfo):
assert pydot.graph_from_dot_data(dot_data) is not None
assert '\n bgcolor="red";\n' in dot_data
assert "\n size=12;\n" in dot_data
assert "bgcolor=none" not in dot_data


def test_asdot_with_styled_edges_and_nodes(reaction: ReactionInfo, output_dir):
Expand Down

0 comments on commit 8ea1be2

Please sign in to comment.