from bart.common import Utils
import unittest
import pandas as pd


class TestCommonUtils(unittest.TestCase):

    def __init__(self, *args, **kwargs):
        super(TestCommonUtils, self).__init__(*args, **kwargs)

    def test_interval_sum(self):
        """Test Utils Function: interval_sum"""

        array = [0, 0, 1, 1, 1, 1, 0, 0]
        series = pd.Series(array)
        self.assertEqual(Utils.interval_sum(series, 1), 3)

        array = [False, False, True, True, True, True, False, False]
        series = pd.Series(array)
        self.assertEqual(Utils.interval_sum(series), 3)

        array = [0, 0, 1, 0, 0, 0]
        series = pd.Series(array)
        self.assertEqual(Utils.interval_sum(series, 1), 0)

        array = [0, 0, 1, 0, 1, 1]
        series = pd.Series(array)
        self.assertEqual(Utils.interval_sum(series, 1), 1)

@@ -843,8 +843,1063 @@
  1), 1)%0A
+%0A    def test_area_under_curve(self):%0A        %22%22%22Test Utils function: area_under_curve%22%22%22%0A%0A        array = %5B0, 0, 2, 2, 2, 1, 1, 1%5D%0A        series = pd.Series(array)%0A%0A        # Area under curve post stepping%0A        self.assertEqual(%0A            Utils.area_under_curve(%0A                series,%0A                method=%22rect%22,%0A                step=%22post%22),%0A            8)%0A%0A        # Area under curve pre stepping%0A        self.assertEqual(%0A            Utils.area_under_curve(%0A                series,%0A                method=%22rect%22,%0A                step=%22pre%22),%0A            9)%0A%0A        array = %5B1%5D%0A        series = pd.Series(array)%0A%0A        # Area under curve post stepping, edge case%0A        self.assertEqual(%0A            Utils.area_under_curve(%0A                series,%0A                method=%22rect%22,%0A                step=%22post%22),%0A            0)%0A%0A        # Area under curve pre stepping, edge case%0A        self.assertEqual(%0A            Utils.area_under_curve(%0A                series,%0A                method=%22rect%22,%0A                step=%22pre%22),%0A            0)%0A

Add test case for area_under_curve