|
6 | 6 | from itertools import product |
7 | 7 | from typing import TYPE_CHECKING, Callable, Dict, List, Optional, Tuple, Union, cast |
8 | 8 |
|
| 9 | +import numpy as np |
9 | 10 | import pywt |
10 | 11 | import torch |
11 | | -import numpy as np |
12 | 12 |
|
13 | 13 | from ._util import Wavelet, _as_wavelet |
14 | 14 | from .conv_transform import wavedec, waverec |
|
23 | 23 | BaseDict = collections.UserDict |
24 | 24 |
|
25 | 25 |
|
26 | | -def _wpfreq(fs: float, level: int) -> np.ndarray: |
27 | | - """Compute the frequencies for a fully decomposed single dimensional |
28 | | - packet tree. The packet transform linearly subdivides all frequencies |
| 26 | +def _wpfreq(fs: float, level: int) -> List[float]: |
| 27 | + """Compute the frequencies for a fully decomposed 1d packet tree. |
| 28 | +
|
| 29 | + The packet transform linearly subdivides all frequencies |
29 | 30 | from zero up to the Nyquist frequency. |
30 | 31 |
|
31 | 32 | Args: |
32 | | - fs (float): The sampling frequency |
33 | | - level (int): The decomposition level |
| 33 | + fs (float): The sampling frequency. |
| 34 | + level (int): The decomposition level. |
34 | 35 |
|
35 | 36 | Returns: |
36 | | - np.ndarray: The frequency bins of the packets in frequency order. |
| 37 | + List[float]: The frequency bins of the packets in frequency order. |
37 | 38 | """ |
38 | | - n = list(range(int(np.power(2., level)))) |
39 | | - freqs = (fs/2.)*(n/(np.power(2., level))) |
40 | | - return freqs |
| 39 | + n = np.array(range(int(np.power(2.0, level)))) |
| 40 | + freqs = (fs / 2.0) * (n / (np.power(2.0, level))) |
| 41 | + return list(freqs) |
41 | 42 |
|
42 | 43 |
|
43 | 44 | class WaveletPacket(BaseDict): |
|
0 commit comments