@@ -100,7 +100,7 @@ def _evaluate(self, x, _):
100
100
return y
101
101
102
102
def approximate (self , method , ** kwargs ):
103
- r"""Returns a filter which approximates this filter.
103
+ r"""Return a filter which approximates this filter.
104
104
105
105
While approximations might loose accuracy, they allow for much faster
106
106
computations.
@@ -114,7 +114,33 @@ def approximate(self, method, **kwargs):
114
114
115
115
Examples
116
116
--------
117
- TODO: approx plot from notebook (needs new plotting)
117
+
118
+ Approximate a filter with Chebyshev polynomials of various orders:
119
+
120
+ >>> import matplotlib.pyplot as plt
121
+ >>> fig, ax = plt.subplots(1, 1)
122
+ >>>
123
+ >>> G = graphs.Ring()
124
+ >>> G.compute_fourier_basis()
125
+ >>> f1 = filters.Heat(G)
126
+ >>> f1.plot(eigenvalues=True, linewidth=3, label='continuous', ax=ax)
127
+ >>>
128
+ >>> for order in range(1, 5):
129
+ ... f2 = f1.approximate('Chebyshev', order=order)
130
+ ... l = 'Chebyshev order {}'.format(order)
131
+ ... f2.plot(eigenvalues=False, label=l, linestyle='dashed', ax=ax)
132
+ >>>
133
+ >>> _ = ax.set_title('Approximation for various polynomial orders')
134
+ >>> _ = ax.legend()
135
+
136
+ Approximate a filterbank with Chebyshev polynomials:
137
+
138
+ >>> G = graphs.Ring()
139
+ >>> G.compute_fourier_basis()
140
+ >>> f1 = filters.Itersine(G)
141
+ >>> f2 = f1.approximate('Chebyshev', order=20)
142
+ >>> f1.plot(title='Continuous filterbank')
143
+ >>> f2.plot(title='Approximated filterbank')
118
144
119
145
"""
120
146
from . import approximations
@@ -173,7 +199,7 @@ def filter(self, s, method=None, order=30):
173
199
s : ndarray
174
200
Graph signals, a tensor of shape ``(N_NODES, N_SIGNALS,
175
201
N_FEATURES)``, where ``N_NODES`` and ``N_SIGNALS`` are the number
176
- of nodes and signals of the signal tensor that pas passed in, and
202
+ of nodes and signals of the signal tensor that was passed in, and
177
203
``N_FEATURES`` is either 1 (synthesis) or the number of filters in
178
204
the filter bank (analysis).
179
205
0 commit comments