Add zero size argmax test
@@ -58,6 +58,24 @@ class TestSearch(unittest.TestCase):
a = testing.shaped_random((2, 3, 4), xp, dtype)
return a.argmax(axis=2)
+ @testing.for_all_dtypes(no_complex=True)
+ @testing.numpy_cupy_raises(accept_error=ValueError)
+ def test_argmax_zero_size(self, xp, dtype):
+ a = testing.shaped_random((0, 1), xp, dtype)
+ return a.argmax()
+
+ @testing.for_all_dtypes(no_complex=True)
+ @testing.numpy_cupy_raises(accept_error=ValueError)
+ def test_argmax_zero_size_axis0(self, xp, dtype):
+ a = testing.shaped_random((0, 1), xp, dtype)
+ return a.argmax(axis=0)
+
+ @testing.for_all_dtypes(no_complex=True)
+ @testing.numpy_cupy_allclose()
+ def test_argmax_zero_size_axis1(self, xp, dtype):
+ a = testing.shaped_random((0, 1), xp, dtype)
+ return a.argmax(axis=1)
+
@testing.for_all_dtypes(no_complex=True)
@testing.numpy_cupy_allclose()
def test_argmin_all(self, xp, dtype):
@@ -106,6 +124,24 @@ class TestSearch(unittest.TestCase):
a = testing.shaped_random((2, 3, 4), xp, dtype)
return a.argmin(axis=2)
+ @testing.for_all_dtypes(no_complex=True)
+ @testing.numpy_cupy_raises(accept_error=ValueError)
+ def test_argmin_zero_size(self, xp, dtype):
+ a = testing.shaped_random((0, 1), xp, dtype)
+ return a.argmin()
+
+ @testing.for_all_dtypes(no_complex=True)
+ @testing.numpy_cupy_raises(accept_error=ValueError)
+ def test_argmin_zero_size_axis0(self, xp, dtype):
+ a = testing.shaped_random((0, 1), xp, dtype)
+ return a.argmin(axis=0)
+
+ @testing.for_all_dtypes(no_complex=True)
+ @testing.numpy_cupy_allclose()
+ def test_argmin_zero_size_axis1(self, xp, dtype):
+ a = testing.shaped_random((0, 1), xp, dtype)
+ return a.argmin(axis=1)
+
@testing.parameterize(
{'cond_shape': (2, 3, 4), 'x_shape': (2, 3, 4), 'y_shape': (2, 3, 4)},
