Commits

Romain Guillebert committed b52f6e5

Test more

Comments (0)

Files changed (3)

pypy/module/micronumpy/__init__.py

         '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',

pypy/module/micronumpy/interp_numarray.py

 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),

pypy/module/micronumpy/test/test_scalar.py

     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