Fix several bugs

older_libs
LEdoian 2 years ago
parent 105f00705c
commit b49b6a7ad9

@ -187,9 +187,9 @@ def annotate_topology(topology,
) )
assert initial_annotation.topology is topology assert initial_annotation.topology is topology
# FIXME: probably shouldn't rely on topology having correct keys. # FIXME: probably shouldn't rely on topology having correct keys.
assert all(k in router_annotations for k in topology.routers.keys()) assert all(k in initial_annotation.router_annotations for k in topology.routers.keys())
assert all(k in network_annotations for k in topology.networks.keys()) assert all(k in initial_annotation.network_annotations for k in topology.networks.keys())
assert all(k in link_annotations for k in topology.links.keys()) assert all(k in initial_annotation.link_annotations for k in topology.links.keys())
for annotator in annotators: for annotator in annotators:
new_annotation = annotator(initial_annotation) new_annotation = annotator(initial_annotation)

@ -38,7 +38,7 @@ def difference_annotator(at, reference_src='reference', actual_src='actual'):
# Nodes currently cannot have discrepant information (provided the # Nodes currently cannot have discrepant information (provided the
# Topology.is_valid()) # Topology.is_valid())
if data is topo.links: if data is topo.links:
if k.metric < 0: if v.metric < 0:
verdict = DifferenceStatus.DISCREPANCY verdict = DifferenceStatus.DISCREPANCY
# TODO: We should probably disallow mutating previous AnnotatedTopologies. # TODO: We should probably disallow mutating previous AnnotatedTopologies.
@ -64,14 +64,14 @@ def extract_positions(at, directive='visualisation default'):
]: ]:
for k, v in data.items(): for k, v in data.items():
visu_directive = None visu_directive = None
for details in k.all_details: for details in v.all_details:
visu_directives = list(filter(lambda x: x[0] == directive, details)) visu_directives = list(filter(lambda x: x[0] == directive, details[1]))
if len(visu_directives) > 0: if len(visu_directives) > 0:
visu_directive = visu_directives[-1] # Use the last one found. visu_directive = visu_directives[-1] # Use the last one found.
position = None position = None
if visu_directive is not None: if visu_directive is not None:
for pos in visu_directive[1]: for pos in visu_directive[1]:
m = re.match(r'position \[([0-9.]+) ([0-9.]+)\]', pos) m = re.match(r'position \[([0-9.]+) ([0-9.]+)\]', pos[0])
if pos is not None: if pos is not None:
x, y = m.groups() x, y = m.groups()
position = Position(x = float(x), y = float(y)) position = Position(x = float(x), y = float(y))
@ -79,7 +79,7 @@ def extract_positions(at, directive='visualisation default'):
annot[k].append(position) annot[k].append(position)
return at return at
def random_posiiton(at): def random_position(at):
# Fallback when no position could be extracted # Fallback when no position could be extracted
# TODO: this should use some kind of heuristic or existing layout engine. # TODO: this should use some kind of heuristic or existing layout engine.
topo = at.topology topo = at.topology

Loading…
Cancel
Save