KP Singh | 7319a88 | 2014-12-24 18:18:01 +0000 | [diff] [blame] | 1 | #!/usr/bin/env python |
| 2 | |
| 3 | import unittest |
| 4 | import matplotlib |
| 5 | import pandas as pd |
| 6 | |
| 7 | from test_thermal import BaseTestThermal |
| 8 | import cr2 |
| 9 | |
| 10 | |
| 11 | class TestPlotter(BaseTestThermal): |
| 12 | |
| 13 | """No Bombing testcases for plotter""" |
| 14 | |
| 15 | def __init__(self, *args, **kwargs): |
| 16 | super(TestPlotter, self).__init__(*args, **kwargs) |
| 17 | |
| 18 | def test_plot_no_pivot(self): |
| 19 | """Tests LinePlot with no pivot""" |
| 20 | run1 = cr2.Run(name="first") |
| 21 | l = cr2.LinePlot(run1, cr2.thermal.Thermal, column="temp") |
| 22 | l.view() |
| 23 | matplotlib.pyplot.close('all') |
| 24 | |
| 25 | def test_plot_multi_run(self): |
| 26 | """Tests LinePlot with no Pivot multi runs""" |
| 27 | run1 = cr2.Run(name="first") |
| 28 | run2 = cr2.Run(name="second") |
| 29 | l = cr2.LinePlot( |
| 30 | [run1, run2], cr2.thermal.Thermal, column="temp") |
| 31 | l.view() |
| 32 | matplotlib.pyplot.close('all') |
| 33 | |
| 34 | def test_plot_multi(self): |
| 35 | """Tests LinePlot with no Pivot multi attrs""" |
| 36 | run1 = cr2.Run(name="first") |
| 37 | run2 = cr2.Run(name="second") |
| 38 | l = cr2.LinePlot([run1, |
Kapileshwar Singh | 1882075 | 2015-02-11 12:01:08 +0000 | [diff] [blame^] | 39 | run2], |
| 40 | [cr2.thermal.Thermal, |
| 41 | cr2.thermal.ThermalGovernor], |
| 42 | column=["temp", |
| 43 | "power_range"]) |
KP Singh | 7319a88 | 2014-12-24 18:18:01 +0000 | [diff] [blame] | 44 | l.view() |
| 45 | matplotlib.pyplot.close('all') |
| 46 | |
| 47 | def test_plot_filter(self): |
| 48 | """Tests LinePlot with no Pivot with filters""" |
| 49 | run1 = cr2.Run(name="first") |
| 50 | run2 = cr2.Run(name="second") |
| 51 | l = cr2.LinePlot([run1, |
Kapileshwar Singh | 1882075 | 2015-02-11 12:01:08 +0000 | [diff] [blame^] | 52 | run2], |
| 53 | [cr2.power.OutPower], |
| 54 | column=["power"], |
| 55 | filters={"cdev_state": [1]}) |
KP Singh | 7319a88 | 2014-12-24 18:18:01 +0000 | [diff] [blame] | 56 | l.view() |
| 57 | matplotlib.pyplot.close('all') |
| 58 | |
| 59 | def test_plot_pivot(self): |
| 60 | """Tests LinePlot with Pivot""" |
| 61 | run1 = cr2.Run(name="first") |
| 62 | l = cr2.LinePlot( |
| 63 | run1, |
| 64 | cr2.thermal.Thermal, |
| 65 | column="temp", |
| 66 | pivot="thermal_zone") |
| 67 | l.view() |
| 68 | matplotlib.pyplot.close('all') |
| 69 | |
| 70 | def test_plot_multi_run_pivot(self): |
| 71 | """Tests LinePlot with Pivot multi runs""" |
| 72 | run1 = cr2.Run(name="first") |
| 73 | run2 = cr2.Run(name="second") |
| 74 | l = cr2.LinePlot( |
| 75 | [run1, run2], cr2.power.OutPower, column="power", pivot="cpus") |
| 76 | l.view() |
| 77 | matplotlib.pyplot.close('all') |
| 78 | |
| 79 | def test_plot_multi_pivot(self): |
| 80 | """Tests LinePlot with Pivot with multi attrs""" |
| 81 | run1 = cr2.Run(name="first") |
| 82 | run2 = cr2.Run(name="second") |
| 83 | l = cr2.LinePlot([run1, |
Kapileshwar Singh | 1882075 | 2015-02-11 12:01:08 +0000 | [diff] [blame^] | 84 | run2], |
| 85 | [cr2.power.InPower, |
| 86 | cr2.power.OutPower], |
| 87 | column=["dynamic_power", |
| 88 | "power"], |
| 89 | pivot="cpus") |
KP Singh | 7319a88 | 2014-12-24 18:18:01 +0000 | [diff] [blame] | 90 | l.view() |
| 91 | matplotlib.pyplot.close('all') |
| 92 | |
| 93 | def test_plot_multi_pivot_filter(self): |
| 94 | """Tests LinePlot with Pivot and filters""" |
| 95 | run1 = cr2.Run(name="first") |
| 96 | run2 = cr2.Run(name="second") |
| 97 | l = cr2.LinePlot( |
| 98 | run1, |
| 99 | cr2.power.InPower, |
| 100 | column=[ |
Kapileshwar Singh | 1882075 | 2015-02-11 12:01:08 +0000 | [diff] [blame^] | 101 | "dynamic_power", |
KP Singh | 7319a88 | 2014-12-24 18:18:01 +0000 | [diff] [blame] | 102 | "load1"], |
| 103 | filters={ |
| 104 | "cdev_state": [ |
| 105 | 1, |
| 106 | 0]}, |
| 107 | pivot="cpus") |
| 108 | l.view() |
| 109 | matplotlib.pyplot.close('all') |