From b49b6a7ad93dcfc39cdabd39898c7e1ebc4c3b0a Mon Sep 17 00:00:00 2001 From: Pavel 'LEdoian' Turinsky Date: Fri, 30 Sep 2022 06:12:58 +0200 Subject: [PATCH] Fix several bugs --- birdvisu/maps_new/__init__.py | 6 +++--- birdvisu/visualisation/annotators.py | 10 +++++----- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/birdvisu/maps_new/__init__.py b/birdvisu/maps_new/__init__.py index 316aa37..602b4be 100644 --- a/birdvisu/maps_new/__init__.py +++ b/birdvisu/maps_new/__init__.py @@ -187,9 +187,9 @@ def annotate_topology(topology, ) assert initial_annotation.topology is topology # 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 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.router_annotations for k in topology.routers.keys()) + assert all(k in initial_annotation.network_annotations for k in topology.networks.keys()) + assert all(k in initial_annotation.link_annotations for k in topology.links.keys()) for annotator in annotators: new_annotation = annotator(initial_annotation) diff --git a/birdvisu/visualisation/annotators.py b/birdvisu/visualisation/annotators.py index 55e3f3f..b31637a 100644 --- a/birdvisu/visualisation/annotators.py +++ b/birdvisu/visualisation/annotators.py @@ -38,7 +38,7 @@ def difference_annotator(at, reference_src='reference', actual_src='actual'): # Nodes currently cannot have discrepant information (provided the # Topology.is_valid()) if data is topo.links: - if k.metric < 0: + if v.metric < 0: verdict = DifferenceStatus.DISCREPANCY # 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(): visu_directive = None - for details in k.all_details: - visu_directives = list(filter(lambda x: x[0] == directive, details)) + for details in v.all_details: + visu_directives = list(filter(lambda x: x[0] == directive, details[1])) if len(visu_directives) > 0: visu_directive = visu_directives[-1] # Use the last one found. position = None if visu_directive is not None: 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: x, y = m.groups() position = Position(x = float(x), y = float(y)) @@ -79,7 +79,7 @@ def extract_positions(at, directive='visualisation default'): annot[k].append(position) return at -def random_posiiton(at): +def random_position(at): # Fallback when no position could be extracted # TODO: this should use some kind of heuristic or existing layout engine. topo = at.topology