Revision: 7288
          http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7288&view=rev
Author:   jswhit
Date:     2009-07-23 18:25:39 +0000 (Thu, 23 Jul 2009)

Log Message:
-----------
check for nonuniform grid spacing when using inter='linear' in griddata.
update griddata_demo.py (negative seeds not allowed in numpy svn mtrand)

Modified Paths:
--------------
    trunk/matplotlib/examples/pylab_examples/griddata_demo.py
    trunk/matplotlib/lib/matplotlib/mlab.py

Modified: trunk/matplotlib/examples/pylab_examples/griddata_demo.py
===================================================================
--- trunk/matplotlib/examples/pylab_examples/griddata_demo.py   2009-07-23 
12:10:18 UTC (rev 7287)
+++ trunk/matplotlib/examples/pylab_examples/griddata_demo.py   2009-07-23 
18:25:39 UTC (rev 7288)
@@ -4,7 +4,7 @@
 import numpy as np
 # make up data.
 #npts = int(raw_input('enter # of random points to plot:'))
-seed(-1)
+seed(0)
 npts = 200
 x = uniform(-2,2,npts)
 y = uniform(-2,2,npts)

Modified: trunk/matplotlib/lib/matplotlib/mlab.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/mlab.py     2009-07-23 12:10:18 UTC (rev 
7287)
+++ trunk/matplotlib/lib/matplotlib/mlab.py     2009-07-23 18:25:39 UTC (rev 
7288)
@@ -2717,6 +2717,14 @@
             interp = tri.nn_interpolator(z)
             zo = interp(xi,yi)
         elif interp == 'linear':
+            # make sure grid has constant dx, dy
+            dx = xi[0,1:]-xi[0,0:-1]
+            dy = yi[1:,0]-yi[0:-1,0]
+            epsx = np.finfo(xi.dtype).resolution
+            epsy = np.finfo(yi.dtype).resolution
+            if dx.max()-dx.min() > epsx or dy.max()-dy.min() > epsy:
+                raise ValueError("output grid must have constant spacing"
+                                 " when using interp='linear'")
             interp = tri.linear_interpolator(z)
             zo = interp[yi.min():yi.max():complex(0,yi.shape[0]),
                         xi.min():xi.max():complex(0,xi.shape[1])]


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

------------------------------------------------------------------------------
_______________________________________________
Matplotlib-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-checkins

Reply via email to