diff options
author | Bas van Beek <b.f.van.beek@vu.nl> | 2020-08-13 15:15:56 +0200 |
---|---|---|
committer | Bas van Beek <b.f.van.beek@vu.nl> | 2020-08-13 15:15:56 +0200 |
commit | f977f575d6263cac4703d809f57fe895415993ae (patch) | |
tree | 9e12c30498df50e0dcc8b33a52426cfb9f3f6761 /numpy/lib/function_base.py | |
parent | e62d5d15f3b8df247dcb133eaaceb71f5f60d8c0 (diff) | |
download | numpy-f977f575d6263cac4703d809f57fe895415993ae.tar.gz |
MAINT: Issue the DeprecationWarning after creating the to-be returned array
Diffstat (limited to 'numpy/lib/function_base.py')
-rw-r--r-- | numpy/lib/function_base.py | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/numpy/lib/function_base.py b/numpy/lib/function_base.py index e9fe936e9..8e25074ab 100644 --- a/numpy/lib/function_base.py +++ b/numpy/lib/function_base.py @@ -1634,11 +1634,12 @@ def trim_zeros(filt, trim='fb'): "that supports elementwise comparisons with zero" ) warning.__cause__ = ex - warnings.warn(warning, stacklevel=3) - # Fall back to the old implementation if an exception is encountered - # Note that the same exception may or may not be raised here as well - return _trim_zeros_old(filt, trim) + # Fall back to the old implementation if an exception is encountered + # Note that the same exception may or may not be raised here as well + ret = _trim_zeros_old(filt, trim) + warnings.warn(warning, stacklevel=3) + return ret def _trim_zeros_new(filt, trim='fb'): |