From feee90d9e14490daa2439eb37c8511555d073f92 Mon Sep 17 00:00:00 2001 From: Kexuan Sun Date: Thu, 25 Jul 2019 11:26:06 -0700 Subject: 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. --- numpy/core/arrayprint.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'numpy/core/arrayprint.py') 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 -- cgit v1.2.1