Skip to content

Commit 7e12c73

Browse files
Diagnose PR118 seasonal causation lags
1 parent 39959f4 commit 7e12c73

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import numpy as np
2+
3+
from nns import nns_causation
4+
from nns.seasonality import nns_seas
5+
6+
7+
def test_pr118_debug_seasonal_lags():
8+
t = np.arange(1, 71, dtype=np.float64)
9+
x = np.sin(2.0 * np.pi * t / 7.0)
10+
y = np.roll(x, 1) + 0.05 * np.cos(t / 3.0)
11+
rows = {
12+
'period7_x_periods': nns_seas(x, plot=False)['periods'].tolist(),
13+
'period7_y_periods': nns_seas(y, plot=False)['periods'].tolist(),
14+
'period7_by_tau': {tau: list(nns_causation(x, y, tau=tau).values()) for tau in range(1, 9)},
15+
}
16+
t2 = np.arange(1, 81, dtype=np.float64)
17+
z = [
18+
np.sin(2.0 * np.pi * t2 / 5.0),
19+
np.sin(2.0 * np.pi * t2 / 6.0 + 0.2),
20+
np.sin(2.0 * np.pi * t2 / 7.0 + 0.5),
21+
]
22+
rows['matrix_periods'] = [nns_seas(v, plot=False)['periods'].tolist() for v in z]
23+
raise AssertionError(repr(rows))

0 commit comments

Comments
 (0)