updated tests, all are accurate and passing

This commit is contained in:
Gourav Kumar 2023-07-16 19:54:14 +05:30
parent f317a93bfe
commit a455cdfc65

View File

@ -30,7 +30,7 @@ class TestDateSeries:
def test_monthly(self): def test_monthly(self):
start_date = datetime.datetime(2020, 1, 1) start_date = datetime.datetime(2020, 1, 1)
end_date = datetime.datetime(2020, 12, 31) end_date = datetime.datetime(2020, 12, 31)
d = create_date_series(start_date, end_date, frequency="M") d = create_date_series(start_date, end_date, frequency="M", ensure_coverage=False)
assert len(d) == 12 assert len(d) == 12
d = create_date_series(start_date, end_date, frequency="M", eomonth=True) d = create_date_series(start_date, end_date, frequency="M", eomonth=True)
@ -327,7 +327,7 @@ class TestExpand:
ts_data = create_test_data(AllFrequencies.M, num=6) ts_data = create_test_data(AllFrequencies.M, num=6)
ts = TimeSeries(ts_data, "M") ts = TimeSeries(ts_data, "M")
expanded_ts = ts.expand("W", "ffill") expanded_ts = ts.expand("W", "ffill")
assert len(expanded_ts) == 22 assert len(expanded_ts) == 23
assert expanded_ts.frequency.name == "weekly" assert expanded_ts.frequency.name == "weekly"
assert expanded_ts.iloc[0][1] == expanded_ts.iloc[1][1] assert expanded_ts.iloc[0][1] == expanded_ts.iloc[1][1]
@ -346,7 +346,7 @@ class TestShrink:
ts = TimeSeries(ts_data, "D") ts = TimeSeries(ts_data, "D")
shrunk_ts_w = ts.shrink("W", "ffill") shrunk_ts_w = ts.shrink("W", "ffill")
shrunk_ts_m = ts.shrink("M", "ffill") shrunk_ts_m = ts.shrink("M", "ffill")
assert len(shrunk_ts_w) == 143 assert len(shrunk_ts_w) == 144
assert len(shrunk_ts_m) == 34 assert len(shrunk_ts_m) == 34
def test_weekly_to_smaller(self, create_test_data): def test_weekly_to_smaller(self, create_test_data):
@ -376,7 +376,7 @@ class TestTransform:
ts = TimeSeries(ts_data, "D") ts = TimeSeries(ts_data, "D")
tst = ts.transform("W", "mean") tst = ts.transform("W", "mean")
assert isinstance(tst, TimeSeries) assert isinstance(tst, TimeSeries)
assert len(tst) == 156 assert len(tst) == 157
assert "2017-01-30" in tst assert "2017-01-30" in tst
assert tst.iloc[4] == (datetime.datetime(2017, 1, 30), 1021.19) assert tst.iloc[4] == (datetime.datetime(2017, 1, 30), 1021.19)