@@ -446,8 +446,7 @@ def test_toolmanager_update_keymap():
446446@pytest .mark .parametrize ("patch_vis" , [True , False ])
447447@pytest .mark .parametrize ("forward_nav" , [True , False , "auto" ])
448448@pytest .mark .parametrize ("t_s" , ["twin" , "share" ])
449- def test_interactive_pan_zoom_events (tool , button , patch_vis ,
450- forward_nav , t_s ):
449+ def test_interactive_pan_zoom_events (tool , button , patch_vis , forward_nav , t_s ):
451450 # Bottom axes: ax_b Top axes: ax_t
452451 fig , ax_b = plt .subplots ()
453452 ax_t = fig .add_subplot (221 , zorder = 99 )
@@ -492,7 +491,7 @@ def test_interactive_pan_zoom_events(tool, button, patch_vis,
492491 xstart_t , xstop_t , ystart_t , ystop_t = 1 , 2 , 1 , 2
493492 # Convert to screen coordinates ("s"). Events are defined only with pixel
494493 # precision, so round the pixel values, and below, check against the
495- # corresponding xdata/ydata, which are close but not equal to d0/d1 .
494+ # corresponding xdata/ydata, which are close but not equal to s0/s1 .
496495 s0 = ax_t .transData .transform ((xstart_t , ystart_t )).astype (int )
497496 s1 = ax_t .transData .transform ((xstop_t , ystop_t )).astype (int )
498497
@@ -501,30 +500,25 @@ def test_interactive_pan_zoom_events(tool, button, patch_vis,
501500 xstop_b , ystop_b = ax_b .transData .inverted ().transform (s1 )
502501
503502 # Set up the mouse movements
504- start_event = MouseEvent (
505- "button_press_event" , fig .canvas , * s0 , button )
506- stop_event = MouseEvent (
507- "button_release_event" , fig .canvas , * s1 , button )
503+ start_event = MouseEvent ("button_press_event" , fig .canvas , * s0 , button )
504+ stop_event = MouseEvent ("button_release_event" , fig .canvas , * s1 , button )
508505
509506 tb = NavigationToolbar2 (fig .canvas )
510507
511508 if tool == "zoom" :
512509 # Evaluate expected limits before executing the zoom-event
513510 direction = ("in" if button == 1 else "out" )
514511
515- xlim_t , ylim_t = ax_t ._prepare_view_from_bbox (
516- [* s0 , * s1 ], direction )
512+ xlim_t , ylim_t = ax_t ._prepare_view_from_bbox ([* s0 , * s1 ], direction )
517513
518514 if ax_t .get_forward_navigation_events () is True :
519- xlim_b , ylim_b = ax_b ._prepare_view_from_bbox (
520- [* s0 , * s1 ], direction )
515+ xlim_b , ylim_b = ax_b ._prepare_view_from_bbox ([* s0 , * s1 ], direction )
521516 elif ax_t .get_forward_navigation_events () is False :
522517 xlim_b = init_xlim
523518 ylim_b = init_ylim
524519 else :
525- if ax_t .patch .get_visible () is False :
526- xlim_b , ylim_b = ax_b ._prepare_view_from_bbox (
527- [* s0 , * s1 ], direction )
520+ if not ax_t .patch .get_visible ():
521+ xlim_b , ylim_b = ax_b ._prepare_view_from_bbox ([* s0 , * s1 ], direction )
528522 else :
529523 xlim_b = init_xlim
530524 ylim_b = init_ylim
@@ -540,31 +534,26 @@ def test_interactive_pan_zoom_events(tool, button, patch_vis,
540534 assert ax_b .get_ylim () == pytest .approx (ylim_b , abs = 0.15 )
541535
542536 # Check if twin-axes are properly triggered
543- assert ax_t .get_xlim () == pytest .approx (ax_t_twin .get_xlim (),
544- abs = 0.15 )
545- assert ax_b .get_xlim () == pytest .approx (ax_b_twin .get_xlim (),
546- abs = 0.15 )
537+ assert ax_t .get_xlim () == pytest .approx (ax_t_twin .get_xlim (), abs = 0.15 )
538+ assert ax_b .get_xlim () == pytest .approx (ax_b_twin .get_xlim (), abs = 0.15 )
547539 else :
548540 # Evaluate expected limits
549541 # (call start_pan to make sure ax._pan_start is set)
550542 ax_t .start_pan (* s0 , button )
551- xlim_t , ylim_t = ax_t ._get_pan_points (
552- button , None , * s1 ).T .astype (float )
543+ xlim_t , ylim_t = ax_t ._get_pan_points (button , None , * s1 ).T .astype (float )
553544 ax_t .end_pan ()
554545
555546 if ax_t .get_forward_navigation_events () is True :
556547 ax_b .start_pan (* s0 , button )
557- xlim_b , ylim_b = ax_b ._get_pan_points (
558- button , None , * s1 ).T .astype (float )
548+ xlim_b , ylim_b = ax_b ._get_pan_points (button , None , * s1 ).T .astype (float )
559549 ax_b .end_pan ()
560550 elif ax_t .get_forward_navigation_events () is False :
561551 xlim_b = init_xlim
562552 ylim_b = init_ylim
563553 else :
564- if ax_t .patch .get_visible () is False :
554+ if not ax_t .patch .get_visible ():
565555 ax_b .start_pan (* s0 , button )
566- xlim_b , ylim_b = ax_b ._get_pan_points (
567- button , None , * s1 ).T .astype (float )
556+ xlim_b , ylim_b = ax_b ._get_pan_points (button , None , * s1 ).T .astype (float )
568557 ax_b .end_pan ()
569558 else :
570559 xlim_b = init_xlim
@@ -581,7 +570,5 @@ def test_interactive_pan_zoom_events(tool, button, patch_vis,
581570 assert ax_b .get_ylim () == pytest .approx (ylim_b , abs = 0.15 )
582571
583572 # Check if twin-axes are properly triggered
584- assert ax_t .get_xlim () == pytest .approx (ax_t_twin .get_xlim (),
585- abs = 0.15 )
586- assert ax_b .get_xlim () == pytest .approx (ax_b_twin .get_xlim (),
587- abs = 0.15 )
573+ assert ax_t .get_xlim () == pytest .approx (ax_t_twin .get_xlim (), abs = 0.15 )
574+ assert ax_b .get_xlim () == pytest .approx (ax_b_twin .get_xlim (), abs = 0.15 )
0 commit comments