[Scipy-svn] r3026 - in trunk/Lib: interpolate io

scipy-svn@scip... scipy-svn@scip...
Mon May 21 20:49:53 CDT 2007


Author: oliphant
Date: 2007-05-21 20:49:39 -0500 (Mon, 21 May 2007)
New Revision: 3026

Modified:
   trunk/Lib/interpolate/interpolate.py
   trunk/Lib/io/netcdf.py
Log:
Fix up some spline work.  Add place-holder for netcdf write capability.

Modified: trunk/Lib/interpolate/interpolate.py
===================================================================
--- trunk/Lib/interpolate/interpolate.py	2007-05-22 00:09:59 UTC (rev 3025)
+++ trunk/Lib/interpolate/interpolate.py	2007-05-22 01:49:39 UTC (rev 3026)
@@ -553,7 +553,7 @@
     return ppform([c3,c2,c1,c0], xk)
 
 def splmake(xk,yk,order=3,kind='not-a-knot',conds=None):
-    """Return an (mk,xk,yk) representation of a spline given
+    """Return an (mk,xk,yk,order) representation of a spline given
     data-points
 
     yk can be an N-d array to represent more than one curve, through
@@ -603,9 +603,9 @@
 def spltopp(mk,xk,yk,order=3):
     return eval('_sp%dtopp'%order)(mk,xk,yk)
 
-def spline(xk,yk,xnew,order=3,kwds='not-a-knot',conds=None):
+def spline(xk,yk,xnew,order=3,kind='not-a-knot',conds=None):
     func = eval('_sp%deval'%order)
-    return func(splmake(xk,yk,order=order,kind=kind,conds=conds),xnew)
+    return func(splmake(xk,yk,order=order,kind=kind,conds=conds)[:-1],xnew)
 
 def _sp2topp(zk,xk,yk):
     dk = xk[1:]-xk[:-1]
@@ -626,7 +626,7 @@
     res *= d
     res += zk0
     res *= d
-    res += wk[indxs]
+    res += yk[indxs]
     return res
     
 def _sp4topp(mk,xk,yk):

Modified: trunk/Lib/io/netcdf.py
===================================================================
--- trunk/Lib/io/netcdf.py	2007-05-22 00:09:59 UTC (rev 3025)
+++ trunk/Lib/io/netcdf.py	2007-05-22 01:49:39 UTC (rev 3026)
@@ -37,10 +37,29 @@
 class netcdf_file(object):
     """A NetCDF file parser."""
 
-    def __init__(self, file):
-        self._buffer = open(file, 'rb')
-        self._parse()
+    def __init__(self, file, mode):
+        mode += 'b'
+        self._buffer = open(file, mode)
+        if mode in ['rb', 'r+b']:
+            self._parse()
+        elif mode == 'ab':
+            raise NotImplementedError
 
+    def flush(self):
+        pass
+
+    def sync(self):
+        pass
+
+    def close(self):
+        pass
+
+    def create_dimension(self, name, length):
+        pass
+
+    def create_variable(self, name, type, dimensions):
+        pass
+
     def read(self, size=-1):
         """Alias for reading the file buffer."""
         return self._buffer.read(size)
@@ -225,6 +244,11 @@
         if isrec:
             # Record variables are not stored contiguosly on disk, so we 
             # need to create a separate array for each record.
+            #
+            # TEO:  This will copy data from the newly-created array
+            #  into the __array_data__ region, thus removing any benefit of using
+            #  a memory-mapped file.  You might as well just read the data
+            #  in directly. 
             self.__array_data__ = zeros(shape, dtype)
             bytes += (shape[0] - 1) * recsize
             for n in range(shape[0]):
@@ -250,6 +274,10 @@
         """For scalars."""
         return self.__array_data__.item()
 
+    def assignValue(self, value):
+        """For scalars."""
+        self.__array_data__.itemset(value)
+    
     def typecode(self):
         return ['b', 'c', 'h', 'i', 'f', 'd'][self._nc_type-1]
 



More information about the Scipy-svn mailing list