From 3eef647fcc486c87da719fa480232fd351384a35 Mon Sep 17 00:00:00 2001 From: James Gerity Date: Sun, 24 Jan 2021 23:30:17 -0500 Subject: DOC: Drop '1-D' from docstring --- numpy/random/_generator.pyx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'numpy') diff --git a/numpy/random/_generator.pyx b/numpy/random/_generator.pyx index 3033a1495..60017e8ce 100644 --- a/numpy/random/_generator.pyx +++ b/numpy/random/_generator.pyx @@ -599,7 +599,7 @@ cdef class Generator: """ choice(a, size=None, replace=True, p=None, axis=0, shuffle=True) - Generates a random sample from a given 1-D array + Generates a random sample from a given array Parameters ---------- -- cgit v1.2.1 From 25885174d684d4eb9e162c09fd91e8296241df6e Mon Sep 17 00:00:00 2001 From: James Gerity Date: Sun, 24 Jan 2021 23:45:09 -0500 Subject: DOC: add example of sampling from 2-D array --- numpy/random/_generator.pyx | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'numpy') diff --git a/numpy/random/_generator.pyx b/numpy/random/_generator.pyx index 60017e8ce..cba13ed59 100644 --- a/numpy/random/_generator.pyx +++ b/numpy/random/_generator.pyx @@ -665,6 +665,13 @@ cdef class Generator: array([3,1,0]) # random >>> #This is equivalent to rng.permutation(np.arange(5))[:3] + Generate a uniform random sample from a 2-D array, without + replacement: + + >>> rng.choice([[0, 1, 2], [3, 4, 5], [6, 7, 8]], 2, replace=False) + array([[3, 4, 5], + [0, 1, 2]]) + Generate a non-uniform random sample from np.arange(5) of size 3 without replacement: -- cgit v1.2.1 From edab247184252508b51f6012bcf86c438d1f596e Mon Sep 17 00:00:00 2001 From: James Gerity Date: Tue, 26 Jan 2021 17:06:23 -0500 Subject: Mark example as random --- numpy/random/_generator.pyx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'numpy') diff --git a/numpy/random/_generator.pyx b/numpy/random/_generator.pyx index cba13ed59..93b1d6160 100644 --- a/numpy/random/_generator.pyx +++ b/numpy/random/_generator.pyx @@ -669,7 +669,7 @@ cdef class Generator: replacement: >>> rng.choice([[0, 1, 2], [3, 4, 5], [6, 7, 8]], 2, replace=False) - array([[3, 4, 5], + array([[3, 4, 5], # random [0, 1, 2]]) Generate a non-uniform random sample from np.arange(5) of size -- cgit v1.2.1 From f7d26c28190b430407e35c2169af88935353403c Mon Sep 17 00:00:00 2001 From: James Gerity Date: Tue, 26 Jan 2021 17:08:06 -0500 Subject: Clarify description of example --- numpy/random/_generator.pyx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'numpy') diff --git a/numpy/random/_generator.pyx b/numpy/random/_generator.pyx index 93b1d6160..0a41f13b6 100644 --- a/numpy/random/_generator.pyx +++ b/numpy/random/_generator.pyx @@ -665,8 +665,8 @@ cdef class Generator: array([3,1,0]) # random >>> #This is equivalent to rng.permutation(np.arange(5))[:3] - Generate a uniform random sample from a 2-D array, without - replacement: + Generate a uniform random sample from a 2-D array along the first + axis (the default), without replacement: >>> rng.choice([[0, 1, 2], [3, 4, 5], [6, 7, 8]], 2, replace=False) array([[3, 4, 5], # random -- cgit v1.2.1