add tests with non-contiguous arrays
@@ -48,6 +48,12 @@ class TestRealImag(unittest.TestCase):
x = xp.array(1, dtype=dtype)
return x.real
+ @testing.for_all_dtypes()
+ @testing.numpy_cupy_array_almost_equal(accept_error=False)
+ def test_real_non_contiguous(self, xp, dtype):
+ x = testing.shaped_arange((2, 3, 2), xp, dtype).transpose(0, 2, 1)
+ return x.real
+
@testing.for_all_dtypes()
@testing.numpy_cupy_array_almost_equal(accept_error=False)
def test_imag(self, xp, dtype):
@@ -60,6 +66,12 @@ class TestRealImag(unittest.TestCase):
x = xp.array(1, dtype=dtype)
return x.imag
+ @testing.for_all_dtypes()
+ @testing.numpy_cupy_array_almost_equal(accept_error=False)
+ def test_imag_non_contiguous(self, xp, dtype):
+ x = testing.shaped_arange((2, 3, 2), xp, dtype).transpose(0, 2, 1)
+ return x.imag
+
@testing.for_all_dtypes()
@testing.numpy_cupy_array_almost_equal(accept_error=False)
def test_real_setter(self, xp, dtype):
@@ -74,6 +86,13 @@ class TestRealImag(unittest.TestCase):
x.real = 2
return x
+ @testing.for_dtypes('FD')
+ @testing.numpy_cupy_array_almost_equal(accept_error=False)
+ def test_real_setter_non_contiguous(self, xp, dtype):
+ x = testing.shaped_arange((2, 3, 2), xp, dtype).transpose(0, 2, 1)
+ x.real = testing.shaped_reverse_arange((2, 2, 3), xp, dtype).real
+ return x
+
@testing.for_dtypes('FD')
@testing.numpy_cupy_array_almost_equal(accept_error=False)
def test_imag_setter(self, xp, dtype):
@@ -88,6 +107,13 @@ class TestRealImag(unittest.TestCase):
x.imag = 2
return x
+ @testing.for_dtypes('FD')
+ @testing.numpy_cupy_array_almost_equal(accept_error=False)
+ def test_imag_setter_non_contiguous(self, xp, dtype):
+ x = testing.shaped_arange((2, 3, 2), xp, dtype).transpose(0, 2, 1)
+ x.imag = testing.shaped_reverse_arange((2, 2, 3), xp, dtype).real
+ return x
+
@testing.for_all_dtypes(no_complex=True)
@testing.numpy_cupy_raises(accept_error=TypeError)
def test_imag_setter_raise(self, xp, dtype):
