MCPcopy Create free account
hub / github.com/PyWavelets/pywt / _modes_per_axis

Function _modes_per_axis

pywt/_utils.py:72–104  ·  view source on GitHub ↗

Initialize mode for each axis to be transformed. Parameters ---------- modes : str or tuple of strings If a single mode is provided, it will used for all axes. Otherwise one mode per axis must be provided. axes : tuple The tuple of axes to be transformed.

(modes, axes)

Source from the content-addressed store, hash-verified

70
71
72def _modes_per_axis(modes, axes):
73 """Initialize mode for each axis to be transformed.
74
75 Parameters
76 ----------
77 modes : str or tuple of strings
78 If a single mode is provided, it will used for all axes. Otherwise
79 one mode per axis must be provided.
80 axes : tuple
81 The tuple of axes to be transformed.
82
83 Returns
84 -------
85 modes : tuple of int
86 A tuple of Modes equal in length to ``axes``.
87
88 """
89 axes = tuple(axes)
90 if isinstance(modes, (int, str)):
91 # same wavelet on all axes
92 modes = [Modes.from_object(modes), ] * len(axes)
93 elif isinstance(modes, Iterable):
94 if len(modes) == 1:
95 modes = [Modes.from_object(modes[0]), ] * len(axes)
96 else:
97 # (potentially) unique wavelet per axis (e.g. for dual-tree DWT)
98 if len(modes) != len(axes):
99 raise ValueError("The number of modes must match the number "
100 "of axes to be transformed.")
101 modes = [Modes.from_object(mode) for mode in modes]
102 else:
103 raise ValueError("modes must be a str, Mode enum or iterable")
104 return modes

Callers 5

dwtnFunction · 0.85
idwtnFunction · 0.85
mranFunction · 0.85
wavedecn_shapesFunction · 0.85
fswavedecnFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected