Skip to content

Commit 2932f0c

Browse files
committed
packet docs.
1 parent 6a9d413 commit 2932f0c

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

src/ptwt/packets.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,23 @@ def __init__(
5050
maxlevel (int, optional): Value is passed on to `transform`.
5151
The highest decomposition level to compute. If None, the maximum level
5252
is determined from the input data shape. Defaults to None.
53+
54+
Example:
55+
>>> import torch, pywt, ptwt
56+
>>> import numpy as np
57+
>>> import scipy.signal
58+
>>> import matplotlib.pyplot as plt
59+
>>> t = np.linspace(0, 10, 1500)
60+
>>> w = scipy.signal.chirp(t, f0=1, f1=50, t1=10, method="linear")
61+
>>> wp = ptwt.WaveletPacket(data=torch.from_numpy(w.astype(np.float32)),
62+
wavelet=pywt.Wavelet("db3"), mode="reflect")
63+
>>> np_lst = []
64+
>>> for node in wp.get_level(5):
65+
>>> np_lst.append(wp[node])
66+
>>> viz = np.stack(np_lst).squeeze()
67+
>>> plt.imshow(np.abs(viz))
68+
>>> plt.show()
69+
5370
"""
5471
self.wavelet = _as_wavelet(wavelet)
5572
self.mode = mode

0 commit comments

Comments
 (0)