Hi all, these are just a couple of small fixes to the string support in
Numexpr, and a test case for the string copy operation.

For the base patches:

1.http://www.mail-archive.com/numpy-discussion@lists.sourceforge.net/msg01551.html
2.http://www.mail-archive.com/numpy-discussion@lists.sourceforge.net/msg02261.html

Cheers,

::

        Ivan Vilata i Balaguer   >qo<   http://www.carabos.com/
               Cárabos Coop. V.  V  V   Enjoy Data
                                  ""
Index: numexpr/tests/test_numexpr.py
===================================================================
--- numexpr/tests/test_numexpr.py.orig
+++ numexpr/tests/test_numexpr.py
@@ -326,10 +326,22 @@
         self.assertEqual(resnx.dtype.name, 'int64')
 
 class test_strings(NumpyTestCase):
-    str_array1 = array(['foo', 'bar', '', '  '])
-    str_array2 = array(['foo', '', 'x', ' '])
+    BLOCK_SIZE1 = 128
+    BLOCK_SIZE2 = 8
+    str_list1 = ['foo', 'bar', '', '  ']
+    str_list2 = ['foo', '', 'x', ' ']
+    str_nloops = len(str_list1) * (BLOCK_SIZE1 + BLOCK_SIZE2 + 1)
+    str_array1 = array(str_list1 * str_nloops)
+    str_array2 = array(str_list2 * str_nloops)
     str_constant = 'doodoo'
 
+    def check_compare_copy(self):
+        sarr = self.str_array1
+        expr = 'sarr'
+        res1 = eval(expr)
+        res2 = evaluate(expr)
+        assert_array_equal(res1, res2)
+
     def check_compare_array(self):
         sarr1 = self.str_array1
         sarr2 = self.str_array2
Index: numexpr/interpreter.c
===================================================================
--- numexpr/interpreter.c.orig
+++ numexpr/interpreter.c
@@ -317,6 +317,7 @@
             break;
         case OP_COPY_SS:
             if (n == 0 || n == 1) return 's';
+	    break;
         case OP_PROD_IIN:
         case OP_SUM_IIN:
             if (n == 0 || n == 1) return 'i';
@@ -1216,7 +1217,8 @@
             Py_INCREF(PyArray_DESCR(a));
             PyObject *b = PyArray_SimpleNewFromDescr(1, dims, PyArray_DESCR(a));
             if (!b) goto cleanup_and_exit;
-            self->memsteps[i+1] = self->memsizes[i+1] = PyArray_ITEMSIZE(a);
+            self->memsteps[i+1] = 0;
+            self->memsizes[i+1] = PyArray_ITEMSIZE(a);
             PyTuple_SET_ITEM(a_inputs, i+2*n_inputs, b);  /* steals reference */
             inputs[i] = PyArray_DATA(b);
             if (typecode == PyArray_BOOL) {

Attachment: signature.asc
Description: OpenPGP digital signature

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Numpy-discussion mailing list
Numpy-discussion@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/numpy-discussion

Reply via email to