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

Skip to content

Commit 5aa377b

Browse files
committed
Improved input type error messages for contour and spy
svn path=/trunk/matplotlib/; revision=2927
1 parent ce93d47 commit 5aa377b

2 files changed

Lines changed: 8 additions & 1 deletion

File tree

lib/matplotlib/axes.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4415,6 +4415,10 @@ def spy(self, Z, precision=None, marker=None, markersize=None,
44154415
number to specify the aspect ratio of an array element
44164416
directly.
44174417
4418+
Two plotting styles are available: image or marker. Both
4419+
are available for full arrays, but only the marker style
4420+
works for scipy.sparse.spmatrix instances.
4421+
44184422
If marker and markersize are None, an image will be
44194423
returned and any remaining kwargs are passed to imshow;
44204424
else, a Line2D object will be returned with the value
@@ -4442,6 +4446,8 @@ def spy(self, Z, precision=None, marker=None, markersize=None,
44424446
44434447
"""
44444448
if marker is None and markersize is None:
4449+
if hasattr(Z, 'tocoo'):
4450+
raise TypeError, "Image mode does not support scipy.sparse arrays"
44454451
Z = asarray(Z)
44464452
if precision is None: mask = Z!=0.
44474453
else: mask = absolute(Z)>precision

src/cntr.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1612,7 +1612,8 @@ Cntr_init(Cntr *self, PyObject *args, PyObject *kwds)
16121612
if (xpa == NULL || ypa == NULL || zpa == NULL || (marg && mpa == NULL))
16131613
{
16141614
PyErr_SetString(PyExc_ValueError,
1615-
"Arguments x, y, z, mask (if present) must be 2D arrays.");
1615+
"Arguments x, y, z, mask (if present) must be 2D arrays.\n"
1616+
"x, y, z must be castable to double.");
16161617
goto error;
16171618
}
16181619
iMax = zpa->dimensions[1];

0 commit comments

Comments
 (0)