Skip to content

Fix pen_width bug in cairo_draw

Snehal Shekatkar requested to merge snehal/graph-tool:master into master

When user passes pen_width value only for either vertex or edge, an error is thrown since inside min_lw, lw may be None. This bug fixes that by assigning value lw=0.1 whenever it is 0.1

In the absence of this fix, the following code throws error:


import graph_tool.all as gt
g = gt.collection.data['karate']
gt.graph_draw(g, vertex_pen_width=5, vertex_color = 'k', output='test.png')

Actual error:

Traceback (most recent call last): File "test.py", line 4, in gt.graph_draw(g, vertex_pen_width=1, output='test.png') File "/usr/lib/python3/dist-packages/graph_tool/draw/cairo_draw.py", line 1153, in graph_draw x, y, zoom = fit_to_view_ink(g, pos, output_size, vprops, File "/usr/lib/python3/dist-packages/graph_tool/draw/cairo_draw.py", line 1345, in fit_to_view_ink eprops = dict(eprops, pen_width=min_lw(eprops.get("pen_width"))) File "/usr/lib/python3/dist-packages/graph_tool/draw/cairo_draw.py", line 1342, in min_lw lw = max(lw, 0.1) TypeError: '>' not supported between instances of 'float' and 'NoneType'

Merge request reports