Skip to content

Commit

Permalink
Merge pull request #64 from grlee77/idwt2_variable_names
Browse files Browse the repository at this point in the history
MAINT: make LH, HL variable names in idwt2 consistent with dwt2
  • Loading branch information
rgommers committed Oct 26, 2015
2 parents aa98acd + d80dab2 commit da1c6b4
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 18 deletions.
20 changes: 10 additions & 10 deletions pywt/multidim.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def dwt2(data, wavelet, mode='sym'):
-------
(cA, (cH, cV, cD)) : tuple
Approximation, horizontal detail, vertical detail and diagonal
detail coefficients respectively.
detail coefficients respectively. Horizontal refers to array axis 0.
Examples
--------
Expand Down Expand Up @@ -122,7 +122,7 @@ def idwt2(coeffs, wavelet, mode='sym'):
raise ValueError("Invalid coeffs param")

# L -low-pass data, H - high-pass data
LL, (LH, HL, HH) = coeffs
LL, (HL, LH, HH) = coeffs

if LL is not None:
LL = np.transpose(LL)
Expand Down Expand Up @@ -151,29 +151,29 @@ def idwt2(coeffs, wavelet, mode='sym'):

# idwt columns
L = []
if LL is None and LH is None:
if LL is None and HL is None:
L = None
else:
if LL is None:
# IDWT can handle None input values - equals to zero-array
LL = cycle([None])
if LH is None:
if HL is None:
# IDWT can handle None input values - equals to zero-array
LH = cycle([None])
for rowL, rowH in zip(LL, LH):
HL = cycle([None])
for rowL, rowH in zip(LL, HL):
L.append(idwt(rowL, rowH, wavelet, mode, 1))

H = []
if HL is None and HH is None:
if LH is None and HH is None:
H = None
else:
if HL is None:
if LH is None:
# IDWT can handle None input values - equals to zero-array
HL = cycle([None])
LH = cycle([None])
if HH is None:
# IDWT can handle None input values - equals to zero-array
HH = cycle([None])
for rowL, rowH in zip(HL, HH):
for rowL, rowH in zip(LH, HH):
H.append(idwt(rowL, rowH, wavelet, mode, 1))

if L is not None:
Expand Down
16 changes: 8 additions & 8 deletions pywt/wavelet_packets.py
Original file line number Diff line number Diff line change
Expand Up @@ -441,16 +441,16 @@ class Node2D(BaseNode):
"""
WaveletPacket tree node.
Subnodes are called 'a' (LL), 'h' (LH), 'v' (HL) and 'd' (HH), like
Subnodes are called 'a' (LL), 'h' (HL), 'v' (LH) and 'd' (HH), like
approximation and detail coefficients in the 2D Discrete Wavelet Transform
"""

LL = 'a'
LH = 'h'
HL = 'v'
HL = 'h'
LH = 'v'
HH = 'd'

PARTS = LL, LH, HL, HH
PARTS = LL, HL, LH, HH
PART_LEN = 1

def _create_subnode(self, part, data=None, overwrite=True):
Expand All @@ -466,14 +466,14 @@ def _decompose(self):
if self.is_empty:
data_ll, data_lh, data_hl, data_hh = None, None, None, None
else:
data_ll, (data_lh, data_hl, data_hh) =\
data_ll, (data_hl, data_lh, data_hh) =\
dwt2(self.data, self.wavelet, self.mode)
self._create_subnode(self.LL, data_ll)
self._create_subnode(self.LH, data_lh)
self._create_subnode(self.HL, data_hl)
self._create_subnode(self.HH, data_hh)
return (self._get_node(self.LL), self._get_node(self.LH),
self._get_node(self.HL), self._get_node(self.HH))
return (self._get_node(self.LL), self._get_node(self.HL),
self._get_node(self.LH), self._get_node(self.HH))

def _reconstruct(self, update):
data_ll, data_lh, data_hl, data_hh = None, None, None, None
Expand All @@ -498,7 +498,7 @@ def _reconstruct(self, update):
"are None. Cannot reconstruct node." % self.path
)
else:
coeffs = data_ll, (data_lh, data_hl, data_hh)
coeffs = data_ll, (data_hl, data_lh, data_hh)
rec = idwt2(coeffs, self.wavelet, self.mode)
if update:
self.data = rec
Expand Down

0 comments on commit da1c6b4

Please sign in to comment.