summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatti Picus <matti.picus@gmail.com>2020-05-07 11:22:07 +0300
committerGitHub <noreply@github.com>2020-05-07 11:22:07 +0300
commit666b17976e1ee7bb2079259831ccba41d37cf078 (patch)
treef12881ec210893e50ed1a5111f48d981ce4610ec
parentecf407ec846324cabaa0afd4bcfbe90899c94da1 (diff)
parent63673a81d910c42aae60d6489674cdbd8c7b664e (diff)
downloadnumpy-666b17976e1ee7bb2079259831ccba41d37cf078.tar.gz
Merge pull request #16078 from rossbar/doc/axis_to_new_or_different
DOC: Add axis to random module "new or different" docs
-rw-r--r--doc/source/reference/random/index.rst3
-rw-r--r--doc/source/reference/random/new-or-different.rst12
2 files changed, 15 insertions, 0 deletions
diff --git a/doc/source/reference/random/index.rst b/doc/source/reference/random/index.rst
index bda9c4d96..d559f2327 100644
--- a/doc/source/reference/random/index.rst
+++ b/doc/source/reference/random/index.rst
@@ -168,6 +168,9 @@ What's New or Different
Python's `random.random`.
* All BitGenerators in numpy use `SeedSequence` to convert seeds into
initialized states.
+* The addition of an ``axis`` keyword argument to methods such as
+ `Generator.choice`, `Generator.permutation`, and `Generator.shuffle`
+ improves support for sampling from and shuffling multi-dimensional arrays.
See :ref:`new-or-different` for a complete list of improvements and
differences from the traditional ``Randomstate``.
diff --git a/doc/source/reference/random/new-or-different.rst b/doc/source/reference/random/new-or-different.rst
index 1d6b09faf..03e7775a0 100644
--- a/doc/source/reference/random/new-or-different.rst
+++ b/doc/source/reference/random/new-or-different.rst
@@ -115,3 +115,15 @@ And in more detail:
rg.random(out=existing[:2])
print(existing)
+* Optional ``axis`` argument for methods like `~.Generator.choice`,
+ `~.Generator.permutation` and `~.Generator.shuffle` that controls which
+ axis an operation is performed over for multi-dimensional arrays.
+
+.. ipython:: python
+
+ rg = Generator(PCG64(123456789))
+ a = np.arange(12).reshape((3, 4))
+ a
+ rg.choice(a, axis=1, size=5)
+ rg.shuffle(a, axis=1) # Shuffle in-place
+ a