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

Function test_acorr_integers

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

Source from the content-addressed store, hash-verified

179
180@check_figures_equal()
181def 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()

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…