summaryrefslogtreecommitdiff
path: root/numpy/core/arrayprint.py
diff options
context:
space:
mode:
authorKexuan Sun <me@kianasun.com>2019-07-25 11:26:06 -0700
committerSebastian Berg <sebastian@sipsolutions.net>2019-07-25 11:26:06 -0700
commitfeee90d9e14490daa2439eb37c8511555d073f92 (patch)
treeef2208871d0a6023ba6603fb4c2c57a023ca1307 /numpy/core/arrayprint.py
parent9259a7ff720ebebdd90dbe5469f08ed386de5f1d (diff)
downloadnumpy-feee90d9e14490daa2439eb37c8511555d073f92.tar.gz
MAINT: Change the type of error raised in set_printoptions (gh-13899)
Previously an incorrect ``threshold`` raised ``ValueError``; it now raises ``TypeError`` for non-numeric types and ``ValueError`` for ``nan`` values.
Diffstat (limited to 'numpy/core/arrayprint.py')
-rw-r--r--numpy/core/arrayprint.py6
1 files changed, 4 insertions, 2 deletions
diff --git a/numpy/core/arrayprint.py b/numpy/core/arrayprint.py
index 108364824..ecd05d3ac 100644
--- a/numpy/core/arrayprint.py
+++ b/numpy/core/arrayprint.py
@@ -89,8 +89,10 @@ def _make_options_dict(precision=None, threshold=None, edgeitems=None,
"`False`", stacklevel=3)
if threshold is not None:
# forbid the bad threshold arg suggested by stack overflow, gh-12351
- if not isinstance(threshold, numbers.Number) or np.isnan(threshold):
- raise ValueError("threshold must be numeric and non-NAN, try "
+ if not isinstance(threshold, numbers.Number):
+ raise TypeError("threshold must be numeric")
+ if np.isnan(threshold):
+ raise ValueError("threshold must be non-NAN, try "
"sys.maxsize for untruncated representation")
return options