33
44
55class FFTConvolveBase :
6- """Base class for FFT convolve."""
6+ """Abstract class for FFT convolve."""
77
88 def __init__ (self , filter , length ) -> None :
99 """
10+ Base class for creating a convolver that uses the same filter.
11+
1012 Parameters
1113 ----------
12- filter : np .ndarray
14+ filter : :py:class:`~numpy .ndarray`
1315 Filter to convolve with. Must be real.
1416 length : int
1517 Length of the signal to convolve with.
@@ -22,22 +24,38 @@ def __init__(self, filter, length) -> None:
2224 self .filter_frequency_response = self ._compute_filter_frequency_response ()
2325
2426 @abstractmethod
25- def _compute_filter_frequency_response (self , filter ) -> np .ndarray :
27+ def _compute_filter_frequency_response (self ) -> np .ndarray :
28+ """
29+ Compute the filter frequency response.
30+
31+ Parameters
32+ ----------
33+ filter : :py:class:`~numpy.ndarray`
34+ Filter to compute the frequency response for.
35+
36+ Returns
37+ -------
38+ filter_frequency_response : :py:class:`~numpy.ndarray`
39+ Filter frequency response.
40+ """
2641 raise NotImplementedError
2742
2843 @abstractmethod
2944 def __call__ (self , signal ) -> np .ndarray :
45+ """Apply the filter to the signal, in the frequency domain."""
3046 pass
3147
3248
3349class RFFTConvolve (FFTConvolveBase ):
3450 """Real FFT convolve."""
3551
3652 def __init__ (self , filter , length ) -> None :
37- """
53+ r"""
54+ Create convolver that uses a real-valued filter.
55+
3856 Parameters
3957 ----------
40- filter : np .ndarray
58+ filter : :py:class:`~numpy .ndarray`
4159 Filter to convolve with. Must be real.
4260 length : int
4361 Length of the signal to convolve with.
@@ -48,19 +66,21 @@ def __init__(self, filter, length) -> None:
4866 super (RFFTConvolve , self ).__init__ (filter , length )
4967
5068 def _compute_filter_frequency_response (self ):
51- """Compute the filter frequency response."""
69+ r """Compute the filter frequency response."""
5270 return np .fft .rfft (self .filter , n = self .pad_length )
5371
5472 def __call__ (self , signal ) -> np .ndarray :
55- """
73+ r"""
74+ Apply the real-valued filter to the signal, in the frequency domain.
75+
5676 Parameters
5777 ----------
58- signal : np .ndarray
78+ signal : :py:class:`~numpy .ndarray`
5979 Signal to convolve with. Must be real.
6080
6181 Returns
6282 -------
63- result : np .ndarray
83+ result : :py:class:`~numpy .ndarray`
6484 Convolved signal.
6585 """
6686 signal_frequency_response = np .fft .rfft (signal , n = self .pad_length )
@@ -73,6 +93,16 @@ class FFTConvolve(FFTConvolveBase):
7393 """General FFT convolve."""
7494
7595 def __init__ (self , filter , length ) -> None :
96+ """
97+ Create convolver that uses a fixed filter.
98+
99+ Parameters
100+ ----------
101+ filter : :py:class:`~numpy.ndarray`
102+ Filter to convolve with. Must be real.
103+ length : int
104+ Length of the signal to convolve with.
105+ """
76106 super (FFTConvolve , self ).__init__ (filter , length )
77107
78108 def _compute_filter_frequency_response (self ):
@@ -81,14 +111,16 @@ def _compute_filter_frequency_response(self):
81111
82112 def __call__ (self , signal ) -> np .ndarray :
83113 """
114+ Apply the filter to the signal, in the frequency domain.
115+
84116 Parameters
85117 ----------
86- signal : np .ndarray
118+ signal : :py:class:`~numpy .ndarray`
87119 Signal to convolve with.
88120
89121 Returns
90122 -------
91- result : np .ndarray
123+ result : :py:class:`~numpy .ndarray`
92124 Convolved signal.
93125 """
94126 signal_frequency_response = np .fft .fft (signal , n = self .pad_length )
0 commit comments