Commits

mattip committed a5c03ba

reorder checks for upstream compatability, enable pedantic test

  • Participants
  • Parent commits 6a6f679

Comments (0)

Files changed (2)

pypy/module/micronumpy/interp_arrayops.py

     _axis = axis
     if axis < 0:
         _axis = len(shape) + axis
-    if _axis < 0 or len(shape) <= _axis:
-        raise operationerrfmt(space.w_IndexError, "axis %d out of bounds [0, %d)", axis, len(shape))
     for arr in args_w[1:]:
-        dtype = interp_ufuncs.find_binop_result_dtype(space, dtype,
-                                                      arr.get_dtype())
-        if _axis < 0 or len(arr.get_shape()) <= _axis:
-            raise operationerrfmt(space.w_IndexError, "axis %d out of bounds [0, %d)", axis, len(shape))
         for i, axis_size in enumerate(arr.get_shape()):
             if len(arr.get_shape()) != len(shape) or (i != _axis and axis_size != shape[i]):
                 raise OperationError(space.w_ValueError, space.wrap(
                     "all the input arrays must have same number of dimensions"))
             elif i == _axis:
                 shape[i] += axis_size
+        dtype = interp_ufuncs.find_binop_result_dtype(space, dtype,
+                                                      arr.get_dtype())
+        if _axis < 0 or len(arr.get_shape()) <= _axis:
+            raise operationerrfmt(space.w_IndexError, "axis %d out of bounds [0, %d)", axis, len(shape))
+    if _axis < 0 or len(shape) <= _axis:
+        raise operationerrfmt(space.w_IndexError, "axis %d out of bounds [0, %d)", axis, len(shape))
     res = W_NDimArray.from_shape(shape, dtype, 'C')
     chunks = [Chunk(0, i, 1, i) for i in shape]
     axis_start = 0

pypy/module/micronumpy/test/test_numarray.py

         assert str(exc.value) == \
                 "all the input arrays must have same number of dimensions"
 
-        if 0: # XXX too pedantic
-            g1 = array([0,1,2])
-            g2 = array([[3,4,5]])
-            exc = raises(ValueError, concatenate, (g1, g2), axis=2)
-            assert str(exc.value) == \
-                    "all the input arrays must have same number of dimensions"
+        g1 = array([0,1,2])
+        g2 = array([[3,4,5]])
+        exc = raises(ValueError, concatenate, (g1, g2), axis=2)
+        assert str(exc.value) == \
+                "all the input arrays must have same number of dimensions"
 
         a = array([1, 2, 3, 4, 5, 6])
         a = (a + a)[::2]