[pypy-commit] pypy remove-numpypy: port test_scalar

bdkearns noreply at buildbot.pypy.org
Tue Oct 29 23:42:34 CET 2013


Author: Brian Kearns <bdkearns at gmail.com>
Branch: remove-numpypy
Changeset: r67716:3f6b7f94ea32
Date: 2013-10-29 18:41 -0400
http://bitbucket.org/pypy/pypy/changeset/3f6b7f94ea32/

Log:	port test_scalar

diff --git a/pypy/module/micronumpy/test/test_scalar.py b/pypy/module/micronumpy/test/test_scalar.py
--- a/pypy/module/micronumpy/test/test_scalar.py
+++ b/pypy/module/micronumpy/test/test_scalar.py
@@ -4,12 +4,16 @@
     spaceconfig = dict(usemodules=["micronumpy", "binascii", "struct"])
 
     def test_pickle(self):
-        from numpypy import dtype, int32, float64, complex128, zeros, sum
-        from numpypy.core.multiarray import scalar
+        from numpypy import dtype, zeros
+        try:
+            from numpy.core.multiarray import scalar
+        except ImportError:
+            # running on dummy module
+            from numpy import scalar
         from cPickle import loads, dumps
-        i = int32(1337)
-        f = float64(13.37)
-        c = complex128(13 + 37.j)
+        i = dtype('int32').type(1337)
+        f = dtype('float64').type(13.37)
+        c = dtype('complex128').type(13 + 37.j)
 
         assert i.__reduce__() == (scalar, (dtype('int32'), '9\x05\x00\x00'))
         assert f.__reduce__() == (scalar, (dtype('float64'), '=\n\xd7\xa3p\xbd*@'))
@@ -20,14 +24,14 @@
         assert loads(dumps(c)) == c
 
         a = zeros(3)
-        assert loads(dumps(sum(a))) == sum(a)
+        assert loads(dumps(a.sum())) == a.sum()
 
     def test_round(self):
-        from numpypy import int32, float64, complex128, bool_
-        i = int32(1337)
-        f = float64(13.37)
-        c = complex128(13 + 37.j)
-        b = bool_(1)
+        import numpy as np
+        i = np.dtype('int32').type(1337)
+        f = np.dtype('float64').type(13.37)
+        c = np.dtype('complex128').type(13 + 37.j)
+        b = np.dtype('bool').type(1)
         assert i.round(decimals=-2) == 1300
         assert i.round(decimals=1) == 1337
         assert c.round() == c
@@ -39,5 +43,6 @@
 
     def test_attributes(self):
         import numpypy as np
-        assert np.int64(0).dtype == np.dtype('int64')
-        assert np.int64(0).itemsize == 8
+        value = np.dtype('int64').type(12345)
+        assert value.dtype == np.dtype('int64')
+        assert value.itemsize == 8


More information about the pypy-commit mailing list