From f11984e25b6a794599f21fc0dca62b9c6df906f4 Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Tue, 9 Apr 2024 19:36:17 +0530 Subject: [PATCH] DOC: Fix indentation for some interactive examples --- doc/source/ref/cwt.rst | 32 +++++++++---------- doc/source/ref/signal-extension-modes.rst | 6 ++-- doc/source/ref/wavelets.rst | 38 +++++++++++------------ 3 files changed, 38 insertions(+), 38 deletions(-) diff --git a/doc/source/ref/cwt.rst b/doc/source/ref/cwt.rst index f0d5ab539..bbf47b320 100644 --- a/doc/source/ref/cwt.rst +++ b/doc/source/ref/cwt.rst @@ -92,8 +92,8 @@ wavelet names compatible with ``cwt`` can be obtained by: .. try_examples:: :button_text: Try it in your browser! - >>> import pywt - >>> wavelist = pywt.wavelist(kind='continuous') + >>> import pywt + >>> wavelist = pywt.wavelist(kind='continuous') Here is an overview of all available wavelets for ``cwt``. Note, that they can be customized by passing parameters such as ``center_frequency`` and ``bandwidth_frequency`` @@ -210,12 +210,12 @@ particular wavelet, one would analyze a signal using ``scales >= 2``. .. try_examples:: :button_text: Try it in your browser! - >>> import numpy as np - >>> import pywt - >>> dt = 0.01 # 100 Hz sampling - >>> frequencies = pywt.scale2frequency('cmor1.5-1.0', [1, 2, 3, 4]) / dt - >>> frequencies - array([ 100. , 50. , 33.33333333, 25. ]) + >>> import numpy as np + >>> import pywt + >>> dt = 0.01 # 100 Hz sampling + >>> frequencies = pywt.scale2frequency('cmor1.5-1.0', [1, 2, 3, 4]) / dt + >>> frequencies + array([ 100. , 50. , 33.33333333, 25. ]) The CWT in PyWavelets is applied to discrete data by convolution with samples of the integral of the wavelet. If ``scale`` is too low, this will result in @@ -241,14 +241,14 @@ of frequency directly. .. try_examples:: :button_text: Try it in your browser! - >>> import numpy as np - >>> import pywt - >>> dt = 0.01 # 100 Hz sampling - >>> fs = 1 / dt - >>> frequencies = np.array([100, 50, 33.33333333, 25]) / fs # normalize - >>> scale = pywt.frequency2scale('cmor1.5-1.0', frequencies) - >>> scale - array([ 1., 2., 3., 4.]) + >>> import numpy as np + >>> import pywt + >>> dt = 0.01 # 100 Hz sampling + >>> fs = 1 / dt + >>> frequencies = np.array([100, 50, 33.33333333, 25]) / fs # normalize + >>> scale = pywt.frequency2scale('cmor1.5-1.0', frequencies) + >>> scale + array([ 1., 2., 3., 4.]) .. plot:: pyplots/cwt_scaling_demo.py diff --git a/doc/source/ref/signal-extension-modes.rst b/doc/source/ref/signal-extension-modes.rst index 9ea76a66c..a93661ea1 100644 --- a/doc/source/ref/signal-extension-modes.rst +++ b/doc/source/ref/signal-extension-modes.rst @@ -92,9 +92,9 @@ computations can be performed with the `periodization`_ mode: .. try_examples:: :button_text: Try it in your browser! - >>> import pywt - >>> print(pywt.Modes.modes) - ['zero', 'constant', 'symmetric', 'periodic', 'smooth', 'periodization', 'reflect', 'antisymmetric', 'antireflect'] + >>> import pywt + >>> print(pywt.Modes.modes) + ['zero', 'constant', 'symmetric', 'periodic', 'smooth', 'periodization', 'reflect', 'antisymmetric', 'antireflect'] The following figure illustrates how a short signal (red) gets extended (black) outside of its original extent. Note that periodization first extends the diff --git a/doc/source/ref/wavelets.rst b/doc/source/ref/wavelets.rst index 8fe6c319a..854699987 100644 --- a/doc/source/ref/wavelets.rst +++ b/doc/source/ref/wavelets.rst @@ -241,25 +241,25 @@ The Wavelet object created in this way is a standard :class:`Wavelet` instance. The following example illustrates the way of creating custom Wavelet objects from plain Python lists of filter coefficients and a *filter bank-like* object. - **Example:** - - .. try_examples:: - :button_text: Try it in your browser! - - >>> import pywt, math - >>> c = math.sqrt(2)/2 - >>> dec_lo, dec_hi, rec_lo, rec_hi = [c, c], [-c, c], [c, c], [c, -c] - >>> filter_bank = [dec_lo, dec_hi, rec_lo, rec_hi] - >>> myWavelet = pywt.Wavelet(name="myHaarWavelet", filter_bank=filter_bank) - >>> - >>> class HaarFilterBank(object): - ... @property - ... def filter_bank(self): - ... c = math.sqrt(2)/2 - ... dec_lo, dec_hi, rec_lo, rec_hi = [c, c], [-c, c], [c, c], [c, -c] - ... return [dec_lo, dec_hi, rec_lo, rec_hi] - >>> filter_bank = HaarFilterBank() - >>> myOtherWavelet = pywt.Wavelet(name="myHaarWavelet", filter_bank=filter_bank) +**Example:** + +.. try_examples:: + :button_text: Try it in your browser! + + >>> import pywt, math + >>> c = math.sqrt(2)/2 + >>> dec_lo, dec_hi, rec_lo, rec_hi = [c, c], [-c, c], [c, c], [c, -c] + >>> filter_bank = [dec_lo, dec_hi, rec_lo, rec_hi] + >>> myWavelet = pywt.Wavelet(name="myHaarWavelet", filter_bank=filter_bank) + >>> + >>> class HaarFilterBank(object): + ... @property + ... def filter_bank(self): + ... c = math.sqrt(2)/2 + ... dec_lo, dec_hi, rec_lo, rec_hi = [c, c], [-c, c], [c, c], [c, -c] + ... return [dec_lo, dec_hi, rec_lo, rec_hi] + >>> filter_bank = HaarFilterBank() + >>> myOtherWavelet = pywt.Wavelet(name="myHaarWavelet", filter_bank=filter_bank) .. _ContinuousWavelet: