Skip to content

Commit d417753

Browse files
authored
Merge pull request matplotlib#15772 from anntzer/spectral-cleandocs
Directly dedent the spectral parameter docs.
2 parents 1cd9137 + 438f7d4 commit d417753

File tree

1 file changed

+56
-67
lines changed

1 file changed

+56
-67
lines changed

lib/matplotlib/mlab.py

Lines changed: 56 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@
5454
"""
5555

5656
import csv
57-
import inspect
5857
from numbers import Number
5958

6059
import numpy as np
@@ -613,72 +612,62 @@ def _single_spectrum_helper(x, mode, Fs=None, window=None, pad_to=None,
613612

614613

615614
# Split out these keyword docs so that they can be used elsewhere
616-
docstring.interpd.update(Spectral=inspect.cleandoc("""
617-
Fs : scalar
618-
The sampling frequency (samples per time unit). It is used
619-
to calculate the Fourier frequencies, freqs, in cycles per time
620-
unit. The default value is 2.
621-
622-
window : callable or ndarray
623-
A function or a vector of length *NFFT*. To create window vectors see
624-
`.window_hanning`, `.window_none`, `numpy.blackman`, `numpy.hamming`,
625-
`numpy.bartlett`, `scipy.signal`, `scipy.signal.get_window`, etc. The
626-
default is `.window_hanning`. If a function is passed as the argument,
627-
it must take a data segment as an argument and return the windowed
628-
version of the segment.
629-
630-
sides : {'default', 'onesided', 'twosided'}
631-
Which sides of the spectrum to return. 'default' is one-sided for real
632-
data and two-sided for complex data. 'onesided' forces the return of a
633-
one-sided spectrum, while 'twosided' forces two-sided.
634-
"""))
635-
636-
637-
docstring.interpd.update(Single_Spectrum=inspect.cleandoc("""
638-
pad_to : int
639-
The number of points to which the data segment is padded when
640-
performing the FFT. While not increasing the actual resolution of
641-
the spectrum (the minimum distance between resolvable peaks),
642-
this can give more points in the plot, allowing for more
643-
detail. This corresponds to the *n* parameter in the call to fft().
644-
The default is None, which sets *pad_to* equal to the length of the
645-
input signal (i.e. no padding).
646-
"""))
647-
648-
649-
docstring.interpd.update(PSD=inspect.cleandoc("""
650-
pad_to : int
651-
The number of points to which the data segment is padded when
652-
performing the FFT. This can be different from *NFFT*, which
653-
specifies the number of data points used. While not increasing
654-
the actual resolution of the spectrum (the minimum distance between
655-
resolvable peaks), this can give more points in the plot,
656-
allowing for more detail. This corresponds to the *n* parameter
657-
in the call to fft(). The default is None, which sets *pad_to*
658-
equal to *NFFT*
659-
660-
NFFT : int
661-
The number of data points used in each block for the FFT.
662-
A power 2 is most efficient. The default value is 256.
663-
This should *NOT* be used to get zero padding, or the scaling of the
664-
result will be incorrect. Use *pad_to* for this instead.
665-
666-
detrend : {'none', 'mean', 'linear'} or callable, default 'none'
667-
The function applied to each segment before fft-ing, designed to
668-
remove the mean or linear trend. Unlike in MATLAB, where the
669-
*detrend* parameter is a vector, in Matplotlib is it a function.
670-
The :mod:`~matplotlib.mlab` module defines `.detrend_none`,
671-
`.detrend_mean`, and `.detrend_linear`, but you can use a custom
672-
function as well. You can also use a string to choose one of the
673-
functions: 'none' calls `.detrend_none`. 'mean' calls `.detrend_mean`.
674-
'linear' calls `.detrend_linear`.
675-
676-
scale_by_freq : bool, optional
677-
Whether the resulting density values should be scaled by the scaling
678-
frequency, which gives density in units of Hz^-1. This allows for
679-
integration over the returned frequency values. The default is True
680-
for MATLAB compatibility.
681-
"""))
615+
docstring.interpd.update(
616+
Spectral="""\
617+
Fs : scalar, default: 2
618+
The sampling frequency (samples per time unit). It is used to calculate
619+
the Fourier frequencies, *freqs*, in cycles per time unit.
620+
621+
window : callable or ndarray, default: `.window_hanning`
622+
A function or a vector of length *NFFT*. To create window vectors see
623+
`.window_hanning`, `.window_none`, `numpy.blackman`, `numpy.hamming`,
624+
`numpy.bartlett`, `scipy.signal`, `scipy.signal.get_window`, etc. If a
625+
function is passed as the argument, it must take a data segment as an
626+
argument and return the windowed version of the segment.
627+
628+
sides : {'default', 'onesided', 'twosided'}, optional
629+
Which sides of the spectrum to return. 'default' is one-sided for real
630+
data and two-sided for complex data. 'onesided' forces the return of a
631+
one-sided spectrum, while 'twosided' forces two-sided.""",
632+
633+
Single_Spectrum="""\
634+
pad_to : int, optional
635+
The number of points to which the data segment is padded when performing
636+
the FFT. While not increasing the actual resolution of the spectrum (the
637+
minimum distance between resolvable peaks), this can give more points in
638+
the plot, allowing for more detail. This corresponds to the *n* parameter
639+
in the call to fft(). The default is None, which sets *pad_to* equal to
640+
the length of the input signal (i.e. no padding).""",
641+
642+
PSD="""\
643+
pad_to : int, optional
644+
The number of points to which the data segment is padded when performing
645+
the FFT. This can be different from *NFFT*, which specifies the number
646+
of data points used. While not increasing the actual resolution of the
647+
spectrum (the minimum distance between resolvable peaks), this can give
648+
more points in the plot, allowing for more detail. This corresponds to
649+
the *n* parameter in the call to fft(). The default is None, which sets
650+
*pad_to* equal to *NFFT*
651+
652+
NFFT : int, default: 256
653+
The number of data points used in each block for the FFT. A power 2 is
654+
most efficient. This should *NOT* be used to get zero padding, or the
655+
scaling of the result will be incorrect; use *pad_to* for this instead.
656+
657+
detrend : {'none', 'mean', 'linear'} or callable, default 'none'
658+
The function applied to each segment before fft-ing, designed to remove
659+
the mean or linear trend. Unlike in MATLAB, where the *detrend* parameter
660+
is a vector, in Matplotlib is it a function. The :mod:`~matplotlib.mlab`
661+
module defines `.detrend_none`, `.detrend_mean`, and `.detrend_linear`,
662+
but you can use a custom function as well. You can also use a string to
663+
choose one of the functions: 'none' calls `.detrend_none`. 'mean' calls
664+
`.detrend_mean`. 'linear' calls `.detrend_linear`.
665+
666+
scale_by_freq : bool, optional, default: True
667+
Whether the resulting density values should be scaled by the scaling
668+
frequency, which gives density in units of Hz^-1. This allows for
669+
integration over the returned frequency values. The default is True for
670+
MATLAB compatibility.""")
682671

683672

684673
@docstring.dedent_interpd

0 commit comments

Comments
 (0)