diff options
author | Javi Merino <javi.merino@arm.com> | 2016-06-17 19:51:47 +0100 |
---|---|---|
committer | Javi Merino <javi.merino@arm.com> | 2016-07-04 17:54:10 +0100 |
commit | e5c3597852f0bd31494b60b463d3b88e922d59cf (patch) | |
tree | 4e11664d0c07a8d8945b707b60e643f6d8228e6c /tests | |
parent | 25ffb28cd8c46e2f3c44e89b719cc79dcc33cb06 (diff) | |
download | trappy-e5c3597852f0bd31494b60b463d3b88e922d59cf.tar.gz |
plotter: augment the signals spec to include colors
Now that we have color support in all plots, augment the signal spec to
have color as an additional third parameter. With this syntax, signal
"thermal:temp:255,0,255" plots the temp column of the thermal trace in
pink.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test_plotter.py | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/tests/test_plotter.py b/tests/test_plotter.py index 8d33c57..68dff9e 100644 --- a/tests/test_plotter.py +++ b/tests/test_plotter.py @@ -155,6 +155,7 @@ class TestPlotter(BaseTestThermal): self.assertEquals(l._attr["column"][0], "dynamic_power") self.assertTrue(l.templates[1], type(trappy.cpu_power.CpuOutPower)) self.assertEquals(l._attr["column"][1], "power") + self.assertTrue("colors" not in l._attr) # Check that plotting doesn't barf l.view(test=True) @@ -192,6 +193,33 @@ class TestPlotter(BaseTestThermal): "cpu_out_power:power"], pivot="cpus") + def test_signals_colors(self): + """Test signals with colors in LinePlot""" + + trace1 = trappy.FTrace(name="first") + trace2 = trappy.FTrace(name="second") + + l = trappy.LinePlot([trace1, trace2], + signals=["thermal:temp:1,2,3", + "cpu_in_power:load2:200,100,0"], + pivot="cpus") + + self.assertTrue(isinstance(l.templates[0], type(trappy.thermal.Thermal))) + self.assertEquals(l._attr["column"][0], "temp") + self.assertEquals(l._attr["colors"][0], [1, 2, 3]) + self.assertTrue(l.templates[1], type(trappy.cpu_power.CpuInPower)) + self.assertEquals(l._attr["column"][1], "load2") + self.assertEquals(l._attr["colors"][1], [200, 100, 0]) + + # Check that plotting doesn't barf + l.view(test=True) + + # Test hex color + l = trappy.LinePlot([trace1, trace2], + signals=["thermal:prev_temp:0xff,0x3a,0x3"], + pivot="cpus") + self.assertEquals(l._attr["colors"][0], [0xff, 0x3a, 0x3]) + def test_lineplot_dataframe(self): """LinePlot plots DataFrames without exploding""" data = np.random.randn(4, 2) |