@@ -459,9 +459,11 @@ def test_rectangle_resize_square_center(ax):
459
459
def test_selector_rotate (ax , selector_class ):
460
460
ax .set_aspect (1 )
461
461
tool = selector_class (ax , interactive = True )
462
+ corners = np .array ([[100 , 130 , 130 , 100 ], [100 , 100 , 140 , 140 ]])
462
463
# Draw rectangle
463
464
click_and_drag (tool , start = (100 , 100 ), end = (130 , 140 ))
464
465
assert_allclose (tool .extents , (100 , 130 , 100 , 140 ))
466
+ assert_allclose (tool .corners , corners , atol = 1e-6 )
465
467
assert len (tool ._state ) == 0
466
468
467
469
# Rotate anticlockwise using top-right corner
@@ -474,20 +476,37 @@ def test_selector_rotate(ax, selector_class):
474
476
# Extents change as the selector remains rigid in display coordinates
475
477
assert_allclose (tool .extents , (110.10 , 119.90 , 95.49 , 144.51 ), atol = 0.01 )
476
478
assert_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
+
477
492
tool .rotation = 45
478
493
assert tool .rotation == 45
479
- # Corners should move
494
+ # Corners should move again
480
495
assert_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 )
483
498
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 )
487
505
488
506
if selector_class == widgets .RectangleSelector :
507
+ assert tool ._selection_artist .rotation_point == 'xy'
489
508
with pytest .raises (ValueError ):
490
- tool ._selection_artist .rotation_point = 'unvalid_value '
509
+ tool ._selection_artist .rotation_point = 'invalid_value '
491
510
492
511
493
512
def test_rectangle_add_remove_set (ax ):
0 commit comments