# Path: dynts/utils/test.py
# def haszoo():
#     def __init__(self, *args, **kwargs):
#     def setUp(self):
#     def tearDown(self):
#     def randomts(self, **kwargs):
#     def getdata(self, size=100, cols=1, delta=1, start=None):
#     def getts(self, returndata=False, delta=1, cols=1, size=100):
#     def timeseries(self, name='', date=None, data=None):
#     def isiterable(self, a):
#     def assertAlmostEqual(self, a, b, places=7, msg=None):
#     def assertEqual(self, exp, recv, msg = None):
#     def check_dates(self, ts, dts):
#     def check_values(self, ts, vals):
#     def _check_vectors(self, v1, v2, equal=True):
# class TestCase(unittest.TestCase):


from numpy import nan
from dynts.utils import test
class TestClean(test.TestCase):

    def testClean(self):
        ts1 = self.timeseries(date=[1, 2, 3, 4, 5, 6],
                              data=[nan, nan, 5, 6, nan, -1])
        ts2 = self.timeseries(date=[1, 2, 3, 4, 5, 6, 7],
                              data=[nan, -4, 5, 6, -1, nan, -5])
        ts = ts1.merge(ts2)
        self.assertEqual(ts.count(), 2)
        self.assertEqual(len(ts), 7)
        cts = ts.clean()
        self.assertEqual(len(cts), 4)
        return ts

    def testClean2(self):
        ts1 = self.timeseries(date=[1, 2], data=[2, -1])
        ts2 = self.timeseries(date=[1, 2], data=[-4, nan])
        ts = ts1.merge(ts2)
        self.assertEqual(ts.count(), 2)
        self.assertEqual(len(ts), 2)
        cts = ts.clean()
        self.assertEqual(len(cts), 2)
        return ts

    def testItems(self):
        ts = self.testClean()
        v = list(ts.items(start_value=0))
        self.assertTrue(v)



# Path: dynts/utils/test.py
# def haszoo():
#     def __init__(self, *args, **kwargs):
#     def setUp(self):
#     def tearDown(self):
#     def randomts(self, **kwargs):
#     def getdata(self, size=100, cols=1, delta=1, start=None):
#     def getts(self, returndata=False, delta=1, cols=1, size=100):
#     def timeseries(self, name='', date=None, data=None):
#     def isiterable(self, a):
#     def assertAlmostEqual(self, a, b, places=7, msg=None):
#     def assertEqual(self, exp, recv, msg = None):
#     def check_dates(self, ts, dts):
#     def check_values(self, ts, vals):
#     def _check_vectors(self, v1, v2, equal=True):
# class TestCase(unittest.TestCase):


# Path: tests/unit/test_clean.py
from numpy import nan
from dynts.utils import test

class TestClean(test.TestCase):

    def testClean(self):
        ts1 = self.timeseries(date=[1, 2, 3, 4, 5, 6],
                              data=[nan, nan, 5, 6, nan, -1])
        ts2 = self.timeseries(date=[1, 2, 3, 4, 5, 6, 7],
                              data=[nan, -4, 5, 6, -1, nan, -5])
        ts = ts1.merge(ts2)
        self.assertEqual(ts.count(), 2)
        self.assertEqual(len(ts), 7)
        cts = ts.clean()
        self.assertEqual(len(cts), 4)
        return ts

    def testClean2(self):
        ts1 = self.timeseries(date=[1, 2], data=[2, -1])
        ts2 = self.timeseries(date=[1, 2], data=[-4, nan])
        ts = ts1.merge(ts2)
        self.assertEqual(ts.count(), 2)
        self.assertEqual(len(ts), 2)
        cts = ts.clean()
        self.assertEqual(len(cts), 2)
        return ts

    def testItems(self):
        ts = self.testClean()
        v = list(ts.items(start_value=0))
        self.assertTrue(v)



@test.skipUnless(test.haszoo(), 'Requires R zoo package')