Skip to content

Commit f3432e8

Browse files
przembcharris
authored andcommitted
Documentation updated.
1 parent 499447e commit f3432e8

File tree

2 files changed

+22
-31
lines changed

2 files changed

+22
-31
lines changed

numpy/random/_generator.pyx

+19-26
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ cdef class Generator:
261261

262262
def random(self, size=None, dtype=np.float64, out=None):
263263
"""
264-
random(size=None, dtype='d', out=None)
264+
random(size=None, dtype=np.float64, out=None)
265265
266266
Return random floats in the half-open interval [0.0, 1.0).
267267
@@ -277,10 +277,9 @@ cdef class Generator:
277277
Output shape. If the given shape is, e.g., ``(m, n, k)``, then
278278
``m * n * k`` samples are drawn. Default is None, in which case a
279279
single value is returned.
280-
dtype : {str, dtype}, optional
281-
Desired dtype of the result, either 'd' (or 'float64') or 'f'
282-
(or 'float32'). All dtypes are determined by their name. The
283-
default value is 'd'.
280+
dtype : dtype, optional
281+
Desired dtype of the result, only `float64` and `float32` are supported.
282+
Byteorder must be native. The default value is np.float64.
284283
out : ndarray, optional
285284
Alternative output array in which to place the result. If size is not None,
286285
it must have the same shape as the provided size and must match the type of
@@ -416,7 +415,7 @@ cdef class Generator:
416415

417416
def standard_exponential(self, size=None, dtype=np.float64, method=u'zig', out=None):
418417
"""
419-
standard_exponential(size=None, dtype='d', method='zig', out=None)
418+
standard_exponential(size=None, dtype=np.float64, method='zig', out=None)
420419
421420
Draw samples from the standard exponential distribution.
422421
@@ -430,9 +429,8 @@ cdef class Generator:
430429
``m * n * k`` samples are drawn. Default is None, in which case a
431430
single value is returned.
432431
dtype : dtype, optional
433-
Desired dtype of the result, either 'd' (or 'float64') or 'f'
434-
(or 'float32'). All dtypes are determined by their name. The
435-
default value is 'd'.
432+
Desired dtype of the result, only `float64` and `float32` are supported.
433+
Byteorder must be native. The default value is np.float64.
436434
method : str, optional
437435
Either 'inv' or 'zig'. 'inv' uses the default inverse CDF method.
438436
'zig' uses the much faster Ziggurat method of Marsaglia and Tsang.
@@ -470,7 +468,7 @@ cdef class Generator:
470468

471469
def integers(self, low, high=None, size=None, dtype=np.int64, endpoint=False):
472470
"""
473-
integers(low, high=None, size=None, dtype='int64', endpoint=False)
471+
integers(low, high=None, size=None, dtype=np.int64, endpoint=False)
474472
475473
Return random integers from `low` (inclusive) to `high` (exclusive), or
476474
if endpoint=True, `low` (inclusive) to `high` (inclusive). Replaces
@@ -495,11 +493,9 @@ cdef class Generator:
495493
Output shape. If the given shape is, e.g., ``(m, n, k)``, then
496494
``m * n * k`` samples are drawn. Default is None, in which case a
497495
single value is returned.
498-
dtype : {str, dtype}, optional
499-
Desired dtype of the result. All dtypes are determined by their
500-
name, i.e., 'int64', 'int', etc, so byteorder is not available
501-
and a specific precision may have different C types depending
502-
on the platform. The default value is `np.int_`.
496+
dtype : dtype, optional
497+
Desired dtype of the result. Byteorder must be native.
498+
The default value is np.int64.
503499
endpoint : bool, optional
504500
If true, sample from the interval [low, high] instead of the
505501
default [low, high)
@@ -976,7 +972,7 @@ cdef class Generator:
976972
# Complicated, continuous distributions:
977973
def standard_normal(self, size=None, dtype=np.float64, out=None):
978974
"""
979-
standard_normal(size=None, dtype='d', out=None)
975+
standard_normal(size=None, dtype=np.float64, out=None)
980976
981977
Draw samples from a standard Normal distribution (mean=0, stdev=1).
982978
@@ -986,10 +982,9 @@ cdef class Generator:
986982
Output shape. If the given shape is, e.g., ``(m, n, k)``, then
987983
``m * n * k`` samples are drawn. Default is None, in which case a
988984
single value is returned.
989-
dtype : {str, dtype}, optional
990-
Desired dtype of the result, either 'd' (or 'float64') or 'f'
991-
(or 'float32'). All dtypes are determined by their name. The
992-
default value is 'd'.
985+
dtype : dtype, optional
986+
Desired dtype of the result, only `float64` and `float32` are supported.
987+
Byteorder must be native. The default value is np.float64.
993988
out : ndarray, optional
994989
Alternative output array in which to place the result. If size is not None,
995990
it must have the same shape as the provided size and must match the type of
@@ -1042,7 +1037,6 @@ cdef class Generator:
10421037
return double_fill(&random_standard_normal_fill, &self._bitgen, size, self.lock, out)
10431038
elif _dtype == np.float32:
10441039
return float_fill(&random_standard_normal_fill_f, &self._bitgen, size, self.lock, out)
1045-
10461040
else:
10471041
raise TypeError('Unsupported dtype %r for standard_normal' % _dtype)
10481042

@@ -1150,7 +1144,7 @@ cdef class Generator:
11501144

11511145
def standard_gamma(self, shape, size=None, dtype=np.float64, out=None):
11521146
"""
1153-
standard_gamma(shape, size=None, dtype='d', out=None)
1147+
standard_gamma(shape, size=None, dtype=np.float64, out=None)
11541148
11551149
Draw samples from a standard Gamma distribution.
11561150
@@ -1166,10 +1160,9 @@ cdef class Generator:
11661160
``m * n * k`` samples are drawn. If size is ``None`` (default),
11671161
a single value is returned if ``shape`` is a scalar. Otherwise,
11681162
``np.array(shape).size`` samples are drawn.
1169-
dtype : {str, dtype}, optional
1170-
Desired dtype of the result, either 'd' (or 'float64') or 'f'
1171-
(or 'float32'). All dtypes are determined by their name. The
1172-
default value is 'd'.
1163+
dtype : dtype, optional
1164+
Desired dtype of the result, only `float64` and `float32` are supported.
1165+
Byteorder must be native. The default value is np.float64.
11731166
out : ndarray, optional
11741167
Alternative output array in which to place the result. If size is
11751168
not None, it must have the same shape as the provided size and

numpy/random/mtrand.pyx

+3-5
Original file line numberDiff line numberDiff line change
@@ -640,7 +640,7 @@ cdef class RandomState:
640640

641641
def randint(self, low, high=None, size=None, dtype=int):
642642
"""
643-
randint(low, high=None, size=None, dtype='l')
643+
randint(low, high=None, size=None, dtype=int)
644644
645645
Return random integers from `low` (inclusive) to `high` (exclusive).
646646
@@ -667,10 +667,8 @@ cdef class RandomState:
667667
``m * n * k`` samples are drawn. Default is None, in which case a
668668
single value is returned.
669669
dtype : dtype, optional
670-
Desired dtype of the result. All dtypes are determined by their
671-
name, i.e., 'int64', 'int', etc, so byteorder is not available
672-
and a specific precision may have different C types depending
673-
on the platform. The default value is `np.int_`.
670+
Desired dtype of the result. Byteorder must be native.
671+
The default value is int.
674672
675673
.. versionadded:: 1.11.0
676674

0 commit comments

Comments
 (0)