| 179 | |
| 180 | @check_figures_equal() |
| 181 | def test_acorr_integers(fig_test, fig_ref): |
| 182 | np.random.seed(19680801) |
| 183 | Nx = 51 |
| 184 | x = (np.random.rand(Nx) * 10).cumsum() |
| 185 | x = (np.ceil(x)).astype(np.int64) |
| 186 | maxlags = Nx-1 |
| 187 | |
| 188 | ax_test = fig_test.subplots() |
| 189 | ax_test.acorr(x, maxlags=maxlags) |
| 190 | |
| 191 | ax_ref = fig_ref.subplots() |
| 192 | |
| 193 | # Normalized autocorrelation |
| 194 | norm_auto_corr = np.correlate(x, x, mode="full")/np.dot(x, x) |
| 195 | lags = np.arange(-maxlags, maxlags+1) |
| 196 | norm_auto_corr = norm_auto_corr[Nx-1-maxlags:Nx+maxlags] |
| 197 | ax_ref.vlines(lags, [0], norm_auto_corr) |
| 198 | ax_ref.axhline(y=0, xmin=0, xmax=1) |
| 199 | |
| 200 | |
| 201 | @check_figures_equal() |