MCPcopy Index your code
hub / github.com/matplotlib/matplotlib / test_acorr

Function test_acorr

lib/matplotlib/tests/test_axes.py:162–177  ·  view source on GitHub ↗
(fig_test, fig_ref)

Source from the content-addressed store, hash-verified

160
161@check_figures_equal()
162def test_acorr(fig_test, fig_ref):
163 np.random.seed(19680801)
164 Nx = 512
165 x = np.random.normal(0, 1, Nx).cumsum()
166 maxlags = Nx-1
167
168 ax_test = fig_test.subplots()
169 ax_test.acorr(x, maxlags=maxlags)
170
171 ax_ref = fig_ref.subplots()
172 # Normalized autocorrelation
173 norm_auto_corr = np.correlate(x, x, mode="full")/np.dot(x, x)
174 lags = np.arange(-maxlags, maxlags+1)
175 norm_auto_corr = norm_auto_corr[Nx-1-maxlags:Nx+maxlags]
176 ax_ref.vlines(lags, [0], norm_auto_corr)
177 ax_ref.axhline(y=0, xmin=0, xmax=1)
178
179
180@check_figures_equal()

Callers

nothing calls this directly

Calls 5

acorrMethod · 0.80
dotMethod · 0.80
vlinesMethod · 0.80
axhlineMethod · 0.80
subplotsMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…