33import numpy as np
44import pytest
55
6- from matplotlib import mlab , _api
6+ from matplotlib import mlab
77
88
99class TestStride :
@@ -13,12 +13,7 @@ def get_base(self, x):
1313 y = y .base
1414 return y
1515
16- @pytest .fixture (autouse = True )
17- def stride_is_deprecated (self ):
18- with _api .suppress_matplotlib_deprecation_warning ():
19- yield
20-
21- def calc_window_target (self , x , NFFT , noverlap = 0 , axis = 0 ):
16+ def calc_window_target (self , x , NFFT , noverlap = 0 ):
2217 """
2318 This is an adaptation of the original window extraction algorithm.
2419 This is here to test to make sure the new implementation has the same
@@ -32,55 +27,43 @@ def calc_window_target(self, x, NFFT, noverlap=0, axis=0):
3227 # do the ffts of the slices
3328 for i in range (n ):
3429 result [:, i ] = x [ind [i ]:ind [i ]+ NFFT ]
35- if axis == 1 :
36- result = result .T
3730 return result
3831
39- @pytest .mark .parametrize ('shape' , [(), (10 , 1 )], ids = ['0D' , '2D' ])
40- def test_stride_windows_invalid_input_shape (self , shape ):
41- x = np .arange (np .prod (shape )).reshape (shape )
42- with pytest .raises (ValueError ):
43- mlab .stride_windows (x , 5 )
44-
4532 @pytest .mark .parametrize ('n, noverlap' ,
46- [(0 , None ), (11 , None ), (2 , 2 ), (2 , 3 )],
47- ids = ['n less than 1' , 'n greater than input' ,
48- 'noverlap greater than n' ,
33+ [(2 , 2 ), (2 , 3 )],
34+ ids = ['noverlap greater than n' ,
4935 'noverlap equal to n' ])
5036 def test_stride_windows_invalid_params (self , n , noverlap ):
5137 x = np .arange (10 )
5238 with pytest .raises (ValueError ):
53- mlab .stride_windows (x , n , noverlap )
39+ mlab ._stride_windows (x , n , noverlap )
5440
55- @pytest .mark .parametrize ('axis' , [0 , 1 ], ids = ['axis0' , 'axis1' ])
5641 @pytest .mark .parametrize ('n, noverlap' ,
5742 [(1 , 0 ), (5 , 0 ), (15 , 2 ), (13 , - 3 )],
5843 ids = ['n1-noverlap0' , 'n5-noverlap0' ,
5944 'n15-noverlap2' , 'n13-noverlapn3' ])
60- def test_stride_windows (self , n , noverlap , axis ):
45+ def test_stride_windows (self , n , noverlap ):
6146 x = np .arange (100 )
62- y = mlab .stride_windows (x , n , noverlap = noverlap , axis = axis )
47+ y = mlab ._stride_windows (x , n , noverlap = noverlap )
6348
6449 expected_shape = [0 , 0 ]
65- expected_shape [axis ] = n
66- expected_shape [1 - axis ] = 100 // (n - noverlap )
67- yt = self .calc_window_target (x , n , noverlap = noverlap , axis = axis )
50+ expected_shape [0 ] = n
51+ expected_shape [1 ] = 100 // (n - noverlap )
52+ yt = self .calc_window_target (x , n , noverlap = noverlap )
6853
6954 assert yt .shape == y .shape
7055 assert_array_equal (yt , y )
7156 assert tuple (expected_shape ) == y .shape
7257 assert self .get_base (y ) is x
7358
74- @pytest .mark .parametrize ('axis' , [0 , 1 ], ids = ['axis0' , 'axis1' ])
75- def test_stride_windows_n32_noverlap0_unflatten (self , axis ):
59+ def test_stride_windows_n32_noverlap0_unflatten (self ):
7660 n = 32
7761 x = np .arange (n )[np .newaxis ]
7862 x1 = np .tile (x , (21 , 1 ))
7963 x2 = x1 .flatten ()
80- y = mlab .stride_windows (x2 , n , axis = axis )
64+ y = mlab ._stride_windows (x2 , n )
8165
82- if axis == 0 :
83- x1 = x1 .T
66+ x1 = x1 .T
8467 assert y .shape == x1 .shape
8568 assert_array_equal (y , x1 )
8669
0 commit comments