Debian Codegraph @

pywt/tests/test_deprecations.py

raw symbols SCIP
1 import warnings
2
3 import numpy as np
4 from numpy.testing import assert_warns, assert_array_equal
5
6 import pywt
7
8
9 def test_intwave_deprecation():
10 wavelet = pywt.Wavelet('db3')
11 assert_warns(DeprecationWarning, pywt.intwave, wavelet)
12
13
14 def test_centrfrq_deprecation():
15 wavelet = pywt.Wavelet('db3')
16 assert_warns(DeprecationWarning, pywt.centrfrq, wavelet)
17
18
19 def test_scal2frq_deprecation():
20 wavelet = pywt.Wavelet('db3')
21 assert_warns(DeprecationWarning, pywt.scal2frq, wavelet, 1)
22
23
24 def test_orthfilt_deprecation():
25 assert_warns(DeprecationWarning, pywt.orthfilt, range(6))
26
27
28 def test_integrate_wave_tuple():
29 sig = [0, 1, 2, 3]
30 xgrid = [0, 1, 2, 3]
31 assert_warns(DeprecationWarning, pywt.integrate_wavelet, (sig, xgrid))
32
33
34 old_modes = ['zpd',
35 'cpd',
36 'sym',
37 'ppd',
38 'sp1',
39 'per',
40 ]
41
42
43 def test_MODES_from_object_deprecation():
44 for mode in old_modes:
45 assert_warns(DeprecationWarning, pywt.Modes.from_object, mode)
46
47
48 def test_MODES_attributes_deprecation():
49 def get_mode(Modes, name):
50 return getattr(Modes, name)
51
52 for mode in old_modes:
53 assert_warns(DeprecationWarning, get_mode, pywt.Modes, mode)
54
55
56 def test_MODES_deprecation_new():
57 def use_MODES_new():
58 return pywt.MODES.symmetric
59
60 assert_warns(DeprecationWarning, use_MODES_new)
61
62
63 def test_MODES_deprecation_old():
64 def use_MODES_old():
65 return pywt.MODES.sym
66
67 assert_warns(DeprecationWarning, use_MODES_old)
68
69
70 def test_MODES_deprecation_getattr():
71 def use_MODES_new():
72 return getattr(pywt.MODES, 'symmetric')
73
74 assert_warns(DeprecationWarning, use_MODES_new)
75
76
77 def test_mode_equivalence():
78 old_new = [('zpd', 'zero'),
79 ('cpd', 'constant'),
80 ('sym', 'symmetric'),
81 ('ppd', 'periodic'),
82 ('sp1', 'smooth'),
83 ('per', 'periodization')]
84 x = np.arange(8.)
85 with warnings.catch_warnings():
86 warnings.simplefilter('ignore', DeprecationWarning)
87 for old, new in old_new:
88 assert_array_equal(pywt.dwt(x, 'db2', mode=old),
89 pywt.dwt(x, 'db2', mode=new))