diff options
author | Raghav Khanna <37894186+raghavkhanna18@users.noreply.github.com> | 2020-08-24 08:43:05 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-08-23 18:43:05 -0600 |
commit | 196d633cb19274ddffb4ba42928126fd15e3282d (patch) | |
tree | 896d58410f7fdec1ac3fe3f55e6c6b258285201f /numpy/lib/arraysetops.py | |
parent | 551773f27ccc955ce24d15eae84eed924250c573 (diff) | |
download | numpy-196d633cb19274ddffb4ba42928126fd15e3282d.tar.gz |
MAINT: Chain some exceptions in arraysetops. (#17132)
* MAINT: chain type error line 303 arraysetops.py
* MAINT: chain axis error line 281 arraysetops.py
* Revert "MAINT: chain axis error line 281 arraysetops.py"
This reverts commit f6e1f544bebb7e5346cb83bdac9756be6ee9f4f6.
* MAINT: chain axis error line 281 arraysetops.py to be from None
Diffstat (limited to 'numpy/lib/arraysetops.py')
-rw-r--r-- | numpy/lib/arraysetops.py | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/numpy/lib/arraysetops.py b/numpy/lib/arraysetops.py index df9a110c5..6a2ad004c 100644 --- a/numpy/lib/arraysetops.py +++ b/numpy/lib/arraysetops.py @@ -278,7 +278,7 @@ def unique(ar, return_index=False, return_inverse=False, ar = np.moveaxis(ar, axis, 0) except np.AxisError: # this removes the "axis1" or "axis2" prefix from the error message - raise np.AxisError(axis, ar.ndim) + raise np.AxisError(axis, ar.ndim) from None # Must reshape to a contiguous 2D array for this to work... orig_shape, orig_dtype = ar.shape, ar.dtype @@ -300,10 +300,10 @@ def unique(ar, return_index=False, return_inverse=False, # array with shape `(len(ar),)`. Because `dtype` in this case has # itemsize 0, the total size of the result is still 0 bytes. consolidated = np.empty(len(ar), dtype=dtype) - except TypeError: + except TypeError as e: # There's no good way to do this for object arrays, etc... msg = 'The axis argument to unique is not supported for dtype {dt}' - raise TypeError(msg.format(dt=ar.dtype)) + raise TypeError(msg.format(dt=ar.dtype)) from e def reshape_uniq(uniq): n = len(uniq) |