1414TOLS = [1e-3 , 1e-6 ]
1515OUTPUT_ARGS = [False , True ]
1616CONTIGUOUS = [False , True ]
17+ MODEORDS = [0 , 1 ]
1718
1819
1920@pytest .mark .parametrize ("dtype" , DTYPES )
2021@pytest .mark .parametrize ("shape" , SHAPES )
2122@pytest .mark .parametrize ("M" , MS )
2223@pytest .mark .parametrize ("tol" , TOLS )
2324@pytest .mark .parametrize ("output_arg" , OUTPUT_ARGS )
24- def test_type1 (to_gpu , to_cpu , dtype , shape , M , tol , output_arg ):
25+ @pytest .mark .parametrize ("modeord" , MODEORDS )
26+ def test_type1 (to_gpu , to_cpu , dtype , shape , M , tol , output_arg , modeord ):
2527 complex_dtype = utils ._complex_dtype (dtype )
2628
2729 k , c = utils .type1_problem (dtype , shape , M )
2830
2931 k_gpu = to_gpu (k )
3032 c_gpu = to_gpu (c )
3133
32- plan = Plan (1 , shape , eps = tol , dtype = complex_dtype )
34+ plan = Plan (1 , shape , eps = tol , dtype = complex_dtype , modeord = modeord )
3335
3436 # Since k_gpu is an array of shape (dim, M), this will expand to
3537 # plan.setpts(k_gpu[0], ..., k_gpu[dim]), allowing us to handle all
@@ -43,38 +45,8 @@ def test_type1(to_gpu, to_cpu, dtype, shape, M, tol, output_arg):
4345 fk_gpu = plan .execute (c_gpu )
4446
4547 fk = to_cpu (fk_gpu )
46-
47- utils .verify_type1 (k , c , fk , tol )
48-
49-
50- @pytest .mark .parametrize ("dtype" , DTYPES )
51- @pytest .mark .parametrize ("shape" , SHAPES )
52- @pytest .mark .parametrize ("M" , MS )
53- @pytest .mark .parametrize ("tol" , TOLS )
54- @pytest .mark .parametrize ("output_arg" , OUTPUT_ARGS )
55- def test_type1_modeord (to_gpu , to_cpu , dtype , shape , M , tol , output_arg ):
56- complex_dtype = utils ._complex_dtype (dtype )
57-
58- k , c = utils .type1_problem (dtype , shape , M )
59-
60- k_gpu = to_gpu (k )
61- c_gpu = to_gpu (c )
62-
63- plan = Plan (1 , shape , eps = tol , dtype = complex_dtype , modeord = 1 )
64-
65- # Since k_gpu is an array of shape (dim, M), this will expand to
66- # plan.setpts(k_gpu[0], ..., k_gpu[dim]), allowing us to handle all
67- # dimensions with the same call.
68- plan .setpts (* k_gpu )
69-
70- if output_arg :
71- fk_gpu = _compat .array_empty_like (c_gpu , shape , dtype = complex_dtype )
72- plan .execute (c_gpu , out = fk_gpu )
73- else :
74- fk_gpu = plan .execute (c_gpu )
75-
76- fk = to_cpu (fk_gpu )
77- fk = np .fft .fftshift (fk )
48+ if modeord == 1 :
49+ fk = np .fft .fftshift (fk )
7850
7951 utils .verify_type1 (k , c , fk , tol )
8052
@@ -85,12 +57,13 @@ def test_type1_modeord(to_gpu, to_cpu, dtype, shape, M, tol, output_arg):
8557@pytest .mark .parametrize ("tol" , TOLS )
8658@pytest .mark .parametrize ("output_arg" , OUTPUT_ARGS )
8759@pytest .mark .parametrize ("contiguous" , CONTIGUOUS )
88- def test_type2 (to_gpu , to_cpu , dtype , shape , M , tol , output_arg , contiguous ):
60+ @pytest .mark .parametrize ("modeord" , MODEORDS )
61+ def test_type2 (to_gpu , to_cpu , dtype , shape , M , tol , output_arg , contiguous , modeord ):
8962 complex_dtype = utils ._complex_dtype (dtype )
9063
9164 k , fk = utils .type2_problem (dtype , shape , M )
9265
93- plan = Plan (2 , shape , eps = tol , dtype = complex_dtype )
66+ plan = Plan (2 , shape , eps = tol , dtype = complex_dtype , modeord = modeord )
9467
9568 check_result = True
9669
@@ -113,7 +86,12 @@ def _execute(*args, **kwargs):
11386 return plan .execute (* args , ** kwargs )
11487
11588 k_gpu = to_gpu (k )
116- fk_gpu = to_gpu (fk )
89+
90+ if modeord == 1 :
91+ _fk = np .fft .ifftshift (fk )
92+ else :
93+ _fk = fk
94+ fk_gpu = to_gpu (_fk )
11795
11896 plan .setpts (* k_gpu )
11997
0 commit comments