-
-
Notifications
You must be signed in to change notification settings - Fork 11.2k
Open
Description
Proposed new feature or change:
Many np.random.Generator
distribution methods generate floating point arrays, but don't accept a dtype
parameter to control the desired precision. As a result, the generated arrays have limited utility in some situations, or for downcasting, have to be reconstructed afterward with the desired precision. For example, standard_exponential()
has a dtype
parameter, but uniform()
doesn't. Providing intentionally-typed float parameters to uniform()
still doesn't affect the output dtype
(always np.float64
)
>>> rng = np.random.default_rng(42)
>>> result = rng.uniform(np.float32(0.0), np.float32(10), 20)
>>> result.dtype
dtype('float64')
ngoldbaum, pwuertz and patrick-kidger