Commit fdc1c377 authored by Tiago Peixoto's avatar Tiago Peixoto
Browse files

PropertyMap: assure that filtered arrays (fa) have always the correct size

This closes issue #228
parent 06157bcc
...@@ -552,8 +552,10 @@ class PropertyMap(object): ...@@ -552,8 +552,10 @@ class PropertyMap(object):
filt = [None] filt = [None]
if self.__key_type == 'v': if self.__key_type == 'v':
filt = g.get_vertex_filter() filt = g.get_vertex_filter()
N = g.num_vertices()
elif self.__key_type == 'e': elif self.__key_type == 'e':
filt = g.get_edge_filter() filt = g.get_edge_filter()
N = g._get_max_edge_index()
if g.get_vertex_filter()[0] is not None: if g.get_vertex_filter()[0] is not None:
filt = (g.new_edge_property("bool"), filt[1]) filt = (g.new_edge_property("bool"), filt[1])
u = GraphView(g, directed=True, skip_properties=True) u = GraphView(g, directed=True, skip_properties=True)
...@@ -569,7 +571,7 @@ class PropertyMap(object): ...@@ -569,7 +571,7 @@ class PropertyMap(object):
return a return a
if filt[0] is None: if filt[0] is None:
return a return a
return a[filt[0].a == (not filt[1])] return a[filt[0].a == (not filt[1])][:N]
else: else:
if a is None: if a is None:
return return
...@@ -580,6 +582,7 @@ class PropertyMap(object): ...@@ -580,6 +582,7 @@ class PropertyMap(object):
a[:] = v[:len(a)] a[:] = v[:len(a)]
else: else:
m = filt[0].a == (not filt[1]) m = filt[0].a == (not filt[1])
m *= m.cumsum() <= N
try: try:
a[m] = v a[m] = v
except ValueError: except ValueError:
......
...@@ -1137,7 +1137,7 @@ def scale_ink(scale, vprops, eprops): ...@@ -1137,7 +1137,7 @@ def scale_ink(scale, vprops, eprops):
def get_bb(g, pos, size, pen_width, size_scale=1, text=None, font_family=None, def get_bb(g, pos, size, pen_width, size_scale=1, text=None, font_family=None,
font_size=None, cr=None): font_size=None, cr=None):
size = size.fa[:g.num_vertices()] if isinstance(size, PropertyMap) else size size = size.fa if isinstance(size, PropertyMap) else size
pen_width = pen_width.fa if isinstance(pen_width, PropertyMap) else pen_width pen_width = pen_width.fa if isinstance(pen_width, PropertyMap) else pen_width
pos_x, pos_y = ungroup_vector_property(pos, [0, 1]) pos_x, pos_y = ungroup_vector_property(pos, [0, 1])
if text is not None and text != "": if text is not None and text != "":
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment