From 461fb6d0a63d22250d03f43ff901b1f6a60f9f43 Mon Sep 17 00:00:00 2001 From: "Mads R. B. Kristensen" Date: Wed, 19 Apr 2017 10:55:18 +0200 Subject: [PATCH] graph: translate_dict() now also sort the labels --- module/benchpress/grapher/bar_per_script.py | 4 ++-- module/benchpress/grapher/graph.py | 5 ++++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/module/benchpress/grapher/bar_per_script.py b/module/benchpress/grapher/bar_per_script.py index a2fd1c22..b0838532 100644 --- a/module/benchpress/grapher/bar_per_script.py +++ b/module/benchpress/grapher/bar_per_script.py @@ -143,8 +143,8 @@ def render(self): scripts.sort() # Get translation of the components and scripts - comp_dict = translate_dict(comps, self.args.stack_map) - script_dict = translate_dict(scripts, self.args.script_map) + (comp_dict, comps) = translate_dict(comps, self.args.stack_map) + (script_dict, scripts) = translate_dict(scripts, self.args.script_map) # Convert to a bar-plot friendly format data = [] diff --git a/module/benchpress/grapher/graph.py b/module/benchpress/grapher/graph.py index 5147cc38..1b6c0ac3 100644 --- a/module/benchpress/grapher/graph.py +++ b/module/benchpress/grapher/graph.py @@ -75,16 +75,19 @@ def translate_dict(names, name_map): names = list(names) ret = {} + ret_list = [] for (old, new) in name_map: if len(new) > 0: for i in range(len(names)): if re.search(old, names[i]) is not None: ret[names[i]] = new + ret_list.append(names[i]) names.pop(i) break for old, new in [(t, t) for t in names]: ret[old] = new - return ret + ret_list.append(old) + return ret, ret_list class Grapher(object):