aboutsummaryrefslogtreecommitdiff
path: root/tests/test_plotter.py
diff options
context:
space:
mode:
authorKapileshwar Singh <kapileshwarsingh@gmail.com>2016-07-04 20:27:31 +0200
committerGitHub <noreply@github.com>2016-07-04 20:27:31 +0200
commit68e30d3539a282ef484c6caf2c89cacc905b1956 (patch)
treed1f7d5c1b2a8f110d03c456fced1120d00b805ab /tests/test_plotter.py
parent40ce06ea8e3833205793b6004713b3fddd6218c0 (diff)
parent2cc3c48095950dd429ad5bc896b7e2928e29c6af (diff)
downloadtrappy-68e30d3539a282ef484c6caf2c89cacc905b1956.tar.gz
Merge pull request #204 from JaviMerino/plotter_color_everywhere_v2
Plotter color everywhere v2
Diffstat (limited to 'tests/test_plotter.py')
-rw-r--r--tests/test_plotter.py46
1 files changed, 46 insertions, 0 deletions
diff --git a/tests/test_plotter.py b/tests/test_plotter.py
index e2d622a..2ec1fd8 100644
--- a/tests/test_plotter.py
+++ b/tests/test_plotter.py
@@ -151,6 +151,13 @@ class TestPlotter(BaseTestThermal):
"cpu_out_power:power"],
pivot="cpus")
+ self.assertTrue(isinstance(l.templates[0], type(trappy.cpu_power.CpuInPower)))
+ 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)
@@ -186,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)
@@ -280,6 +314,18 @@ class TestILinePlotter(unittest.TestCase):
expected_index.sort()
self.assertEquals(expected_index, merged.index.tolist())
+ def test_dygraph_colors(self):
+ """Check that to_dygraph_colors() constructs a valid dygraph colors argument"""
+ from trappy.plotter.ColorMap import to_dygraph_colors
+
+ color_map = [[86, 58, 206]]
+ expected = '["rgb(86, 58, 206)"]'
+ self.assertEquals(to_dygraph_colors(color_map), expected)
+
+ color_map = [[0, 0, 0], [123, 23, 45]]
+ expected = '["rgb(0, 0, 0)", "rgb(123, 23, 45)"]'
+ self.assertEquals(to_dygraph_colors(color_map), expected)
+
class TestBarPlot(unittest.TestCase):
def setUp(self):
self.dfr = pd.DataFrame({"foo": [1, 2, 3],