1
1
import six
2
2
import numpy as np
3
- from . import fftwf_xfftn , fftw_xfftn , fftwl_xfftn
3
+ from . import fftw_xfftn
4
+ try :
5
+ from . import fftwf_xfftn
6
+ except ImportError :
7
+ fftwf_xfftn = None
8
+ try :
9
+ from . import fftwl_xfftn
10
+ except ImportError :
11
+ fftwl_xfftn = None
4
12
from .utilities import FFTW_FORWARD , FFTW_MEASURE
5
13
6
- fftlib = {
7
- 'F' : fftwf_xfftn ,
8
- 'D' : fftw_xfftn ,
9
- 'G' : fftwl_xfftn }
14
+ fftlib = {}
15
+ for k , v in zip (( 'F' , 'D' , 'G' ), ( fftwf_xfftn , fftw_xfftn , fftwl_xfftn ))
16
+ if v is not None :
17
+ fftlib [ k ] = v
10
18
11
19
def get_planned_FFT (input_array , output_array , axes = (- 1 ,), kind = FFTW_FORWARD ,
12
20
threads = 1 , flags = (FFTW_MEASURE ,), normalize = 1 ):
@@ -60,6 +68,7 @@ def get_planned_FFT(input_array, output_array, axes=(-1,), kind=FFTW_FORWARD,
60
68
61
69
"""
62
70
dtype = input_array .dtype .char
71
+ assert dtype .upper () in fftlib
63
72
_fft = fftlib [dtype .upper ()]
64
73
return _fft .FFT (input_array , output_array , axes , kind , threads , flags ,
65
74
normalize )
@@ -74,8 +83,8 @@ def export_wisdom(filename):
74
83
75
84
Note
76
85
----
77
- Wisdom is stored for all three precisions, float, double and long double,
78
- using, respectively, prefix ``F_``, ``D_`` and ``G_``. Wisdom is
86
+ Wisdom is stored for all precisions available: float, double and long
87
+ double, using, respectively, prefix ``F_``, ``D_`` and ``G_``. Wisdom is
79
88
imported using :func:`.import_wisdom`.
80
89
81
90
See also
@@ -98,8 +107,8 @@ def import_wisdom(filename):
98
107
99
108
Note
100
109
----
101
- Wisdom is imported for all three precisions, float, double and long double,
102
- using, respectively, prefix ``F_``, ``D_`` and ``G_``. Wisdom is
110
+ Wisdom is imported for all available precisions: float, double and long
111
+ double, using, respectively, prefix ``F_``, ``D_`` and ``G_``. Wisdom is
103
112
exported using :func:`.export_wisdom`.
104
113
105
114
See also
@@ -130,4 +139,3 @@ def set_timelimit(limit):
130
139
def cleanup ():
131
140
for lib in fftlib .values ():
132
141
lib .cleanup ()
133
-
0 commit comments