Commits

Maciej Fijalkowski  committed c14c527

minor tests and fixes

  • Participants
  • Parent commits 6bed352

Comments (0)

Files changed (3)

File pypy/module/micronumpy/__init__.py

         'int_': 'interp_boxes.W_LongBox',
         'inexact': 'interp_boxes.W_InexactBox',
         'floating': 'interp_boxes.W_FloatingBox',
+        'float_': 'interp_boxes.W_Float64Box',
         'float32': 'interp_boxes.W_Float32Box',
         'float64': 'interp_boxes.W_Float64Box',
     }

File pypy/module/micronumpy/interp_boxes.py

     descr_sub = _binop_impl("subtract")
     descr_mul = _binop_impl("multiply")
     descr_div = _binop_impl("divide")
+    descr_pow = _binop_impl("power")
     descr_eq = _binop_impl("equal")
     descr_ne = _binop_impl("not_equal")
     descr_lt = _binop_impl("less")
     _attrs_ = ()
 
 class W_IntegerBox(W_NumberBox):
-    pass
+    descr__new__, get_dtype = new_dtype_getter("long")
 
 class W_SignedIntegerBox(W_IntegerBox):
     pass
     __sub__ = interp2app(W_GenericBox.descr_sub),
     __mul__ = interp2app(W_GenericBox.descr_mul),
     __div__ = interp2app(W_GenericBox.descr_div),
+    __pow__ = interp2app(W_GenericBox.descr_pow),
 
     __radd__ = interp2app(W_GenericBox.descr_radd),
     __rsub__ = interp2app(W_GenericBox.descr_rsub),
 )
 
 W_IntegerBox.typedef = TypeDef("integer", W_NumberBox.typedef,
+    __new__ = interp2app(W_IntegerBox.descr__new__.im_func),
     __module__ = "numpypy",
 )
 

File pypy/module/micronumpy/test/test_dtypes.py

         # You can't subclass dtype
         raises(TypeError, type, "Foo", (dtype,), {})
 
+    def test_new(self):
+        import _numpypy as np
+        assert np.int_(4) == 4
+        assert np.float_(3.4) == 3.4
+
+    def test_pow(self):
+        from _numpypy import int_
+        assert int_(4) ** 2 == 16
+
 class AppTestTypes(BaseNumpyAppTest):
     def test_abstract_types(self):
         import _numpypy as numpy