Skip to content

Commit f51e0ba

Browse files
committed
Add updated test_ffts.py
1 parent 8aeb057 commit f51e0ba

File tree

1 file changed

+24
-17
lines changed

1 file changed

+24
-17
lines changed

pytests/test_ffts.py

Lines changed: 24 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,19 @@
1010

1111
par1 = {'nt': 101, 'nx': 31, 'ny': 10,
1212
'nfft': None, 'real': False,
13-
'ffthshift': False} # nfft=nt, complex input
13+
'ffthshift': False, 'dtype':np.complex128} # nfft=nt, complex input
1414
par2 = {'nt': 101, 'nx': 31, 'ny': 10,
1515
'nfft': 256, 'real': False,
16-
'ffthshift': False} # nfft>nt, complex input
16+
'ffthshift': False, 'dtype':np.complex64} # nfft>nt, complex input
1717
par3 = {'nt': 101, 'nx': 31, 'ny': 10,
1818
'nfft': None, 'real': True,
19-
'ffthshift': False} # nfft=nt, real input
19+
'ffthshift': False, 'dtype':np.float64} # nfft=nt, real input
2020
par4 = {'nt': 101, 'nx': 31, 'ny': 10,
2121
'nfft': 256, 'real': True,
22-
'ffthshift': False} # nfft>nt, real input
22+
'ffthshift': False, 'dtype':np.float32} # nfft>nt, real input
2323
par5 = {'nt': 101, 'nx': 31, 'ny': 10,
2424
'nfft': 256, 'real': True,
25-
'ffthshift': True} # nfft>nt, real input and fftshift
25+
'ffthshift': True, 'dtype':np.float32} # nfft>nt, real input and fftshift
2626

2727
@pytest.mark.parametrize("par", [(par1), (par2), (par3), (par4), (par5)])
2828
def test_FFT_1dsignal(par):
@@ -33,8 +33,9 @@ def test_FFT_1dsignal(par):
3333
x = da.from_array(np.sin(2 * np.pi * f0 * t))
3434
nfft = par['nt'] if par['nfft'] is None else par['nfft']
3535
dFFTop = dFFT(dims=[par['nt']], nfft=nfft, sampling=dt, real=par['real'],
36-
chunks = (par['nt'], nfft))
37-
FFTop = FFT(dims=[par['nt']], nfft=nfft, sampling=dt, real=par['real'])
36+
chunks=(par['nt'], nfft), dtype=par['dtype'])
37+
FFTop = FFT(dims=[par['nt']], nfft=nfft, sampling=dt, real=par['real'],
38+
dtype=par['dtype'])
3839

3940
# FFT with real=True cannot pass dot-test neither be inverted correctly,
4041
# see FFT documentation for a detailed explanation. We thus test FFT.H*FFT
@@ -71,8 +72,9 @@ def test_FFT_2dsignal(par):
7172
nfft = par['nt'] if par['nfft'] is None else par['nfft']
7273
dFFTop = dFFT(dims=(nt, nx), dir=0, nfft=nfft,
7374
sampling=dt, real=par['real'],
74-
chunks=((nt, nx), (nfft, nx)))
75-
FFTop = FFT(dims=(nt, nx), dir=0, nfft=nfft, sampling=dt)
75+
chunks=((nt, nx), (nfft, nx)), dtype=par['dtype'])
76+
FFTop = FFT(dims=(nt, nx), dir=0, nfft=nfft, sampling=dt,
77+
dtype=par['dtype'])
7678

7779
# FFT with real=True cannot pass dot-test neither be inverted correctly,
7880
# see FFT documentation for a detailed explanation. We thus test FFT.H*FFT
@@ -96,8 +98,10 @@ def test_FFT_2dsignal(par):
9698
# 2nd dimension
9799
nfft = par['nx'] if par['nfft'] is None else par['nfft']
98100
dFFTop = dFFT(dims=(nt, nx), dir=1, nfft=nfft, sampling=dt,
99-
real=par['real'], chunks=((nt, nx), (nt, nfft)))
100-
FFTop = FFT(dims=(nt, nx), dir=1, nfft=nfft, sampling=dt)
101+
real=par['real'], chunks=((nt, nx), (nt, nfft)),
102+
dtype=par['dtype'])
103+
FFTop = FFT(dims=(nt, nx), dir=1, nfft=nfft, sampling=dt,
104+
dtype=par['dtype'])
101105

102106
# FFT with real=True cannot pass dot-test neither be inverted correctly,
103107
# see FFT documentation for a detailed explanation. We thus test FFT.H*FFT
@@ -134,9 +138,10 @@ def test_FFT_3dsignal(par):
134138
# 1st dimension
135139
nfft = par['nt'] if par['nfft'] is None else par['nfft']
136140
dFFTop = dFFT(dims=(nt, nx, ny), dir=0, nfft=nfft, sampling=dt,
137-
real=par['real'], chunks=((nt, nx, ny), (nfft, nx, ny)))
141+
real=par['real'], chunks=((nt, nx, ny), (nfft, nx, ny)),
142+
dtype=par['dtype'])
138143
FFTop = FFT(dims=(nt, nx, ny), dir=0, nfft=nfft, sampling=dt,
139-
real=par['real'])
144+
real=par['real'], dtype=par['dtype'])
140145

141146
# FFT with real=True cannot pass dot-test neither be inverted correctly,
142147
# see FFT documentation for a detailed explanation. We thus test FFT.H*FFT
@@ -160,9 +165,10 @@ def test_FFT_3dsignal(par):
160165
# 2nd dimension
161166
nfft = par['nx'] if par['nfft'] is None else par['nfft']
162167
dFFTop = dFFT(dims=(nt, nx, ny), dir=1, nfft=nfft, sampling=dt,
163-
real=par['real'], chunks=((nt, nx, ny), (nt, nfft, ny)))
168+
real=par['real'], chunks=((nt, nx, ny), (nt, nfft, ny)),
169+
dtype=par['dtype'])
164170
FFTop = FFT(dims=(nt, nx, ny), dir=1, nfft=nfft, sampling=dt,
165-
real=par['real'])
171+
real=par['real'], dtype=par['dtype'])
166172

167173
# FFT with real=True cannot pass dot-test neither be inverted correctly,
168174
# see FFT documentation for a detailed explanation. We thus test FFT.H*FFT
@@ -186,9 +192,10 @@ def test_FFT_3dsignal(par):
186192
# 3rd dimension
187193
nfft = par['ny'] if par['nfft'] is None else par['nfft']
188194
dFFTop = dFFT(dims=(nt, nx, ny), dir=2, nfft=nfft, sampling=dt,
189-
real=par['real'], chunks=((nt, nx, ny), (nt, ny, nfft)))
195+
real=par['real'], chunks=((nt, nx, ny), (nt, ny, nfft)),
196+
dtype=par['dtype'])
190197
FFTop = FFT(dims=(nt, nx, ny), dir=2, nfft=nfft, sampling=dt,
191-
real=par['real'])
198+
real=par['real'], dtype=par['dtype'])
192199

193200
# FFT with real=True cannot pass dot-test neither be inverted correctly,
194201
# see FFT documentation for a detailed explanation. We thus test FFT.H*FFT

0 commit comments

Comments
 (0)