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

Optimize histogram graph generation

parent 1383ec9e
......@@ -170,7 +170,10 @@ class MeasureSetHandler:
common_metadatas = []
for metadata_name in first_metadata:
if metadata_name not in metadata_mask:
common_metadatas.append("{}: {}".format(MeasureSet.abbreviations[metadata_name], first_metadata[metadata_name]))
if metadata_name in MeasureSet.abbreviations:
common_metadatas.append("{}: {}".format(MeasureSet.abbreviations[metadata_name], first_metadata[metadata_name]))
else:
common_metadatas.append("{}: {}".format(metadata_name, first_metadata[metadata_name]))
report.write(", ".join(common_metadatas) + "\n\n")
for mid in self.measure_sets[mtype]['ids']:
......@@ -270,13 +273,6 @@ class MeasureSet:
self.avg = [statistics.mean(prop) for prop in props]
self.var = [statistics.variance(prop) for prop in props]
def histogram_to_chronological(histogram):
chrono = list(map(lambda x: [x[0]]*x[1], list(enumerate(histogram))))
chrono = [x for l in chrono for x in l]
return chrono
def add_histogram(self, props_names, props):
self.props = props
......@@ -375,16 +371,15 @@ class MeasureSet:
self.add_chronological(props_names, props)
def generate_histogram(self, i, color):
histogram = MeasureSet.histogram_to_chronological(self.props[i])
n, bins, patches = plt.hist(histogram, len(self.props[i]), facecolor=color, alpha=0.5)
max_height = max([patch.get_height() for patch in patches])
min_height = max_height / 100.0
bins = [i for i in range(self.max[i] + 1)]
vals = self.props[i][:self.max[i] + 1]
min_val = max(vals) / 140
vals = list(map(lambda x: min_val if x != 0 and x < min_val else x, vals))
for j, patch in enumerate(patches):
height = patch.get_height()
if self.props[i][j] > 0 and height < min_height:
patch.set_height(min_height)
plt.bar(bins, vals)
def generate_chrono_graph(self, i, color):
prop = self.props[i]
......
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