plot_utils: let plot_temperature() and plot_temperature_hist() work if
the provided run didn't have thermal trace
Some traces don't have the thermal_core tracepoints. Let
cr2.summary_plots() still plot everything for them. Skip the histogram
of temperatures for the time being.
diff --git a/cr2/plot_utils.py b/cr2/plot_utils.py
index 9e0c517..3ae88de 100644
--- a/cr2/plot_utils.py
+++ b/cr2/plot_utils.py
@@ -125,9 +125,13 @@
for run in runs:
current_temp = run.thermal_governor.data_frame["current_temperature"]
delta_temp = run.thermal_governor.data_frame["delta_temperature"]
- control_temp_series = (current_temp + delta_temp) / 1000
- run.thermal.plot_temperature(control_temperature=control_temp_series,
- ax=ax, legend_label=run.name)
+ control_series = (current_temp + delta_temp) / 1000
+
+ try:
+ run.thermal.plot_temperature(control_temperature=control_series,
+ ax=ax, legend_label=run.name)
+ except ValueError:
+ run.thermal_governor.plot_temperature(ax=ax, legend_label=run.name)
post_plot_setup(ax, title="Temperature", ylim=ylim)
plt.legend(loc="best")
@@ -216,7 +220,14 @@
def plot_temperature_hist(runs):
"""Plot temperature histograms for all the runs"""
- num_runs = len(runs)
+ num_runs = 0
+ for run in runs:
+ if len(run.thermal.data_frame):
+ num_runs += 1
+
+ if num_runs == 0:
+ return
+
axis = pre_plot_setup(ncols=num_runs)
if num_runs == 1:
diff --git a/tests/test_cr2.py b/tests/test_cr2.py
index 23c9384..931cce6 100644
--- a/tests/test_cr2.py
+++ b/tests/test_cr2.py
@@ -1,6 +1,7 @@
#!/usr/bin/python
import os
+import re
import matplotlib, tempfile
import cr2
@@ -58,6 +59,23 @@
# Sanity check that the test actually ran from another directory
self.assertEquals(os.getcwd(), other_random_dir)
+ def test_summary_plots_only_power_allocator_trace(self):
+ """Test that summary_plots() work if there is only power allocator
+ trace"""
+
+ # Strip out "thermal_temperature" from the trace
+ trace_out = ""
+ with open("trace.txt") as fin:
+ for line in fin:
+ if not re.search("thermal_temperature:", line):
+ trace_out += line
+
+ with open("trace.txt", "w") as fout:
+ fout.write(trace_out)
+
+ cr2.summary_plots(self.actor_order, self.map_label)
+ matplotlib.pyplot.close('all')
+
def test_compare_runs(self):
"""Basic compare_runs() functionality"""