Commit d4513bf4 authored by Joanne Hugé's avatar Joanne Hugé

Fix table display when no metadata information is present

parent bdb875a0
...@@ -372,7 +372,7 @@ class MeasureSet: ...@@ -372,7 +372,7 @@ class MeasureSet:
return data return data
def import_from_json(self, path, flat=False, cyclictest=False): def import_from_json(self, path, flat=False, cyclictest=False, user_input=False):
with open(path) as infile: with open(path) as infile:
...@@ -381,6 +381,7 @@ class MeasureSet: ...@@ -381,6 +381,7 @@ class MeasureSet:
else: else:
data = json.load(infile) data = json.load(infile)
if user_input:
self.metadata.update(data['metadata']) self.metadata.update(data['metadata'])
data['metadata'] = self.input_metadata() data['metadata'] = self.input_metadata()
...@@ -437,8 +438,10 @@ class MeasureSet: ...@@ -437,8 +438,10 @@ class MeasureSet:
if headers: if headers:
# Table headers
headers = ["Min", "Max", "Avg", "Var"] headers = ["Min", "Max", "Avg", "Var"]
# Add a metadata information column if the metadata_mask isn't empty
if metadata_mask != []: if metadata_mask != []:
table += [["Metadata"] + headers] table += [["Metadata"] + headers]
table += [["**" + ", ".join(metadata_mask) + "**"] + ["**" + " - ".join(self.props_names) + "**"] * len(headers)] table += [["**" + ", ".join(metadata_mask) + "**"] + ["**" + " - ".join(self.props_names) + "**"] * len(headers)]
...@@ -451,7 +454,7 @@ class MeasureSet: ...@@ -451,7 +454,7 @@ class MeasureSet:
values = [[ (format(m[i][j], '.4f') + self.units[j]) for j in range(len(m[0]))] for i in range(len(m))] values = [[ (format(m[i][j], '.4f') + self.units[j]) for j in range(len(m[0]))] for i in range(len(m))]
if metadata_mask != {}: if metadata_mask != []:
metadata_info = ["{}".format(self.metadata[metadata_name]) for metadata_name in metadata_mask] metadata_info = ["{}".format(self.metadata[metadata_name]) for metadata_name in metadata_mask]
table += [[", ".join(metadata_info)] + [" - ".join(values[i]) for i in range(len(values))]] table += [[", ".join(metadata_info)] + [" - ".join(values[i]) for i in range(len(values))]]
else: else:
...@@ -506,9 +509,9 @@ def parse_args(): ...@@ -506,9 +509,9 @@ def parse_args():
measure_set = MeasureSet() measure_set = MeasureSet()
if args.c: if args.c:
measure_set.import_from_json(args.i[0], cyclictest=True) measure_set.import_from_json(args.i[0], cyclictest=True, userInput=True)
else: else:
measure_set.import_from_json(args.i[0], flat=True) measure_set.import_from_json(args.i[0], flat=True, userInput=True)
ms_handler.add_measure_set(measure_set) ms_handler.add_measure_set(measure_set)
......
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