Skip to content

Commit 9618459

Browse files
authored
Merge pull request #253 from kayjan/misc-cleanup
Misc cleanup
2 parents bb1ddc8 + f602899 commit 9618459

File tree

2 files changed

+9
-23
lines changed

2 files changed

+9
-23
lines changed

bigtree/dag/export.py

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -240,23 +240,10 @@ def dag_to_dot(
240240
(pydot.Dot)
241241
"""
242242
# Get style
243-
if bg_colour:
244-
graph_style = dict(bgcolor=bg_colour)
245-
else:
246-
graph_style = dict()
247-
248-
if node_colour:
249-
node_style = dict(style="filled", fillcolor=node_colour)
250-
else:
251-
node_style = dict()
252-
253-
if node_shape:
254-
node_style["shape"] = node_shape
255-
256-
if edge_colour:
257-
edge_style = dict(color=edge_colour)
258-
else:
259-
edge_style = dict()
243+
graph_style = dict(bgcolor=bg_colour) if bg_colour else {}
244+
node_style = dict(style="filled", fillcolor=node_colour) if node_colour else {}
245+
node_style.update({"shape": node_shape} if node_shape else {})
246+
edge_style = dict(color=edge_colour) if edge_colour else {}
260247

261248
_graph = pydot.Dot(
262249
graph_type="digraph", strict=True, rankdir=rankdir, **graph_style

bigtree/tree/export.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1251,11 +1251,10 @@ def tree_to_dot(
12511251
(pydot.Dot)
12521252
"""
12531253
# Get style
1254-
graph_style = dict(bgcolor=bg_colour) if bg_colour else dict()
1255-
node_style = dict(style="filled", fillcolor=node_colour) if node_colour else dict()
1256-
if node_shape:
1257-
node_style["shape"] = node_shape
1258-
edge_style = dict(color=edge_colour) if edge_colour else dict()
1254+
graph_style = dict(bgcolor=bg_colour) if bg_colour else {}
1255+
node_style = dict(style="filled", fillcolor=node_colour) if node_colour else {}
1256+
node_style.update({"shape": node_shape} if node_shape else {})
1257+
edge_style = dict(color=edge_colour) if edge_colour else {}
12591258

12601259
tree = tree.copy()
12611260
_graph = (
@@ -1785,7 +1784,7 @@ def _serialize(item: Any) -> Any:
17851784
return item
17861785

17871786
node_name_str = ""
1788-
if (intermediate_node_name) or (not intermediate_node_name and tree.is_leaf):
1787+
if intermediate_node_name or (not intermediate_node_name and tree.is_leaf):
17891788
node_name_str = _serialize(tree.node_name)
17901789
if length_attr and not tree.is_root:
17911790
if not tree.get_attr(length_attr):

0 commit comments

Comments
 (0)