[Scipy-svn] r2034 - trunk/Lib/weave/examples

scipy-svn at scipy.org scipy-svn at scipy.org
Mon Jul 3 18:32:49 EDT 2006


Author: oliphant
Date: 2006-07-03 17:32:46 -0500 (Mon, 03 Jul 2006)
New Revision: 2034

Modified:
   trunk/Lib/weave/examples/cast_copy_transpose.py
   trunk/Lib/weave/examples/ramp2.py
Log:
Fix usage of Float64

Modified: trunk/Lib/weave/examples/cast_copy_transpose.py
===================================================================
--- trunk/Lib/weave/examples/cast_copy_transpose.py	2006-06-30 20:52:56 UTC (rev 2033)
+++ trunk/Lib/weave/examples/cast_copy_transpose.py	2006-07-03 22:32:46 UTC (rev 2034)
@@ -20,7 +20,7 @@
 sys.path.insert(0,'..')
 import scipy.weave.inline_tools as inline_tools
 import scipy.weave.c_spec as c_spec
-from weave.converters import blitz as cblitz
+from scipy.weave.converters import blitz as cblitz
 
 def _cast_copy_transpose(type,a_2d):
     assert(len(shape(a_2d)) == 2)
@@ -58,7 +58,7 @@
 
 def _inplace_transpose(a_2d):
     assert(len(shape(a_2d)) == 2)
-    numeric_type = c_spec.num_to_c_types[a_2d.typecode()]
+    numeric_type = c_spec.num_to_c_types[a_2d.dtype.char]
     code = """
            %s temp;
            for(int i = 0; i < Na_2d[0]; i++)
@@ -120,6 +120,7 @@
 
 def _castCopyAndTranspose(type, *arrays):
     cast_arrays = ()
+    import copy
     for a in arrays:
         if a.dtype == numpy.dtype(type):
             cast_arrays = cast_arrays + (copy.copy(numpy.transpose(a)),)
@@ -135,8 +136,8 @@
 
 
 def compare(m,n):
-    a = ones((n,n),Float64)
-    type = Float32
+    a = ones((n,n),float64)
+    type = float32
     print 'Cast/Copy/Transposing (%d,%d)array %d times' % (n,n,m)
     t1 = time.time()
     for i in range(m):

Modified: trunk/Lib/weave/examples/ramp2.py
===================================================================
--- trunk/Lib/weave/examples/ramp2.py	2006-06-30 20:52:56 UTC (rev 2033)
+++ trunk/Lib/weave/examples/ramp2.py	2006-07-03 22:32:46 UTC (rev 2034)
@@ -19,7 +19,7 @@
     mod = ext_tools.ext_module('ramp_ext')
 
     # type declarations
-    result = array([0],float)
+    result = array([0],float64)
     start,end = 0.,0.
     code = """
            const int size = Nresult[0];
@@ -51,7 +51,7 @@
     except:
         build_ramp_ext()
         import ramp_ext
-    arr = array([0]*10000,float)
+    arr = array([0]*10000,float64)
     for i in xrange(10000):
         ramp_ext.Ramp(arr, 0.0, 1.0)
     t2 = time.time()




More information about the Scipy-svn mailing list