Author: mattip <[email protected]>
Branch: fix-result-types
Changeset: r77676:ed34be59182f
Date: 2015-05-29 09:14 +0300
http://bitbucket.org/pypy/pypy/changeset/ed34be59182f/

Log:    test, fix scalar indexing for -A compatability

diff --git a/pypy/module/micronumpy/boxes.py b/pypy/module/micronumpy/boxes.py
--- a/pypy/module/micronumpy/boxes.py
+++ b/pypy/module/micronumpy/boxes.py
@@ -180,10 +180,11 @@
 
     def descr_getitem(self, space, w_item):
         from pypy.module.micronumpy.base import convert_to_array
-        if space.is_w(w_item, space.w_Ellipsis) or \
-                (space.isinstance_w(w_item, space.w_tuple) and
+        if space.is_w(w_item, space.w_Ellipsis):
+            return convert_to_array(space, self)
+        elif (space.isinstance_w(w_item, space.w_tuple) and
                     space.len_w(w_item) == 0):
-            return convert_to_array(space, self)
+            return self
         raise OperationError(space.w_IndexError, space.wrap(
             "invalid index to scalar variable"))
 
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
@@ -143,7 +143,7 @@
         assert f.round(decimals=1) == 13.4
         assert f.round(decimals=1, out=None) == 13.4
         assert b.round() == 1.0
-        assert b.round(decimals=5) is b
+        raises(TypeError,  b.round, decimals=5)
 
     def test_astype(self):
         import numpy as np
@@ -222,10 +222,14 @@
     def test_indexing(self):
         import numpy as np
         v = np.int32(2)
-        for b in [v[()], v[...]]:
-            assert isinstance(b, np.ndarray)
-            assert b.shape == ()
-            assert b == v
+        b = v[()]
+        assert isinstance(b, np.int32)
+        assert b.shape == ()
+        assert b == v
+        b = v[...]
+        assert isinstance(b, np.ndarray)
+        assert b.shape == ()
+        assert b == v
         raises(IndexError, "v['blah']")
 
     def test_realimag(self):
diff --git a/pypy/module/micronumpy/types.py b/pypy/module/micronumpy/types.py
--- a/pypy/module/micronumpy/types.py
+++ b/pypy/module/micronumpy/types.py
@@ -437,7 +437,9 @@
     @specialize.argtype(1)
     def round(self, v, decimals=0):
         if decimals != 0:
-            return v
+            # numpy incompatible message
+            raise oefmt(self.space.w_TypeError,
+                "Cannot use float math on bool dtype")
         return Float64(self.space).box(self.unbox(v))
 
 class Integer(Primitive):
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to