Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 469e289

Browse files
committed
TST: Remove nose functions in the last set of files.
1 parent ba30f11 commit 469e289

File tree

4 files changed

+125
-98
lines changed

4 files changed

+125
-98
lines changed

lib/matplotlib/tests/test_axes.py

Lines changed: 99 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,6 @@
77
from distutils.version import LooseVersion
88
import io
99

10-
from nose.tools import assert_raises
11-
from nose.plugins.skip import SkipTest
12-
1310
import datetime
1411

1512
import pytz
@@ -375,7 +372,8 @@ def test_shaped_data():
375372
plt.plot(y2)
376373

377374
plt.subplot(413)
378-
assert_raises(ValueError, plt.plot, (y1, y2))
375+
with pytest.raises(ValueError):
376+
plt.plot((y1, y2))
379377

380378
plt.subplot(414)
381379
plt.plot(xdata[:, 1], xdata[1, :], 'o')
@@ -863,12 +861,14 @@ def test_pcolorargs():
863861
Z = np.sqrt(X**2 + Y**2)/5
864862

865863
_, ax = plt.subplots()
866-
assert_raises(TypeError, ax.pcolormesh, y, x, Z)
867-
assert_raises(TypeError, ax.pcolormesh, X, Y, Z.T)
868-
assert_raises(TypeError, ax.pcolormesh, x, y, Z[:-1, :-1],
869-
shading="gouraud")
870-
assert_raises(TypeError, ax.pcolormesh, X, Y, Z[:-1, :-1],
871-
shading="gouraud")
864+
with pytest.raises(TypeError):
865+
ax.pcolormesh(y, x, Z)
866+
with pytest.raises(TypeError):
867+
ax.pcolormesh(X, Y, Z.T)
868+
with pytest.raises(TypeError):
869+
ax.pcolormesh(x, y, Z[:-1, :-1], shading="gouraud")
870+
with pytest.raises(TypeError):
871+
ax.pcolormesh(X, Y, Z[:-1, :-1], shading="gouraud")
872872

873873

874874
@image_comparison(baseline_images=['canonical'])
@@ -1316,13 +1316,15 @@ def test_scatter_2D():
13161316
fig, ax = plt.subplots()
13171317
ax.scatter(x, y, c=z, s=200, edgecolors='face')
13181318

1319+
13191320
@cleanup
13201321
def test_scatter_color():
13211322
# Try to catch cases where 'c' kwarg should have been used.
1322-
assert_raises(ValueError, plt.scatter, [1, 2], [1, 2],
1323-
color=[0.1, 0.2])
1324-
assert_raises(ValueError, plt.scatter, [1, 2, 3], [1, 2, 3],
1325-
color=[1, 2, 3])
1323+
with pytest.raises(ValueError):
1324+
plt.scatter([1, 2], [1, 2], color=[0.1, 0.2])
1325+
with pytest.raises(ValueError):
1326+
plt.scatter([1, 2, 3], [1, 2, 3], color=[1, 2, 3])
1327+
13261328

13271329
@cleanup
13281330
def test_as_mpl_axes_api():
@@ -1813,7 +1815,8 @@ def test_bxp_bad_widths():
18131815

18141816
fig, ax = plt.subplots()
18151817
ax.set_yscale('log')
1816-
assert_raises(ValueError, ax.bxp, logstats, widths=[1])
1818+
with pytest.raises(ValueError):
1819+
ax.bxp(logstats, widths=[1])
18171820

18181821

18191822
@cleanup
@@ -1825,7 +1828,8 @@ def test_bxp_bad_positions():
18251828

18261829
fig, ax = plt.subplots()
18271830
ax.set_yscale('log')
1828-
assert_raises(ValueError, ax.bxp, logstats, positions=[2, 3])
1831+
with pytest.raises(ValueError):
1832+
ax.bxp(logstats, positions=[2, 3])
18291833

18301834

18311835
@image_comparison(baseline_images=['boxplot', 'boxplot'],
@@ -2010,24 +2014,26 @@ def test_boxplot_bad_medians_1():
20102014
x = np.linspace(-7, 7, 140)
20112015
x = np.hstack([-25, x, 25])
20122016
fig, ax = plt.subplots()
2013-
assert_raises(ValueError, ax.boxplot, x, usermedians=[1, 2])
2017+
with pytest.raises(ValueError):
2018+
ax.boxplot(x, usermedians=[1, 2])
20142019

20152020

20162021
@cleanup
20172022
def test_boxplot_bad_medians_2():
20182023
x = np.linspace(-7, 7, 140)
20192024
x = np.hstack([-25, x, 25])
20202025
fig, ax = plt.subplots()
2021-
assert_raises(ValueError, ax.boxplot, [x, x], usermedians=[[1, 2], [1, 2]])
2026+
with pytest.raises(ValueError):
2027+
ax.boxplot([x, x], usermedians=[[1, 2], [1, 2]])
20222028

20232029

20242030
@cleanup
20252031
def test_boxplot_bad_ci_1():
20262032
x = np.linspace(-7, 7, 140)
20272033
x = np.hstack([-25, x, 25])
20282034
fig, ax = plt.subplots()
2029-
assert_raises(ValueError, ax.boxplot, [x, x],
2030-
conf_intervals=[[1, 2]])
2035+
with pytest.raises(ValueError):
2036+
ax.boxplot([x, x], conf_intervals=[[1, 2]])
20312037

20322038

20332039
@cleanup
@@ -2043,8 +2049,8 @@ def test_boxplot_bad_ci_2():
20432049
x = np.linspace(-7, 7, 140)
20442050
x = np.hstack([-25, x, 25])
20452051
fig, ax = plt.subplots()
2046-
assert_raises(ValueError, ax.boxplot, [x, x],
2047-
conf_intervals=[[1, 2], [1]])
2052+
with pytest.raises(ValueError):
2053+
ax.boxplot([x, x], conf_intervals=[[1, 2], [1]])
20482054

20492055

20502056
@image_comparison(baseline_images=['boxplot_mod_artists_after_plotting'],
@@ -2227,7 +2233,8 @@ def test_violinplot_bad_positions():
22272233
# First 9 digits of frac(sqrt(47))
22282234
np.random.seed(855654600)
22292235
data = [np.random.normal(size=100) for i in range(4)]
2230-
assert_raises(ValueError, ax.violinplot, data, positions=range(5))
2236+
with pytest.raises(ValueError):
2237+
ax.violinplot(data, positions=range(5))
22312238

22322239

22332240
@cleanup
@@ -2236,8 +2243,8 @@ def test_violinplot_bad_widths():
22362243
# First 9 digits of frac(sqrt(53))
22372244
np.random.seed(280109889)
22382245
data = [np.random.normal(size=100) for i in range(4)]
2239-
assert_raises(ValueError, ax.violinplot, data, positions=range(4),
2240-
widths=[1, 2, 3])
2246+
with pytest.raises(ValueError):
2247+
ax.violinplot(data, positions=range(4), widths=[1, 2, 3])
22412248

22422249

22432250
@cleanup
@@ -2319,9 +2326,12 @@ def test_errorbar_shape():
23192326
yerr = np.vstack((yerr1, 2*yerr1)).T
23202327
xerr = 0.1 + yerr
23212328

2322-
assert_raises(ValueError, ax.errorbar, x, y, yerr=yerr, fmt='o')
2323-
assert_raises(ValueError, ax.errorbar, x, y, xerr=xerr, fmt='o')
2324-
assert_raises(ValueError, ax.errorbar, x, y, yerr=yerr, xerr=xerr, fmt='o')
2329+
with pytest.raises(ValueError):
2330+
ax.errorbar(x, y, yerr=yerr, fmt='o')
2331+
with pytest.raises(ValueError):
2332+
ax.errorbar(x, y, xerr=xerr, fmt='o')
2333+
with pytest.raises(ValueError):
2334+
ax.errorbar(x, y, yerr=yerr, xerr=xerr, fmt='o')
23252335

23262336

23272337
@image_comparison(baseline_images=['errorbar_limits'])
@@ -3119,17 +3129,20 @@ def test_specgram_angle_freqs():
31193129
spec13 = ax13.specgram(y, NFFT=NFFT, Fs=Fs, noverlap=noverlap,
31203130
pad_to=pad_to, sides='twosided', mode='angle')
31213131

3122-
assert_raises(ValueError, ax11.specgram, y, NFFT=NFFT, Fs=Fs,
3123-
noverlap=noverlap, pad_to=pad_to, sides='default',
3124-
mode='phase', scale='dB')
3132+
with pytest.raises(ValueError):
3133+
ax11.specgram(y, NFFT=NFFT, Fs=Fs,
3134+
noverlap=noverlap, pad_to=pad_to, sides='default',
3135+
mode='phase', scale='dB')
31253136

3126-
assert_raises(ValueError, ax12.specgram, y, NFFT=NFFT, Fs=Fs,
3127-
noverlap=noverlap, pad_to=pad_to, sides='onesided',
3128-
mode='phase', scale='dB')
3137+
with pytest.raises(ValueError):
3138+
ax12.specgram(y, NFFT=NFFT, Fs=Fs,
3139+
noverlap=noverlap, pad_to=pad_to, sides='onesided',
3140+
mode='phase', scale='dB')
31293141

3130-
assert_raises(ValueError, ax13.specgram, y, NFFT=NFFT, Fs=Fs,
3131-
noverlap=noverlap, pad_to=pad_to, sides='twosided',
3132-
mode='phase', scale='dB')
3142+
with pytest.raises(ValueError):
3143+
ax13.specgram(y, NFFT=NFFT, Fs=Fs,
3144+
noverlap=noverlap, pad_to=pad_to, sides='twosided',
3145+
mode='phase', scale='dB')
31333146

31343147

31353148
@image_comparison(baseline_images=['specgram_angle_noise'],
@@ -3166,17 +3179,20 @@ def test_specgram_noise_angle():
31663179
spec13 = ax13.specgram(y, NFFT=NFFT, Fs=Fs, noverlap=noverlap,
31673180
pad_to=pad_to, sides='twosided', mode='angle')
31683181

3169-
assert_raises(ValueError, ax11.specgram, y, NFFT=NFFT, Fs=Fs,
3170-
noverlap=noverlap, pad_to=pad_to, sides='default',
3171-
mode='phase', scale='dB')
3182+
with pytest.raises(ValueError):
3183+
ax11.specgram(y, NFFT=NFFT, Fs=Fs,
3184+
noverlap=noverlap, pad_to=pad_to, sides='default',
3185+
mode='phase', scale='dB')
31723186

3173-
assert_raises(ValueError, ax12.specgram, y, NFFT=NFFT, Fs=Fs,
3174-
noverlap=noverlap, pad_to=pad_to, sides='onesided',
3175-
mode='phase', scale='dB')
3187+
with pytest.raises(ValueError):
3188+
ax12.specgram(y, NFFT=NFFT, Fs=Fs,
3189+
noverlap=noverlap, pad_to=pad_to, sides='onesided',
3190+
mode='phase', scale='dB')
31763191

3177-
assert_raises(ValueError, ax13.specgram, y, NFFT=NFFT, Fs=Fs,
3178-
noverlap=noverlap, pad_to=pad_to, sides='twosided',
3179-
mode='phase', scale='dB')
3192+
with pytest.raises(ValueError):
3193+
ax13.specgram(y, NFFT=NFFT, Fs=Fs,
3194+
noverlap=noverlap, pad_to=pad_to, sides='twosided',
3195+
mode='phase', scale='dB')
31803196

31813197

31823198
@image_comparison(baseline_images=['specgram_phase_freqs'],
@@ -3221,17 +3237,20 @@ def test_specgram_freqs_phase():
32213237
spec13 = ax13.specgram(y, NFFT=NFFT, Fs=Fs, noverlap=noverlap,
32223238
pad_to=pad_to, sides='twosided', mode='phase')
32233239

3224-
assert_raises(ValueError, ax11.specgram, y, NFFT=NFFT, Fs=Fs,
3225-
noverlap=noverlap, pad_to=pad_to, sides='default',
3226-
mode='phase', scale='dB')
3240+
with pytest.raises(ValueError):
3241+
ax11.specgram(y, NFFT=NFFT, Fs=Fs,
3242+
noverlap=noverlap, pad_to=pad_to, sides='default',
3243+
mode='phase', scale='dB')
32273244

3228-
assert_raises(ValueError, ax12.specgram, y, NFFT=NFFT, Fs=Fs,
3229-
noverlap=noverlap, pad_to=pad_to, sides='onesided',
3230-
mode='phase', scale='dB')
3245+
with pytest.raises(ValueError):
3246+
ax12.specgram(y, NFFT=NFFT, Fs=Fs,
3247+
noverlap=noverlap, pad_to=pad_to, sides='onesided',
3248+
mode='phase', scale='dB')
32313249

3232-
assert_raises(ValueError, ax13.specgram, y, NFFT=NFFT, Fs=Fs,
3233-
noverlap=noverlap, pad_to=pad_to, sides='twosided',
3234-
mode='phase', scale='dB')
3250+
with pytest.raises(ValueError):
3251+
ax13.specgram(y, NFFT=NFFT, Fs=Fs,
3252+
noverlap=noverlap, pad_to=pad_to, sides='twosided',
3253+
mode='phase', scale='dB')
32353254

32363255

32373256
@image_comparison(baseline_images=['specgram_phase_noise'],
@@ -3271,17 +3290,20 @@ def test_specgram_noise_phase():
32713290
pad_to=pad_to, sides='twosided',
32723291
mode='phase', )
32733292

3274-
assert_raises(ValueError, ax11.specgram, y, NFFT=NFFT, Fs=Fs,
3275-
noverlap=noverlap, pad_to=pad_to, sides='default',
3276-
mode='phase', scale='dB')
3293+
with pytest.raises(ValueError):
3294+
ax11.specgram(y, NFFT=NFFT, Fs=Fs,
3295+
noverlap=noverlap, pad_to=pad_to, sides='default',
3296+
mode='phase', scale='dB')
32773297

3278-
assert_raises(ValueError, ax12.specgram, y, NFFT=NFFT, Fs=Fs,
3279-
noverlap=noverlap, pad_to=pad_to, sides='onesided',
3280-
mode='phase', scale='dB')
3298+
with pytest.raises(ValueError):
3299+
ax12.specgram(y, NFFT=NFFT, Fs=Fs,
3300+
noverlap=noverlap, pad_to=pad_to, sides='onesided',
3301+
mode='phase', scale='dB')
32813302

3282-
assert_raises(ValueError, ax13.specgram, y, NFFT=NFFT, Fs=Fs,
3283-
noverlap=noverlap, pad_to=pad_to, sides='twosided',
3284-
mode='phase', scale='dB')
3303+
with pytest.raises(ValueError):
3304+
ax13.specgram(y, NFFT=NFFT, Fs=Fs,
3305+
noverlap=noverlap, pad_to=pad_to, sides='twosided',
3306+
mode='phase', scale='dB')
32853307

32863308

32873309
@image_comparison(baseline_images=['psd_freqs'], remove_text=True,
@@ -4230,8 +4252,10 @@ def test_square_plot():
42304252
@cleanup
42314253
def test_no_None():
42324254
fig, ax = plt.subplots()
4233-
assert_raises(ValueError, plt.plot, None)
4234-
assert_raises(ValueError, plt.plot, None, None)
4255+
with pytest.raises(ValueError):
4256+
plt.plot(None)
4257+
with pytest.raises(ValueError):
4258+
plt.plot(None, None)
42354259

42364260

42374261
@cleanup
@@ -4335,8 +4359,10 @@ def test_title_location_roundtrip():
43354359
assert 'right' == ax.get_title(loc='right')
43364360
assert 'aardvark' == ax.get_title()
43374361

4338-
assert_raises(ValueError, ax.get_title, loc='foo')
4339-
assert_raises(ValueError, ax.set_title, 'fail', loc='foo')
4362+
with pytest.raises(ValueError):
4363+
ax.get_title(loc='foo')
4364+
with pytest.raises(ValueError):
4365+
ax.set_title('fail', loc='foo')
43404366

43414367

43424368
@image_comparison(baseline_images=["loglog"], remove_text=True,
@@ -4484,7 +4510,7 @@ def test_pandas_indexing_dates():
44844510
try:
44854511
import pandas as pd
44864512
except ImportError:
4487-
raise SkipTest("Pandas not installed")
4513+
pytest.skip("Pandas not installed")
44884514

44894515
dates = np.arange('2005-02', '2005-03', dtype='datetime64[D]')
44904516
values = np.sin(np.array(range(len(dates))))
@@ -4501,7 +4527,7 @@ def test_pandas_errorbar_indexing():
45014527
try:
45024528
import pandas as pd
45034529
except ImportError:
4504-
raise SkipTest("Pandas not installed")
4530+
pytest.skip("Pandas not installed")
45054531

45064532
df = pd.DataFrame(np.random.uniform(size=(5, 4)),
45074533
columns=['x', 'y', 'xe', 'ye'],
@@ -4515,7 +4541,7 @@ def test_pandas_indexing_hist():
45154541
try:
45164542
import pandas as pd
45174543
except ImportError:
4518-
raise SkipTest("Pandas not installed")
4544+
pytest.skip("Pandas not installed")
45194545

45204546
ser_1 = pd.Series(data=[1, 2, 2, 3, 3, 4, 4, 4, 4, 5])
45214547
ser_2 = ser_1.iloc[1:]
@@ -4545,8 +4571,8 @@ def test_none_kwargs():
45454571

45464572
@cleanup
45474573
def test_ls_ds_conflict():
4548-
assert_raises(ValueError, plt.plot, range(32),
4549-
linestyle='steps-pre:', drawstyle='steps-post')
4574+
with pytest.raises(ValueError):
4575+
plt.plot(range(32), linestyle='steps-pre:', drawstyle='steps-post')
45504576

45514577

45524578
@image_comparison(baseline_images=['date_timezone_x'], extensions=['png'])

0 commit comments

Comments
 (0)