|
3 | 3 | from matplotlib.testing.decorators import cleanup, image_comparison
|
4 | 4 | from matplotlib import pyplot as plt
|
5 | 5 |
|
| 6 | +import re |
| 7 | + |
6 | 8 |
|
7 | 9 | @cleanup
|
8 | 10 | def test_contour_shape_1d_valid():
|
@@ -97,14 +99,18 @@ def test_contour_shape_mismatch_4():
|
97 | 99 | ax.contour(b, g, z)
|
98 | 100 | except TypeError as exc:
|
99 | 101 | print exc.args[0]
|
100 |
| - assert exc.args[0] == 'Shape of x does not match that of z: ' + \ |
101 |
| - 'found (9, 9) instead of (9, 10).' |
| 102 | + assert re.match( |
| 103 | + r'Shape of x does not match that of z: ' + |
| 104 | + r'found \(9L?, 9L?\) instead of \(9L?, 10L?\)\.', |
| 105 | + exc.args[0]) is not None |
102 | 106 |
|
103 | 107 | try:
|
104 | 108 | ax.contour(g, b, z)
|
105 | 109 | except TypeError as exc:
|
106 |
| - assert exc.args[0] == 'Shape of y does not match that of z: ' + \ |
107 |
| - 'found (9, 9) instead of (9, 10).' |
| 110 | + assert re.match( |
| 111 | + r'Shape of y does not match that of z: ' + |
| 112 | + r'found \(9L?, 9L?\) instead of \(9L?, 10L?\)\.', |
| 113 | + exc.args[0]) is not None |
108 | 114 |
|
109 | 115 |
|
110 | 116 | @cleanup
|
@@ -157,23 +163,23 @@ def test_given_colors_levels_and_extends():
|
157 | 163 | _, axes = plt.subplots(2, 4)
|
158 | 164 |
|
159 | 165 | data = np.arange(12).reshape(3, 4)
|
160 |
| - |
| 166 | + |
161 | 167 | colors = ['red', 'yellow', 'pink', 'blue', 'black']
|
162 | 168 | levels = [2, 4, 8, 10]
|
163 |
| - |
| 169 | + |
164 | 170 | for i, ax in enumerate(axes.flatten()):
|
165 | 171 | plt.sca(ax)
|
166 |
| - |
| 172 | + |
167 | 173 | filled = i % 2 == 0.
|
168 | 174 | extend = ['neither', 'min', 'max', 'both'][i // 2]
|
169 |
| - |
| 175 | + |
170 | 176 | if filled:
|
171 | 177 | last_color = -1 if extend in ['min', 'max'] else None
|
172 | 178 | plt.contourf(data, colors=colors[:last_color], levels=levels, extend=extend)
|
173 | 179 | else:
|
174 | 180 | last_level = -1 if extend == 'both' else None
|
175 | 181 | plt.contour(data, colors=colors, levels=levels[:last_level], extend=extend)
|
176 |
| - |
| 182 | + |
177 | 183 | plt.colorbar()
|
178 | 184 |
|
179 | 185 |
|
|
0 commit comments