Add more mean/std/var tests for 0-length dimensions
@@ -180,20 +180,37 @@ class TestMeanVar(unittest.TestCase):
a = testing.shaped_arange((2, 3, 4), xp, dtype)
return xp.std(a, axis=1, ddof=1)
+
+@testing.parameterize(*testing.product({
+ 'params': [
+ ((), None),
+ ((0,), None),
+ ((0, 0), None),
+ ((0, 0), 1),
+ ((0, 0, 0), None),
+ ((0, 0, 0), (0, 2)),
+ ],
+}))
+@testing.gpu
+class TestProductZeroLength(unittest.TestCase):
+
@testing.for_all_dtypes(no_complex=True)
@testing.numpy_cupy_allclose()
- def test_external_mean_zero_len_axis(self, xp, dtype):
- a = testing.shaped_arange((0, 0), xp, dtype)
- return xp.mean(a, axis=1)
+ def test_external_mean_zero_len(self, xp, dtype):
+ shape, axis = self.params
+ a = testing.shaped_arange(shape, xp, dtype)
+ return xp.mean(a, axis=axis)
@testing.for_all_dtypes(no_complex=True)
@testing.numpy_cupy_allclose()
- def test_external_var_zero_len_axis(self, xp, dtype):
- a = testing.shaped_arange((0, 0), xp, dtype)
- return xp.var(a, axis=1)
+ def test_external_std_zero_len(self, xp, dtype):
+ shape, axis = self.params
+ a = testing.shaped_arange(shape, xp, dtype)
+ return xp.std(a, axis=axis)
@testing.for_all_dtypes(no_complex=True)
@testing.numpy_cupy_allclose()
- def test_external_std_zero_len_axis(self, xp, dtype):
- a = testing.shaped_arange((0, 0), xp, dtype)
- return xp.std(a, axis=1)
+ def test_external_var_zero_len(self, xp, dtype):
+ shape, axis = self.params
+ a = testing.shaped_arange(shape, xp, dtype)
+ return xp.var(a, axis=axis)
