Commits

Romain Guillebert committed 0c8318c

(mattip, rguillebert) Test int(array(1.5)) -> 1

Comments (0)

Files changed (2)

pypy/module/micronumpy/interp_numarray.py

         shape = self.get_shape()
         if len(shape) == 0:
             assert isinstance(self.implementation, scalar.Scalar)
-            return space.wrap(self.implementation.get_scalar_value())
+            return space.int(space.wrap(self.implementation.get_scalar_value()))
         if shape == [1]:
-            return self.descr_getitem(space, space.wrap(0))
+            return space.int(self.descr_getitem(space, space.wrap(0)))
         raise OperationError(space.w_TypeError, space.wrap("only length-1 arrays can be converted to Python scalars"))
 
 

pypy/module/micronumpy/test/test_numarray.py

         assert int(array(1)) == 1
         assert int(array([1])) == 1
         assert raises(TypeError, "int(array([1, 2]))")
+        assert int(array([1.5])) == 1
 
 
 class AppTestMultiDim(BaseNumpyAppTest):