Skip to content

Commit ec6b15c

Browse files
committed
Format documentation.
1 parent f98664b commit ec6b15c

File tree

3 files changed

+93
-13
lines changed

3 files changed

+93
-13
lines changed

docs/source/conf.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,14 @@
4343
"sphinx.ext.intersphinx",
4444
"sphinx.ext.autosummary",
4545
"sphinx.ext.autodoc",
46+
"sphinx.ext.napoleon",
4647
]
4748

49+
autodoc_default_options = {
50+
"members": True,
51+
}
52+
autodoc_typehints = "none" # for cleaner sphinx output, don't show type hints
53+
4854
intersphinx_mapping = {
4955
"python": ("https://docs.python.org/3/", None),
5056
"NumPy [latest]": ("https://docs.scipy.org/doc/numpy/", None),

docs/source/fftconvolve.rst

Lines changed: 44 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,49 @@
11
FFT Convolve
22
============
33

4-
.. automodule:: pydevtips.fftconvolve
4+
.. GENERATE DOCUMENTATION FOR ALL CLASSES
5+
.. .. automodule:: pydevtips.fftconvolve
6+
.. :member-order: bysource
7+
.. :show-inheritance:
8+
.. :special-members: __init__, __call__
9+
10+
11+
.. GENERATE ONE AT A TIME WITH CUSTOM TEXT
12+
13+
There are two classes in this module for performing convolution in the frequency domain with a fixed filter.
14+
15+
.. autosummary::
16+
pydevtips.fftconvolve.RFFTConvolve
17+
pydevtips.fftconvolve.FFTConvolve
18+
19+
Both inherit from the base class :class:`pydevtips.fftconvolve.FFTConvolveBase`,
20+
overwriting the abstract methods: :func:`pydevtips.fftconvolve.FFTConvolveBase._compute_filter_frequency_response` and
21+
:func:`pydevtips.fftconvolve.FFTConvolveBase.__call__`.
22+
23+
RFFTConvolve
24+
------------
25+
26+
.. autoclass:: pydevtips.fftconvolve.RFFTConvolve
27+
:member-order: bysource
28+
:show-inheritance:
29+
:special-members: __init__, __call__
30+
31+
FFTConvolve
32+
-----------
33+
34+
.. autoclass:: pydevtips.fftconvolve.FFTConvolve
35+
:member-order: bysource
36+
:show-inheritance:
37+
:special-members: __init__, __call__
38+
39+
40+
FFTConvolveBase
41+
---------------
42+
43+
.. autoclass:: pydevtips.fftconvolve.FFTConvolveBase
44+
:member-order: bysource
45+
:show-inheritance:
546
:members:
647
:undoc-members:
7-
:show-inheritance:
48+
:special-members: __init__, __call__
49+
:private-members: _compute_filter_frequency_response

pydevtips/fftconvolve.py

Lines changed: 43 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,15 @@
33

44

55
class 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

3349
class 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

Comments
 (0)