Romain Guillebert avatar 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):
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.