@@ -459,9 +459,11 @@ def test_rectangle_resize_square_center(ax):
459459def test_selector_rotate (ax ,selector_class ):
460460ax .set_aspect (1 )
461461tool = selector_class (ax ,interactive = True )
462+ corners = np .array ([[100 ,130 ,130 ,100 ], [100 ,100 ,140 ,140 ]])
462463# Draw rectangle
463464click_and_drag (tool ,start = (100 ,100 ),end = (130 ,140 ))
464465assert_allclose (tool .extents , (100 ,130 ,100 ,140 ))
466+ assert_allclose (tool .corners ,corners ,atol = 1e-6 )
465467assert len (tool ._state )== 0
466468
467469# Rotate anticlockwise using top-right corner
@@ -474,20 +476,37 @@ def test_selector_rotate(ax, selector_class):
474476# Extents change as the selector remains rigid in display coordinates
475477assert_allclose (tool .extents , (110.10 ,119.90 ,95.49 ,144.51 ),atol = 0.01 )
476478assert_allclose (tool .rotation ,25.56 ,atol = 0.01 )
479+ angle = tool .rotation
480+ corners_dragged = tool .corners
481+
482+ # Check corners on returning to unrotated position, then rotate back with @setter
483+ tool .rotation = 0
484+ assert tool .rotation == 0
485+ assert_allclose (tool .corners ,corners ,atol = 1e-6 )
486+
487+ tool .rotation = angle
488+ assert_allclose (tool .rotation ,25.56 ,atol = 0.01 )
489+ assert_allclose (tool .corners ,corners_dragged ,atol = 1e-6 )
490+ assert_allclose (tool .extents , (110.10 ,119.90 ,95.49 ,144.51 ),atol = 0.01 )
491+
477492tool .rotation = 45
478493assert tool .rotation == 45
479- # Corners should move
494+ # Corners should move again
480495assert_allclose (tool .corners ,
481- np .array ([[110.10 , 131.31 , 103.03 , 81.81 ],
482- [95.49 ,116.70 ,144.98 ,123.77 ]]),atol = 0.01 )
496+ np .array ([[118.54 , 139.75 , 111.46 , 90.25 ],
497+ [95.25 ,116.46 ,144.75 ,123.54 ]]),atol = 0.01 )
483498
484- # Scale using top-right corner
485- click_and_drag (tool ,start = (110 ,145 ),end = (110 ,160 ))
486- assert_allclose (tool .extents , (110 ,110 ,145 ,160 ),atol = 0.01 )
499+ # Rescale using top-right corner
500+ click_and_drag (tool ,start = (111 ,145 ),end = (111 ,160 ))
501+ assert_allclose (tool .corners ,
502+ np .array ([[118.54 ,147.25 ,111.46 ,82.75 ],
503+ [95.25 ,123.96 ,159.75 ,131.04 ]]),atol = 0.01 )
504+ assert_allclose (tool .extents , (118.54 ,111.46 ,95.25 ,159.75 ),atol = 0.01 )
487505
488506if selector_class == widgets .RectangleSelector :
507+ assert tool ._selection_artist .rotation_point == 'xy'
489508with pytest .raises (ValueError ):
490- tool ._selection_artist .rotation_point = 'unvalid_value '
509+ tool ._selection_artist .rotation_point = 'invalid_value '
491510
492511
493512def test_rectangle_add_remove_set (ax ):
@@ -570,7 +589,7 @@ def test_selector_handles(ax, selector_class):
570589"""Test geometry of Rectangle/Ellipse Selector [bounding box]"""
571590tool = selector_class (ax ,grab_range = 10 ,interactive = True ,
572591handle_props = {'markerfacecolor' :'r' ,
573- 'markeredgecolor' :'b' })
592+ 'markeredgecolor' :'b' })
574593tool .extents = (100 ,150 ,100 ,150 )
575594
576595assert_allclose (tool .corners , ((100 ,150 ,150 ,100 ), (100 ,100 ,150 ,150 )))