Repository: chainer/chainer

Issue:
Support numpy 1.10
numpy 1.10.0 is released on 2015/10/07

https://pypi.python.org/pypi/numpy/1.10.0



Discussion:
I ran the test with the newest numpy, and got errors.
Summary is below:
- inplace operations are now permitted with only `'same_kind'`: https://github.com/numpy/numpy/blob/master/doc/release/1.10.0-notes.rst#default-casting-rule-change
- <del>`inner` method with `[::-1]` fails  (maybe numpy's bug?)</del>
  - this bug is fixed in the master branch (will be released in 1.10.2) https://github.com/numpy/numpy/pull/6552


Resolving patch:
diff --git a/cupy/creation/ranges.py b/cupy/creation/ranges.py
--- a/cupy/creation/ranges.py
+++ b/cupy/creation/ranges.py
@@ -85,9 +85,10 @@ def linspace(start, stop, num=50, endpoint=True, retstep=False, dtype=None):
 
         if step == 0.0:
             # for underflow
-            _linspace_ufunc_underflow(start, stop - start, div, ret)
+            _linspace_ufunc_underflow(start, stop - start, div, ret,
+                                      casting='unsafe')
         else:
-            _linspace_ufunc(start, step, ret)
+            _linspace_ufunc(start, step, ret, casting='unsafe')
 
         if endpoint:
             ret[-1] = stop


Test patch:
diff --git a/tests/cupy_tests/core_tests/test_ndarray_elementwise_op.py b/tests/cupy_tests/core_tests/test_ndarray_elementwise_op.py
--- a/tests/cupy_tests/core_tests/test_ndarray_elementwise_op.py
+++ b/tests/cupy_tests/core_tests/test_ndarray_elementwise_op.py
@@ -28,6 +28,7 @@ def test_add_scalar(self):
     def test_radd_scalar(self):
         self.check_array_scalar_op(operator.add, swap=True)
 
+    @testing.with_requires('numpy>=1.10')
     def test_iadd_scalar(self):
         self.check_array_scalar_op(operator.iadd)
 
@@ -37,6 +38,7 @@ def test_sub_scalar(self):
     def test_rsub_scalar(self):
         self.check_array_scalar_op(operator.sub, swap=True)
 
+    @testing.with_requires('numpy>=1.10')
     def test_isub_scalar(self):
         self.check_array_scalar_op(operator.isub)
 
@@ -46,6 +48,7 @@ def test_mul_scalar(self):
     def test_rmul_scalar(self):
         self.check_array_scalar_op(operator.mul, swap=True)
 
+    @testing.with_requires('numpy>=1.10')
     def test_imul_scalar(self):
         self.check_array_scalar_op(operator.imul)
 
@@ -57,6 +60,7 @@ def test_rtruediv_scalar(self):
         with testing.NumpyError(divide='ignore'):
             self.check_array_scalar_op(operator.truediv, swap=True)
 
+    @testing.with_requires('numpy>=1.10')
     def test_itruediv_scalar(self):
         with testing.NumpyError(divide='ignore'):
             self.check_array_scalar_op(operator.itruediv)
@@ -73,6 +77,7 @@ def test_rdiv_scalar(self):
         with testing.NumpyError(divide='ignore'):
             self.check_array_scalar_op(operator.div, swap=True)
 
+    @testing.with_requires('numpy>=1.10')
     def test_idiv_scalar(self):
         if six.PY3:
             return
@@ -87,6 +92,7 @@ def test_rfloordiv_scalar(self):
         with testing.NumpyError(divide='ignore'):
             self.check_array_scalar_op(operator.floordiv, swap=True)
 
+    @testing.with_requires('numpy>=1.10')
     def test_ifloordiv_scalar(self):
         with testing.NumpyError(divide='ignore'):
             self.check_array_scalar_op(operator.ifloordiv)
@@ -103,6 +109,7 @@ def check_ipow_scalar(self, xp, x_type, y_type):
         a = xp.array([[1, 2, 3], [4, 5, 6]], x_type)
         return operator.ipow(a, y_type(3))
 
+    @testing.with_requires('numpy>=1.10')
     def test_ipow_scalar(self):
         self.check_ipow_scalar()
 
@@ -150,18 +157,21 @@ def check_array_array_op(self, op, xp, x_type, y_type):
     def test_add_array(self):
         self.check_array_array_op(operator.add)
 
+    @testing.with_requires('numpy>=1.10')
     def test_iadd_array(self):
         self.check_array_array_op(operator.iadd)
 
     def test_sub_array(self):
         self.check_array_array_op(operator.sub)
 
+    @testing.with_requires('numpy>=1.10')
     def test_isub_array(self):
         self.check_array_array_op(operator.isub)
 
     def test_mul_array(self):
         self.check_array_array_op(operator.mul)
 
+    @testing.with_requires('numpy>=1.10')
     def test_imul_array(self):
         self.check_array_array_op(operator.imul)
 
@@ -169,6 +179,7 @@ def test_truediv_array(self):
         with testing.NumpyError(divide='ignore'):
             self.check_array_array_op(operator.truediv)
 
+    @testing.with_requires('numpy>=1.10')
     def test_itruediv_array(self):
         with testing.NumpyError(divide='ignore'):
             self.check_array_array_op(operator.itruediv)
@@ -179,6 +190,7 @@ def test_div_array(self):
         with testing.NumpyError(divide='ignore'):
             self.check_array_array_op(operator.div)
 
+    @testing.with_requires('numpy>=1.10')
     def test_idiv_array(self):
         if six.PY3:
             return
@@ -189,6 +201,7 @@ def test_floordiv_array(self):
         with testing.NumpyError(divide='ignore'):
             self.check_array_array_op(operator.floordiv)
 
+    @testing.with_requires('numpy>=1.10')
     def test_ifloordiv_array(self):
         with testing.NumpyError(divide='ignore'):
             self.check_array_array_op(operator.ifloordiv)
@@ -203,6 +216,7 @@ def check_ipow_array(self, xp, x_type, y_type):
         b = xp.array([[6, 5, 4], [3, 2, 1]], y_type)
         return operator.ipow(a, b)
 
+    @testing.with_requires('numpy>=1.10')
     def test_ipow_array(self):
         self.check_ipow_array()
 
@@ -242,18 +256,21 @@ def check_array_broadcasted_op(self, op, xp, x_type, y_type):
     def test_broadcasted_add(self):
         self.check_array_broadcasted_op(operator.add)
 
+    @testing.with_requires('numpy>=1.10')
     def test_broadcasted_iadd(self):
         self.check_array_broadcasted_op(operator.iadd)
 
     def test_broadcasted_sub(self):
         self.check_array_broadcasted_op(operator.sub)
 
+    @testing.with_requires('numpy>=1.10')
     def test_broadcasted_isub(self):
         self.check_array_broadcasted_op(operator.isub)
 
     def test_broadcasted_mul(self):
         self.check_array_broadcasted_op(operator.mul)
 
+    @testing.with_requires('numpy>=1.10')
     def test_broadcasted_imul(self):
         self.check_array_broadcasted_op(operator.imul)
 
@@ -261,6 +278,7 @@ def test_broadcasted_truediv(self):
         with testing.NumpyError(divide='ignore'):
             self.check_array_broadcasted_op(operator.truediv)
 
+    @testing.with_requires('numpy>=1.10')
     def test_broadcasted_itruediv(self):
         with testing.NumpyError(divide='ignore'):
             self.check_array_broadcasted_op(operator.itruediv)
@@ -271,6 +289,7 @@ def test_broadcasted_div(self):
         with testing.NumpyError(divide='ignore'):
             self.check_array_broadcasted_op(operator.div)
 
+    @testing.with_requires('numpy>=1.10')
     def test_broadcasted_idiv(self):
         if six.PY3:
             return
@@ -281,6 +300,7 @@ def test_broadcasted_floordiv(self):
         with testing.NumpyError(divide='ignore'):
             self.check_array_broadcasted_op(operator.floordiv)
 
+    @testing.with_requires('numpy>=1.10')
     def test_broadcasted_ifloordiv(self):
         with testing.NumpyError(divide='ignore'):
             self.check_array_broadcasted_op(operator.ifloordiv)
@@ -288,6 +308,7 @@ def test_broadcasted_ifloordiv(self):
     def test_broadcasted_pow(self):
         self.check_array_broadcasted_op(operator.pow)
 
+    @testing.with_requires('numpy>=1.10')
     @testing.for_all_dtypes_combination(names=['x_type', 'y_type'])
     @testing.numpy_cupy_allclose(atol=1.0)
     def check_broadcasted_ipow(self, xp, x_type, y_type):
@@ -295,6 +316,7 @@ def check_broadcasted_ipow(self, xp, x_type, y_type):
         b = xp.array([[1], [2]], y_type)
         return operator.ipow(a, b)
 
+    @testing.with_requires('numpy>=1.10')
     def test_broadcasted_ipow(self):
         self.check_broadcasted_ipow()
 
@@ -558,30 +580,35 @@ def check_array_array_op(self, op, xp, x_type, y_type):
     def test_lshift_array(self):
         self.check_array_array_op(operator.lshift)
 
+    @testing.with_requires('numpy>=1.10')
     def test_ilshift_array(self):
         self.check_array_array_op(operator.ilshift)
 
     def test_rshift_array(self):
         self.check_array_array_op(operator.rshift)
 
+    @testing.with_requires('numpy>=1.10')
     def test_irshift_array(self):
         self.check_array_array_op(operator.irshift)
 
     def test_and_array(self):
         self.check_array_array_op(operator.and_)
 
+    @testing.with_requires('numpy>=1.10')
     def test_iand_array(self):
         self.check_array_array_op(operator.iand)
 
     def test_or_array(self):
         self.check_array_array_op(operator.or_)
 
+    @testing.with_requires('numpy>=1.10')
     def test_ior_array(self):
         self.check_array_array_op(operator.ior)
 
     def test_xor_array(self):
         self.check_array_array_op(operator.xor)
 
+    @testing.with_requires('numpy>=1.10')
     def test_ixor_array(self):
         self.check_array_array_op(operator.ixor)
 
@@ -589,6 +616,7 @@ def test_mod_array(self):
         with testing.NumpyError(divide='ignore', invalid='ignore'):
             self.check_array_array_op(operator.mod)
 
+    @testing.with_requires('numpy>=1.10')
     def test_imod_array(self):
         with testing.NumpyError(divide='ignore', invalid='ignore'):
             self.check_array_array_op(operator.imod)
@@ -603,30 +631,35 @@ def check_array_broadcasted_op(self, op, xp, x_type, y_type):
     def test_broadcasted_lshift(self):
         self.check_array_broadcasted_op(operator.lshift)
 
+    @testing.with_requires('numpy>=1.10')
     def test_broadcasted_ilshift(self):
         self.check_array_broadcasted_op(operator.ilshift)
 
     def test_broadcasted_rshift(self):
         self.check_array_broadcasted_op(operator.rshift)
 
+    @testing.with_requires('numpy>=1.10')
     def test_broadcasted_irshift(self):
         self.check_array_broadcasted_op(operator.irshift)
 
     def test_broadcasted_and(self):
         self.check_array_broadcasted_op(operator.and_)
 
+    @testing.with_requires('numpy>=1.10')
     def test_broadcasted_iand(self):
         self.check_array_broadcasted_op(operator.iand)
 
     def test_broadcasted_or(self):
         self.check_array_broadcasted_op(operator.or_)
 
+    @testing.with_requires('numpy>=1.10')
     def test_broadcasted_ior(self):
         self.check_array_broadcasted_op(operator.ior)
 
     def test_broadcasted_xor(self):
         self.check_array_broadcasted_op(operator.xor)
 
+    @testing.with_requires('numpy>=1.10')
     def test_broadcasted_ixor(self):
         self.check_array_broadcasted_op(operator.ixor)
 
@@ -634,6 +667,7 @@ def test_broadcasted_mod(self):
         with testing.NumpyError(divide='ignore', invalid='ignore'):
             self.check_array_broadcasted_op(operator.mod)
 
+    @testing.with_requires('numpy>=1.10')
     def test_broadcasted_imod(self):
         with testing.NumpyError(divide='ignore', invalid='ignore'):
             self.check_array_broadcasted_op(operator.imod)