diff options
author | Chris Holland <chrisholland3553@gmail.com> | 2020-04-23 20:19:39 -0700 |
---|---|---|
committer | Chris Holland <chrisholland3553@gmail.com> | 2020-04-23 20:19:39 -0700 |
commit | 45126aa4caa9ae9f83ec7d5235ca07c59a4d0747 (patch) | |
tree | 179b82735a71d87d9ce30b2915f2d2bbd33bac62 | |
parent | bcb036a58aac566d4050b163a0f6b77e09c40123 (diff) | |
download | numpy-45126aa4caa9ae9f83ec7d5235ca07c59a4d0747.tar.gz |
Added some chained exceptions
-rw-r--r-- | numpy/linalg/linalg.py | 8 | ||||
-rw-r--r-- | numpy/polynomial/polyutils.py | 8 |
2 files changed, 8 insertions, 8 deletions
diff --git a/numpy/linalg/linalg.py b/numpy/linalg/linalg.py index eac6267c6..6d3afdd49 100644 --- a/numpy/linalg/linalg.py +++ b/numpy/linalg/linalg.py @@ -622,8 +622,8 @@ def matrix_power(a, n): try: n = operator.index(n) - except TypeError: - raise TypeError("exponent must be an integer") + except TypeError as e: + raise TypeError("exponent must be an integer") from e # Fall back on dot for object arrays. Object arrays are not supported by # the current implementation of matmul using einsum @@ -2540,8 +2540,8 @@ def norm(x, ord=None, axis=None, keepdims=False): elif not isinstance(axis, tuple): try: axis = int(axis) - except Exception: - raise TypeError("'axis' must be None, an integer or a tuple of integers") + except Exception as e: + raise TypeError("'axis' must be None, an integer or a tuple of integers") from e axis = (axis,) if len(axis) == 1: diff --git a/numpy/polynomial/polyutils.py b/numpy/polynomial/polyutils.py index ec7ba6f1d..b1cf07e8a 100644 --- a/numpy/polynomial/polyutils.py +++ b/numpy/polynomial/polyutils.py @@ -193,8 +193,8 @@ def as_series(alist, trim=True): else: try: dtype = np.common_type(*arrays) - except Exception: - raise ValueError("Coefficient arrays have no common type") + except Exception as e: + raise ValueError("Coefficient arrays have no common type") from e ret = [np.array(a, copy=True, dtype=dtype) for a in arrays] return ret @@ -777,7 +777,7 @@ def _deprecate_as_int(x, desc): """ try: return operator.index(x) - except TypeError: + except TypeError as e: # Numpy 1.17.0, 2019-03-11 try: ix = int(x) @@ -793,4 +793,4 @@ def _deprecate_as_int(x, desc): ) return ix - raise TypeError(f"{desc} must be an integer") + raise TypeError(f"{desc} must be an integer") from e |