@@ -95,18 +95,23 @@ def test_label_loc_rc(fig_test, fig_ref):
95
95
cbar .set_label ("Z Label" , x = 1 , ha = 'right' )
96
96
97
97
98
- @image_comparison (['acorr.png' ], style = 'mpl20' )
99
- def test_acorr ():
100
- # Remove this line when this test image is regenerated.
101
- plt .rcParams ['text.kerning_factor' ] = 6
102
-
98
+ @check_figures_equal (extensions = ["png" ])
99
+ def test_acorr (fig_test , fig_ref ):
103
100
np .random .seed (19680801 )
104
- n = 512
105
- x = np .random .normal (0 , 1 , n ).cumsum ()
106
-
107
- fig , ax = plt .subplots ()
108
- ax .acorr (x , maxlags = n - 1 , label = 'acorr' )
109
- ax .legend ()
101
+ Nx = 512
102
+ x = np .random .normal (0 , 1 , Nx ).cumsum ()
103
+ maxlags = Nx - 1
104
+
105
+ fig_test , ax_test = plt .subplots ()
106
+ ax_test .acorr (x , maxlags = maxlags )
107
+
108
+ fig_ref , ax_ref = plt .subplots ()
109
+ # Normalized autocorrelation
110
+ norm_auto_corr = np .correlate (x , x , mode = "full" )/ np .dot (x , x )
111
+ lags = np .arange (- maxlags , maxlags + 1 )
112
+ norm_auto_corr = norm_auto_corr [Nx - 1 - maxlags :Nx + maxlags ]
113
+ ax_ref .vlines (lags , [0 ], norm_auto_corr )
114
+ ax_ref .axhline (y = 0 , xmin = 0 , xmax = 1 )
110
115
111
116
112
117
@check_figures_equal (extensions = ["png" ])
0 commit comments