Fix shaped_random for complex number
@@ -971,8 +971,12 @@ def shaped_random(shape, xp=cupy, dtype=numpy.float32, scale=10, seed=0):
with specified dtype.
"""
numpy.random.seed(seed)
- if numpy.dtype(dtype).type == numpy.bool_:
+ dtype = numpy.dtype(dtype)
+ if dtype == '?':
return xp.asarray(numpy.random.randint(2, size=shape).astype(dtype))
+ elif dtype.kind == 'c':
+ a = numpy.random.rand(*shape) + 1j * numpy.random.rand(*shape)
+ return xp.asarray((a * scale).astype(dtype))
else:
return xp.asarray((numpy.random.rand(*shape) * scale).astype(dtype))
