Skip to content

Commit 9110e11

Browse files
committed
Update descriptions of functions in RandomState class
1 parent 3a31b82 commit 9110e11

File tree

1 file changed

+46
-30
lines changed

1 file changed

+46
-30
lines changed

dpnp/random/dpnp_random_state.py

Lines changed: 46 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,22 @@ class RandomState:
5757
A container for the Mersenne Twister pseudo-random number generator.
5858
5959
For full documentation refer to :obj:`numpy.random.RandomState`.
60+
61+
Parameters
62+
----------
63+
device : {None, string, SyclDevice, SyclQueue}, optional
64+
An array API concept of device where the output array is created.
65+
`device` can be ``None`` (the default), a oneAPI filter selector string,
66+
an instance of :class:`dpctl.SyclDevice` corresponding to a non-partitioned SYCL device,
67+
an instance of :class:`dpctl.SyclQueue`, or a `Device` object returned by
68+
:obj:`dpnp.dpnp_array.dpnp_array.device` property.
69+
sycl_queue : {None, SyclQueue}, optional
70+
The SYCL queue to use for output array allocation and copying.
71+
72+
Limitations
73+
-----------
74+
Parameter `seed` is supported as either a integer scalar or array_like
75+
of maximumum three integer scalars.
6076
"""
6177

6278
def __init__(self, seed=None, device=None, sycl_queue=None):
@@ -107,9 +123,9 @@ def _is_signbit_scalar(self, x):
107123

108124
def _validate_float_dtype(self, dtype, supported_types):
109125
"""
110-
Test an input floating type if it is listed in ``supported_types`` and
126+
Test an input floating type if it is listed in `supported_types` and
111127
if it is supported by the used SYCL device.
112-
If ``dtype`` is None, default floating type will be validating.
128+
If `dtype` is ``None``, default floating type will be validating.
113129
Return the examined floating type if it follows all validation checks.
114130
"""
115131

@@ -139,7 +155,7 @@ def get_state(self):
139155

140156
def get_sycl_queue(self):
141157
"""
142-
Return an instance of of :class:`dpctl.SyclQueue` used within the generator for data allocation.
158+
Return an instance of :class:`dpctl.SyclQueue` used within the generator for data allocation.
143159
144160
Returns
145161
-------
@@ -151,7 +167,7 @@ def get_sycl_queue(self):
151167

152168
def get_sycl_device(self):
153169
"""
154-
Return an instance of of :class:`dpctl.SyclDevice` used within the generator to allocate data on.
170+
Return an instance of :class:`dpctl.SyclDevice` used within the generator to allocate data on.
155171
156172
Returns
157173
-------
@@ -169,21 +185,21 @@ def normal(self, loc=0.0, scale=1.0, size=None, dtype=None, usm_type="device"):
169185
170186
Parameters
171187
----------
172-
usm_type : ("device" | "shared" | "host"), optional
188+
usm_type : {"device", "shared", "host"}, optional
173189
The type of SYCL USM allocation for the output array.
174190
175191
Returns
176192
-------
177193
out : dpnp.ndarray
178194
Drawn samples from the parameterized normal distribution.
179-
Output array data type is the same as input ``dtype``. If ``dtype`` is None (default),
180-
:obj:`dpnp.float64` type will be used if device supports it or :obj:`dpnp.float32` otherwise.
195+
Output array data type is the same as input `dtype`. If `dtype` is ``None`` (the default),
196+
:obj:`dpnp.float64` type will be used if device supports it, or :obj:`dpnp.float32` otherwise.
181197
182198
Limitations
183199
-----------
184-
Parameters ``loc`` and ``scale`` are supported as scalar. Otherwise,
200+
Parameters `loc` and `scale` are supported as scalar. Otherwise,
185201
:obj:`numpy.random.RandomState.normal(loc, scale, size)` samples are drawn.
186-
Parameter ``dtype`` is supported only for :obj:`dpnp.float32`, :obj:`dpnp.float64` or `None`.
202+
Parameter `dtype` is supported only as :obj:`dpnp.float32`, :obj:`dpnp.float64` or ``None``.
187203
188204
Examples
189205
--------
@@ -241,14 +257,14 @@ def rand(self, *args, usm_type="device"):
241257
242258
Parameters
243259
----------
244-
usm_type : ("device" | "shared" | "host"), optional
260+
usm_type : {"device", "shared", "host"}, optional
245261
The type of SYCL USM allocation for the output array.
246262
247263
Returns
248264
-------
249265
out : dpnp.ndarray
250266
Random values in a given shape.
251-
Output array data type is :obj:`dpnp.float64` if device supports it or :obj:`dpnp.float32` otherwise.
267+
Output array data type is :obj:`dpnp.float64` if device supports it, or :obj:`dpnp.float32` otherwise.
252268
253269
Examples
254270
--------
@@ -284,21 +300,21 @@ def randint(self, low, high=None, size=None, dtype=int, usm_type="device"):
284300
285301
Parameters
286302
----------
287-
usm_type : ("device" | "shared" | "host"), optional
303+
usm_type : {"device", "shared", "host"}, optional
288304
The type of SYCL USM allocation for the output array.
289305
290306
Returns
291307
-------
292308
out : dpnp.ndarray
293309
`size`-shaped array of random integers from the appropriate distribution,
294-
or a single such random int if `size` not provided.
295-
Output array data type is the same as input ``dtype``.
310+
or a single such random int if `size` is not provided.
311+
Output array data type is the same as input `dtype`.
296312
297313
Limitations
298314
-----------
299-
Parameters ``low`` and ``high`` are supported only as scalar.
300-
Parameter ``dtype`` is supported only as :obj:`dpnp.int32` or `int`,
301-
but `int` value is considered to be exactly equivalent to :obj:`dpnp.int32`.
315+
Parameters `low` and `high` are supported only as a scalar.
316+
Parameter `dtype` is supported only as :obj:`dpnp.int32` or ``int``,
317+
but ``int`` value is considered to be exactly equivalent to :obj:`dpnp.int32`.
302318
Otherwise, :obj:`numpy.random.randint(low, high, size, dtype)` samples are drawn.
303319
304320
Examples
@@ -359,7 +375,7 @@ def randn(self, *args, usm_type="device"):
359375
360376
Parameters
361377
----------
362-
usm_type : ("device" | "shared" | "host"), optional
378+
usm_type : {"device", "shared", "host"}, optional
363379
The type of SYCL USM allocation for the output array.
364380
365381
Returns
@@ -368,7 +384,7 @@ def randn(self, *args, usm_type="device"):
368384
A ``(d0, d1, ..., dn)``-shaped array of floating-point samples from
369385
the standard normal distribution, or a single such float if
370386
no parameters were supplied.
371-
Output array data type is :obj:`dpnp.float64` if device supports it
387+
Output array data type is :obj:`dpnp.float64` if device supports it,
372388
or :obj:`dpnp.float32` otherwise.
373389
374390
Examples
@@ -408,15 +424,15 @@ def random_sample(self, size=None, usm_type="device"):
408424
409425
Parameters
410426
----------
411-
usm_type : ("device" | "shared" | "host"), optional
427+
usm_type : {"device", "shared", "host"}, optional
412428
The type of SYCL USM allocation for the output array.
413429
414430
Returns
415431
-------
416432
out : dpnp.ndarray
417433
Array of random floats of shape `size` (if ``size=None``,
418434
zero dimension array with a single float is returned).
419-
Output array data type is :obj:`dpnp.float64` if device supports it
435+
Output array data type is :obj:`dpnp.float64` if device supports it,
420436
or :obj:`dpnp.float32` otherwise.
421437
422438
Examples
@@ -447,15 +463,15 @@ def standard_normal(self, size=None, usm_type="device"):
447463
448464
Parameters
449465
----------
450-
usm_type : ("device" | "shared" | "host"), optional
466+
usm_type : {"device", "shared", "host"}, optional
451467
The type of SYCL USM allocation for the output array.
452468
453469
Returns
454470
-------
455471
out : dpnp.ndarray
456-
A floating-point array of shape ``size`` of drawn samples, or a
457-
single sample if ``size`` was not specified.
458-
Output array data type is :obj:`dpnp.float64` if device supports it
472+
A floating-point array of shape `size` of drawn samples, or a
473+
single sample if `size` was not specified.
474+
Output array data type is :obj:`dpnp.float64` if device supports it,
459475
or :obj:`dpnp.float32` otherwise.
460476
461477
Examples
@@ -492,21 +508,21 @@ def uniform(self, low=0.0, high=1.0, size=None, dtype=None, usm_type="device"):
492508
493509
Parameters
494510
----------
495-
usm_type : ("device" | "shared" | "host"), optional
511+
usm_type : {"device", "shared", "host"}, optional
496512
The type of SYCL USM allocation for the output array.
497513
498514
Returns
499515
-------
500516
out : dpnp.ndarray
501517
Drawn samples from the parameterized uniform distribution.
502-
Output array data type is the same as input ``dtype``. If ``dtype`` is None (default),
503-
:obj:`dpnp.float64` type will be used if device supports it or :obj:`dpnp.float32` otherwise.
518+
Output array data type is the same as input `dtype`. If `dtype` is ``None`` (the default),
519+
:obj:`dpnp.float64` type will be used if device supports it, or :obj:`dpnp.float32` otherwise.
504520
505521
Limitations
506522
-----------
507-
Parameters ``low`` and ``high`` are supported as scalar. Otherwise,
523+
Parameters `low` and `high` are supported as scalar. Otherwise,
508524
:obj:`numpy.random.uniform(low, high, size)` samples are drawn.
509-
Parameter ``dtype`` is supported only for :obj:`dpnp.int32`, :obj:`dpnp.float32`, :obj:`dpnp.float64` or `None`.
525+
Parameter `dtype` is supported only as :obj:`dpnp.int32`, :obj:`dpnp.float32`, :obj:`dpnp.float64` or ``None``.
510526
511527
Examples
512528
--------

0 commit comments

Comments
 (0)