Esempio n. 1
0
            import matpotlib
        except ImportError:
            try:
                csv = ts.dump('plot')
            except FormattingException:
                pass
        else:
            plot = ts.dump('plot')
            self.assertTrue(plot)

    def testDslNames(self):
        res = self.evaluate('amzn:yahoo, min(amzn:yahoo)',
                            backend=self.backend)
        self.assertEqual(str(res.expression), 'AMZN:YAHOO, min(AMZN:YAHOO)')
        self.assertEqual(len(res.data), 1)
        ts = res.ts()
        self.assertEqual(ts.count(), 2)
        self.assertEqual(ts.names(),
                         ['AMZN:YAHOO', 'min(AMZN:YAHOO, window=20)'])



@test.skipUnless(hasextensions(), 'Requires C extensions')
class TestFallBackNumpyTS(TestTS):
    fallback = True


@test.skipUnless(test.haszoo(), 'Requires R zoo package')
class TestTSZoo(TestTS):
    backend = 'zoo'
Esempio n. 2
0
            p = v

    def testRank(self):
        sl = self.make()
        for i in range(len(sl)):
            self.assertEqual(sl.rank(sl[i]),i)
        self.assertRaises(IndexError, lambda : sl[10000])
        N = len(sl)
        v1 = sl[100]
        v0 = sl[99]
        r = sl.rank(0.5*(v1 + v0))
        self.assertEqual(r,-99)
        self.assertEqual(sl.rank(sl[0]-1),-1)
        self.assertEqual(sl.rank(sl[N-1]+1),-N+1)

    def testRollingOp(self):
        data  = populate(size = 500)[:,0]
        roll  = rollingOperation(data, 20, skiplist_class = self.skiplist)
        rmin  = roll.min()
        rmax  = roll.max()
        rmed  = roll.median()
        for m0,m1,m2 in zip(rmin,rmed,rmax):
            self.assertTrue(m1>=m0)
            self.assertTrue(m2>=m1)


if dynts.hasextensions():

    class FallbackRollingFunctionSkipList(RollingFunctionSkipList):
        fallback = True
Esempio n. 3
0
        try:
            import matpotlib
        except ImportError:
            try:
                csv = ts.dump('plot')
            except FormattingException:
                pass
        else:
            plot = ts.dump('plot')
            self.assertTrue(plot)

    def testDslNames(self):
        res = self.evaluate('amzn:yahoo, min(amzn:yahoo)',
                            backend=self.backend)
        self.assertEqual(str(res.expression), 'AMZN:YAHOO, min(AMZN:YAHOO)')
        self.assertEqual(len(res.data), 1)
        ts = res.ts()
        self.assertEqual(ts.count(), 2)
        self.assertEqual(ts.names(),
                         ['AMZN:YAHOO', 'min(AMZN:YAHOO, window=20)'])


@test.skipUnless(hasextensions(), 'Requires C extensions')
class TestFallBackNumpyTS(TestTS):
    fallback = True


@test.skipUnless(test.haszoo(), 'Requires R zoo package')
class TestTSZoo(TestTS):
    backend = 'zoo'