curry_fn = lambda: op(ts1, ts2) self.assertRaises(ExpressionError, curry_fn) def testArithOpWithMissingDates(self): ts1, dates1, data1 = self.getts(returndata=True, cols=2) ts2, dates2, data2 = self.getts(returndata=True, cols=2, delta=2) all_dates = list(set(dates1).union(set(dates2))) all_dates.sort() op = list(ops.values())[0] ts3 = op(ts1, ts2) # Check that all the dates are in the return series by default self.check_dates(ts3, all_dates) btree = ts3.asbtree() not_in_dates2 = set(dates1) - set(dates2) self._check_missing_dts(not_in_dates2, btree) not_in_dates1 = set(dates2) - set(dates1) self._check_missing_dts(not_in_dates1, btree) def _check_missing_dts(self, dts, btree): for dt in dts: vals = btree[dt] for val in vals: self.assertNotEqual(val, val) @test.skipUnless(test.haszoo(), 'Requires R zoo package') class TestOperatorsZoo(TestOperators): backend = 'zoo'
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') class TestCleanZoo(TestClean): backend = 'zoo'