Beispiel #1
0
 def test__different_timedelta(self):
     t = Timeframe(pd_start_date=pd_ts('2017-01-01 1:00'),
                   pd_end_date=pd_ts('2017-01-01 1:35'),
                   pd_timedelta=pandas.Timedelta(minutes=15))
     t.add_timedelta()
     self.assertEqual(t.date(), pd_ts('2017-01-01 1:15'))
     t.add_timedelta()
     self.assertEqual(t.date(), pd_ts('2017-01-01 1:30'))
     t.add_timedelta()
     self.assertEqual(t.date(), None)
Beispiel #2
0
 def test__different_timedelta(self):
     t = Timeframe(pd_start_date=pd_ts('2017-01-01 1:00'),
                   pd_end_date=pd_ts('2017-01-01 1:35'),
                   pd_interval=pandas.Timedelta(minutes=15))
     t.add_timedelta()
     self.assertEqual(t.date(), pd_ts('2017-01-01 1:15'))
     t.add_timedelta()
     self.assertEqual(t.date(), pd_ts('2017-01-01 1:30'))
     self.assertEqual(t.finished(), False)
     t.add_timedelta()
     self.assertEqual(t.finished(), True)
     self.assertEqual(t.date(), pd_ts('2017-01-01 1:35'))
Beispiel #3
0
 def test__add_timedelta__date(self):
     t = Timeframe(pd_start_date=pd_ts('2017-01-01 1:00'),
                   pd_end_date=pd_ts('2017-01-01 1:03'),
                   pd_timedelta=pandas.Timedelta(minutes=1))
     self.assertEqual(t.date(), pd_ts('2017-01-01 1:00'))
     # should return the same value
     self.assertEqual(t.date(), pd_ts('2017-01-01 1:00'))
     t.add_timedelta()
     self.assertEqual(t.date(), pd_ts('2017-01-01 1:01'))
     t.add_timedelta()
     t.add_timedelta()
     self.assertEqual(t.date(), pd_ts('2017-01-01 1:03'))
     t.add_timedelta()
     self.assertEqual(t.date(), None)
Beispiel #4
0
 def test__add_timedelta_until__add_multiple_times(self):
     t = Timeframe(pd_start_date=pd_ts('2017-01-01 1:00'),
                   pd_end_date=pd_ts('2017-01-01 2:35'),
                   pd_timedelta=pandas.Timedelta(minutes=15))
     t.add_timedelta_until(pd_ts('2017-01-01 2:31'))
     self.assertEqual(t.date(), pd_ts('2017-01-01 2:30'))
Beispiel #5
0
 def test__add_timedelta_until__single(self):
     t = Timeframe(pd_start_date=pd_ts('2017-01-01 1:00'),
                   pd_end_date=pd_ts('2017-01-01 2:35'),
                   pd_interval=pandas.Timedelta(minutes=15))
     t.add_timedelta_until(pd_ts('2017-01-01 1:29'))
     self.assertEqual(t.date(), pd_ts('2017-01-01 1:15'))