summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWarren Weckesser <warren.weckesser@gmail.com>2021-02-19 18:28:18 -0500
committerWarren Weckesser <warren.weckesser@gmail.com>2021-02-19 18:28:18 -0500
commit54572d275dd5d12b564ab444958af7a0aa91e701 (patch)
tree3695afd99cdf5c9a8bba808218cb1cf54f98295b
parent4de12597c1f15fad33201aea2cc918a687c20665 (diff)
downloadnumpy-54572d275dd5d12b564ab444958af7a0aa91e701.tar.gz
MAINT: random: use 'from exc' instead of 'from None'; tweak error messages.
-rw-r--r--numpy/random/_generator.pyx14
1 files changed, 7 insertions, 7 deletions
diff --git a/numpy/random/_generator.pyx b/numpy/random/_generator.pyx
index b246037f1..2e0b9817d 100644
--- a/numpy/random/_generator.pyx
+++ b/numpy/random/_generator.pyx
@@ -700,17 +700,17 @@ cdef class Generator:
try:
# __index__ must return an integer by python rules.
pop_size = operator.index(a.item())
- except TypeError:
- raise ValueError("a must be an array or an integer, "
- f"not {type(a_original)}") from None
+ except TypeError as exc:
+ raise ValueError("a must be a sequence or an integer, "
+ f"not {type(a_original)}") from exc
if pop_size <= 0 and np.prod(size) != 0:
- raise ValueError("a must be a positive integer unless no"
- " samples are taken")
+ raise ValueError("a must be a positive integer unless no "
+ "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")
+ raise ValueError("a cannot be empty unless no samples are "
+ "taken")
if p is not None:
d = len(p)