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:
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:
......@@ -381,8 +381,9 @@ class MeasureSet:
else:
data = json.load(infile)
self.metadata.update(data['metadata'])
data['metadata'] = self.input_metadata()
if user_input:
self.metadata.update(data['metadata'])
data['metadata'] = self.input_metadata()
measure_type = data['measure_type']
units = data['units']
......@@ -437,8 +438,10 @@ class MeasureSet:
if headers:
# Table headers
headers = ["Min", "Max", "Avg", "Var"]
# Add a metadata information column if the metadata_mask isn't empty
if metadata_mask != []:
table += [["Metadata"] + headers]
table += [["**" + ", ".join(metadata_mask) + "**"] + ["**" + " - ".join(self.props_names) + "**"] * len(headers)]
......@@ -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))]
if metadata_mask != {}:
if 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))]]
else:
......@@ -506,9 +509,9 @@ def parse_args():
measure_set = MeasureSet()
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:
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)
......
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