Author: Romain Guillebert <romain...@gmail.com>
Branch: numpy-pickle
Changeset: r64540:b52f6e59e41a
Date: 2013-05-24 16:57 +0200
http://bitbucket.org/pypy/pypy/changeset/b52f6e59e41a/

Log:    Test more

diff --git a/pypy/module/micronumpy/__init__.py 
b/pypy/module/micronumpy/__init__.py
--- a/pypy/module/micronumpy/__init__.py
+++ b/pypy/module/micronumpy/__init__.py
@@ -13,6 +13,7 @@
         'empty': 'interp_numarray.zeros',
         'ones': 'interp_numarray.ones',
         '_reconstruct' : 'interp_numarray._reconstruct',
+        'scalar' : 'interp_numarray.scalar',
         'dot': 'interp_arrayops.dot',
         'fromstring': 'interp_support.fromstring',
         'flatiter': 'interp_flatiter.W_FlatIterator',
diff --git a/pypy/module/micronumpy/interp_numarray.py 
b/pypy/module/micronumpy/interp_numarray.py
--- a/pypy/module/micronumpy/interp_numarray.py
+++ b/pypy/module/micronumpy/interp_numarray.py
@@ -1051,6 +1051,9 @@
 def _reconstruct(space, w_subtype, w_shape, w_dtype):
     return descr_new_array(space, w_subtype, w_shape, w_dtype)
 
+def scalar(space, w_dtype):
+    pass
+
 W_FlatIterator.typedef = TypeDef(
     'flatiter',
     __iter__ = interp2app(W_FlatIterator.descr_iter),
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
@@ -6,6 +6,15 @@
     def test_pickle(self):
         from numpypy import dtype, int32, float64, complex128
         from numpypy.core.multiarray import scalar
-        assert int32(1337).__reduce__() == (scalar, (dtype('int32'), 
'9\x05\x00\x00'))
-        assert float64(13.37).__reduce__() == (scalar, (dtype('float64'), 
'=\n\xd7\xa3p\xbd*@'))
-        assert complex128(13 + 37.j).__reduce__() == (scalar, 
(dtype('complex128'), '\x00\x00\x00\x00\x00\x00*@\x00\x00\x00\x00\x00\x80B@'))
+        from cPickle import loads, dumps
+        i = int32(1337)
+        f = float64(13.37)
+        c = complex128(13 + 37.j)
+
+        assert i.__reduce__() == (scalar, (dtype('int32'), '9\x05\x00\x00'))
+        assert f.__reduce__() == (scalar, (dtype('float64'), 
'=\n\xd7\xa3p\xbd*@'))
+        assert c.__reduce__() == (scalar, (dtype('complex128'), 
'\x00\x00\x00\x00\x00\x00*@\x00\x00\x00\x00\x00\x80B@'))
+
+        assert loads(dumps(i)) == i
+        assert loads(dumps(f)) == f
+        assert loads(dumps(c)) == c
_______________________________________________
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to