def setUp(self): series = ReferencedSeries(np.random.rand(360), start_date=ts.Date('M', '1970-01-01')) series[1:-1:10] = masked refperiod = ts.DateArray( [ts.Date('M', '1980-01-01'), ts.Date('M', '1990-01-01')], freq='M') self.series = series self.refperiod = refperiod
def test_get_refperiod(self): "Check that the reference period has always the proper frequency" a = ReferencedSeries(np.arange(2000, 2010), start_date=ts.Date('Y', '2000'), refperiod=(ts.Date('Y', '2003'), ts.Date('A', '2006'))) assert (isinstance(a.refperiod, ts.DateArray)) assert_equal(a.refperiod.freq, a.dates.freq) a = a.convert('M') assert_equal(a.refperiod.freq, a.dates.freq)
def test_check_refperiod(self): "Test that the reference period is always a DateArray" series = ReferencedSeries(np.arange(10), start_date=ts.Date('M', '2001-01')) refperiod = series._optinfo['reference_period'] self.failUnless(refperiod is None) series.refperiod = None refperiod = series._optinfo['reference_period'] self.failUnless(isinstance(refperiod, ts.DateArray)) assert_equal(refperiod.tovalues(), series.dates[[0, -1]].tovalues()) series.refperiod = None assert_equal(refperiod, series.dates[[0, -1]]) self.failUnless(isinstance(refperiod, ts.DateArray))