Skip to content

Commit 75a80e7

Browse files
committed
Update docs
1 parent c69bddd commit 75a80e7

File tree

1 file changed

+117
-108
lines changed

1 file changed

+117
-108
lines changed

torch/signal/windows/__init__.py

Lines changed: 117 additions & 108 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@ def _add_docstr(function, docstr):
1515
function.__doc__ = docstr
1616

1717

18-
_add_docstr(cosine, r"""
18+
_add_docstr(
19+
cosine,
20+
r"""
1921
Computes a window with a simple cosine waveform.
2022
Also known as the sine window.
2123
@@ -26,39 +28,42 @@ def _add_docstr(function, docstr):
2628
2729
Where `M` is the length of the window.
2830
""" +
29-
r"""
30-
31-
Args:
32-
window_length (int): the length of the output window.
33-
In other words, the number of points of the cosine window.
34-
periodic (bool, optional): If `True`, returns a periodic window suitable for use in spectral analysis.
35-
If `False`, returns a symmetric window suitable for use in filter design. Default: `True`.
36-
37-
Keyword args:
38-
{dtype}
39-
{layout}
40-
{device}
41-
{requires_grad}
42-
43-
Examples:
44-
>>> # Generate a cosine window without keyword args.
45-
>>> torch.signal.windows.cosine(10)
46-
tensor([0.1423, 0.4154, 0.6549, 0.8413, 0.9595, 1.0000, 0.9595, 0.8413, 0.6549,
47-
0.4154])
48-
49-
>>> # Generate a symmetric cosine window.
50-
>>> torch.signal.windows.cosine(10,periodic=False)
51-
tensor([0.1564, 0.4540, 0.7071, 0.8910, 0.9877, 0.9877, 0.8910, 0.7071, 0.4540,
52-
0.1564])
53-
54-
.. note::
55-
The window is normalized to 1 (maximum value is 1), however, the 1 doesn't appear if `M` is even
56-
and `periodic` is `False`.
57-
""".format(
58-
**factory_common_args
59-
))
60-
61-
_add_docstr(exponential, r"""
31+
r"""
32+
33+
Args:
34+
window_length (int): the length of the output window.
35+
In other words, the number of points of the cosine window.
36+
periodic (bool, optional): If `True`, returns a periodic window suitable for use in spectral analysis.
37+
If `False`, returns a symmetric window suitable for use in filter design. Default: `True`.
38+
39+
Keyword args:
40+
{dtype}
41+
{layout}
42+
{device}
43+
{requires_grad}
44+
45+
Examples:
46+
>>> # Generate a cosine window without keyword args.
47+
>>> torch.signal.windows.cosine(10)
48+
tensor([0.1423, 0.4154, 0.6549, 0.8413, 0.9595, 1.0000, 0.9595, 0.8413, 0.6549,
49+
0.4154])
50+
51+
>>> # Generate a symmetric cosine window.
52+
>>> torch.signal.windows.cosine(10,periodic=False)
53+
tensor([0.1564, 0.4540, 0.7071, 0.8910, 0.9877, 0.9877, 0.8910, 0.7071, 0.4540,
54+
0.1564])
55+
56+
.. note::
57+
The window is normalized to 1 (maximum value is 1), however, the 1 doesn't appear if `M` is even
58+
and `periodic` is `False`.
59+
""".format(
60+
**factory_common_args
61+
)
62+
)
63+
64+
_add_docstr(
65+
exponential,
66+
r"""
6267
Computes a window with an exponential waveform.
6368
Also known as Poisson window.
6469
@@ -67,84 +72,88 @@ def _add_docstr(function, docstr):
6772
.. math::
6873
w(n) = \exp{\left(-\frac{|n - center|}{\tau}\right)}
6974
""" +
70-
r"""
71-
72-
Args:
73-
window_length (int): the length of the output window.
74-
In other words, the number of points of the ee window.
75-
periodic (bool, optional): If `True`, returns a periodic window suitable for use in spectral analysis.
76-
If `False`, returns a symmetric window suitable for use in filter design. Default: `True`.
77-
center (float, optional): his value defines where the center of the window will be located.
78-
In other words, at which sample the peak of the window can be found.
79-
Default: `window_length / 2` if `periodic` is `True` (default), else `(window_length - 1) / 2`.
80-
tau (float, optional): the decay value.
81-
For `center = 0`, it's suggested to use :math:`\tau = -\frac{(M - 1)}{\ln(x)}`,
82-
if `x` is the fraction of the window remaining at the end. Default: 1.0.
83-
""" +
84-
r"""
85-
86-
Keyword args:
87-
{dtype}
88-
{layout}
89-
{device}
90-
{requires_grad}
91-
92-
Examples:
93-
>>> # Generate an exponential window without keyword args.
94-
>>> torch.signal.windows.exponential(10)
95-
tensor([0.0067, 0.0183, 0.0498, 0.1353, 0.3679, 1.0000, 0.3679, 0.1353, 0.0498,
96-
0.0183])
97-
98-
>>> # Generate a symmetric exponential window and decay factor equal to .5
99-
>>> torch.signal.windows.exponential(10,periodic=False,tau=.5)
100-
tensor([1.2341e-04, 9.1188e-04, 6.7379e-03, 4.9787e-02, 3.6788e-01, 3.6788e-01,
101-
4.9787e-02, 6.7379e-03, 9.1188e-04, 1.2341e-04])
102-
103-
.. note::
104-
The window is normalized to 1 (maximum value is 1), however, the 1 doesn't appear if `M` is even
105-
and `periodic` is `False`.
106-
""".format(
107-
**factory_common_args
108-
))
109-
110-
_add_docstr(gaussian, r"""
75+
r"""
76+
77+
Args:
78+
window_length (int): the length of the output window.
79+
In other words, the number of points of the ee window.
80+
periodic (bool, optional): If `True`, returns a periodic window suitable for use in spectral analysis.
81+
If `False`, returns a symmetric window suitable for use in filter design. Default: `True`.
82+
center (float, optional): his value defines where the center of the window will be located.
83+
In other words, at which sample the peak of the window can be found.
84+
Default: `window_length / 2` if `periodic` is `True` (default), else `(window_length - 1) / 2`.
85+
tau (float, optional): the decay value.
86+
For `center = 0`, it's suggested to use :math:`\tau = -\frac{(M - 1)}{\ln(x)}`,
87+
if `x` is the fraction of the window remaining at the end. Default: 1.0.
88+
""" +
89+
r"""
90+
91+
Keyword args:
92+
{dtype}
93+
{layout}
94+
{device}
95+
{requires_grad}
96+
97+
Examples:
98+
>>> # Generate an exponential window without keyword args.
99+
>>> torch.signal.windows.exponential(10)
100+
tensor([0.0067, 0.0183, 0.0498, 0.1353, 0.3679, 1.0000, 0.3679, 0.1353, 0.0498,
101+
0.0183])
102+
103+
>>> # Generate a symmetric exponential window and decay factor equal to .5
104+
>>> torch.signal.windows.exponential(10,periodic=False,tau=.5)
105+
tensor([1.2341e-04, 9.1188e-04, 6.7379e-03, 4.9787e-02, 3.6788e-01, 3.6788e-01,
106+
4.9787e-02, 6.7379e-03, 9.1188e-04, 1.2341e-04])
107+
108+
.. note::
109+
The window is normalized to 1 (maximum value is 1), however, the 1 doesn't appear if `M` is even
110+
and `periodic` is `False`.
111+
""".format(
112+
**factory_common_args
113+
)
114+
)
115+
116+
_add_docstr(
117+
gaussian,
118+
r"""
111119
Computes a window with a gaussian waveform.
112120
113121
The gaussian window is defined as follows:
114122
115123
.. math::
116124
w(n) = \exp{\left(-\left(\frac{n}{2\sigma}\right)^2\right)}
117125
""" +
118-
r"""
119-
120-
Args:
121-
window_length (int): the length of the output window.
122-
In other words, the number of points of the cosine window.
123-
periodic (bool, optional): If `True`, returns a periodic window suitable for use in spectral analysis.
124-
If `False`, returns a symmetric window suitable for use in filter design. Default: `True`
125-
std (float, optional): the standard deviation of the gaussian. It controls how narrow or wide the window is.
126-
Default: 0.5.
127-
128-
Keyword args:
129-
{dtype}
130-
{layout}
131-
{device}
132-
{requires_grad}
133-
134-
Examples:
135-
>>> # Generate a gaussian window without keyword args.
136-
>>> torch.signal.windows.gaussian(10)
137-
tensor([1.9287e-22, 1.2664e-14, 1.5230e-08, 3.3546e-04, 1.3534e-01, 1.0000e+00,
138-
1.3534e-01, 3.3546e-04, 1.5230e-08, 1.2664e-14])
139-
140-
>>> # Generate a symmetric gaussian window and standard deviation equal to 0.9.
141-
>>> torch.signal.windows.gaussian(10,periodic=False,std=0.9)
142-
tensor([3.7267e-06, 5.1998e-04, 2.1110e-02, 2.4935e-01, 8.5700e-01, 8.5700e-01,
143-
2.4935e-01, 2.1110e-02, 5.1998e-04, 3.7267e-06])
144-
145-
.. note::
146-
The window is normalized to 1 (maximum value is 1), however, the 1 doesn't appear if `M` is even
147-
and `periodic` is `False`.
148-
""".format(
149-
**factory_common_args
150-
))
126+
r"""
127+
128+
Args:
129+
window_length (int): the length of the output window.
130+
In other words, the number of points of the cosine window.
131+
periodic (bool, optional): If `True`, returns a periodic window suitable for use in spectral analysis.
132+
If `False`, returns a symmetric window suitable for use in filter design. Default: `True`
133+
std (float, optional): the standard deviation of the gaussian. It controls how narrow or wide the window is.
134+
Default: 0.5.
135+
136+
Keyword args:
137+
{dtype}
138+
{layout}
139+
{device}
140+
{requires_grad}
141+
142+
Examples:
143+
>>> # Generate a gaussian window without keyword args.
144+
>>> torch.signal.windows.gaussian(10)
145+
tensor([1.9287e-22, 1.2664e-14, 1.5230e-08, 3.3546e-04, 1.3534e-01, 1.0000e+00,
146+
1.3534e-01, 3.3546e-04, 1.5230e-08, 1.2664e-14])
147+
148+
>>> # Generate a symmetric gaussian window and standard deviation equal to 0.9.
149+
>>> torch.signal.windows.gaussian(10,periodic=False,std=0.9)
150+
tensor([3.7267e-06, 5.1998e-04, 2.1110e-02, 2.4935e-01, 8.5700e-01, 8.5700e-01,
151+
2.4935e-01, 2.1110e-02, 5.1998e-04, 3.7267e-06])
152+
153+
.. note::
154+
The window is normalized to 1 (maximum value is 1), however, the 1 doesn't appear if `M` is even
155+
and `periodic` is `False`.
156+
""".format(
157+
**factory_common_args
158+
)
159+
)

0 commit comments

Comments
 (0)