Skip to content
Open
Show file tree
Hide file tree
Changes from all 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: 1 addition & 1 deletion burr/core/graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ def visualize(
)
for g_key, g_value in engine_kwargs.items():
if isinstance(g_value, dict):
digraph_attr[g_key].update(**g_value)
digraph_attr.setdefault(g_key, {}).update(**g_value)
else:
digraph_attr[g_key] = g_value
digraph = graphviz.Digraph(**digraph_attr)
Expand Down
16 changes: 16 additions & 0 deletions tests/core/test_graphviz_display.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,3 +99,19 @@ def test_visualize_include_state_multiline_label(reads: list, writes: list, expe
digraph = graph.visualize(include_state=True)

assert expected_label in digraph.source


def test_visualize_engine_kwargs_attr_dicts(graph):
"""Attribute dicts passed through ``engine_kwargs`` reach the graphviz.Digraph,
including ones (like ``edge_attr``) that have no Burr default to merge into."""
digraph = graph.visualize(
graph_attr={"rankdir": "LR"},
node_attr={"fontname": "Courier"},
edge_attr={"color": "red"},
)

assert digraph.graph_attr["rankdir"] == "LR"
assert digraph.graph_attr["ranksep"] == "0.4" # Burr default is kept
assert digraph.node_attr["fontname"] == "Courier"
assert digraph.node_attr["fillcolor"] == "#b4d8e4" # Burr default is kept
assert digraph.edge_attr == {"color": "red"}
Loading