Skip to content

Commit 3f45e42

Browse files
committed
fix up test_mlab.py raises and nose import lines
1 parent ac14548 commit 3f45e42

File tree

1 file changed

+47
-57
lines changed

1 file changed

+47
-57
lines changed

lib/matplotlib/tests/test_mlab.py

Lines changed: 47 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -404,19 +404,19 @@ def test_apply_window_1D_axis1_ValueError(self):
404404
def test_apply_window_1D_els_wrongsize_ValueError(self):
405405
x = self.sig_rand
406406
window = mlab.window_hanning(np.ones(x.shape[0]-1))
407-
pytest.raises(ValueError, mlab.apply_window(x, window))
407+
pytest.raises(ValueError, mlab.apply_windowx, window)
408408

409409
def test_apply_window_0D_ValueError(self):
410410
x = np.array(0)
411411
window = mlab.window_hanning
412-
pytest.raises(ValueError, mlab.apply_window(x, window, axis=1,
413-
return_window=False))
412+
pytest.raises(ValueError, mlab.apply_windowx, window, axis=1,
413+
return_window=False)
414414

415415
def test_apply_window_3D_ValueError(self):
416416
x = self.sig_rand[np.newaxis][np.newaxis]
417417
window = mlab.window_hanning
418-
pytest.raises(ValueError, mlab.apply_window(x, window, axis=1,
419-
return_window=False))
418+
pytest.raises(ValueError, mlab.apply_windowx, window, axis=1,
419+
return_window=False)
420420

421421
def test_apply_window_hanning_1D(self):
422422
x = self.sig_rand
@@ -1095,43 +1095,43 @@ def test_demean_2D_axism1(self):
10951095

10961096
def test_detrend_bad_key_str_ValueError(self):
10971097
input = self.sig_slope[np.newaxis]
1098-
pytest.raises(ValueError, mlab.detrend(input, key='spam'))
1098+
pytest.raises(ValueError, mlab.detrend, input, key='spam')
10991099

11001100
def test_detrend_bad_key_var_ValueError(self):
11011101
input = self.sig_slope[np.newaxis]
1102-
pytest.raises(ValueError, mlab.detrend(input, key=5))
1102+
pytest.raises(ValueError, mlab.detrend, input, key=5)
11031103

11041104
def test_detrend_mean_0D_d0_ValueError(self):
11051105
input = 5.5
1106-
pytest.raises(ValueError, mlab.detrend_mean(input, axis=0))
1106+
pytest.raises(ValueError, mlab.detrend_mean, input, axis=0)
11071107

11081108
def test_detrend_0D_d0_ValueError(self):
11091109
input = 5.5
1110-
pytest.raises(ValueError, mlab.detrend(input, axis=0))
1110+
pytest.raises(ValueError, mlab.detrend, input, axis=0)
11111111

11121112
def test_detrend_mean_1D_d1_ValueError(self):
11131113
input = self.sig_slope
1114-
pytest.raises(ValueError, mlab.detrend_mean(input, axis=1))
1114+
pytest.raises(ValueError, mlab.detrend_mean, input, axis=1)
11151115

11161116
def test_detrend_1D_d1_ValueError(self):
11171117
input = self.sig_slope
1118-
pytest.raises(ValueError, mlab.detrend(input, axis=1))
1118+
pytest.raises(ValueError, mlab.detrend, input, axis=1)
11191119

11201120
def test_demean_1D_d1_ValueError(self):
11211121
input = self.sig_slope
1122-
pytest.raises(ValueError, mlab.demean(input, axis=1))
1122+
pytest.raises(ValueError, mlab.demean, input, axis=1)
11231123

11241124
def test_detrend_mean_2D_d2_ValueError(self):
11251125
input = self.sig_slope[np.newaxis]
1126-
pytest.raises(ValueError, mlab.detrend_mean(input, axis=2))
1126+
pytest.raises(ValueError, mlab.detrend_mean, input, axis=2)
11271127

11281128
def test_detrend_2D_d2_ValueError(self):
11291129
input = self.sig_slope[np.newaxis]
1130-
pytest.raises(ValueError, mlab.detrend(input, axis=2))
1130+
pytest.raises(ValueError, mlab.detrend, input, axis=2)
11311131

11321132
def test_demean_2D_d2_ValueError(self):
11331133
input = self.sig_slope[np.newaxis]
1134-
pytest.raises(ValueError, mlab.demean(input, axis=2))
1134+
pytest.raises(ValueError, mlab.demean, input, axis=2)
11351135

11361136
def test_detrend_linear_0D_zeros(self):
11371137
input = 0.
@@ -1195,7 +1195,7 @@ def test_detrend_linear_1d_slope_off_list(self):
11951195

11961196
def test_detrend_linear_2D_ValueError(self):
11971197
input = self.sig_slope[np.newaxis]
1198-
pytest.raises(ValueError, mlab.detrend_linear(input))
1198+
pytest.raises(ValueError, mlab.detrend_linear, input)
11991199

12001200
def test_detrend_str_linear_2d_slope_off_axis0(self):
12011201
arri = [self.sig_off,
@@ -1430,58 +1430,58 @@ def check_maxfreq(self, spec, fsp, fstims):
14301430

14311431
def test_spectral_helper_raises_complex_same_data(self):
14321432
# test that mode 'complex' cannot be used if x is not y
1433-
pytest.raises(ValueError, mlab._spectral_helper(
1434-
x=self.y, y=self.y+1, mode='complex'))
1433+
pytest.raises(ValueError, mlab._spectral_helper,
1434+
x=self.y, y=self.y+1, mode='complex')
14351435

14361436
def test_spectral_helper_raises_magnitude_same_data(self):
14371437
# test that mode 'magnitude' cannot be used if x is not y
1438-
pytest.raises(ValueError, mlab._spectral_helper(
1439-
x=self.y, y=self.y+1, mode='magnitude'))
1438+
pytest.raises(ValueError, mlab._spectral_helper,
1439+
x=self.y, y=self.y+1, mode='magnitude')
14401440

14411441
def test_spectral_helper_raises_angle_same_data(self):
14421442
# test that mode 'angle' cannot be used if x is not y
1443-
pytest.raises(ValueError, mlab._spectral_helper(
1444-
x=self.y, y=self.y+1, mode='angle'))
1443+
pytest.raises(ValueError, mlab._spectral_helper,
1444+
x=self.y, y=self.y+1, mode='angle')
14451445

14461446
def test_spectral_helper_raises_phase_same_data(self):
14471447
# test that mode 'phase' cannot be used if x is not y
1448-
pytest.raises(ValueError, mlab._spectral_helper(
1449-
x=self.y, y=self.y+1, mode='phase'))
1448+
pytest.raises(ValueError, mlab._spectral_helper,
1449+
x=self.y, y=self.y+1, mode='phase')
14501450

14511451
def test_spectral_helper_raises_unknown_mode(self):
14521452
# test that unknown value for mode cannot be used
1453-
pytest.raises(ValueError, mlab._spectral_helper(
1454-
x=self.y, mode='spam'))
1453+
pytest.raises(ValueError, mlab._spectral_helper,
1454+
x=self.y, mode='spam')
14551455

14561456
def test_spectral_helper_raises_unknown_sides(self):
14571457
# test that unknown value for sides cannot be used
1458-
pytest.raises(ValueError, mlab._spectral_helper(
1459-
x=self.y, y=self.y, sides='eggs'))
1458+
pytest.raises(ValueError, mlab._spectral_helper,
1459+
x=self.y, y=self.y, sides='eggs')
14601460

14611461
def test_spectral_helper_raises_noverlap_gt_NFFT(self):
14621462
# test that noverlap cannot be larger than NFFT
1463-
pytest.raises(ValueError, mlab._spectral_helper(
1464-
x=self.y, y=self.y, NFFT=10, noverlap=20))
1463+
pytest.raises(ValueError, mlab._spectral_helper,
1464+
x=self.y, y=self.y, NFFT=10, noverlap=20)
14651465

14661466
def test_spectral_helper_raises_noverlap_eq_NFFT(self):
14671467
# test that noverlap cannot be equal to NFFT
1468-
pytest.raises(ValueError, mlab._spectral_helper(
1469-
x=self.y, NFFT=10, noverlap=10))
1468+
pytest.raises(ValueError, mlab._spectral_helper,
1469+
x=self.y, NFFT=10, noverlap=10)
14701470

14711471
def test_spectral_helper_raises_winlen_ne_NFFT(self):
14721472
# test that the window length cannot be different from NFFT
1473-
pytest.raises(ValueError, mlab._spectral_helper(
1474-
x=self.y, y=self.y, NFFT=10, window=np.ones(9)))
1473+
pytest.raises(ValueError, mlab._spectral_helper,
1474+
x=self.y, y=self.y, NFFT=10, window=np.ones(9))
14751475

14761476
def test_single_spectrum_helper_raises_mode_default(self):
14771477
# test that mode 'default' cannot be used with _single_spectrum_helper
1478-
pytest.raises(ValueError, mlab._single_spectrum_helper(
1479-
x=self.y, mode='default'))
1478+
pytest.raises(ValueError, mlab._single_spectrum_helper,
1479+
x=self.y, mode='default')
14801480

14811481
def test_single_spectrum_helper_raises_mode_psd(self):
14821482
# test that mode 'psd' cannot be used with _single_spectrum_helper
1483-
pytest.raises(ValueError, mlab._single_spectrum_helper(
1484-
x=self.y, mode='psd'))
1483+
pytest.raises(ValueError, mlab._single_spectrum_helper,
1484+
x=self.y, mode='psd')
14851485

14861486
def test_spectral_helper_psd(self):
14871487
freqs = self.freqs_density
@@ -2771,10 +2771,10 @@ def get_z(x, y):
27712771
np.testing.assert_array_almost_equal(zi, correct_zi, 5)
27722772

27732773
# Decreasing xi or yi should raise ValueError.
2774-
pytest.raises(ValueError, mlab.griddata(x, y, z, xi[::-1], yi,
2775-
interp='nn'))
2776-
pytest.raises(ValueError, mlab.griddata(x, y, z, xi, yi[::-1],
2777-
interp='nn'))
2774+
pytest.raises(ValueError, mlab.griddata, x, y, z, xi[::-1], yi,
2775+
interp='nn')
2776+
pytest.raises(ValueError, mlab.griddata, x, y, z, xi, yi[::-1],
2777+
interp='nn')
27782778

27792779
# Passing 2D xi and yi arrays to griddata.
27802780
xi, yi = np.meshgrid(xi, yi)
@@ -2868,7 +2868,7 @@ def test_scott_multidim_dataset(self):
28682868
"""Use a multi-dimensional array as the dataset and test scott's output
28692869
"""
28702870
x1 = np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]])
2871-
pytest.raises(np.linalg.LinAlgError, mlab.GaussianKDE(x1, "scott"))
2871+
pytest.raises(np.linalg.LinAlgError, mlab.GaussianKDE, x1, "scott")
28722872

28732873
def test_scott_singledim_dataset(self):
28742874
"""Use a single-dimensional array as the dataset and test scott's
@@ -2881,7 +2881,7 @@ def test_scott_singledim_dataset(self):
28812881
def test_scalar_empty_dataset(self):
28822882
"""Use an empty array as the dataset and test the scalar's cov factor
28832883
"""
2884-
pytest.raises(ValueError, mlab.GaussianKDE([], bw_method=5))
2884+
pytest.raises(ValueError, mlab.GaussianKDE, [], bw_method=5)
28852885

28862886
def test_scalar_covariance_dataset(self):
28872887
"""Use a dataset and test a scalar's cov factor
@@ -2921,7 +2921,7 @@ def test_wrong_bw_method(self):
29212921
np.random.seed(8765678)
29222922
n_basesample = 50
29232923
data = np.random.randn(n_basesample)
2924-
pytest.raises(ValueError, mlab.GaussianKDE(data, bw_method="invalid"))
2924+
pytest.raises(ValueError, mlab.GaussianKDE, data, bw_method="invalid")
29252925

29262926

29272927
class gaussian_kde_evaluate_tests(object):
@@ -2947,7 +2947,7 @@ def test_evaluate_inv_dim(self):
29472947
multidim_data = np.random.randn(n_basesample)
29482948
kde = mlab.GaussianKDE(multidim_data)
29492949
x2 = [[1], [2], [3]]
2950-
pytest.raises(ValueError, kde.evaluate(x2))
2950+
pytest.raises(ValueError, kde.evaluate, x2)
29512951

29522952
def test_evaluate_dim_and_num(self):
29532953
""" Tests if evaluated against a one by one array"""
@@ -2963,7 +2963,7 @@ def test_evaluate_point_dim_not_one(self):
29632963
x1 = np.arange(3, 10, 2)
29642964
x2 = [np.arange(3, 10, 2), np.arange(3, 10, 2)]
29652965
kde = mlab.GaussianKDE(x1)
2966-
pytest.raises(ValueError, kde.evaluate(x2))
2966+
pytest.raises(ValueError, kde.evaluate, x2)
29672967

29682968
def test_evaluate_equal_dim_and_num_lt(self):
29692969
"""Test when line 3810 fails"""
@@ -3008,13 +3008,3 @@ def test_psd_onesided_norm():
30083008
sides='onesided')
30093009
Su_1side = np.append([Su[0]], Su[1:4] + Su[4:][::-1])
30103010
assert_allclose(P, Su_1side, atol=1e-06)
3011-
3012-
3013-
if __name__ == '__main__':
3014-
import nose
3015-
import sys
3016-
3017-
args = ['-s', '--with-doctest']
3018-
argv = sys.argv
3019-
argv = argv[:1] + args + argv[1:]
3020-
nose.runmodule(argv=argv, exit=False)

0 commit comments

Comments
 (0)