Skip to content

Commit c273643

Browse files
grlee77rgommers
authored andcommitted
TST: test deprecated mode names give identical result
update doctests to reflect new order of modes list make test_dwt_coeff_len result not depend on order of the modes in list remove doctest that is a duplication of test_dwt_coeff_len unittest
1 parent fad3cf0 commit c273643

5 files changed

Lines changed: 33 additions & 10 deletions

File tree

doc/source/regression/dwt-idwt.rst

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,7 @@ extension mode (please refer to the PyWavelets' documentation for the
7474
:ref:`extension modes <Modes>` available:
7575

7676
>>> pywt.Modes.modes
77-
['zero', 'constant', 'symmetric', 'reflect', 'periodic', 'smooth', 'periodization']
78-
79-
>>> [int(pywt.dwt_coeff_len(len(x), w.dec_len, mode)) for mode in pywt.Modes.modes]
80-
[6, 6, 6, 6, 6, 6, 4]
77+
['zero', 'constant', 'symmetric', 'periodic', 'smooth', 'periodization', 'reflect']
8178

8279
As you see in the above example, the :ref:`periodization <Modes.periodization>`
8380
(periodization) mode is slightly different from the others. It's aim when

doc/source/regression/modes.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ Import :mod:`pywt` first
1919
List of available signal extension :ref:`modes <Modes>`:
2020

2121
>>> print(pywt.Modes.modes)
22-
['zero', 'constant', 'symmetric', 'reflect', 'periodic', 'smooth', 'periodization']
22+
['zero', 'constant', 'symmetric', 'periodic', 'smooth', 'periodization', 'reflect']
2323

2424

2525
Invalid mode name should rise a :exc:`ValueError`:

pywt/tests/test_deprecations.py

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
from numpy.testing import assert_warns
1+
import warnings
2+
3+
import numpy as np
4+
from numpy.testing import assert_warns, run_module_suite, assert_array_equal
25

36
import pywt
47

@@ -74,3 +77,22 @@ def use_MODES_new():
7477
return getattr(pywt.MODES, 'symmetric')
7578

7679
assert_warns(DeprecationWarning, use_MODES_new)
80+
81+
82+
def test_mode_equivalence():
83+
old_new = [('zpd', 'zero'),
84+
('cpd', 'constant'),
85+
('sym', 'symmetric'),
86+
('ppd', 'periodic'),
87+
('sp1', 'smooth'),
88+
('per', 'periodization')]
89+
x = np.arange(8.)
90+
with warnings.catch_warnings():
91+
warnings.simplefilter('ignore', DeprecationWarning)
92+
for old, new in old_new:
93+
assert_array_equal(pywt.dwt(x, 'db2', mode=old),
94+
pywt.dwt(x, 'db2', mode=new))
95+
96+
97+
if __name__ == '__main__':
98+
run_module_suite()

pywt/tests/test_dwt_idwt.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,10 +97,14 @@ def test_dwt_coeff_len():
9797
w = pywt.Wavelet('sym3')
9898
ln_modes = [pywt.dwt_coeff_len(len(x), w.dec_len, mode) for mode in
9999
pywt.Modes.modes]
100-
assert_allclose(ln_modes, [6, 6, 6, 6, 6, 6, 4])
100+
101+
expected_result = [6, ] * len(pywt.Modes.modes)
102+
expected_result[pywt.Modes.modes.index('periodization')] = 4
103+
104+
assert_allclose(ln_modes, expected_result)
101105
ln_modes = [pywt.dwt_coeff_len(len(x), w, mode) for mode in
102106
pywt.Modes.modes]
103-
assert_allclose(ln_modes, [6, 6, 6, 6, 6, 6, 4])
107+
assert_allclose(ln_modes, expected_result)
104108

105109

106110
def test_idwt_none_input():

pywt/tests/test_modes.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99

1010

1111
def test_available_modes():
12-
modes = ['zero', 'constant', 'symmetric', 'reflect',
13-
'periodic', 'smooth', 'periodization']
12+
modes = ['zero', 'constant', 'symmetric', 'periodic', 'smooth',
13+
'periodization', 'reflect']
1414
assert_equal(pywt.Modes.modes, modes)
1515
assert_equal(pywt.Modes.from_object('constant'), 2)
1616

0 commit comments

Comments
 (0)