diff options
author | bartosz-grabowski <58475557+bartosz-grabowski@users.noreply.github.com> | 2020-05-14 23:57:24 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-05-14 16:57:24 -0500 |
commit | a813a5feb53cef3b22d60599ec330cc945f1b85c (patch) | |
tree | b8314f0388a249ebcddc1af1089f57728f508e92 /numpy/matrixlib/defmatrix.py | |
parent | 59e8fc601bf38c94bf1ee0a7153a7ee385133e4b (diff) | |
download | numpy-a813a5feb53cef3b22d60599ec330cc945f1b85c.tar.gz |
MAINT: Chain exceptions and use NameError in np.bmat (#16215)
This solution is related to the issue #15986. I also made a change to the newer string formatting.
Uses NameError, which prints nicer, and is actually the more correct error type.
Co-authored-by: Eric Wieser <wieser.eric@gmail.com>
Co-authored-by: Ross Barnowski <rossbar@berkeley.edu>
Diffstat (limited to 'numpy/matrixlib/defmatrix.py')
-rw-r--r-- | numpy/matrixlib/defmatrix.py | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/numpy/matrixlib/defmatrix.py b/numpy/matrixlib/defmatrix.py index d1a1211aa..a13ff23f4 100644 --- a/numpy/matrixlib/defmatrix.py +++ b/numpy/matrixlib/defmatrix.py @@ -1024,8 +1024,8 @@ def _from_string(str, gdict, ldict): except KeyError: try: thismat = gdict[col] - except KeyError: - raise KeyError("%s not found" % (col,)) + except KeyError as e: + raise NameError(f"name {col!r} is not defined") from None coltup.append(thismat) rowtup.append(concatenate(coltup, axis=-1)) |