diff options
Diffstat (limited to 'doc/source/user/absolute_beginners.rst')
-rw-r--r-- | doc/source/user/absolute_beginners.rst | 29 |
1 files changed, 14 insertions, 15 deletions
diff --git a/doc/source/user/absolute_beginners.rst b/doc/source/user/absolute_beginners.rst index 27e9e1f63..2c6882905 100644 --- a/doc/source/user/absolute_beginners.rst +++ b/doc/source/user/absolute_beginners.rst @@ -229,8 +229,8 @@ content is random and depends on the state of the memory. The reason to use fill every element afterwards! :: >>> # Create an empty array with 2 elements - >>> np.empty(2) - array([ 3.14, 42. ]) # may vary + >>> np.empty(2) #doctest: +SKIP + array([3.14, 42. ]) # may vary You can create an array with a range of elements:: @@ -669,18 +669,18 @@ If you wanted to split this array into three equally shaped arrays, you would run:: >>> np.hsplit(x, 3) - [array([[1, 2, 3, 4], - [13, 14, 15, 16]]), array([[ 5, 6, 7, 8], - [17, 18, 19, 20]]), array([[ 9, 10, 11, 12], - [21, 22, 23, 24]])] + [array([[ 1, 2, 3, 4], + [13, 14, 15, 16]]), array([[ 5, 6, 7, 8], + [17, 18, 19, 20]]), array([[ 9, 10, 11, 12], + [21, 22, 23, 24]])] If you wanted to split your array after the third and fourth column, you'd run:: >>> np.hsplit(x, (3, 4)) - [array([[1, 2, 3], - [13, 14, 15]]), array([[ 4], - [16]]), array([[ 5, 6, 7, 8, 9, 10, 11, 12], - [17, 18, 19, 20, 21, 22, 23, 24]])] + [array([[ 1, 2, 3], + [13, 14, 15]]), array([[ 4], + [16]]), array([[ 5, 6, 7, 8, 9, 10, 11, 12], + [17, 18, 19, 20, 21, 22, 23, 24]])] :ref:`Learn more about stacking and splitting arrays here <quickstart.stacking-arrays>`. @@ -967,9 +967,8 @@ All you need to do is pass in the number of elements you want it to generate:: array([1., 1., 1.]) >>> np.zeros(3) array([0., 0., 0.]) - # the simplest way to generate random numbers - >>> rng = np.random.default_rng(0) - >>> rng.random(3) + >>> rng = np.random.default_rng() # the simplest way to generate random numbers + >>> rng.random(3) #doctest: +SKIP array([0.63696169, 0.26978671, 0.04097352]) .. image:: images/np_ones_zeros_random.png @@ -985,7 +984,7 @@ a 2D array if you give them a tuple describing the dimensions of the matrix:: array([[0., 0.], [0., 0.], [0., 0.]]) - >>> rng.random((3, 2)) + >>> rng.random((3, 2)) #doctest: +SKIP array([[0.01652764, 0.81327024], [0.91275558, 0.60663578], [0.72949656, 0.54362499]]) # may vary @@ -1011,7 +1010,7 @@ that this is inclusive with NumPy) to high (exclusive). You can set You can generate a 2 x 4 array of random integers between 0 and 4 with:: - >>> rng.integers(5, size=(2, 4)) + >>> rng.integers(5, size=(2, 4)) #doctest: +SKIP array([[2, 1, 1, 0], [0, 0, 0, 4]]) # may vary |