check value of n rather than ret value when size is (0,)
@@ -606,6 +606,9 @@ class RandomState(object):
n = functools.reduce(operator.mul, size, 1)
+ if n is 0:
+ return cupy.array(())
+
sample = cupy.empty((n,), dtype=dtype)
n_rem = n # The number of remaining elements to sample
ret = None
@@ -632,9 +635,7 @@ class RandomState(object):
n_rem -= n_succ
assert n_rem == 0
-
- if ret is None:
- return cupy.array(())
+ assert n is not None
return ret.reshape(size)
