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

Skip to content

Commit 17fe952

Browse files
committed
TST: Run nose2pytest on a few files.
1 parent 1a9b4ee commit 17fe952

File tree

5 files changed

+132
-138
lines changed

5 files changed

+132
-138
lines changed

lib/matplotlib/tests/test_animation.py

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77
import sys
88
import tempfile
99
import numpy as np
10-
from numpy.testing import assert_equal
11-
from nose.tools import assert_false, assert_true
1210
import matplotlib as mpl
1311
from matplotlib import pyplot as plt
1412
from matplotlib import animation
@@ -67,12 +65,12 @@ def animate(i):
6765
anim.save(filename, dpi=dpi, writer=writer,
6866
savefig_kwargs=savefig_kwargs)
6967

70-
assert_equal(writer.fig, fig)
71-
assert_equal(writer.outfile, filename)
72-
assert_equal(writer.dpi, dpi)
73-
assert_equal(writer.args, ())
74-
assert_equal(writer.savefig_kwargs, savefig_kwargs)
75-
assert_equal(writer._count, num_frames)
68+
assert writer.fig == fig
69+
assert writer.outfile == filename
70+
assert writer.dpi == dpi
71+
assert writer.args == ()
72+
assert writer.savefig_kwargs == savefig_kwargs
73+
assert writer._count == num_frames
7674

7775

7876
@animation.writers.register('null')
@@ -174,23 +172,23 @@ def test_movie_writer_registry():
174172
ffmpeg_path = mpl.rcParams['animation.ffmpeg_path']
175173
# Not sure about the first state as there could be some writer
176174
# which set rcparams
177-
#assert_false(animation.writers._dirty)
178-
assert_true(len(animation.writers._registered) > 0)
175+
# assert not animation.writers._dirty
176+
assert len(animation.writers._registered) > 0
179177
animation.writers.list() # resets dirty state
180-
assert_false(animation.writers._dirty)
178+
assert not animation.writers._dirty
181179
mpl.rcParams['animation.ffmpeg_path'] = u"not_available_ever_xxxx"
182-
assert_true(animation.writers._dirty)
180+
assert animation.writers._dirty
183181
animation.writers.list() # resets
184-
assert_false(animation.writers._dirty)
185-
assert_false(animation.writers.is_available("ffmpeg"))
182+
assert not animation.writers._dirty
183+
assert not animation.writers.is_available("ffmpeg")
186184
# something which is guaranteed to be available in path
187185
# and exits immediately
188186
bin = u"true" if sys.platform != 'win32' else u"where"
189187
mpl.rcParams['animation.ffmpeg_path'] = bin
190-
assert_true(animation.writers._dirty)
188+
assert animation.writers._dirty
191189
animation.writers.list() # resets
192-
assert_false(animation.writers._dirty)
193-
assert_true(animation.writers.is_available("ffmpeg"))
190+
assert not animation.writers._dirty
191+
assert animation.writers.is_available("ffmpeg")
194192
mpl.rcParams['animation.ffmpeg_path'] = ffmpeg_path
195193

196194

lib/matplotlib/tests/test_axes.py

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

10-
from nose.tools import assert_equal, assert_raises, assert_false, assert_true
10+
from nose.tools import assert_raises
1111
from nose.plugins.skip import SkipTest
1212

1313
import datetime
@@ -129,22 +129,22 @@ def test_twinx_cla():
129129
ax2 = ax.twinx()
130130
ax3 = ax2.twiny()
131131
plt.draw()
132-
assert_false(ax2.xaxis.get_visible())
133-
assert_false(ax2.patch.get_visible())
132+
assert not ax2.xaxis.get_visible()
133+
assert not ax2.patch.get_visible()
134134
ax2.cla()
135135
ax3.cla()
136136

137-
assert_false(ax2.xaxis.get_visible())
138-
assert_false(ax2.patch.get_visible())
139-
assert_true(ax2.yaxis.get_visible())
137+
assert not ax2.xaxis.get_visible()
138+
assert not ax2.patch.get_visible()
139+
assert ax2.yaxis.get_visible()
140140

141-
assert_true(ax3.xaxis.get_visible())
142-
assert_false(ax3.patch.get_visible())
143-
assert_false(ax3.yaxis.get_visible())
141+
assert ax3.xaxis.get_visible()
142+
assert not ax3.patch.get_visible()
143+
assert not ax3.yaxis.get_visible()
144144

145-
assert_true(ax.xaxis.get_visible())
146-
assert_true(ax.patch.get_visible())
147-
assert_true(ax.yaxis.get_visible())
145+
assert ax.xaxis.get_visible()
146+
assert ax.patch.get_visible()
147+
assert ax.yaxis.get_visible()
148148

149149

150150
@image_comparison(baseline_images=["minorticks_on_rcParams_both"], extensions=['png'])
@@ -420,7 +420,6 @@ def test_polar_wrap():
420420
@image_comparison(baseline_images=['polar_units', 'polar_units_2'])
421421
def test_polar_units():
422422
import matplotlib.testing.jpl_units as units
423-
from nose.tools import assert_true
424423
units.register()
425424

426425
pi = np.pi
@@ -445,7 +444,7 @@ def test_polar_units():
445444
# make sure runits and theta units work
446445
y1 = [y*km for y in y1]
447446
plt.polar(x2, y1, color="blue", thetaunits="rad", runits="km")
448-
assert_true(isinstance(plt.gca().get_xaxis().get_major_formatter(), units.UnitDblFormatter))
447+
assert isinstance(plt.gca().get_xaxis().get_major_formatter(), units.UnitDblFormatter)
449448

450449

451450
@image_comparison(baseline_images=['polar_rmin'])
@@ -2671,7 +2670,7 @@ def test_eventplot():
26712670
linelengths=linelengths)
26722671

26732672
num_collections = len(colls)
2674-
np.testing.assert_equal(num_collections, num_datasets)
2673+
assert num_collections == num_datasets
26752674

26762675
# Reuse testcase from above for a labeled data test
26772676
data = {"pos": data, "c": colors, "lo": lineoffsets, "ll": linelengths}
@@ -2680,7 +2679,7 @@ def test_eventplot():
26802679
colls = axobj.eventplot("pos", colors="c", lineoffsets="lo",
26812680
linelengths="ll", data=data)
26822681
num_collections = len(colls)
2683-
np.testing.assert_equal(num_collections, num_datasets)
2682+
assert num_collections == num_datasets
26842683

26852684

26862685
@image_comparison(baseline_images=['test_eventplot_defaults'], extensions=['png'], remove_text=True)
@@ -2727,9 +2726,8 @@ def test_eventplot_problem_kwargs():
27272726
linestyle=['dashdot', 'dotted'])
27282727

27292728
# check that three IgnoredKeywordWarnings were raised
2730-
assert_equal(len(w), 3)
2731-
assert_true(all(issubclass(wi.category, IgnoredKeywordWarning)
2732-
for wi in w))
2729+
assert len(w) == 3
2730+
assert all(issubclass(wi.category, IgnoredKeywordWarning) for wi in w)
27332731

27342732

27352733
@cleanup
@@ -2870,7 +2868,7 @@ def test_mixed_collection():
28702868
def test_subplot_key_hash():
28712869
ax = plt.subplot(np.float64(5.5), np.int64(1), np.float64(1.2))
28722870
ax.twinx()
2873-
assert_equal((5, 1, 0, None), ax.get_subplotspec().get_geometry())
2871+
assert (5, 1, 0, None) == ax.get_subplotspec().get_geometry()
28742872

28752873

28762874
@image_comparison(baseline_images=['specgram_freqs',
@@ -3825,7 +3823,7 @@ def test_rcparam_grid_minor():
38253823
matplotlib.rcParams['axes.grid.which'] = locator
38263824
fig = plt.figure()
38273825
ax = fig.add_subplot(1, 1, 1)
3828-
assert((ax.xaxis._gridOnMajor, ax.xaxis._gridOnMinor) == result)
3826+
assert (ax.xaxis._gridOnMajor, ax.xaxis._gridOnMinor) == result
38293827

38303828
matplotlib.rcParams['axes.grid'] = orig_grid
38313829
matplotlib.rcParams['axes.grid.which'] = orig_locator
@@ -4043,17 +4041,17 @@ def test_margins():
40434041
fig1, ax1 = plt.subplots(1, 1)
40444042
ax1.plot(data)
40454043
ax1.margins(1)
4046-
assert_equal(ax1.margins(), (1, 1))
4044+
assert ax1.margins() == (1, 1)
40474045

40484046
fig2, ax2 = plt.subplots(1, 1)
40494047
ax2.plot(data)
40504048
ax2.margins(1, 0.5)
4051-
assert_equal(ax2.margins(), (1, 0.5))
4049+
assert ax2.margins() == (1, 0.5)
40524050

40534051
fig3, ax3 = plt.subplots(1, 1)
40544052
ax3.plot(data)
40554053
ax3.margins(x=1, y=0.5)
4056-
assert_equal(ax3.margins(), (1, 0.5))
4054+
assert ax3.margins() == (1, 0.5)
40574055

40584056

40594057
@cleanup
@@ -4074,7 +4072,7 @@ def test_pathological_hexbin():
40744072
fig, ax = plt.subplots(1, 1)
40754073
ax.hexbin(mylist, mylist)
40764074
fig.savefig(out)
4077-
assert_equal(len(w), 0)
4075+
assert len(w) == 0
40784076

40794077

40804078
@cleanup
@@ -4089,7 +4087,7 @@ def test_color_alias():
40894087
# issues 4157 and 4162
40904088
fig, ax = plt.subplots()
40914089
line = ax.plot([0, 1], c='lime')[0]
4092-
assert_equal('lime', line.get_color())
4090+
assert 'lime' == line.get_color()
40934091

40944092

40954093
@cleanup
@@ -4120,7 +4118,7 @@ def test_move_offsetlabel():
41204118
fig, ax = plt.subplots()
41214119
ax.plot(data)
41224120
ax.yaxis.tick_right()
4123-
assert_equal((1, 0.5), ax.yaxis.offsetText.get_position())
4121+
assert (1, 0.5) == ax.yaxis.offsetText.get_position()
41244122

41254123

41264124
@image_comparison(baseline_images=['rc_spines'], extensions=['png'],
@@ -4209,11 +4207,11 @@ def test_rc_major_minor_tick():
42094207
def test_bar_negative_width():
42104208
fig, ax = plt.subplots()
42114209
res = ax.bar(range(1, 5), range(1, 5), width=-1)
4212-
assert_equal(len(res), 4)
4210+
assert len(res) == 4
42134211
for indx, b in enumerate(res):
4214-
assert_equal(b._x, indx)
4215-
assert_equal(b._width, 1)
4216-
assert_equal(b._height, indx + 1)
4212+
assert b._x == indx
4213+
assert b._width == 1
4214+
assert b._height == indx + 1
42174215

42184216

42194217
@cleanup
@@ -4224,8 +4222,8 @@ def test_square_plot():
42244222
ax.plot(x, y, 'mo')
42254223
ax.axis('square')
42264224
xlim, ylim = ax.get_xlim(), ax.get_ylim()
4227-
assert_true(np.diff(xlim) == np.diff(ylim))
4228-
assert_true(ax.get_aspect() == 'equal')
4225+
assert np.diff(xlim) == np.diff(ylim)
4226+
assert ax.get_aspect() == 'equal'
42294227

42304228

42314229
@cleanup
@@ -4254,15 +4252,15 @@ def test_shared_scale():
42544252
axs[0, 0].set_yscale("log")
42554253

42564254
for ax in axs.flat:
4257-
assert_equal(ax.get_yscale(), 'log')
4258-
assert_equal(ax.get_xscale(), 'log')
4255+
assert ax.get_yscale() == 'log'
4256+
assert ax.get_xscale() == 'log'
42594257

42604258
axs[1, 1].set_xscale("linear")
42614259
axs[1, 1].set_yscale("linear")
42624260

42634261
for ax in axs.flat:
4264-
assert_equal(ax.get_yscale(), 'linear')
4265-
assert_equal(ax.get_xscale(), 'linear')
4262+
assert ax.get_yscale() == 'linear'
4263+
assert ax.get_xscale() == 'linear'
42664264

42674265

42684266
@cleanup
@@ -4336,9 +4334,9 @@ def test_title_location_roundtrip():
43364334
ax.set_title('left', loc='left')
43374335
ax.set_title('right', loc='right')
43384336

4339-
assert_equal('left', ax.get_title(loc='left'))
4340-
assert_equal('right', ax.get_title(loc='right'))
4341-
assert_equal('aardvark', ax.get_title())
4337+
assert 'left' == ax.get_title(loc='left')
4338+
assert 'right' == ax.get_title(loc='right')
4339+
assert 'aardvark' == ax.get_title()
43424340

43434341
assert_raises(ValueError, ax.get_title, loc='foo')
43444342
assert_raises(ValueError, ax.set_title, 'fail', loc='foo')

0 commit comments

Comments
 (0)