summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--numpy/random/_generator.pyx8
1 files changed, 5 insertions, 3 deletions
diff --git a/numpy/random/_generator.pyx b/numpy/random/_generator.pyx
index a7d98e2ed..b246037f1 100644
--- a/numpy/random/_generator.pyx
+++ b/numpy/random/_generator.pyx
@@ -694,21 +694,23 @@ cdef class Generator:
cdef uint64_t set_size, mask
cdef uint64_t[::1] hash_set
# Format and Verify input
+ a_original = a
a = np.array(a, copy=False)
if a.ndim == 0:
try:
# __index__ must return an integer by python rules.
pop_size = operator.index(a.item())
except TypeError:
- raise ValueError("a must an array or an integer")
+ raise ValueError("a must be an array or an integer, "
+ f"not {type(a_original)}") from None
if pop_size <= 0 and np.prod(size) != 0:
raise ValueError("a must be a positive integer unless no"
- "samples are taken")
+ " samples are taken")
else:
pop_size = a.shape[axis]
if pop_size == 0 and np.prod(size) != 0:
raise ValueError("a cannot be empty unless no samples are"
- "taken")
+ " taken")
if p is not None:
d = len(p)