[Scipy-svn] r4649 - in branches/sandbox/scipy/sandbox/mkufunc: . examples mkufunc

scipy-svn@scip... scipy-svn@scip...
Mon Aug 18 00:37:28 CDT 2008


Author: ilan
Date: 2008-08-18 00:37:28 -0500 (Mon, 18 Aug 2008)
New Revision: 4649

Modified:
   branches/sandbox/scipy/sandbox/mkufunc/TODO.txt
   branches/sandbox/scipy/sandbox/mkufunc/examples/benchmark.py
   branches/sandbox/scipy/sandbox/mkufunc/examples/mandel_c.py
   branches/sandbox/scipy/sandbox/mkufunc/examples/mandel_py.py
   branches/sandbox/scipy/sandbox/mkufunc/mkufunc/api.py
   branches/sandbox/scipy/sandbox/mkufunc/mkufunc/test_func_hash.py
   branches/sandbox/scipy/sandbox/mkufunc/mkufunc/test_mkufunc.py
   branches/sandbox/scipy/sandbox/mkufunc/setup.py
Log:
Made things work with Python 2.4 and added items to TODO

Modified: branches/sandbox/scipy/sandbox/mkufunc/TODO.txt
===================================================================
--- branches/sandbox/scipy/sandbox/mkufunc/TODO.txt	2008-08-17 00:34:27 UTC (rev 4648)
+++ branches/sandbox/scipy/sandbox/mkufunc/TODO.txt	2008-08-18 05:37:28 UTC (rev 4649)
@@ -7,3 +7,9 @@
 
 - add Csrc attribute to ufunc object
 
+
+- improved function hash
+
+- rename to fast_vectorize
+
+- which python version should this work with?

Modified: branches/sandbox/scipy/sandbox/mkufunc/examples/benchmark.py
===================================================================
--- branches/sandbox/scipy/sandbox/mkufunc/examples/benchmark.py	2008-08-17 00:34:27 UTC (rev 4648)
+++ branches/sandbox/scipy/sandbox/mkufunc/examples/benchmark.py	2008-08-18 05:37:28 UTC (rev 4649)
@@ -1,6 +1,7 @@
 #!/usr/bin/env python
 from math import sin, cos
-import time, hashlib
+import time
+import md5
 
 from numpy import linspace, vectorize, allclose, empty_like
 from scipy import weave
@@ -51,7 +52,7 @@
 ufunc_info = weave.base_info.custom_info()
 ufunc_info.add_header('"numpy/ufuncobject.h"')
 
-ufunc = weave.inline('/*' + hashlib.md5(support_code).hexdigest() + '''*/
+ufunc = weave.inline('/*' + md5.md5(support_code).hexdigest() + '''*/
 import_ufunc();
 
 return_val = PyUFunc_FromFuncAndData(

Modified: branches/sandbox/scipy/sandbox/mkufunc/examples/mandel_c.py
===================================================================
--- branches/sandbox/scipy/sandbox/mkufunc/examples/mandel_c.py	2008-08-17 00:34:27 UTC (rev 4648)
+++ branches/sandbox/scipy/sandbox/mkufunc/examples/mandel_c.py	2008-08-18 05:37:28 UTC (rev 4649)
@@ -1,5 +1,5 @@
 #!/usr/bin/env python
-import hashlib
+import md5
 
 from numpy import array
 from scipy import weave
@@ -53,7 +53,7 @@
 ufunc_info = weave.base_info.custom_info()
 ufunc_info.add_header('"numpy/ufuncobject.h"')
 
-mandel = weave.inline('/*' + hashlib.md5(support_code).hexdigest() + '''*/
+mandel = weave.inline('/*' + md5.md5(support_code).hexdigest() + '''*/
 import_ufunc();
 
 return_val = PyUFunc_FromFuncAndData(
@@ -78,5 +78,5 @@
     assert mandel(-1, .3) == 36
     assert mandel(0, 0) == -1
     assert mandel(10, 10) == 1
-    assert all(mandel(array([-1, 0, 10]), array([.3, 0, 10])) ==
-               array([36, -1,  1]))
+    assert (mandel(array([-1, 0, 10]), array([.3, 0, 10])) ==
+            array([36, -1,  1])).all()

Modified: branches/sandbox/scipy/sandbox/mkufunc/examples/mandel_py.py
===================================================================
--- branches/sandbox/scipy/sandbox/mkufunc/examples/mandel_py.py	2008-08-17 00:34:27 UTC (rev 4648)
+++ branches/sandbox/scipy/sandbox/mkufunc/examples/mandel_py.py	2008-08-18 05:37:28 UTC (rev 4649)
@@ -27,5 +27,6 @@
     assert mandel(-1, .3) == 36
     assert mandel(0, 0) == -1
     assert mandel(10, 10) == 1
-    assert all(mandel(array([-1, 0, 10]), array([.3, 0, 10])) ==
-               array([36, -1,  1]))
+    assert (mandel(array([-1, 0, 10]), array([.3, 0, 10])) ==
+            array([36, -1,  1])).all()
+    

Modified: branches/sandbox/scipy/sandbox/mkufunc/mkufunc/api.py
===================================================================
--- branches/sandbox/scipy/sandbox/mkufunc/mkufunc/api.py	2008-08-17 00:34:27 UTC (rev 4648)
+++ branches/sandbox/scipy/sandbox/mkufunc/mkufunc/api.py	2008-08-18 05:37:28 UTC (rev 4649)
@@ -7,7 +7,7 @@
 import re
 import os, os.path
 import cStringIO
-import hashlib
+import md5
 from types import FunctionType
 
 import numpy
@@ -21,8 +21,7 @@
     """ Return a MD5 hash for a function object as string.
     """
     co = f.func_code
-    return hashlib.md5(co.co_code + repr(co.co_names) + repr(salt)
-                       ).hexdigest()
+    return md5.md5(co.co_code + repr(co.co_names) + repr(salt)).hexdigest()
 
 
 def translate(f, argtypes):

Modified: branches/sandbox/scipy/sandbox/mkufunc/mkufunc/test_func_hash.py
===================================================================
--- branches/sandbox/scipy/sandbox/mkufunc/mkufunc/test_func_hash.py	2008-08-17 00:34:27 UTC (rev 4648)
+++ branches/sandbox/scipy/sandbox/mkufunc/mkufunc/test_func_hash.py	2008-08-18 05:37:28 UTC (rev 4649)
@@ -1,6 +1,6 @@
 import unittest
 
-from mkufunc.api import func_hash
+from api import func_hash
 
 
 class Tests(unittest.TestCase):

Modified: branches/sandbox/scipy/sandbox/mkufunc/mkufunc/test_mkufunc.py
===================================================================
--- branches/sandbox/scipy/sandbox/mkufunc/mkufunc/test_mkufunc.py	2008-08-17 00:34:27 UTC (rev 4648)
+++ branches/sandbox/scipy/sandbox/mkufunc/mkufunc/test_mkufunc.py	2008-08-18 05:37:28 UTC (rev 4649)
@@ -243,8 +243,10 @@
         def f(i):
             return i % 5
 
-        self.assert_(all(f(range(7)) == array([0, 1, 2, 3, 4, 0, 1])))
-        self.assert_(all(f(arange(8)) == array([0, 1, 2, 3, 4, 0, 1, 2])))
+        for i in xrange(100):
+            self.assertEqual(f(i), i % 5)
+        
+        self.assert_((f(arange(8)) == array([0, 1, 2, 3, 4, 0, 1, 2])).all())
 
 
 class Control_Flow_Tests(unittest.TestCase):

Modified: branches/sandbox/scipy/sandbox/mkufunc/setup.py
===================================================================
--- branches/sandbox/scipy/sandbox/mkufunc/setup.py	2008-08-17 00:34:27 UTC (rev 4648)
+++ branches/sandbox/scipy/sandbox/mkufunc/setup.py	2008-08-18 05:37:28 UTC (rev 4649)
@@ -6,10 +6,9 @@
     description  = 'C compiled UFuncs from python source',
 
     name         = "mkufunc",
-    version      = "0.1",
-
+    
     zip_safe = False,
     package_data = {'': ['*.h']},
-    packages = find_packages(),
-    install_requires = ['scipy >= 0.6.0']
+    packages = find_packages()
+    #install_requires = ['scipy >= 0.6.0']
     )



More information about the Scipy-svn mailing list