Skip to content

Commit a91bc87

Browse files
committed
fix(plot): don't require Matplotlib if no Window asked
1 parent dc5a21a commit a91bc87

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

graphkit/network.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -524,8 +524,6 @@ def plot_graph(graph, filename=None, show=False, steps=None,
524524
525525
"""
526526
import pydot
527-
import matplotlib.pyplot as plt
528-
import matplotlib.image as mpimg
529527

530528
assert graph is not None
531529

@@ -610,6 +608,9 @@ def get_node_name(a):
610608

611609
# display graph via matplotlib
612610
if show:
611+
import matplotlib.pyplot as plt
612+
import matplotlib.image as mpimg
613+
613614
png = g.create_png()
614615
sio = io.BytesIO(png)
615616
img = mpimg.imread(sio)

test/test_graphkit.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,8 @@ def test_plotting():
117117
solution=pipeline(inputs)
118118

119119
# ...not working on my PC ...
120-
forbidden_formats = ".dia .hpgl .mif .pcl .pic .vtx .xlib".split()
120+
forbidden_formats = ".dia .hpgl .mif .mp .pcl .pic .vtx .xlib".split()
121+
121122
tdir = tempfile.mkdtemp()
122123
counter = 0
123124
try:

0 commit comments

Comments
 (0)