@@ -446,8 +446,7 @@ def test_toolmanager_update_keymap():
446
446
@pytest .mark .parametrize ("patch_vis" , [True , False ])
447
447
@pytest .mark .parametrize ("forward_nav" , [True , False , "auto" ])
448
448
@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 ):
451
450
# Bottom axes: ax_b Top axes: ax_t
452
451
fig , ax_b = plt .subplots ()
453
452
ax_t = fig .add_subplot (221 , zorder = 99 )
@@ -492,7 +491,7 @@ def test_interactive_pan_zoom_events(tool, button, patch_vis,
492
491
xstart_t , xstop_t , ystart_t , ystop_t = 1 , 2 , 1 , 2
493
492
# Convert to screen coordinates ("s"). Events are defined only with pixel
494
493
# 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 .
496
495
s0 = ax_t .transData .transform ((xstart_t , ystart_t )).astype (int )
497
496
s1 = ax_t .transData .transform ((xstop_t , ystop_t )).astype (int )
498
497
@@ -501,30 +500,25 @@ def test_interactive_pan_zoom_events(tool, button, patch_vis,
501
500
xstop_b , ystop_b = ax_b .transData .inverted ().transform (s1 )
502
501
503
502
# 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 )
508
505
509
506
tb = NavigationToolbar2 (fig .canvas )
510
507
511
508
if tool == "zoom" :
512
509
# Evaluate expected limits before executing the zoom-event
513
510
direction = ("in" if button == 1 else "out" )
514
511
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 )
517
513
518
514
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 )
521
516
elif ax_t .get_forward_navigation_events () is False :
522
517
xlim_b = init_xlim
523
518
ylim_b = init_ylim
524
519
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 )
528
522
else :
529
523
xlim_b = init_xlim
530
524
ylim_b = init_ylim
@@ -540,31 +534,26 @@ def test_interactive_pan_zoom_events(tool, button, patch_vis,
540
534
assert ax_b .get_ylim () == pytest .approx (ylim_b , abs = 0.15 )
541
535
542
536
# 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 )
547
539
else :
548
540
# Evaluate expected limits
549
541
# (call start_pan to make sure ax._pan_start is set)
550
542
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 )
553
544
ax_t .end_pan ()
554
545
555
546
if ax_t .get_forward_navigation_events () is True :
556
547
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 )
559
549
ax_b .end_pan ()
560
550
elif ax_t .get_forward_navigation_events () is False :
561
551
xlim_b = init_xlim
562
552
ylim_b = init_ylim
563
553
else :
564
- if ax_t .patch .get_visible () is False :
554
+ if not ax_t .patch .get_visible ():
565
555
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 )
568
557
ax_b .end_pan ()
569
558
else :
570
559
xlim_b = init_xlim
@@ -581,7 +570,5 @@ def test_interactive_pan_zoom_events(tool, button, patch_vis,
581
570
assert ax_b .get_ylim () == pytest .approx (ylim_b , abs = 0.15 )
582
571
583
572
# 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