Revision: 5802
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5802&view=rev
Author: efiring
Date: 2008-07-21 19:08:29 +0000 (Mon, 21 Jul 2008)
Log Message:
-----------
In image.py, ensure input can be ndarray or MaskedArray (Klaus Zimmerman).
Masked 2-D arrays are handled automatically by the color mapping
framework, so they need to be passed through; but there is no
point in converting 3-D arrays into masked arrays because there
is no support for dealing with a mask in that case.
Modified Paths:
--------------
trunk/matplotlib/CHANGELOG
trunk/matplotlib/lib/matplotlib/image.py
Modified: trunk/matplotlib/CHANGELOG
===================================================================
--- trunk/matplotlib/CHANGELOG 2008-07-21 12:58:53 UTC (rev 5801)
+++ trunk/matplotlib/CHANGELOG 2008-07-21 19:08:29 UTC (rev 5802)
@@ -1,3 +1,7 @@
+2008-07-21 Changed the "asarray" strategy in image.py so that
+ colormapping of masked input should work for all
+ image types (thanks Klaus Zimmerman) - EF
+
2008-07-20 Rewrote cbook.delete_masked_points and corresponding
unit test to support rgb color array inputs, datetime
inputs, etc. - EF
Modified: trunk/matplotlib/lib/matplotlib/image.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/image.py 2008-07-21 12:58:53 UTC (rev
5801)
+++ trunk/matplotlib/lib/matplotlib/image.py 2008-07-21 19:08:29 UTC (rev
5802)
@@ -272,10 +272,11 @@
ACCEPTS: numpy/PIL Image A"""
# check if data is PIL Image without importing Image
if hasattr(A,'getpixel'):
- X = pil_to_array(A)
+ self._A = pil_to_array(A)
+ elif ma.isMA(A):
+ self._A = A
else:
- X = ma.asarray(A) # assume array
- self._A = X
+ self._A = np.asarray(A) # assume array
self._imcache =None
self._rgbacache = None
@@ -408,7 +409,8 @@
def set_data(self, x, y, A):
x = np.asarray(x,np.float32)
y = np.asarray(y,np.float32)
- A = np.asarray(A)
+ if not ma.isMA(A):
+ A = np.asarray(A)
if len(x.shape) != 1 or len(y.shape) != 1\
or A.shape[0:2] != (y.shape[0], x.shape[0]):
raise TypeError("Axes don't match array shape")
@@ -535,7 +537,8 @@
def set_data(self, x, y, A):
- A = ma.asarray(A)
+ if not ma.isMA(A):
+ A = np.asarray(A)
if x is None:
x = np.arange(0, A.shape[1]+1, dtype=np.float64)
else:
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Matplotlib-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-checkins