@@ -123,43 +123,43 @@ def calc_window_target(self, x, NFFT, noverlap=0):
123
123
124
124
def test_stride_windows_2D_ValueError (self ):
125
125
x = np .arange (10 )[np .newaxis ]
126
- pytest .raise (ValueError , mlab .stride_windows ( x , 5 ))
126
+ pytest .raises (ValueError , mlab .stride_windows ( x , 5 ))
127
127
128
128
def test_stride_windows_0D_ValueError (self ):
129
129
x = np .array (0 )
130
- pytest .raise (ValueError , mlab .stride_windows ( x , 5 ))
130
+ pytest .raises (ValueError , mlab .stride_windows ( x , 5 ))
131
131
132
132
def test_stride_windows_noverlap_gt_n_ValueError (self ):
133
133
x = np .arange (10 )
134
- pytest .raise (ValueError , mlab .stride_windows (x , 2 , 3 )
134
+ pytest .raises (ValueError , mlab .stride_windows (x , 2 , 3 )
135
135
136
136
def test_stride_windows_noverlap_eq_n_ValueError (self ):
137
137
x = np .arange (10 )
138
- pytest .raise (ValueError , mlab .stride_windows (x , 2 , 2 ))
138
+ pytest .raises (ValueError , mlab .stride_windows (x , 2 , 2 ))
139
139
140
140
def test_stride_windows_n_gt_lenx_ValueError (self ):
141
141
x = np .arange (10 )
142
- pytest .raise (ValueError , mlab .stride_windows (x , 11 ))
142
+ pytest .raises (ValueError , mlab .stride_windows (x , 11 ))
143
143
144
144
def test_stride_windows_n_lt_1_ValueError (self ):
145
145
x = np .arange (10 )
146
- pytest .raise (ValueError , mlab .stride_windows (x , 0 ))
146
+ pytest .raises (ValueError , mlab .stride_windows (x , 0 ))
147
147
148
148
def test_stride_repeat_2D_ValueError (self ):
149
149
x = np .arange (10 )[np .newaxis ]
150
- pytest .raise (ValueError , mlab .stride_repeat (x , 5 ))
150
+ pytest .raises (ValueError , mlab .stride_repeat (x , 5 ))
151
151
152
152
def test_stride_repeat_axis_lt_0_ValueError (self ):
153
153
x = np .array (0 )
154
- pytest .raise (ValueError , mlab .stride_repeat (x , 5 , axis = - 1 ))
154
+ pytest .raises (ValueError , mlab .stride_repeat (x , 5 , axis = - 1 ))
155
155
156
156
def test_stride_repeat_axis_gt_1_ValueError (self ):
157
157
x = np .array (0 )
158
- pytest .raise (ValueError , mlab .stride_repeat (x , 5 , axis = 2 ))
158
+ pytest .raises (ValueError , mlab .stride_repeat (x , 5 , axis = 2 ))
159
159
160
160
def test_stride_repeat_n_lt_1_ValueError (self ):
161
161
x = np .arange (10 )
162
- pytest .raise (ValueError , mlab .stride_repeat (x , 0 ))
162
+ pytest .raises (ValueError , mlab .stride_repeat (x , 0 ))
163
163
164
164
def test_stride_repeat_n1_axis0 (self ):
165
165
x = np .arange (10 )
@@ -337,7 +337,7 @@ def test_rec2csv_bad_shape_ValueError(self):
337
337
(str ('y' ), np .float )])
338
338
339
339
# the bad recarray should trigger a ValueError for having ndim > 1.
340
- pytest .raise (ValueError , mlab .rec2csv ( bad , self .fd ))
340
+ pytest .raises (ValueError , mlab .rec2csv ( bad , self .fd ))
341
341
342
342
def test_csv2rec_names_with_comments (self ):
343
343
self .fd .write ('# comment\n 1,2,3\n 4,5,6\n ' )
@@ -399,24 +399,24 @@ def test_window_hanning_ones(self):
399
399
def test_apply_window_1D_axis1_ValueError (self ):
400
400
x = self .sig_rand
401
401
window = mlab .window_hanning
402
- pytest .raise (ValueError , mlab .apply_window ( x , window , axis = 1 ,
402
+ pytest .raises (ValueError , mlab .apply_window ( x , window , axis = 1 ,
403
403
return_window = False ))
404
404
405
405
def test_apply_window_1D_els_wrongsize_ValueError (self ):
406
406
x = self .sig_rand
407
407
window = mlab .window_hanning (np .ones (x .shape [0 ]- 1 ))
408
- pytest .raise (ValueError , mlab .apply_window (x , window ))
408
+ pytest .raises (ValueError , mlab .apply_window (x , window ))
409
409
410
410
def test_apply_window_0D_ValueError (self ):
411
411
x = np .array (0 )
412
412
window = mlab .window_hanning
413
- pytest .raise (ValueError , mlab .apply_window (x , window , axis = 1 ,
413
+ pytest .raises (ValueError , mlab .apply_window (x , window , axis = 1 ,
414
414
return_window = False ))
415
415
416
416
def test_apply_window_3D_ValueError (self ):
417
417
x = self .sig_rand [np .newaxis ][np .newaxis ]
418
418
window = mlab .window_hanning
419
- pytest .raise (ValueError , mlab .apply_window (x , window , axis = 1 ,
419
+ pytest .raises (ValueError , mlab .apply_window (x , window , axis = 1 ,
420
420
return_window = False ))
421
421
422
422
def test_apply_window_hanning_1D (self ):
@@ -1096,43 +1096,43 @@ def test_demean_2D_axism1(self):
1096
1096
1097
1097
def test_detrend_bad_key_str_ValueError (self ):
1098
1098
input = self .sig_slope [np .newaxis ]
1099
- pytest .raise (ValueError , mlab .detrend (input , key = 'spam' ))
1099
+ pytest .raises (ValueError , mlab .detrend (input , key = 'spam' ))
1100
1100
1101
1101
def test_detrend_bad_key_var_ValueError (self ):
1102
1102
input = self .sig_slope [np .newaxis ]
1103
- pytest .raise (ValueError , mlab .detrend (input , key = 5 ))
1103
+ pytest .raises (ValueError , mlab .detrend (input , key = 5 ))
1104
1104
1105
1105
def test_detrend_mean_0D_d0_ValueError (self ):
1106
1106
input = 5.5
1107
- pytest .raise (ValueError , mlab .detrend_mean (input , axis = 0 ))
1107
+ pytest .raises (ValueError , mlab .detrend_mean (input , axis = 0 ))
1108
1108
1109
1109
def test_detrend_0D_d0_ValueError (self ):
1110
1110
input = 5.5
1111
- pytest .raise (ValueError , mlab .detrend (input , axis = 0 ))
1111
+ pytest .raises (ValueError , mlab .detrend (input , axis = 0 ))
1112
1112
1113
1113
def test_detrend_mean_1D_d1_ValueError (self ):
1114
1114
input = self .sig_slope
1115
- pytest .raise (ValueError , mlab .detrend_mean (input , axis = 1 ))
1115
+ pytest .raises (ValueError , mlab .detrend_mean (input , axis = 1 ))
1116
1116
1117
1117
def test_detrend_1D_d1_ValueError (self ):
1118
1118
input = self .sig_slope
1119
- pytest .raise (ValueError , mlab .detrend (input , axis = 1 ))
1119
+ pytest .raises (ValueError , mlab .detrend (input , axis = 1 ))
1120
1120
1121
1121
def test_demean_1D_d1_ValueError (self ):
1122
1122
input = self .sig_slope
1123
- pytest .raise (ValueError , mlab .demean (input , axis = 1 ))
1123
+ pytest .raises (ValueError , mlab .demean (input , axis = 1 ))
1124
1124
1125
1125
def test_detrend_mean_2D_d2_ValueError (self ):
1126
1126
input = self .sig_slope [np .newaxis ]
1127
- pytest .raise (ValueError , mlab .detrend_mean (input , axis = 2 ))
1127
+ pytest .raises (ValueError , mlab .detrend_mean (input , axis = 2 ))
1128
1128
1129
1129
def test_detrend_2D_d2_ValueError (self ):
1130
1130
input = self .sig_slope [np .newaxis ]
1131
- pytest .raise (ValueError , mlab .detrend (input , axis = 2 ))
1131
+ pytest .raises (ValueError , mlab .detrend (input , axis = 2 ))
1132
1132
1133
1133
def test_demean_2D_d2_ValueError (self ):
1134
1134
input = self .sig_slope [np .newaxis ]
1135
- pytest .raise (ValueError , mlab .demean (input , axis = 2 ))
1135
+ pytest .raises (ValueError , mlab .demean (input , axis = 2 ))
1136
1136
1137
1137
def test_detrend_linear_0D_zeros (self ):
1138
1138
input = 0.
@@ -1196,7 +1196,7 @@ def test_detrend_linear_1d_slope_off_list(self):
1196
1196
1197
1197
def test_detrend_linear_2D_ValueError (self ):
1198
1198
input = self .sig_slope [np .newaxis ]
1199
- pytest .raise (ValueError , mlab .detrend_linear (input ))
1199
+ pytest .raises (ValueError , mlab .detrend_linear (input ))
1200
1200
1201
1201
def test_detrend_str_linear_2d_slope_off_axis0 (self ):
1202
1202
arri = [self .sig_off ,
@@ -1431,57 +1431,57 @@ def check_maxfreq(self, spec, fsp, fstims):
1431
1431
1432
1432
def test_spectral_helper_raises_complex_same_data (self ):
1433
1433
# test that mode 'complex' cannot be used if x is not y
1434
- pytest .raise (ValueError , mlab ._spectral_helper (
1434
+ pytest .raises (ValueError , mlab ._spectral_helper (
1435
1435
x = self .y , y = self .y + 1 , mode = 'complex' ))
1436
1436
1437
1437
def test_spectral_helper_raises_magnitude_same_data (self ):
1438
1438
# test that mode 'magnitude' cannot be used if x is not y
1439
- pytest .raise (ValueError , mlab ._spectral_helper (
1439
+ pytest .raises (ValueError , mlab ._spectral_helper (
1440
1440
x = self .y , y = self .y + 1 , mode = 'magnitude' ))
1441
1441
1442
1442
def test_spectral_helper_raises_angle_same_data (self ):
1443
1443
# test that mode 'angle' cannot be used if x is not y
1444
- pytest .raise (ValueError , mlab ._spectral_helper (
1444
+ pytest .raises (ValueError , mlab ._spectral_helper (
1445
1445
x = self .y , y = self .y + 1 , mode = 'angle' ))
1446
1446
1447
1447
def test_spectral_helper_raises_phase_same_data (self ):
1448
1448
# test that mode 'phase' cannot be used if x is not y
1449
- pytest .raise (ValueError , mlab ._spectral_helper (
1449
+ pytest .raises (ValueError , mlab ._spectral_helper (
1450
1450
x = self .y , y = self .y + 1 , mode = 'phase' ))
1451
1451
1452
1452
def test_spectral_helper_raises_unknown_mode (self ):
1453
1453
# test that unknown value for mode cannot be used
1454
- pytest .raise (ValueError , mlab ._spectral_helper (
1454
+ pytest .raises (ValueError , mlab ._spectral_helper (
1455
1455
x = self .y , mode = 'spam' ))
1456
1456
1457
1457
def test_spectral_helper_raises_unknown_sides (self ):
1458
1458
# test that unknown value for sides cannot be used
1459
- pytest .raise (ValueError , mlab ._spectral_helper (
1459
+ pytest .raises (ValueError , mlab ._spectral_helper (
1460
1460
x = self .y , y = self .y , sides = 'eggs' ))
1461
1461
1462
1462
def test_spectral_helper_raises_noverlap_gt_NFFT (self ):
1463
1463
# test that noverlap cannot be larger than NFFT
1464
- pytest .raise (ValueError , mlab ._spectral_helper (
1464
+ pytest .raises (ValueError , mlab ._spectral_helper (
1465
1465
x = self .y , y = self .y , NFFT = 10 , noverlap = 20 ))
1466
1466
1467
1467
def test_spectral_helper_raises_noverlap_eq_NFFT (self ):
1468
1468
# test that noverlap cannot be equal to NFFT
1469
- pytest .raise (ValueError , mlab ._spectral_helper (
1469
+ pytest .raises (ValueError , mlab ._spectral_helper (
1470
1470
x = self .y , NFFT = 10 , noverlap = 10 ))
1471
1471
1472
1472
def test_spectral_helper_raises_winlen_ne_NFFT (self ):
1473
1473
# test that the window length cannot be different from NFFT
1474
- pytest .raise (ValueError , mlab ._spectral_helper (
1474
+ pytest .raises (ValueError , mlab ._spectral_helper (
1475
1475
x = self .y , y = self .y , NFFT = 10 , window = np .ones (9 )))
1476
1476
1477
1477
def test_single_spectrum_helper_raises_mode_default (self ):
1478
1478
# test that mode 'default' cannot be used with _single_spectrum_helper
1479
- pytest .raise (ValueError , mlab ._single_spectrum_helper (
1479
+ pytest .raises (ValueError , mlab ._single_spectrum_helper (
1480
1480
x = self .y , mode = 'default' ))
1481
1481
1482
1482
def test_single_spectrum_helper_raises_mode_psd (self ):
1483
1483
# test that mode 'psd' cannot be used with _single_spectrum_helper
1484
- pytest .raise (ValueError , mlab ._single_spectrum_helper (
1484
+ pytest .raises (ValueError , mlab ._single_spectrum_helper (
1485
1485
x = self .y , mode = 'psd' ))
1486
1486
1487
1487
def test_spectral_helper_psd (self ):
@@ -1587,7 +1587,7 @@ def test_psd_detrend_mean_func_offset(self):
1587
1587
assert_array_equal (fsp_b , fsp_c )
1588
1588
assert_allclose (spec_g , spec_c , atol = 1e-08 )
1589
1589
# these should not be almost equal
1590
- pytest .raise (AssertionError ,
1590
+ pytest .raises (AssertionError ,
1591
1591
assert_allclose (spec_b , spec_c , atol = 1e-08 ))
1592
1592
1593
1593
def test_psd_detrend_mean_str_offset (self ):
@@ -1623,7 +1623,7 @@ def test_psd_detrend_mean_str_offset(self):
1623
1623
assert_array_equal (fsp_b , fsp_c )
1624
1624
assert_allclose (spec_g , spec_c , atol = 1e-08 )
1625
1625
# these should not be almost equal
1626
- pytest .raise (AssertionError ,
1626
+ pytest .raises (AssertionError ,
1627
1627
assert_allclose (spec_b , spec_c , atol = 1e-08 ))
1628
1628
1629
1629
def test_psd_detrend_linear_func_trend (self ):
@@ -1659,7 +1659,7 @@ def test_psd_detrend_linear_func_trend(self):
1659
1659
assert_array_equal (fsp_b , fsp_c )
1660
1660
assert_allclose (spec_g , spec_c , atol = 1e-08 )
1661
1661
# these should not be almost equal
1662
- pytest .raise (AssertionError ,
1662
+ pytest .raises (AssertionError ,
1663
1663
assert_allclose (spec_b , spec_c , atol = 1e-08 ))
1664
1664
1665
1665
def test_psd_detrend_linear_str_trend (self ):
@@ -1695,7 +1695,7 @@ def test_psd_detrend_linear_str_trend(self):
1695
1695
assert_array_equal (fsp_b , fsp_c )
1696
1696
assert_allclose (spec_g , spec_c , atol = 1e-08 )
1697
1697
# these should not be almost equal
1698
- pytest .raise (AssertionError ,
1698
+ pytest .raises (AssertionError ,
1699
1699
assert_allclose (spec_b , spec_c , atol = 1e-08 ))
1700
1700
1701
1701
def test_psd_window_hanning (self ):
@@ -1739,7 +1739,7 @@ def test_psd_window_hanning(self):
1739
1739
assert_array_equal (fsp_b , fsp_c )
1740
1740
assert_allclose (spec_g , spec_c , atol = 1e-08 )
1741
1741
# these should not be almost equal
1742
- pytest .raise (AssertionError ,
1742
+ pytest .raises (AssertionError ,
1743
1743
assert_allclose (spec_b , spec_c , atol = 1e-08 ))
1744
1744
1745
1745
def test_psd_window_hanning_detrend_linear (self ):
@@ -1788,7 +1788,7 @@ def test_psd_window_hanning_detrend_linear(self):
1788
1788
assert_array_equal (fsp_b , fsp_c )
1789
1789
assert_allclose (spec_g , spec_c , atol = 1e-08 )
1790
1790
# these should not be almost equal
1791
- pytest .raise (AssertionError ,
1791
+ pytest .raises (AssertionError ,
1792
1792
assert_allclose (spec_b , spec_c , atol = 1e-08 ))
1793
1793
1794
1794
def test_psd_windowarray (self ):
@@ -2771,9 +2771,9 @@ def get_z(x, y):
2771
2771
np .testing .assert_array_almost_equal (zi , correct_zi , 5 )
2772
2772
2773
2773
# Decreasing xi or yi should raise ValueError.
2774
- pytest .raise (ValueError , mlab .griddata (x , y , z , xi [::- 1 ], yi ,
2774
+ pytest .raises (ValueError , mlab .griddata (x , y , z , xi [::- 1 ], yi ,
2775
2775
interp = 'nn' ))
2776
- pytest .raise (ValueError , mlab .griddata (x , y , z , xi , yi [::- 1 ],
2776
+ pytest .raises (ValueError , mlab .griddata (x , y , z , xi , yi [::- 1 ],
2777
2777
interp = 'nn' ))
2778
2778
2779
2779
# Passing 2D xi and yi arrays to griddata.
@@ -2844,17 +2844,17 @@ def test_kde_bandwidth_method(self):
2844
2844
class gaussian_kde_custom_tests (object ):
2845
2845
def test_no_data (self ):
2846
2846
"""Pass no data into the GaussianKDE class."""
2847
- pytest .raise (ValueError , mlab .GaussianKDE ,([]))
2847
+ pytest .raises (ValueError , mlab .GaussianKDE ,([]))
2848
2848
2849
2849
def test_single_dataset_element (self ):
2850
2850
"""Pass a single dataset element into the GaussianKDE class."""
2851
- pytest .raise (ValueError , mlab .GaussianKDE ([42 ]))
2851
+ pytest .raises (ValueError , mlab .GaussianKDE ([42 ]))
2852
2852
2853
2853
def test_silverman_multidim_dataset (self ):
2854
2854
"""Use a multi-dimensional array as the dataset and test silverman's
2855
2855
output"""
2856
2856
x1 = np .array ([[1 , 2 , 3 ], [4 , 5 , 6 ], [7 , 8 , 9 ]])
2857
- pytest .raise (np .linalg .LinAlgError , mlab .GaussianKDE (x1 , "silverman" ))
2857
+ pytest .raises (np .linalg .LinAlgError , mlab .GaussianKDE (x1 , "silverman" ))
2858
2858
2859
2859
def test_silverman_singledim_dataset (self ):
2860
2860
"""Use a single dimension list as the dataset and test silverman's
@@ -2868,7 +2868,7 @@ def test_scott_multidim_dataset(self):
2868
2868
"""Use a multi-dimensional array as the dataset and test scott's output
2869
2869
"""
2870
2870
x1 = np .array ([[1 , 2 , 3 ], [4 , 5 , 6 ], [7 , 8 , 9 ]])
2871
- pytest .raise (np .linalg .LinAlgError , mlab .GaussianKDE (x1 , "scott" ))
2871
+ pytest .raises (np .linalg .LinAlgError , mlab .GaussianKDE (x1 , "scott" ))
2872
2872
2873
2873
def test_scott_singledim_dataset (self ):
2874
2874
"""Use a single-dimensional array as the dataset and test scott's
@@ -2881,7 +2881,7 @@ def test_scott_singledim_dataset(self):
2881
2881
def test_scalar_empty_dataset (self ):
2882
2882
"""Use an empty array as the dataset and test the scalar's cov factor
2883
2883
"""
2884
- pytest .raise (ValueError , mlab .GaussianKDE ([], bw_method = 5 ))
2884
+ pytest .raises (ValueError , mlab .GaussianKDE ([], bw_method = 5 ))
2885
2885
2886
2886
def test_scalar_covariance_dataset (self ):
2887
2887
"""Use a dataset and test a scalar's cov factor
@@ -2921,7 +2921,7 @@ def test_wrong_bw_method(self):
2921
2921
np .random .seed (8765678 )
2922
2922
n_basesample = 50
2923
2923
data = np .random .randn (n_basesample )
2924
- pytest .raise (ValueError , mlab .GaussianKDE (data , bw_method = "invalid" ))
2924
+ pytest .raises (ValueError , mlab .GaussianKDE (data , bw_method = "invalid" ))
2925
2925
2926
2926
2927
2927
class gaussian_kde_evaluate_tests (object ):
@@ -2947,7 +2947,7 @@ def test_evaluate_inv_dim(self):
2947
2947
multidim_data = np .random .randn (n_basesample )
2948
2948
kde = mlab .GaussianKDE (multidim_data )
2949
2949
x2 = [[1 ], [2 ], [3 ]]
2950
- pytest .raise (ValueError , kde .evaluate (x2 ))
2950
+ pytest .raises (ValueError , kde .evaluate (x2 ))
2951
2951
2952
2952
def test_evaluate_dim_and_num (self ):
2953
2953
""" Tests if evaluated against a one by one array"""
@@ -2963,7 +2963,7 @@ def test_evaluate_point_dim_not_one(self):
2963
2963
x1 = np .arange (3 , 10 , 2 )
2964
2964
x2 = [np .arange (3 , 10 , 2 ), np .arange (3 , 10 , 2 )]
2965
2965
kde = mlab .GaussianKDE (x1 )
2966
- pytest .raise (ValueError , kde .evaluate (x2 ))
2966
+ pytest .raises (ValueError , kde .evaluate (x2 ))
2967
2967
2968
2968
def test_evaluate_equal_dim_and_num_lt (self ):
2969
2969
"""Test when line 3810 fails"""
0 commit comments