def test_autocov():
x = np.random.randn(4096).astype(np.complex128) # 2x extra speedup from casting correct type
M=5
tic = time()
C= compute_autocovariance(x,M)
tocpy = time()-tic
#%%
tic = time()
Cc = S['c'].covariance.autocov(x,M)
tocfortcmpl = time()-tic
tic = time()
Cr = S['r'].covariance.autocov(x.real,M)
tocfortreal = time() - tic
#print(f'autocovariance: python {tocpy:.6f} sec fortran {tocfortcmpl:.6f} sec')
print('autocovariance: Fortran faster than Python by factor:',tocpy/tocfortcmpl)
np.testing.assert_allclose(C,Cc,rtol=1)
np.testing.assert_allclose(C.real,Cr,rtol=1)
评论列表
文章目录