def test_date_from_idx(): d1 = datetime(2008, 12, 31) idx = 15 npt.assert_equal(_date_from_idx(d1, idx, 'Q'), datetime(2012, 9, 30)) npt.assert_equal(_date_from_idx(d1, idx, 'A'), datetime(2023, 12, 31)) npt.assert_equal(_date_from_idx(d1, idx, 'B'), datetime(2009, 1, 21)) npt.assert_equal(_date_from_idx(d1, idx, 'D'), datetime(2009, 1, 15)) npt.assert_equal(_date_from_idx(d1, idx, 'W'), datetime(2009, 4, 12)) npt.assert_equal(_date_from_idx(d1, idx, 'M'), datetime(2010, 3, 31))
freq = self._data.freq out_of_sample = datetools._idx_from_dates(dates[-1], dtend, freq) else: raise err self._make_predict_dates() # attaches self._data.predict_dates elif isinstance(end, int) and dates is not None: try: self._data.predict_end = dates[end] except IndexError, err: nobs = len(self.endog) - 1 # as an index out_of_sample = end - nobs end = nobs freq = self._data.freq self._data.predict_end = datetools._date_from_idx(dates[-1], out_of_sample, freq) self._make_predict_dates() elif isinstance(end, int): nobs = len(self.endog) - 1 # is an index if end > nobs: out_of_sample = end - nobs end = nobs return end, out_of_sample def _make_predict_dates(self): from pandas import DateRange data = self._data dtstart = data.predict_start dtend = data.predict_end
freq = self._data.freq out_of_sample = datetools._idx_from_dates( dates[-1], dtend, freq) else: raise err self._make_predict_dates() # attaches self._data.predict_dates elif isinstance(end, int) and dates is not None: try: self._data.predict_end = dates[end] except IndexError, err: nobs = len(self.endog) - 1 # as an index out_of_sample = end - nobs end = nobs freq = self._data.freq self._data.predict_end = datetools._date_from_idx( dates[-1], out_of_sample, freq) self._make_predict_dates() elif isinstance(end, int): nobs = len(self.endog) - 1 # is an index if end > nobs: out_of_sample = end - nobs end = nobs return end, out_of_sample def _make_predict_dates(self): from pandas import DateRange data = self._data dtstart = data.predict_start dtend = data.predict_end