# 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: dynts/utils/populate.py
# def _generator(x):
#     def __init__(self, data):
#     def __iter__(self):
# def datepopulate(size = 10, start=None, delta=1):
# def populate(size=100, cols=1, generator=None):
# def polygen(*coefficients):
#         def _(i):
# class gdata(object):


from dynts.utils import test
from dynts.utils.populate import randomts, polygen

        self.assertEqual(len(d),len(ts)-2)
        self.assertEqual(d.count(),ts.count())
        for vs in d.values():
            for v in vs:
                self.assertAlmostEqual(v,0.4)

    def testDelta2Lag(self):
        lag = 5
        ts = self.getts(2, 5., 3.5, 0.2)
        d = ts.delta2(lag = lag)
        self.assertEqual(len(d),len(ts)-2*lag)
        self.assertEqual(d.count(),ts.count())
        dv = 0.4 * lag * lag
        for vs in d.values():
            for v in vs:
                self.assertAlmostEqual(v,dv)

    def testComplexDelta(self):
        '''Test for a lagged Delta2 against a double Delta'''
        lag = 5
        ts = self.getts(2, 5., 3.5, 0.2)
        d = ts.delta2(lag = lag)
        dd = ts.delta(lag = lag).delta(lag = lag)
        self.assertEqual(len(d),len(dd))
        self.assertEqual(d.count(),dd.count())
        for dv,ddv in zip(d.values(),dd.values()):
            for v,vv in zip(dv,ddv):
                self.assertAlmostEqual(v,vv)



# 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: dynts/utils/populate.py
# def _generator(x):
#     def __init__(self, data):
#     def __iter__(self):
# def datepopulate(size = 10, start=None, delta=1):
# def populate(size=100, cols=1, generator=None):
# def polygen(*coefficients):
#         def _(i):
# class gdata(object):


# Path: tests/unit/tsdelta.py
from dynts.utils import test
from dynts.utils.populate import randomts, polygen

        self.assertEqual(len(d),len(ts)-2)
        self.assertEqual(d.count(),ts.count())
        for vs in d.values():
            for v in vs:
                self.assertAlmostEqual(v,0.4)

    def testDelta2Lag(self):
        lag = 5
        ts = self.getts(2, 5., 3.5, 0.2)
        d = ts.delta2(lag = lag)
        self.assertEqual(len(d),len(ts)-2*lag)
        self.assertEqual(d.count(),ts.count())
        dv = 0.4 * lag * lag
        for vs in d.values():
            for v in vs:
                self.assertAlmostEqual(v,dv)

    def testComplexDelta(self):
        '''Test for a lagged Delta2 against a double Delta'''
        lag = 5
        ts = self.getts(2, 5., 3.5, 0.2)
        d = ts.delta2(lag = lag)
        dd = ts.delta(lag = lag).delta(lag = lag)
        self.assertEqual(len(d),len(dd))
        self.assertEqual(d.count(),dd.count())
        for dv,ddv in zip(d.values(),dd.values()):
            for v,vv in zip(dv,ddv):
                self.assertAlmostEqual(v,vv)



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