Hi all, I've detected some small errors in the patches I sent some time
ago for adding Int64 and string support to numexpr (see
http://www.mail-archive.com/numpy-discussion%40lists.sourceforge.net/msg01551.html).
 Basically:

* ``numpy.string`` was accessed instead of ``numpy.string_`` (looks like
  one of those not-so-just-aesthetical last-time changes).
* The ``copy_args`` argument to ``evaluate()`` and others was no longer
  needed since discontiguous/unaligned arrays are no longer a special
  case.

I have attached the necessary patch.  Bye!

::

        Ivan Vilata i Balaguer   >qo<   http://www.carabos.com/
               Cárabos Coop. V.  V  V   Enjoy Data
                                  ""
--- compiler.py.orig
+++ compiler.py
@@ -440,7 +440,7 @@
     return context
 
 
-def precompile(ex, signature=(), copy_args=(), **kwargs):
+def precompile(ex, signature=(), **kwargs):
     """Compile the expression to an intermediate form.
     """
     types = dict(signature)
@@ -455,12 +455,6 @@
 
     ast = expressionToAST(ex)
 
-    # Add a copy for strided or unaligned arrays
-    for a in ast.postorderWalk():
-        if a.astType == "variable" and a.value in copy_args:
-            newVar = ASTNode(*a.key())
-            a.astType, a.value, a.children = ('op', 'copy', (newVar,))
-
     if ex.astType not in ('op'):
         ast = ASTNode('op', value='copy', astKind=ex.astKind, children=(ast,))
 
@@ -503,7 +497,7 @@
     return threeAddrProgram, signature, tempsig, constants, input_names
 
 
-def numexpr(ex, signature=(), copy_args=(), **kwargs):
+def numexpr(ex, signature=(), **kwargs):
     """Compile an expression built using E.<variable> variables to a function.
 
     ex can also be specified as a string "2*a+3*b".
@@ -513,7 +507,7 @@
 
     """
     threeAddrProgram, inputsig, tempsig, constants, input_names = \
-                      precompile(ex, signature, copy_args, **kwargs)
+                      precompile(ex, signature, **kwargs)
     program = compileThreeAddrForm(threeAddrProgram)
     return interpreter.NumExpr(inputsig, tempsig, program, constants,
                                input_names)
@@ -567,7 +561,7 @@
         return float
     if issubclass(t, numpy.complexfloating):
         return complex
-    if issubclass(t, numpy.string):
+    if issubclass(t, numpy.string_):
        return str
     raise ValueError("unkown type %s" % a.dtype.name)
 
@@ -607,7 +601,6 @@
     if global_dict is None:
         global_dict = call_frame.f_globals
     arguments = []
-    copy_args = []
     for name in names:
         try:
             a = local_dict[name]
@@ -617,14 +610,13 @@
         arguments.append(numpy.asarray(a)) # don't make a data copy, if possible
     # Create a signature
     signature = [(name, getType(arg)) for (name, arg) in zip(names, arguments)]
-    # Look up numexpr if possible. copy_args *must* be added to the key,
-    # just in case a non-copy expression is already in cache.
-    numexpr_key = expr_key + (tuple(signature),) + tuple(copy_args)
+    # Look up numexpr if possible
+    numexpr_key = expr_key + (tuple(signature),)
     try:
         compiled_ex = _numexpr_cache[numexpr_key]
     except KeyError:
         compiled_ex = _numexpr_cache[numexpr_key] = \
-                      numexpr(ex, signature, copy_args, **kwargs)
+                      numexpr(ex, signature, **kwargs)
     return compiled_ex(*arguments)
 
 

Attachment: signature.asc
Description: OpenPGP digital signature

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Numpy-discussion mailing list
Numpy-discussion@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/numpy-discussion

Reply via email to