Skip to content

Commit

Permalink
updated test_stats.py to include a testcase for hourly frequency data…
Browse files Browse the repository at this point in the history
… and type(lags)==int
  • Loading branch information
AviadAvr committed Jun 14, 2024
1 parent 7d860db commit 5336f24
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions tests/test_stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,14 @@

def acf_func(**kwargs):
index = pd.to_datetime(np.arange(0, 100, 1), unit="D", origin="2000")
index = kwargs.pop("index", index)
data = np.sin(np.linspace(0, 10 * np.pi, 100))
r = pd.Series(data=data, index=index)
acf_true = np.cos(np.linspace(0.0, np.pi, 11))[1:]
acf = ps.stats.acf(r, lags=np.arange(1.0, 11.0), min_obs=1, **kwargs).values
lags = np.arange(1.0, 11.0)
lags = kwargs.pop("lags", lags)
acf_true_len = lags + 1 if isinstance(lags, int) else len(lags) + 1
acf_true = np.cos(np.linspace(0.0, np.pi, acf_true_len))[1:]
acf = ps.stats.acf(r, lags=lags, min_obs=1, **kwargs).values
return acf, acf_true


Expand All @@ -23,6 +27,13 @@ def test_acf_gaussian():
assert abs((acf - acf_true)).max() < 0.05


def test_acf_hourly():
index = pd.to_datetime(np.arange(0, 100, 1), unit="h", origin="2000")
lags = 10
acf, acf_true = acf_func(index=index, lags=lags)
assert abs((acf - acf_true)).max() < 0.05


def test_runs_test():
"""
http://www.itl.nist.gov/div898/handbook/eda/section3/eda35d.htm
Expand Down

0 comments on commit 5336f24

Please sign in to comment.