[pypy-commit] pypy mro-reorder-numpypy-str: fix, make to_str() independent of self

mattip noreply at buildbot.pypy.org
Fri Aug 2 05:19:00 CEST 2013


Author: Matti Picus <matti.picus at gmail.com>
Branch: mro-reorder-numpypy-str
Changeset: r65887:0e0cfbd7c508
Date: 2013-08-02 06:17 +0300
http://bitbucket.org/pypy/pypy/changeset/0e0cfbd7c508/

Log:	fix, make to_str() independent of self

diff --git a/pypy/module/micronumpy/test/test_numarray.py b/pypy/module/micronumpy/test/test_numarray.py
--- a/pypy/module/micronumpy/test/test_numarray.py
+++ b/pypy/module/micronumpy/test/test_numarray.py
@@ -2761,9 +2761,9 @@
 
     def test_to_str(self):
         from numpypy import array
-        a = array(['abc', 'def', 'ab'], 'S3')
-        b = array(['abcdef', 'ab', 'cd'])
-        assert b[0] != a[0]
+        a = array(['abc','abc', 'def', 'ab'], 'S3')
+        b = array(['mnopqr','abcdef', 'ab', 'cd'])
+        assert b[1] != a[1]
 
     def test_string_scalar(self):
         from numpypy import array
diff --git a/pypy/module/micronumpy/types.py b/pypy/module/micronumpy/types.py
--- a/pypy/module/micronumpy/types.py
+++ b/pypy/module/micronumpy/types.py
@@ -1723,6 +1723,7 @@
     @jit.unroll_safe
     def store(self, arr, i, offset, box):
         assert isinstance(box, interp_boxes.W_StringBox)
+        # XXX simplify to range(box.dtype.get_size()) ?
         for k in range(min(self.size, box.arr.size-offset)):
             arr.storage[k + i] = box.arr.storage[k + offset]
 
@@ -1736,7 +1737,7 @@
         builder = StringBuilder()
         assert isinstance(item, interp_boxes.W_StringBox)
         i = item.ofs
-        end = i + min(self.size, item.arr.size)
+        end = i + item.dtype.get_size()
         while i < end:
             assert isinstance(item.arr.storage[i], str)
             if item.arr.storage[i] == '\x00':
@@ -1762,7 +1763,6 @@
 
     @str_binary_op
     def ne(self, v1, v2):
-        print 'string neq',v1,v2
         return v1 != v2
 
     @str_binary_op
@@ -1798,7 +1798,6 @@
         return bool(v1) ^ bool(v2)
 
     def bool(self, v):
-        print 'string bool',v
         return bool(self.to_str(v))
 
     def build_and_convert(self, space, mydtype, box):


More information about the pypy-commit mailing list