summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--doc/source/reference/random/generator.rst2
-rw-r--r--numpy/random/_generator.pyx25
2 files changed, 16 insertions, 11 deletions
diff --git a/doc/source/reference/random/generator.rst b/doc/source/reference/random/generator.rst
index c73ac7b7b..9bee4d756 100644
--- a/doc/source/reference/random/generator.rst
+++ b/doc/source/reference/random/generator.rst
@@ -88,7 +88,7 @@ Note that when ``out`` is given, the return value is ``out``:
>>> y is x
True
-.. _generator-handling-the-axis-parameter:
+.. _generator-handling-axis-parameter:
Handling the ``axis`` parameter
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
diff --git a/numpy/random/_generator.pyx b/numpy/random/_generator.pyx
index 81435731e..5e04b9893 100644
--- a/numpy/random/_generator.pyx
+++ b/numpy/random/_generator.pyx
@@ -4571,27 +4571,32 @@ cdef class Generator:
-------
None
- .. note::
- An important distinction between methods ``shuffle`` and ``permuted`` is
- how they both treat the ``axis`` parameter which can be found at
- :ref:`generator-handling-the-axis-parameter`.
-
See Also
--------
permuted
permutation
+ Notes
+ -----
+ An important distinction between methods ``shuffle`` and ``permuted`` is
+ how they both treat the ``axis`` parameter which can be found at
+ :ref:`generator-handling-axis-parameter`.
+
Examples
--------
>>> rng = np.random.default_rng()
>>> arr = np.arange(10)
- >>> rng.shuffle(arr)
>>> arr
- [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
+ array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
+ >>> rng.shuffle(arr)
>>> arr
- [1 7 5 2 9 4 3 6 0 8] # random
+ array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) # random
>>> arr = np.arange(9).reshape((3, 3))
+ >>> arr
+ array([[0, 1, 2],
+ [3, 4, 5],
+ [6, 7, 8]])
>>> rng.shuffle(arr)
>>> arr
array([[3, 4, 5], # random
@@ -4601,8 +4606,8 @@ cdef class Generator:
>>> arr = np.arange(9).reshape((3, 3))
>>> arr
array([[0, 1, 2],
- [3, 4, 5],
- [6, 7, 8]])
+ [3, 4, 5],
+ [6, 7, 8]])
>>> rng.shuffle(arr, axis=1)
>>> arr
array([[2, 0, 1], # random