@@ -201,17 +201,15 @@ def test_cursor_data():
201201 xdisp , ydisp = ax .transData .transform_point ([x , y ])
202202
203203 event = MouseEvent ('motion_notify_event' , fig .canvas , xdisp , ydisp )
204- z = im .get_cursor_data (event )
205- assert z == 44 , "Did not get 44, got %d" % z
204+ assert im .get_cursor_data (event ) == 44
206205
207206 # Now try for a point outside the image
208207 # Tests issue #4957
209208 x , y = 10.1 , 4
210209 xdisp , ydisp = ax .transData .transform_point ([x , y ])
211210
212211 event = MouseEvent ('motion_notify_event' , fig .canvas , xdisp , ydisp )
213- z = im .get_cursor_data (event )
214- assert z is None , "Did not get None, got %d" % z
212+ assert im .get_cursor_data (event ) is None
215213
216214 # Hmm, something is wrong here... I get 0, not None...
217215 # But, this works further down in the tests with extents flipped
@@ -229,8 +227,7 @@ def test_cursor_data():
229227 xdisp , ydisp = ax .transData .transform_point ([x , y ])
230228
231229 event = MouseEvent ('motion_notify_event' , fig .canvas , xdisp , ydisp )
232- z = im .get_cursor_data (event )
233- assert z == 44 , "Did not get 44, got %d" % z
230+ assert im .get_cursor_data (event ) == 44
234231
235232 fig , ax = plt .subplots ()
236233 im = ax .imshow (np .arange (100 ).reshape (10 , 10 ), extent = [0 , 0.5 , 0 , 0.5 ])
@@ -239,24 +236,21 @@ def test_cursor_data():
239236 xdisp , ydisp = ax .transData .transform_point ([x , y ])
240237
241238 event = MouseEvent ('motion_notify_event' , fig .canvas , xdisp , ydisp )
242- z = im .get_cursor_data (event )
243- assert z == 55 , "Did not get 55, got %d" % z
239+ assert im .get_cursor_data (event ) == 55
244240
245241 # Now try for a point outside the image
246242 # Tests issue #4957
247243 x , y = 0.75 , 0.25
248244 xdisp , ydisp = ax .transData .transform_point ([x , y ])
249245
250246 event = MouseEvent ('motion_notify_event' , fig .canvas , xdisp , ydisp )
251- z = im .get_cursor_data (event )
252- assert z is None , "Did not get None, got %d" % z
247+ assert im .get_cursor_data (event ) is None
253248
254249 x , y = 0.01 , - 0.01
255250 xdisp , ydisp = ax .transData .transform_point ([x , y ])
256251
257252 event = MouseEvent ('motion_notify_event' , fig .canvas , xdisp , ydisp )
258- z = im .get_cursor_data (event )
259- assert z is None , "Did not get None, got %d" % z
253+ assert im .get_cursor_data (event ) is None
260254
261255
262256@image_comparison (baseline_images = ['image_clip' ], style = 'mpl20' )
@@ -295,15 +289,19 @@ def test_imshow():
295289 ax .set_xlim (0 ,3 )
296290 ax .set_ylim (0 ,3 )
297291
298- @image_comparison (baseline_images = ['no_interpolation_origin' ], remove_text = True )
292+
293+ @image_comparison (baseline_images = ['no_interpolation_origin' ],
294+ remove_text = True )
299295def test_no_interpolation_origin ():
300296 fig = plt .figure ()
301297 ax = fig .add_subplot (211 )
302- ax .imshow (np .arange (100 ).reshape ((2 , 50 )), origin = "lower" , interpolation = 'none' )
298+ ax .imshow (np .arange (100 ).reshape ((2 , 50 )), origin = "lower" ,
299+ interpolation = 'none' )
303300
304301 ax = fig .add_subplot (212 )
305302 ax .imshow (np .arange (100 ).reshape ((2 , 50 )), interpolation = 'none' )
306303
304+
307305@image_comparison (baseline_images = ['image_shift' ], remove_text = True ,
308306 extensions = ['pdf' , 'svg' ])
309307def test_image_shift ():
@@ -319,6 +317,7 @@ def test_image_shift():
319317 extent = (tMin , tMax , 1 , 100 ))
320318 ax .set_aspect ('auto' )
321319
320+
322321def test_image_edges ():
323322 f = plt .figure (figsize = [1 , 1 ])
324323 ax = f .add_axes ([0 , 0 , 1 , 1 ], frameon = False )
@@ -514,11 +513,10 @@ def test_jpeg_alpha():
514513 # If this fails, there will be only one color (all black). If this
515514 # is working, we should have all 256 shades of grey represented.
516515 num_colors = len (image .getcolors (256 ))
517- assert 175 <= num_colors <= 185 , 'num colors: %d' % (num_colors , )
518- # The fully transparent part should be red, not white or black
519- # or anything else
516+ assert 175 <= num_colors <= 185
517+ # The fully transparent part should be red.
520518 corner_pixel = image .getpixel ((0 , 0 ))
521- assert corner_pixel == (254 , 0 , 0 ), "corner pixel: %r" % ( corner_pixel , )
519+ assert corner_pixel == (254 , 0 , 0 )
522520
523521
524522def test_nonuniformimage_setdata ():
0 commit comments