Revision: 4393
          http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4393&view=rev
Author:   mdboom
Date:     2007-11-20 06:52:24 -0800 (Tue, 20 Nov 2007)

Log Message:
-----------
Merged revisions 4340-4392 via svnmerge from 
http://matplotlib.svn.sf.net/svnroot/matplotlib/trunk/matplotlib

........
  r4341 | jdh2358 | 2007-11-16 13:15:32 -0500 (Fri, 16 Nov 2007) | 2 lines
  
  removed a couple of pyc files
........
  r4346 | dsdale | 2007-11-16 16:47:17 -0500 (Fri, 16 Nov 2007) | 2 lines
  
  fixed version checking for traits-3
........
  r4347 | mdboom | 2007-11-17 07:44:52 -0500 (Sat, 17 Nov 2007) | 1 line
  
  Bugfix: [1655313] axis label disappears when minor tick labels are hidden
........
  r4374 | efiring | 2007-11-18 13:59:56 -0500 (Sun, 18 Nov 2007) | 11 lines
  
  Let to_rgba return uint8; track changes to cmap
  
  Images require rgba as 4 uint8s, so it is more efficient
  to generate these directly in to_rgba than to generate 4
  doubles and convert them later.
  
  The tracking of changes in ScalarMappable was handling
  communication between objects, but was not keeping track of
  when to_rgba needs to be rerun.  A dictionary was added
  to do this.
........
  r4375 | efiring | 2007-11-18 14:01:39 -0500 (Sun, 18 Nov 2007) | 2 lines
  
  Remove trailing whitespace.
........
  r4376 | efiring | 2007-11-18 14:02:55 -0500 (Sun, 18 Nov 2007) | 2 lines
  
  Use new update_dict from ScalarMappable in QuadMesh
........
  r4377 | efiring | 2007-11-18 14:06:49 -0500 (Sun, 18 Nov 2007) | 7 lines
  
  Add experimental "pcolorfast" for fast interactive pcolor plots
  
  This will need more discussion and work, but it illustrates
  the potential for very fast pcolor-type plotting with all
  three grid types: uniform, irregular but rectilinear, and
  general quadrilateral.
........
  r4379 | efiring | 2007-11-18 15:54:22 -0500 (Sun, 18 Nov 2007) | 2 lines
  
  Remove unnecessary data copying from draw_quad_mesh
........
  r4383 | jdh2358 | 2007-11-19 16:43:24 -0500 (Mon, 19 Nov 2007) | 2 lines
  
  fixed a minor bug in csv2rec
........
  r4387 | mdboom | 2007-11-20 08:13:22 -0500 (Tue, 20 Nov 2007) | 2 lines
  
  Speed improvement initializing mathtext parser.
........
  r4391 | mdboom | 2007-11-20 08:29:20 -0500 (Tue, 20 Nov 2007) | 2 lines
  
  Fix problem with 0-line width drawing in Postscript.  (Thanks Ben North).
........

Modified Paths:
--------------
    branches/transforms/lib/matplotlib/axes.py
    branches/transforms/lib/matplotlib/axis.py
    branches/transforms/lib/matplotlib/backends/backend_ps.py
    branches/transforms/lib/matplotlib/cm.py
    branches/transforms/lib/matplotlib/collections.py
    branches/transforms/lib/matplotlib/image.py
    branches/transforms/lib/matplotlib/mlab.py
    branches/transforms/lib/matplotlib/pyparsing.py
    branches/transforms/setupext.py

Property Changed:
----------------
    branches/transforms/


Property changes on: branches/transforms
___________________________________________________________________
Name: svnmerge-integrated
   - /trunk/matplotlib:1-4339
   + /trunk/matplotlib:1-4392

Modified: branches/transforms/lib/matplotlib/axes.py
===================================================================
--- branches/transforms/lib/matplotlib/axes.py  2007-11-20 13:50:04 UTC (rev 
4392)
+++ branches/transforms/lib/matplotlib/axes.py  2007-11-20 14:52:24 UTC (rev 
4393)
@@ -3774,8 +3774,8 @@
             xs = [thisx for thisx, b in zip(xs, mask) if b]
             ys = [thisy for thisy, b in zip(ys, mask) if b]
             return xs, ys
-            
 
+
         if capsize > 0:
             plot_kw = {
                 'ms':2*capsize,
@@ -3801,16 +3801,16 @@
                     # can't use numpy logical indexing since left and
                     # y are lists
                     leftlo, ylo = xywhere(left, y, xlolims)
-                    
+
                     caplines.extend( self.plot(leftlo, ylo, ls='None', 
marker=mlines.CARETLEFT, **plot_kw) )
                     xlolims = ~xlolims
-                    leftlo, ylo = xywhere(left, y, xlolims)                    
+                    leftlo, ylo = xywhere(left, y, xlolims)
                     caplines.extend( self.plot(leftlo, ylo, 'k|', **plot_kw) )
                 else:
                     caplines.extend( self.plot(left, y, 'k|', **plot_kw) )
 
                 if xuplims.any():
-                    
+
                     rightup, yup = xywhere(right, y, xuplims)
                     caplines.extend( self.plot(rightup,  yup, ls='None', 
marker=mlines.CARETRIGHT, **plot_kw) )
                     xuplims = ~xuplims
@@ -3843,7 +3843,7 @@
 
                 if uplims.any():
                     xup, upperup = xywhere(x, upper, uplims)
-                    
+
                     caplines.extend( self.plot(xup, upperup, ls='None', 
marker=mlines.CARETUP, **plot_kw) )
                     uplims = ~uplims
                     xup, upperup = xywhere(x, upper, uplims)
@@ -4835,6 +4835,177 @@
         return collection
     pcolormesh.__doc__ = cbook.dedent(pcolormesh.__doc__) % martist.kwdocd
 
+    def pcolorfast(self, *args, **kwargs):
+        """
+        Experimental; this is a version of pcolor that
+        does not draw lines, that provides the fastest
+        possible rendering with the Agg backend, and that
+        can handle any quadrilateral grid.
+
+        pcolor(*args, **kwargs): pseudocolor plot of a 2-D array
+
+        Function signatures
+
+          pcolor(C, **kwargs)
+          pcolor(xr, yr, C, **kwargs)
+          pcolor(x, y, C, **kwargs)
+          pcolor(X, Y, C, **kwargs)
+
+        C is the 2D array of color values corresponding to quadrilateral
+        cells. Let (nr, nc) be its shape.  C may be a masked array.
+
+        pcolor(C, **kwargs) is equivalent to
+        pcolor([0,nc], [0,nr], C, **kwargs)
+
+        xr, yr specify the ranges of x and y corresponding to the rectangular
+        region bounding C.  If xr = [x0, x1] and yr = [y0,y1] then
+        x goes from x0 to x1 as the second index of C goes from 0 to nc,
+        etc.  (x0, y0) is the outermost corner of cell (0,0), and (x1, y1)
+        is the outermost corner of cell (nr-1, nc-1).  All cells are
+        rectangles of the same size.  This is the fastest version.
+
+        x, y are 1D arrays of length nc+1 and nr+1, respectively, giving
+        the x and y boundaries of the cells.  Hence the cells are
+        rectangular but the grid may be nonuniform.  The speed is
+        intermediate.  (The grid is checked, and if found to be
+        uniform the fast version is used.)
+
+        X and Y are 2D arrays with shape (nr+1, nc+1) that specify
+        the (x,y) coordinates of the corners of the colored
+        quadrilaterals; the quadrilateral for C[i,j] has corners at
+        (X[i,j],Y[i,j]), (X[i,j+1],Y[i,j+1]), (X[i+1,j],Y[i+1,j]),
+        (X[i+1,j+1],Y[i+1,j+1]).  The cells need not be rectangular.
+        This is the most general, but the slowest to render.  It may
+        produce faster and more compact output using ps, pdf, and
+        svg backends, however.
+
+        Note that the the column index corresponds to the x-coordinate,
+        and the row index corresponds to y; for details, see
+        the "Grid Orientation" section below.
+
+        Optional keyword args are shown with their defaults below (you must
+        use kwargs for these):
+
+          * cmap = cm.jet : a cm Colormap instance from cm
+
+          * norm = Normalize() : mcolors.Normalize instance
+            is used to scale luminance data to 0,1.
+
+          * vmin=None and vmax=None : vmin and vmax are used in conjunction
+            with norm to normalize luminance data.  If either are None, the
+            min and max of the color array C is used.  If you pass a norm
+            instance, vmin and vmax will be None
+
+          * alpha=1.0 : the alpha blending value
+
+        Return value is an image if a regular or rectangular grid
+        is specified, and a QuadMesh collection in the general
+        quadrilateral case.
+
+        """
+
+        if not self._hold: self.cla()
+
+        alpha = kwargs.pop('alpha', 1.0)
+        norm = kwargs.pop('norm', None)
+        cmap = kwargs.pop('cmap', None)
+        vmin = kwargs.pop('vmin', None)
+        vmax = kwargs.pop('vmax', None)
+        if norm is not None: assert(isinstance(norm, mcolors.Normalize))
+        if cmap is not None: assert(isinstance(cmap, mcolors.Colormap))
+
+        C = args[-1]
+        nr, nc = C.shape
+        if len(args) == 1:
+            style = "image"
+            x = [0, nc+1]
+            y = [0, nr+1]
+        elif len(args) == 3:
+            x, y = args[:2]
+            x = npy.asarray(x)
+            y = npy.asarray(y)
+            if x.ndim == 1 and y.ndim == 1:
+                if x.size == 2 and y.size == 2:
+                    style = "image"
+                else:
+                    dx = npy.diff(x)
+                    dy = npy.diff(y)
+                    if (npy.ptp(dx) < 0.01*npy.abs(dx.mean()) and
+                        npy.ptp(dy) < 0.01*npy.abs(dy.mean())):
+                        style = "image"
+                    style = "pcolorimage"
+            elif x.ndim == 2 and y.ndim == 2:
+                style = "quadmesh"
+            else:
+                raise TypeError("arguments do not match valid signatures")
+        else:
+            raise TypeError("need 1 argument or 3 arguments")
+
+        if style == "quadmesh":
+
+            # convert to one dimensional arrays
+            # This should also be moved to the QuadMesh class
+            C = ma.ravel(C) # data point in each cell is value at lower left 
corner
+            X = x.ravel()
+            Y = y.ravel()
+            Nx = nc+1
+            Ny = nr+1
+
+            # The following needs to be cleaned up; the renderer
+            # requires separate contiguous arrays for X and Y,
+            # but the QuadMesh class requires the 2D array.
+            coords = npy.empty(((Nx * Ny), 2), npy.float64)
+            coords[:, 0] = X
+            coords[:, 1] = Y
+
+            # The QuadMesh class can also be changed to
+            # handle relevant superclass kwargs; the initializer
+            # should do much more than it does now.
+            collection = mcoll.QuadMesh(nc, nr, coords, 0)
+            collection.set_alpha(alpha)
+            collection.set_array(C)
+            collection.set_cmap(cmap)
+            collection.set_norm(norm)
+            self.add_collection(collection)
+            xl, xr, yb, yt = X.min(), X.max(), Y.min(), Y.max()
+            ret = collection
+
+        else:
+            # One of the image styles:
+            xl, xr, yb, yt = x[0], x[-1], y[0], y[-1]
+        if style == "image":
+
+            im = mimage.AxesImage(self, cmap, norm,
+                                        interpolation='nearest',
+                                        origin='lower',
+                                        extent=(xl, xr, yb, yt),
+                                         **kwargs)
+            im.set_data(C)
+            im.set_alpha(alpha)
+            self.images.append(im)
+            ret = im
+
+        if style == "pcolorimage":
+            im = mimage.PcolorImage(self, x, y, C,
+                                    cmap=cmap,
+                                    norm=norm,
+                                    alpha=alpha,
+                                    **kwargs)
+            self.images.append(im)
+            ret = im
+
+        self._set_artist_props(ret)
+        if vmin is not None or vmax is not None:
+            ret.set_clim(vmin, vmax)
+        else:
+            ret.autoscale_None()
+        self.update_datalim(npy.array([[xl, yb], [xr, yt]]))
+        self.autoscale_view(tight=True)
+        return ret
+
+
+
+
     def contour(self, *args, **kwargs):
         kwargs['filled'] = False
         return mcontour.ContourSet(self, *args, **kwargs)
@@ -4895,14 +5066,14 @@
         ticks on bottom and the returned axes will have ticks on the
         top
         """
-        
+
         ax2 = self.figure.add_axes(self.get_position(), sharey=self, 
frameon=False)
         ax2.xaxis.tick_top()
         ax2.xaxis.set_label_position('top')
         self.xaxis.tick_bottom()
         return ax2
-    
 
+
     #### Data analysis
 
 

Modified: branches/transforms/lib/matplotlib/axis.py
===================================================================
--- branches/transforms/lib/matplotlib/axis.py  2007-11-20 13:50:04 UTC (rev 
4392)
+++ branches/transforms/lib/matplotlib/axis.py  2007-11-20 14:52:24 UTC (rev 
4393)
@@ -620,10 +620,10 @@
             tick.set_label2(label)
 
             tick.draw(renderer)
-            if tick.label1On:
+            if tick.label1On and tick.label1.get_visible():
                 extent = tick.label1.get_window_extent(renderer)
                 ticklabelBoxes.append(extent)
-            if tick.label2On:
+            if tick.label2On and tick.label2.get_visible():
                 extent = tick.label2.get_window_extent(renderer)
                 ticklabelBoxes2.append(extent)
 

Modified: branches/transforms/lib/matplotlib/backends/backend_ps.py
===================================================================
--- branches/transforms/lib/matplotlib/backends/backend_ps.py   2007-11-20 
13:50:04 UTC (rev 4392)
+++ branches/transforms/lib/matplotlib/backends/backend_ps.py   2007-11-20 
14:52:24 UTC (rev 4393)
@@ -787,6 +787,9 @@
         if self.linewidth > 0 and stroke:
             self.set_color(*gc.get_rgb()[:3])
             write("stroke\n")
+        else:
+            write("newpath\n")
+
         if clippath:
             write("grestore\n")
         if cliprect:

Modified: branches/transforms/lib/matplotlib/cm.py
===================================================================
--- branches/transforms/lib/matplotlib/cm.py    2007-11-20 13:50:04 UTC (rev 
4392)
+++ branches/transforms/lib/matplotlib/cm.py    2007-11-20 14:52:24 UTC (rev 
4393)
@@ -40,6 +40,7 @@
         self.cmap = cmap
         self.observers = []
         self.colorbar = None
+        self.update_dict = {'array':False}
 
     def set_colorbar(self, im, ax):
         'set the colorbar image and axes associated with mappable'
@@ -47,11 +48,26 @@
 
     def to_rgba(self, x, alpha=1.0, bytes=False):
         '''Return a normalized rgba array corresponding to x.
-        If x is already an rgb or rgba array, return it unchanged.
+        If x is already an rgb array, insert alpha; if it is
+        already rgba, return it unchanged.
+        If bytes is True, return rgba as 4 uint8s instead of 4 floats.
         '''
         try:
-            if x.ndim == 3 and (x.shape[2] == 3 or x.shape[2] == 4):
-                return x
+            if x.ndim == 3:
+                if x.shape[2] == 3:
+                    if x.dtype == npy.uint8:
+                        alpha = npy.array(alpha*255, npy.uint8)
+                    m, n = npy.shape[:2]
+                    xx = npy.empty(shape=(m,n,4), dtype = x.dtype)
+                    xx[:,:,:3] = x
+                    xx[:,:,3] = alpha
+                elif x.shape[2] == 4:
+                    xx = x
+                else:
+                    raise ValueError("third dimension must be 3 or 4")
+                if bytes and xx.dtype != npy.uint8:
+                    xx = (xx * 255).astype(npy.uint8)
+                return xx
         except AttributeError:
             pass
         x = ma.asarray(x)
@@ -62,6 +78,7 @@
     def set_array(self, A):
         'Set the image array from numpy array A'
         self._A = A
+        self.update_dict['array'] = True
 
     def get_array(self):
         'Return the array'
@@ -124,7 +141,23 @@
         self.changed()
 
 
+    def add_checker(self, checker):
+        """
+        Add an entry to a dictionary of boolean flags
+        that are set to True when the mappable is changed.
+        """
+        self.update_dict[checker] = False
 
+    def check_update(self, checker):
+        """
+        If mappable has changed since the last check,
+        return True; else return False
+        """
+        if self.update_dict[checker]:
+            self.update_dict[checker] = False
+            return True
+        return False
+
     def add_observer(self, mappable):
         """
         whenever the norm, clim or cmap is set, call the notify
@@ -158,3 +191,6 @@
         """
         for observer in self.observers:
             observer.notify(self)
+        for key in self.update_dict:
+            self.update_dict[key] = True
+

Modified: branches/transforms/lib/matplotlib/collections.py
===================================================================
--- branches/transforms/lib/matplotlib/collections.py   2007-11-20 13:50:04 UTC 
(rev 4392)
+++ branches/transforms/lib/matplotlib/collections.py   2007-11-20 14:52:24 UTC 
(rev 4393)
@@ -441,7 +441,8 @@
         else:
             offsets = npy.asarray(offsets, npy.float_)
 
-        self.update_scalarmappable()
+        if self.check_update('array'):
+            self.update_scalarmappable()
 
         clippath, clippath_trans = self.get_transformed_clip_path_and_affine()
         if clippath_trans is not None:

Modified: branches/transforms/lib/matplotlib/image.py
===================================================================
--- branches/transforms/lib/matplotlib/image.py 2007-11-20 13:50:04 UTC (rev 
4392)
+++ branches/transforms/lib/matplotlib/image.py 2007-11-20 14:52:24 UTC (rev 
4393)
@@ -404,9 +404,107 @@
             raise RuntimeError('Cannot change colors after loading data')
         cm.ScalarMappable.set_cmap(self, norm)
 
+class PcolorImage(martist.Artist, cm.ScalarMappable):
+    def __init__(self, ax,
+                 x=None,
+                 y=None,
+                 A=None,
+                 cmap = None,
+                 norm = None,
+                 **kwargs
+                ):
+        """
+        cmap defaults to its rc setting
 
+        cmap is a colors.Colormap instance
+        norm is a colors.Normalize instance to map luminance to 0-1
 
+        Additional kwargs are matplotlib.artist properties
 
+        """
+        martist.Artist.__init__(self)
+        cm.ScalarMappable.__init__(self, norm, cmap)
+        self.axes = ax
+        self._rgbacache = None
+        self.update(kwargs)
+        self.set_data(x, y, A)
+
+    def make_image(self, magnification=1.0):
+        if self._A is None:
+            raise RuntimeError('You must first set the image array')
+        fc = self.axes.get_frame().get_facecolor()
+        bg = mcolors.colorConverter.to_rgba(fc, 0)
+        bg = (npy.array(bg)*255).astype(npy.uint8)
+        x0, y0, v_width, v_height = self.axes.viewLim.get_bounds()
+        l, b, width, height = self.axes.bbox.get_bounds()
+        width *= magnification
+        height *= magnification
+        if self.check_update('array'):
+            A = self.to_rgba(self._A, alpha=self._alpha, bytes=True)
+            self._rgbacache = A
+            if self._A.ndim == 2:
+                self.is_grayscale = self.cmap.is_gray()
+        else:
+            A = self._rgbacache
+        im = _image.pcolor2(self._Ax, self._Ay, A,
+                           height, width,
+                           (x0, x0+v_width, y0, y0+v_height),
+                           bg)
+        im.is_grayscale = self.is_grayscale
+        return im
+
+    def draw(self, renderer, *args, **kwargs):
+        if not self.get_visible(): return
+        im = self.make_image(renderer.get_image_magnification())
+        l, b, widthDisplay, heightDisplay = self.axes.bbox.get_bounds()
+        renderer.draw_image(l, b, im, self.axes.bbox)
+
+
+    def set_data(self, x, y, A):
+        A = ma.asarray(A)
+        if x is None:
+            x = npy.arange(0, A.shape[1]+1, dtype=npy.float64)
+        else:
+            x = npy.asarray(x, npy.float64).ravel()
+        if y is None:
+            y = npy.arange(0, A.shape[0]+1, dtype=npy.float64)
+        else:
+            y = npy.asarray(y, npy.float64).ravel()
+
+        if A.shape[:2] != (y.size-1, x.size-1):
+            print A.shape
+            print y.size
+            print x.size
+            raise ValueError("Axes don't match array shape")
+        if A.ndim not in [2, 3]:
+            raise ValueError("A must be 2D or 3D")
+        if A.ndim == 3 and A.shape[2] == 1:
+            A.shape = A.shape[:2]
+        self.is_grayscale = False
+        if A.ndim == 3:
+            if A.shape[2] in [3, 4]:
+                if (A[:,:,0] == A[:,:,1]).all() and (A[:,:,0] == 
A[:,:,2]).all():
+                    self.is_grayscale = True
+            else:
+                raise ValueError("3D arrays must have RGB or RGBA as last dim")
+        self._A = A
+        self._Ax = x
+        self._Ay = y
+        self.update_dict['array'] = True
+
+    def set_array(self, *args):
+        raise NotImplementedError('Method not supported')
+
+    def set_alpha(self, alpha):
+        """
+        Set the alpha value used for blending - not supported on
+        all backends
+
+        ACCEPTS: float
+        """
+        martist.Artist.set_alpha(self, alpha)
+        self.update_dict['array'] = True
+
 class FigureImage(martist.Artist, cm.ScalarMappable):
     def __init__(self, fig,
                  cmap = None,

Modified: branches/transforms/lib/matplotlib/mlab.py
===================================================================
--- branches/transforms/lib/matplotlib/mlab.py  2007-11-20 13:50:04 UTC (rev 
4392)
+++ branches/transforms/lib/matplotlib/mlab.py  2007-11-20 14:52:24 UTC (rev 
4393)
@@ -44,7 +44,7 @@
       compute it for a lot of pairs.  This function is optimized to do
       this efficiently by caching the direct FFTs.
 
-= record array helper functions = 
+= record array helper functions =
 
   rec2csv          : store record array in CSV file
   rec2excel        : store record array in excel worksheet - required 
pyExcelerator
@@ -1261,8 +1261,6 @@
         def splitfunc(x):
             return x.split(delimiter)
 
-            
-        
     converterseq = None
     for i,line in enumerate(fh):
         if i<skiprows: continue
@@ -1958,13 +1956,13 @@
     newrec[name] = arr
     return newrec.view(npy.recarray)
 
-  
+
 def rec_drop_fields(rec, names):
-    'return a new numpy record array with fields in names dropped'    
+    'return a new numpy record array with fields in names dropped'
 
     names = set(names)
     Nr = len(rec)
-    
+
     newdtype = npy.dtype([(name, rec.dtype[name]) for name in rec.dtype.names
                        if name not in names])
 
@@ -1974,7 +1972,7 @@
 
     return newrec.view(npy.recarray)
 
-    
+
 def rec_join(key, r1, r2):
     """
     join record arrays r1 and r2 on key; key is a tuple of field
@@ -1992,15 +1990,15 @@
     def makekey(row):
         return tuple([row[name] for name in key])
 
-  
+
     names = list(r1.dtype.names) + [name for name in r2.dtype.names if name 
not in set(r1.dtype.names)]
- 
 
-    
-    r1d = dict([(makekey(row),i) for i,row in enumerate(r1)])        
+
+
+    r1d = dict([(makekey(row),i) for i,row in enumerate(r1)])
     r2d = dict([(makekey(row),i) for i,row in enumerate(r2)])
 
-    r1keys = set(r1d.keys())    
+    r1keys = set(r1d.keys())
     r2keys = set(r2d.keys())
 
     keys = r1keys & r2keys
@@ -2008,7 +2006,7 @@
     r1ind = [r1d[k] for k in keys]
     r2ind = [r2d[k] for k in keys]
 
-    
+
     r1 = r1[r1ind]
     r2 = r2[r2ind]
 
@@ -2028,15 +2026,15 @@
         else:
             return (name, dt2.descr[0][1])
 
-        
-        
+
+
     keydesc = [key_desc(name) for name in key]
 
     newdtype = npy.dtype(keydesc +
                          [desc for desc in r1.dtype.descr if desc[0] not in 
key ] +
                          [desc for desc in r2.dtype.descr if desc[0] not in 
key ] )
-                         
-    
+
+
     newrec = npy.empty(len(r1), dtype=newdtype)
     for field in r1.dtype.names:
         newrec[field] = r1[field]
@@ -2089,7 +2087,7 @@
 
     fh = cbook.to_filehandle(fname)
 
-    
+
     class FH:
         """
         for space delimited files, we want different behavior than
@@ -2115,13 +2113,13 @@
             return self.fix(self.fh.next())
 
         def __iter__(self):
-            for line in self.fh:            
+            for line in self.fh:
                 yield self.fix(line)
 
     if delimiter==' ':
         fh = FH(fh)
 
-    reader = csv.reader(fh, delimiter=delimiter)        
+    reader = csv.reader(fh, delimiter=delimiter)
     def process_skiprows(reader):
         if skiprows:
             for i, row in enumerate(reader):
@@ -2155,7 +2153,7 @@
         'file' : 'file_',
         'print' : 'print_',
         }
-        
+
     def get_converters(reader):
 
         converters = None
@@ -2209,6 +2207,7 @@
 
     # reset the reader and start over
     fh.seek(0)
+    reader = csv.reader(fh, delimiter=delimiter)
     process_skiprows(reader)
     if needheader:
         skipheader = reader.next()
@@ -2232,7 +2231,7 @@
 class FormatObj:
     def tostr(self, x):
         return self.toval(x)
-    
+
     def toval(self, x):
         return str(x)
 
@@ -2255,12 +2254,12 @@
         FormatFormatStr.__init__(self, '%%1.%df'%precision)
         self.precision = precision
         self.scale = scale
-        
+
     def toval(self, x):
         if x is not None:
             x = x * self.scale
         return x
-    
+
 class FormatInt(FormatObj):
     def toval(self, x):
         return x
@@ -2292,20 +2291,20 @@
 
 
 defaultformatd = {
-    npy.int16 : FormatInt(),                
+    npy.int16 : FormatInt(),
     npy.int32 : FormatInt(),
-    npy.int64 : FormatInt(),        
+    npy.int64 : FormatInt(),
     npy.float32 : FormatFloat(),
-    npy.float64 : FormatFloat(),        
+    npy.float64 : FormatFloat(),
     npy.object_ : FormatObj(),
-    npy.string_ : FormatObj(),        
+    npy.string_ : FormatObj(),
     }
 
 def get_formatd(r, formatd=None):
     'build a formatd guaranteed to have a key for every dtype name'
     if formatd is None:
         formatd = dict()
-    
+
     for i, name in enumerate(r.dtype.names):
         dt = r.dtype[name]
         format = formatd.get(name)
@@ -2316,7 +2315,7 @@
 
 def csvformat_factory(format):
     format = copy.deepcopy(format)
-    if isinstance(format, FormatFloat):            
+    if isinstance(format, FormatFloat):
         format.scale = 1. # override scaling for storage
         format.fmt = '%g' # maximal precision
     return format
@@ -2358,14 +2357,14 @@
         """
         format = copy.deepcopy(format)
 
-        
-        
+
+
         xlstyle = excel.XFStyle()
-        if isinstance(format, FormatFloat):            
+        if isinstance(format, FormatFloat):
             zeros = ''.join(['0']*format.precision)
             xlstyle.num_format_str = '#,##0.%s;[RED]-#,##0.%s'%(zeros, zeros)
         elif isinstance(format, FormatInt):
-            xlstyle.num_format_str = '#,##;[RED]-#,##'        
+            xlstyle.num_format_str = '#,##;[RED]-#,##'
         elif isinstance(format, FormatPercent):
             zeros = ''.join(['0']*format.precision)
             xlstyle.num_format_str = '0.%s%;[RED]-0.%s%'%(zeros, zeros)
@@ -2374,7 +2373,7 @@
             xlstyle = None
 
         format.xlstyle = xlstyle
-        
+
         return format
 
     def rec2excel(r, ws, formatd=None, rownum=0):
@@ -2412,7 +2411,7 @@
 
         rownum+=1
 
-            
+
         ind = npy.arange(len(r.dtype.names))
         for row in r:
             for i in ind:
@@ -2470,7 +2469,7 @@
                     cell.set_property('foreground', 'black')
 
 
-        if isinstance(format, FormatFloat) or isinstance(format, FormatInt):   
         
+        if isinstance(format, FormatFloat) or isinstance(format, FormatInt):
             format.cell = negative_red_cell
             format.xalign = 1.
         elif isinstance(format, FormatDate):
@@ -2573,7 +2572,7 @@
             self.clear()
 
         def clear(self):
-            self.iterd = dict()  
+            self.iterd = dict()
             self.iters = []        # an ordered list of iters
             self.rownumd = dict()  # a map from rownum -> symbol
             self.model.clear()
@@ -2596,7 +2595,7 @@
                 thisiter = self.iterd[key]
                 self.model.remove(thisiter)
                 del self.datad[key]
-                del self.iterd[key] 
+                del self.iterd[key]
                 self.iters.remove(thisiter)
 
             for i, thisiter in enumerate(self.iters):
@@ -2611,7 +2610,7 @@
 
 
             del self.datad[key]
-            del self.iterd[key] 
+            del self.iterd[key]
             self.rownumd[len(self.iters)] = key
             self.iters.remove(thisiter)
 
@@ -2619,7 +2618,7 @@
                 if thiskey==key: del self.rownumd[rownum]
 
         def add_row(self, row):
-            thisiter = self.model.append()                
+            thisiter = self.model.append()
             self.model.set(thisiter, *self.flat(row))
             key = tuple(row)
             self.datad[key] = row
@@ -2702,7 +2701,7 @@
             win.add(scroll)
             win.show_all()
             scroll.win = win
-            
+
         return scroll
 
 

Modified: branches/transforms/lib/matplotlib/pyparsing.py
===================================================================
--- branches/transforms/lib/matplotlib/pyparsing.py     2007-11-20 13:50:04 UTC 
(rev 4392)
+++ branches/transforms/lib/matplotlib/pyparsing.py     2007-11-20 14:52:24 UTC 
(rev 4393)
@@ -2845,22 +2845,18 @@
     else:
         warnings.warn("Invalid argument to oneOf, expected string or list",
                 SyntaxWarning, stacklevel=2)
-        
+
+    symbols.sort(reverse=True)
     i = 0
     while i < len(symbols)-1:
         cur = symbols[i]
-        for j,other in enumerate(symbols[i+1:]):
+        for j, other in enumerate(symbols[i+1:]):
             if ( isequal(other, cur) ):
                 del symbols[i+j+1]
+            else:
                 break
-            elif ( masks(cur, other) ):
-                del symbols[i+j+1]
-                symbols.insert(i,other)
-                cur = other
-                break
-        else:
-            i += 1
-
+        i += 1
+    
     if not caseless and useRegex:
         #~ print strs,"->", "|".join( [ _escapeRegexChars(sym) for sym in 
symbols] )
         try:

Modified: branches/transforms/setupext.py
===================================================================
--- branches/transforms/setupext.py     2007-11-20 13:50:04 UTC (rev 4392)
+++ branches/transforms/setupext.py     2007-11-20 14:52:24 UTC (rev 4393)
@@ -466,11 +466,16 @@
             print_status("enthought.traits", "unknown and incompatible 
version: < 2.0")
             return False
         else:
-            if version.version.endswith('mpl'):
+            # traits 2 and 3 store their version strings in different places:
+            try:
+                version = version.version
+            except AttributeError:
+                version = version.__version__
+            if version.endswith('mpl'):
                 print_status("enthought.traits", "matplotlib will provide")
                 return True
             else:
-                print_status("enthought.traits", version.version)
+                print_status("enthought.traits", version)
                 return False
     except ImportError:
         if options['provide_traits']:


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: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Matplotlib-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-checkins

Reply via email to