Skip to content

Commit

Permalink
DOC: Fix indentation for some interactive examples
Browse files Browse the repository at this point in the history
  • Loading branch information
agriyakhetarpal committed Apr 9, 2024
1 parent 8c63926 commit f11984e
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 38 deletions.
32 changes: 16 additions & 16 deletions doc/source/ref/cwt.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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``
Expand Down Expand Up @@ -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
Expand All @@ -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
6 changes: 3 additions & 3 deletions doc/source/ref/signal-extension-modes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
38 changes: 19 additions & 19 deletions doc/source/ref/wavelets.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit f11984e

Please sign in to comment.