diff options
author | shreepads <shreepads@gmail.com> | 2020-04-22 15:16:30 +0530 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-22 05:46:30 -0400 |
commit | 630f094b99afa8c693652066a3fb8918b9f3e142 (patch) | |
tree | 922da49294172d34906812968be469e1e91bb973 /doc | |
parent | b57c5349442d11f7f72aacec299e2c6740ec0a32 (diff) | |
download | numpy-630f094b99afa8c693652066a3fb8918b9f3e142.tar.gz |
DOC: initialise random number generator before first use in quickstart (#16025)
* DOC: make random generator initialisation visible at the first point of use in the quickstart
The random generator in the quickstart is initialised in a hidden test setup
section at the start. This should be made visible at the first point of use
so that new users don't get tripped up trying to set it up. Note that rg is
also visibly initialised lower down in the Histogram section.
Also moved another inline comment in the same example to ensure they
are aligned as per the format used in the quickstart.
Diffstat (limited to 'doc')
-rw-r--r-- | doc/source/user/quickstart.rst | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/doc/source/user/quickstart.rst b/doc/source/user/quickstart.rst index bea07debf..6ad0e52f9 100644 --- a/doc/source/user/quickstart.rst +++ b/doc/source/user/quickstart.rst @@ -8,7 +8,6 @@ Quickstart tutorial >>> import numpy as np >>> import sys - >>> rg = np.random.default_rng(1) Prerequisites ============= @@ -348,6 +347,7 @@ existing array rather than create a new one. :: + >>> rg = np.random.default_rng(1) # create instance of default random number generator >>> a = np.ones((2,3), dtype=int) >>> b = rg.random((2,3)) >>> a *= 3 @@ -358,7 +358,7 @@ existing array rather than create a new one. >>> b array([[3.51182162, 3.9504637 , 3.14415961], [3.94864945, 3.31183145, 3.42332645]]) - >>> a += b # b is not automatically converted to integer type + >>> a += b # b is not automatically converted to integer type Traceback (most recent call last): ... numpy.core._exceptions.UFuncTypeError: Cannot cast ufunc 'add' output from dtype('float64') to dtype('int64') with casting rule 'same_kind' |