[pypy-commit] pypy numpy-full-fromstring: Updated tests for bool, added tests for int, all tests pass on 32-bit and 64-bit

jterrace noreply at buildbot.pypy.org
Thu Dec 15 21:10:45 CET 2011


Author: Jeff Terrace <jterrace at gmail.com>
Branch: numpy-full-fromstring
Changeset: r50590:bca13f8d517c
Date: 2011-12-15 15:10 -0500
http://bitbucket.org/pypy/pypy/changeset/bca13f8d517c/

Log:	Updated tests for bool, added tests for int, all tests pass on
	32-bit and 64-bit

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
@@ -1200,6 +1200,7 @@
 
     def test_fromstring(self):
         from numpypy import fromstring, array, uint8, float32, int32
+        import sys
         a = fromstring(self.data)
         for i in range(4):
             assert a[i] == i + 1
@@ -1251,8 +1252,15 @@
         assert (q == [1.0]).all()
         r = fromstring("\x01\x00\x02", dtype='bool')
         assert (r == [True, False, True]).all()
-        s = fromstring("1,2,3,,5", dtype="bool", sep=",")
+        s = fromstring("1,2,3,,5", dtype=bool, sep=",")
         assert (s == [True, True, True, False, True]).all()
+        t = fromstring("", bool)
+        assert (t == []).all()
+        u = fromstring("\x01\x00\x00\x00\x00\x00\x00\x00", dtype=int)
+        if sys.maxint > 2 ** 31 - 1:
+            assert (u == [1]).all()
+        else:
+            assert (u == [1, 0]).all()
         
     def test_fromstring_types(self):
         from numpypy import fromstring
@@ -1270,7 +1278,7 @@
         e = fromstring('\xFF\xFF\xFF\xFF', dtype=int32)
         assert e[0] == -1
         f = fromstring('\xFF\xFF\xFF\xFF', dtype=uint32)
-        assert f[0] == 4294967295
+        assert repr(f[0]) == '4294967295'
         g = fromstring('\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF', dtype=int64)
         assert g[0] == -1
         h = fromstring(self.float32val, dtype=float32)
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
@@ -208,6 +208,7 @@
 
 class Integer(Primitive):
     _mixin_ = True
+    format_code = 'l'
 
     def _coerce(self, space, w_item):
         return self.box(space.int_w(space.call_function(space.w_int, w_item)))


More information about the pypy-commit mailing list