@@ -62,15 +62,16 @@ def test_contour_shape_error(args, message):
62
62
ax .contour (* args )
63
63
64
64
65
- def test_contour_empty_levels ():
66
-
67
- x = np .arange (9 )
68
- z = np .random .random ((9 , 9 ))
69
-
65
+ def test_contour_no_valid_levels ():
70
66
fig , ax = plt .subplots ()
71
- with pytest .warns (UserWarning ) as record :
72
- ax .contour (x , x , z , levels = [])
73
- assert len (record ) == 1
67
+ # no warning for empty levels.
68
+ ax .contour (np .random .rand (9 , 9 ), levels = [])
69
+ # no warning if levels is given and is not within the range of z.
70
+ cs = ax .contour (np .arange (81 ).reshape ((9 , 9 )), levels = [100 ])
71
+ # ... and if fmt is given.
72
+ ax .clabel (cs , fmt = {100 : '%1.2f' })
73
+ # no warning if z is uniform.
74
+ ax .contour (np .ones ((9 , 9 )))
74
75
75
76
76
77
def test_contour_Nlevels ():
@@ -84,33 +85,6 @@ def test_contour_Nlevels():
84
85
assert (cs1 .levels == cs2 .levels ).all ()
85
86
86
87
87
- def test_contour_badlevel_fmt ():
88
- # Test edge case from https://github.com/matplotlib/matplotlib/issues/9742
89
- # User supplied fmt for each level as a dictionary, but Matplotlib changed
90
- # the level to the minimum data value because no contours possible.
91
- # This was fixed in https://github.com/matplotlib/matplotlib/pull/9743
92
- x = np .arange (9 )
93
- z = np .zeros ((9 , 9 ))
94
-
95
- fig , ax = plt .subplots ()
96
- fmt = {1. : '%1.2f' }
97
- with pytest .warns (UserWarning ) as record :
98
- cs = ax .contour (x , x , z , levels = [1. ])
99
- ax .clabel (cs , fmt = fmt )
100
- assert len (record ) == 1
101
-
102
-
103
- def test_contour_uniform_z ():
104
-
105
- x = np .arange (9 )
106
- z = np .ones ((9 , 9 ))
107
-
108
- fig , ax = plt .subplots ()
109
- with pytest .warns (UserWarning ) as record :
110
- ax .contour (x , x , z )
111
- assert len (record ) == 1
112
-
113
-
114
88
@image_comparison (['contour_manual_labels' ], remove_text = True , style = 'mpl20' )
115
89
def test_contour_manual_labels ():
116
90
x , y = np .meshgrid (np .arange (0 , 10 ), np .arange (0 , 10 ))
0 commit comments