diff options
author | Abhay Raghuvanshi <abhayaman669@gmail.com> | 2021-03-19 04:45:07 +0530 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-03-18 17:15:07 -0600 |
commit | cb71c43d45c0ad6e14db97a51e317b771f6a9ebb (patch) | |
tree | 5af3a6385bdabcb914148d3a4becb7512f405339 | |
parent | ddbff082e0bab0e3580be9f2f275418595879022 (diff) | |
download | numpy-cb71c43d45c0ad6e14db97a51e317b771f6a9ebb.tar.gz |
MAINT: Added Chain exceptions where appropriate (#18400)
* Added chain exception in _pocketfft.py
* Added chain exception in format.py
* Added chain exception in make_lite.py
* Added chain exception in mrecords.py
* added from e for exceptions
* Minor update for _read_array_header exception msg
* Removed \n from excp msg and e from msg format.
Co-authored-by: Eric Wieser <wieser.eric@gmail.com>
* Update numpy/linalg/lapack_lite/make_lite.py
Co-authored-by: Eric Wieser <wieser.eric@gmail.com>
Co-authored-by: Eric Wieser <wieser.eric@gmail.com>
Co-authored-by: Charles Harris <charlesr.harris@gmail.com>
-rw-r--r-- | numpy/fft/_pocketfft.py | 2 | ||||
-rw-r--r-- | numpy/lib/format.py | 4 | ||||
-rw-r--r-- | numpy/ma/mrecords.py | 4 |
3 files changed, 5 insertions, 5 deletions
diff --git a/numpy/fft/_pocketfft.py b/numpy/fft/_pocketfft.py index bf0e60b6d..4ed3042a6 100644 --- a/numpy/fft/_pocketfft.py +++ b/numpy/fft/_pocketfft.py @@ -112,7 +112,7 @@ def _swap_direction(norm): return _SWAP_DIRECTION_MAP[norm] except KeyError: raise ValueError(f'Invalid norm value {norm}; should be "backward", ' - '"ortho" or "forward".') + '"ortho" or "forward".') from None def _fft_dispatcher(a, n=None, axis=None, norm=None): diff --git a/numpy/lib/format.py b/numpy/lib/format.py index ac5f75fba..904c32cc7 100644 --- a/numpy/lib/format.py +++ b/numpy/lib/format.py @@ -594,8 +594,8 @@ def _read_array_header(fp, version): try: d = safe_eval(header) except SyntaxError as e: - msg = "Cannot parse header: {!r}\nException: {!r}" - raise ValueError(msg.format(header, e)) from None + msg = "Cannot parse header: {!r}" + raise ValueError(msg.format(header)) from e if not isinstance(d, dict): msg = "Header is not a dictionary: {!r}" raise ValueError(msg.format(d)) diff --git a/numpy/ma/mrecords.py b/numpy/ma/mrecords.py index 126bdd9dc..9ea4e4e36 100644 --- a/numpy/ma/mrecords.py +++ b/numpy/ma/mrecords.py @@ -660,8 +660,8 @@ def openfile(fname): # Try to open the file and guess its type try: f = open(fname) - except IOError: - raise IOError(f"No such file: '{fname}'") + except IOError as e: + raise IOError(f"No such file: '{fname}'") from e if f.readline()[:2] != "\\x": f.seek(0, 0) return f |