plot_utils: fix plot_allfreqs() for one actor
When the system has only one actor and you use trappy.summary_plots() or
trappy.compare_runs() you get:
Traceback (most recent call last):
File "trappy/tests/test_trappy.py", line 127, in test_summary_plots_one_actor
trappy.summary_plots(self.actor_order, map_label)
File "trappy/trappy/compare_runs.py", line 96, in summary_plots
return compare_runs(actor_order, map_label, [(title, path)], **kwords)
File "trappy/trappy/compare_runs.py", line 78, in compare_runs
trappy.plot_utils.plot_allfreqs(run_data, map_label, **kwords)
File "trappy/trappy/plot_utils.py", line 209, in plot_allfreqs
run.plot_allfreqs(map_label, ax=ax)
File "trappy/trappy/ftrace.py", line 531, in plot_allfreqs
for this_ax, (label, dfr) in zip(ax, all_freqs):
TypeError: zip argument #1 must support iteration
This is because plt.subplots() returns just the axis if ncols and nrows
are both 1, a 1D array if either ncols or nrows is 1 and a 2D array
otherwise. plot_utils.plot_all_freqs() copes with ncols being 1 but not
with nrows being 1. The latter happens when you use summary_plots() or
compare_runs() and there is only one actor.
Fix it so that axis is always a 2D array: the first index is the run and
the second the actor.
diff --git a/tests/test_plot_utils.py b/tests/test_plot_utils.py
index d5a6def..e912762 100644
--- a/tests/test_plot_utils.py
+++ b/tests/test_plot_utils.py
@@ -181,6 +181,21 @@
plot_utils.plot_allfreqs([trace], self.map_label)
matplotlib.pyplot.close('all')
+ def test_plot_allfreqs_one_actor(self):
+ """plot_utils.plot_allfreqs work when there is only one actor"""
+
+ in_data = """ kworker/4:1-397 [004] 720.741349: thermal_power_cpu_get: cpus=00000000,00000006 freq=1400000 raw_cpu_power=189 load={23, 12} power=14
+ kworker/4:1-397 [004] 720.741349: thermal_power_cpu_limit: cpus=00000000,00000006 freq=1400000 cdev_state=1 power=14"""
+
+ with open("trace.txt", "w") as fout:
+ fout.write(in_data)
+
+ traces = [trappy.FTrace(name="first"), trappy.FTrace(name="second")]
+ map_label = {"00000000,00000006": "A57"}
+
+ plot_utils.plot_allfreqs(traces, map_label)
+ matplotlib.pyplot.close("all")
+
def test_plot_controller(self):
"""plot_utils.plot_controller() doesn't bomb"""