[Scipy-svn] r2289 - in trunk/Lib/sandbox/numexpr: . tests

scipy-svn at scipy.org scipy-svn at scipy.org
Mon Oct 16 12:38:06 CDT 2006


Author: tim_hochberg
Date: 2006-10-16 12:38:02 -0500 (Mon, 16 Oct 2006)
New Revision: 2289

Modified:
   trunk/Lib/sandbox/numexpr/expressions.py
   trunk/Lib/sandbox/numexpr/tests/test_numexpr.py
Log:
Fix corner case identified Ivan Vilata i Balaguer where values we didn't know how to handle (e.g., list literals) yielded weird results.

Modified: trunk/Lib/sandbox/numexpr/expressions.py
===================================================================
--- trunk/Lib/sandbox/numexpr/expressions.py	2006-10-16 06:48:38 UTC (rev 2288)
+++ trunk/Lib/sandbox/numexpr/expressions.py	2006-10-16 17:38:02 UTC (rev 2289)
@@ -32,8 +32,8 @@
         for i, x in enumerate(args):
             if isConstant(x):
                 args[i] = x = ConstantNode(x)
-            if not isinstance(x, ExpressionNode):
-                return NotImplemented
+            elif not isinstance(x, ExpressionNode):
+                raise TypeError( "unsupported object type: %s" % type(x) )
         return f(*args)
     func.__name__ = f.__name__
     func.__doc__ = f.__doc__

Modified: trunk/Lib/sandbox/numexpr/tests/test_numexpr.py
===================================================================
--- trunk/Lib/sandbox/numexpr/tests/test_numexpr.py	2006-10-16 06:48:38 UTC (rev 2288)
+++ trunk/Lib/sandbox/numexpr/tests/test_numexpr.py	2006-10-16 17:38:02 UTC (rev 2289)
@@ -170,8 +170,16 @@
         expr = numexpr("2*a+3*b",[('a',float),('b', float)])
         assert_array_equal(expr(a,b), expr.run(a,b))
         
+    def check_illegal_value(self):
+        a = arange(3)
+        try:
+            evaluate("a < [0, 0, 0]")
+        except TypeError:
+            pass
+        else:
+            self.fail()
+            
 
-
 tests = [
 ('MISC', ['b*c+d*e',
           '2*a+3*b',



More information about the Scipy-svn mailing list