@@ -18,26 +18,38 @@ def test_patch_transform_of_none():
18
18
ax .set_xlim ([1 , 3 ])
19
19
ax .set_ylim ([1 , 3 ])
20
20
21
- #draw an ellipse over data coord (2,2) by specifying device coords
21
+ # Draw an ellipse over data coord (2,2) by specifying device coords.
22
22
xy_data = (2 , 2 )
23
23
xy_pix = ax .transData .transform_point (xy_data )
24
24
25
- # not providing a transform of None puts the ellipse in data coordinates
25
+ # Not providing a transform of None puts the ellipse in data coordinates .
26
26
e = mpatches .Ellipse (xy_data , width = 1 , height = 1 , fc = 'yellow' , alpha = 0.5 )
27
27
ax .add_patch (e )
28
28
assert e ._transform == ax .transData
29
29
30
- # providing a transform of None puts the ellipse in device coordinates
30
+ # Providing a transform of None puts the ellipse in device coordinates.
31
31
e = mpatches .Ellipse (xy_pix , width = 120 , height = 120 , fc = 'coral' ,
32
32
transform = None , alpha = 0.5 )
33
+ assert e .is_transform_set () is True
33
34
ax .add_patch (e )
34
35
assert isinstance (e ._transform , mtrans .IdentityTransform )
35
36
36
- # providing an IdentityTransform puts the ellipse in device coordinates
37
+ # Providing an IdentityTransform puts the ellipse in device coordinates.
37
38
e = mpatches .Ellipse (xy_pix , width = 100 , height = 100 ,
38
39
transform = mtrans .IdentityTransform (), alpha = 0.5 )
39
40
ax .add_patch (e )
40
41
assert isinstance (e ._transform , mtrans .IdentityTransform )
42
+
43
+ # Not providing a transform, and then subsequently "get_transform" should
44
+ # not mean that "is_transform_set".
45
+ e = mpatches .Ellipse (xy_pix , width = 120 , height = 120 , fc = 'coral' ,
46
+ alpha = 0.5 )
47
+ intermediate_transform = e .get_transform ()
48
+ assert e .is_transform_set () is False
49
+ ax .add_patch (e )
50
+ assert e .get_transform () != intermediate_transform
51
+ assert e .is_transform_set () is True
52
+ assert e ._transform == ax .transData
41
53
42
54
43
55
@cleanup
0 commit comments