Skip to content

ENH: np.random.rand: support dtype= parameter #29461

@math-hiyoko

Description

@math-hiyoko

Proposed new feature or change:

I propose adding an optional dtype argument to numpy.random.rand so that users can specify the output array’s data type.

example

>>> np.random.rand(3, 2)
array([[0.09799155, 0.80168949],
       [0.58717916, 0.44092481],
       [0.73663285, 0.25938858]])
>>> np.random.rand(3, 2, dtype=np.float32)
array([[0.13287361, 0.5196258 ],
       [0.60567766, 0.11989909],
       [0.3108553 , 0.6204756 ]], dtype=float32)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions