diff options
author | Kapileshwar Singh <kapileshwar.singh@arm.com> | 2015-12-02 16:28:37 +0000 |
---|---|---|
committer | Kapileshwar Singh <kapileshwar.singh@arm.com> | 2015-12-04 14:45:52 +0000 |
commit | cf6db4e4c2979cc684248b24eae98b2f06c9294c (patch) | |
tree | 34693e60a9cb27512fc1701fadc3e08d399861dc | |
parent | 6f612cba3ef9ee574401bfca02625b6f2c3c5824 (diff) | |
download | bart-cf6db4e4c2979cc684248b24eae98b2f06c9294c.tar.gz |
tests: Add tests for conditional_comparison special cases
Signed-off-by: Kapileshwar Singh <kapileshwar.singh@arm.com>
-rw-r--r-- | tests/test_signal.py | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/tests/test_signal.py b/tests/test_signal.py index d8c98b8..fa302d4 100644 --- a/tests/test_signal.py +++ b/tests/test_signal.py @@ -17,6 +17,7 @@ import pandas as pd import trappy from utils_tests import TestBART from bart.common.signal import SignalCompare +import numpy as np class TestSignalCompare(TestBART): @@ -45,3 +46,59 @@ class TestSignalCompare(TestBART): "event:A > event:B", method="rect"), expected) + + def test_get_overshoot(self): + """Test get_overshoot""" + + A = [0, 0, 0, 3, 3, 0, 0, 0] + B = [0, 0, 2, 2, 2, 2, 1, 1] + + run = trappy.Run(".", events=["event"]) + df = pd.DataFrame({"A": A, "B": B}) + run.event.data_frame = df + + s = SignalCompare(run, "event:A", "event:B") + expected = (1.5, 2.0 / 7) + self.assertEqual( + s.get_overshoot(method="rect"), + expected) + + A = [0, 0, 0, 1, 1, 0, 0, 0] + B = [0, 0, 2, 2, 2, 2, 1, 1] + + df = pd.DataFrame({"A": A, "B": B}) + run.event.data_frame = df + s = SignalCompare(run, "event:A", "event:B") + + expected = (float("nan"), 0.0) + result = s.get_overshoot(method="rect") + self.assertTrue(np.isnan(result[0])) + self.assertEqual(result[1], expected[1]) + + def test_get_undershoot(self): + """Test get_undershoot""" + + A = [0, 0, 0, 1, 1, 1, 1, 1] + B = [2, 2, 2, 2, 2, 2, 2, 2] + + run = trappy.Run(".", events=["event"]) + df = pd.DataFrame({"A": A, "B": B}) + run.event.data_frame = df + + s = SignalCompare(run, "event:A", "event:B") + expected = (4.0 / 14.0, 1.0) + self.assertEqual( + s.get_undershoot(method="rect"), + expected) + + A = [3, 3, 3, 3, 3, 3, 3, 3] + B = [2, 2, 2, 2, 2, 2, 1, 1] + + df = pd.DataFrame({"A": A, "B": B}) + run.event.data_frame = df + s = SignalCompare(run, "event:A", "event:B") + + expected = (float("nan"), 0.0) + result = s.get_undershoot(method="rect") + self.assertTrue(np.isnan(result[0])) + self.assertEqual(result[1], expected[1]) |