Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 15c7b9b

Browse files
committed
Merge pull request matplotlib#2106 from mdboom/identitytransform-bugfix
Matplotlib 1.3.0rc2 test errors on win-amd64-py2.7
2 parents 6397fe9 + 910b325 commit 15c7b9b

File tree

3 files changed

+19
-11
lines changed

3 files changed

+19
-11
lines changed

lib/matplotlib/tests/test_contour.py

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
from matplotlib.testing.decorators import cleanup, image_comparison
44
from matplotlib import pyplot as plt
55

6+
import re
7+
68

79
@cleanup
810
def test_contour_shape_1d_valid():
@@ -97,14 +99,18 @@ def test_contour_shape_mismatch_4():
9799
ax.contour(b, g, z)
98100
except TypeError as exc:
99101
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
102106

103107
try:
104108
ax.contour(g, b, z)
105109
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
108114

109115

110116
@cleanup
@@ -157,23 +163,23 @@ def test_given_colors_levels_and_extends():
157163
_, axes = plt.subplots(2, 4)
158164

159165
data = np.arange(12).reshape(3, 4)
160-
166+
161167
colors = ['red', 'yellow', 'pink', 'blue', 'black']
162168
levels = [2, 4, 8, 10]
163-
169+
164170
for i, ax in enumerate(axes.flatten()):
165171
plt.sca(ax)
166-
172+
167173
filled = i % 2 == 0.
168174
extend = ['neither', 'min', 'max', 'both'][i // 2]
169-
175+
170176
if filled:
171177
last_color = -1 if extend in ['min', 'max'] else None
172178
plt.contourf(data, colors=colors[:last_color], levels=levels, extend=extend)
173179
else:
174180
last_level = -1 if extend == 'both' else None
175181
plt.contour(data, colors=colors, levels=levels[:last_level], extend=extend)
176-
182+
177183
plt.colorbar()
178184

179185

lib/matplotlib/tests/test_simplification.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ def test_start_with_moveto():
152152
verts = np.fromstring(decodebytes(data), dtype='<i4')
153153
verts = verts.reshape((len(verts) / 2, 2))
154154
path = Path(verts)
155-
segs = path.iter_segments(transforms.IdentityTransform, clip=(0.0, 0.0, 100.0, 100.0))
155+
segs = path.iter_segments(transforms.IdentityTransform(), clip=(0.0, 0.0, 100.0, 100.0))
156156
segs = list(segs)
157157
assert len(segs) == 1
158158
assert segs[0][1] == Path.MOVETO

src/agg_py_transforms.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,10 @@ py_to_agg_transformation_matrix(PyObject* obj, bool errors = true)
3131
try
3232
{
3333
matrix = (PyArrayObject*) PyArray_FromObject(obj, PyArray_DOUBLE, 2, 2);
34-
if (!matrix)
34+
if (!matrix) {
35+
PyErr_Clear();
3536
throw std::exception();
37+
}
3638
}
3739
catch (...)
3840
{

0 commit comments

Comments
 (0)