Skip to content

Commit be1a712

Browse files
committed
fft: type-tests for fft
1 parent 23673e2 commit be1a712

File tree

1 file changed

+77
-0
lines changed

1 file changed

+77
-0
lines changed

tests/fft/test_basic.pyi

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
from typing import assert_type
2+
3+
import numpy as np
4+
import optype.numpy as onp
5+
6+
from scipy.fft import fft
7+
8+
int_1d: list[int]
9+
int_2d: list[list[int]]
10+
int_3d: list[list[list[int]]]
11+
12+
float_1d: list[float]
13+
float_2d: list[list[float]]
14+
float_3d: list[list[list[float]]]
15+
16+
complex_1d: list[complex]
17+
complex_2d: list[list[complex]]
18+
complex_3d: list[list[list[complex]]]
19+
20+
i16_1d: onp.Array1D[np.int16]
21+
i16_2d: onp.Array2D[np.int16]
22+
i16_3d: onp.Array3D[np.int16]
23+
24+
f32_1d: onp.Array1D[np.float32]
25+
f32_2d: onp.Array2D[np.float32]
26+
f32_3d: onp.Array3D[np.float32]
27+
28+
f64_1d: onp.Array1D[np.float64]
29+
f64_2d: onp.Array2D[np.float64]
30+
f64_3d: onp.Array3D[np.float64]
31+
32+
f80_1d: onp.Array1D[np.longdouble]
33+
f80_2d: onp.Array2D[np.longdouble]
34+
f80_3d: onp.Array3D[np.longdouble]
35+
36+
c64_1d: onp.Array1D[np.complex64]
37+
c64_2d: onp.Array2D[np.complex64]
38+
c64_3d: onp.Array3D[np.complex64]
39+
40+
c128_1d: onp.Array1D[np.complex128]
41+
c128_2d: onp.Array2D[np.complex128]
42+
c128_3d: onp.Array3D[np.complex128]
43+
44+
c160_1d: onp.Array1D[np.clongdouble]
45+
c160_2d: onp.Array2D[np.clongdouble]
46+
c160_3d: onp.Array3D[np.clongdouble]
47+
48+
###
49+
# fft
50+
51+
assert_type(fft(int_1d), onp.Array1D[np.complex128])
52+
assert_type(fft(int_2d), onp.ArrayND[np.complex128])
53+
assert_type(fft(float_1d), onp.Array1D[np.complex128])
54+
assert_type(fft(float_2d), onp.ArrayND[np.complex128])
55+
assert_type(fft(complex_1d), onp.Array1D[np.complex128])
56+
assert_type(fft(complex_2d), onp.ArrayND[np.complex128])
57+
58+
assert_type(fft(i16_1d), onp.Array1D[np.complex128])
59+
assert_type(fft(i16_2d), onp.Array2D[np.complex128])
60+
61+
assert_type(fft(f32_1d), onp.Array1D[np.complex64])
62+
assert_type(fft(f32_2d), onp.Array2D[np.complex64])
63+
64+
assert_type(fft(f64_1d), onp.Array1D[np.complex128])
65+
assert_type(fft(f64_2d), onp.Array2D[np.complex128])
66+
67+
assert_type(fft(f80_1d), onp.Array1D[np.clongdouble])
68+
assert_type(fft(f80_2d), onp.Array2D[np.clongdouble])
69+
70+
assert_type(fft(c64_1d), onp.Array1D[np.complex64])
71+
assert_type(fft(c64_2d), onp.Array2D[np.complex64])
72+
73+
assert_type(fft(c128_1d), onp.Array1D[np.complex128])
74+
assert_type(fft(c128_2d), onp.Array2D[np.complex128])
75+
76+
assert_type(fft(c160_1d), onp.Array1D[np.clongdouble])
77+
assert_type(fft(c160_2d), onp.Array2D[np.clongdouble])

0 commit comments

Comments
 (0)