|
From: <md...@us...> - 2008-10-20 14:16:11
|
Revision: 6283
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6283&view=rev
Author: mdboom
Date: 2008-10-20 14:16:05 +0000 (Mon, 20 Oct 2008)
Log Message:
-----------
[ 2173204 ] implot leaves environment unstable after bad image data
Report errors about invalid data sooner when using imshow.
Modified Paths:
--------------
trunk/matplotlib/lib/matplotlib/image.py
Modified: trunk/matplotlib/lib/matplotlib/image.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/image.py 2008-10-20 14:09:30 UTC (rev 6282)
+++ trunk/matplotlib/lib/matplotlib/image.py 2008-10-20 14:16:05 UTC (rev 6283)
@@ -285,6 +285,13 @@
else:
self._A = np.asarray(A) # assume array
+ if self._A.dtype != np.uint8 and not np.can_cast(self._A.dtype, np.float):
+ raise TypeError("Image data can not convert to float")
+
+ if (self._A.ndim not in (2, 3) or
+ (self._A.ndim == 3 and self._A.shape[-1] not in (3, 4))):
+ raise TypeError("Invalid dimensions for image data")
+
self._imcache =None
self._rgbacache = None
self._oldxslice = None
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|