7
7
from distutils .version import LooseVersion
8
8
import io
9
9
10
- from nose .tools import assert_equal , assert_raises , assert_false , assert_true
10
+ from nose .tools import assert_raises
11
11
from nose .plugins .skip import SkipTest
12
12
13
13
import datetime
@@ -129,22 +129,22 @@ def test_twinx_cla():
129
129
ax2 = ax .twinx ()
130
130
ax3 = ax2 .twiny ()
131
131
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 ()
134
134
ax2 .cla ()
135
135
ax3 .cla ()
136
136
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 ()
140
140
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 ()
144
144
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 ()
148
148
149
149
150
150
@image_comparison (baseline_images = ["minorticks_on_rcParams_both" ], extensions = ['png' ])
@@ -420,7 +420,6 @@ def test_polar_wrap():
420
420
@image_comparison (baseline_images = ['polar_units' , 'polar_units_2' ])
421
421
def test_polar_units ():
422
422
import matplotlib .testing .jpl_units as units
423
- from nose .tools import assert_true
424
423
units .register ()
425
424
426
425
pi = np .pi
@@ -445,7 +444,7 @@ def test_polar_units():
445
444
# make sure runits and theta units work
446
445
y1 = [y * km for y in y1 ]
447
446
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 )
449
448
450
449
451
450
@image_comparison (baseline_images = ['polar_rmin' ])
@@ -2671,7 +2670,7 @@ def test_eventplot():
2671
2670
linelengths = linelengths )
2672
2671
2673
2672
num_collections = len (colls )
2674
- np . testing . assert_equal ( num_collections , num_datasets )
2673
+ assert num_collections == num_datasets
2675
2674
2676
2675
# Reuse testcase from above for a labeled data test
2677
2676
data = {"pos" : data , "c" : colors , "lo" : lineoffsets , "ll" : linelengths }
@@ -2680,7 +2679,7 @@ def test_eventplot():
2680
2679
colls = axobj .eventplot ("pos" , colors = "c" , lineoffsets = "lo" ,
2681
2680
linelengths = "ll" , data = data )
2682
2681
num_collections = len (colls )
2683
- np . testing . assert_equal ( num_collections , num_datasets )
2682
+ assert num_collections == num_datasets
2684
2683
2685
2684
2686
2685
@image_comparison (baseline_images = ['test_eventplot_defaults' ], extensions = ['png' ], remove_text = True )
@@ -2727,9 +2726,8 @@ def test_eventplot_problem_kwargs():
2727
2726
linestyle = ['dashdot' , 'dotted' ])
2728
2727
2729
2728
# 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 )
2733
2731
2734
2732
2735
2733
@cleanup
@@ -2870,7 +2868,7 @@ def test_mixed_collection():
2870
2868
def test_subplot_key_hash ():
2871
2869
ax = plt .subplot (np .float64 (5.5 ), np .int64 (1 ), np .float64 (1.2 ))
2872
2870
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 ()
2874
2872
2875
2873
2876
2874
@image_comparison (baseline_images = ['specgram_freqs' ,
@@ -3825,7 +3823,7 @@ def test_rcparam_grid_minor():
3825
3823
matplotlib .rcParams ['axes.grid.which' ] = locator
3826
3824
fig = plt .figure ()
3827
3825
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
3829
3827
3830
3828
matplotlib .rcParams ['axes.grid' ] = orig_grid
3831
3829
matplotlib .rcParams ['axes.grid.which' ] = orig_locator
@@ -4043,17 +4041,17 @@ def test_margins():
4043
4041
fig1 , ax1 = plt .subplots (1 , 1 )
4044
4042
ax1 .plot (data )
4045
4043
ax1 .margins (1 )
4046
- assert_equal ( ax1 .margins (), (1 , 1 ) )
4044
+ assert ax1 .margins () == (1 , 1 )
4047
4045
4048
4046
fig2 , ax2 = plt .subplots (1 , 1 )
4049
4047
ax2 .plot (data )
4050
4048
ax2 .margins (1 , 0.5 )
4051
- assert_equal ( ax2 .margins (), (1 , 0.5 ) )
4049
+ assert ax2 .margins () == (1 , 0.5 )
4052
4050
4053
4051
fig3 , ax3 = plt .subplots (1 , 1 )
4054
4052
ax3 .plot (data )
4055
4053
ax3 .margins (x = 1 , y = 0.5 )
4056
- assert_equal ( ax3 .margins (), (1 , 0.5 ) )
4054
+ assert ax3 .margins () == (1 , 0.5 )
4057
4055
4058
4056
4059
4057
@cleanup
@@ -4074,7 +4072,7 @@ def test_pathological_hexbin():
4074
4072
fig , ax = plt .subplots (1 , 1 )
4075
4073
ax .hexbin (mylist , mylist )
4076
4074
fig .savefig (out )
4077
- assert_equal ( len (w ), 0 )
4075
+ assert len (w ) == 0
4078
4076
4079
4077
4080
4078
@cleanup
@@ -4089,7 +4087,7 @@ def test_color_alias():
4089
4087
# issues 4157 and 4162
4090
4088
fig , ax = plt .subplots ()
4091
4089
line = ax .plot ([0 , 1 ], c = 'lime' )[0 ]
4092
- assert_equal ( 'lime' , line .get_color () )
4090
+ assert 'lime' == line .get_color ()
4093
4091
4094
4092
4095
4093
@cleanup
@@ -4120,7 +4118,7 @@ def test_move_offsetlabel():
4120
4118
fig , ax = plt .subplots ()
4121
4119
ax .plot (data )
4122
4120
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 ()
4124
4122
4125
4123
4126
4124
@image_comparison (baseline_images = ['rc_spines' ], extensions = ['png' ],
@@ -4209,11 +4207,11 @@ def test_rc_major_minor_tick():
4209
4207
def test_bar_negative_width ():
4210
4208
fig , ax = plt .subplots ()
4211
4209
res = ax .bar (range (1 , 5 ), range (1 , 5 ), width = - 1 )
4212
- assert_equal ( len (res ), 4 )
4210
+ assert len (res ) == 4
4213
4211
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
4217
4215
4218
4216
4219
4217
@cleanup
@@ -4224,8 +4222,8 @@ def test_square_plot():
4224
4222
ax .plot (x , y , 'mo' )
4225
4223
ax .axis ('square' )
4226
4224
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'
4229
4227
4230
4228
4231
4229
@cleanup
@@ -4254,15 +4252,15 @@ def test_shared_scale():
4254
4252
axs [0 , 0 ].set_yscale ("log" )
4255
4253
4256
4254
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'
4259
4257
4260
4258
axs [1 , 1 ].set_xscale ("linear" )
4261
4259
axs [1 , 1 ].set_yscale ("linear" )
4262
4260
4263
4261
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'
4266
4264
4267
4265
4268
4266
@cleanup
@@ -4336,9 +4334,9 @@ def test_title_location_roundtrip():
4336
4334
ax .set_title ('left' , loc = 'left' )
4337
4335
ax .set_title ('right' , loc = 'right' )
4338
4336
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 ()
4342
4340
4343
4341
assert_raises (ValueError , ax .get_title , loc = 'foo' )
4344
4342
assert_raises (ValueError , ax .set_title , 'fail' , loc = 'foo' )
0 commit comments