From 7884a8c9f5f5c6657413dbeaa59ad969280d38ea Mon Sep 17 00:00:00 2001 From: Sebastian Berg Date: Sat, 23 Jan 2016 15:58:58 +0100 Subject: ENH: Add stacklevel to all (or almost all) our function calls --- numpy/core/_methods.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'numpy/core/_methods.py') diff --git a/numpy/core/_methods.py b/numpy/core/_methods.py index 5fc2bc445..54e267541 100644 --- a/numpy/core/_methods.py +++ b/numpy/core/_methods.py @@ -56,7 +56,7 @@ def _mean(a, axis=None, dtype=None, out=None, keepdims=False): rcount = _count_reduce_items(arr, axis) # Make this warning show up first if rcount == 0: - warnings.warn("Mean of empty slice.", RuntimeWarning) + warnings.warn("Mean of empty slice.", RuntimeWarning, stacklevel=2) # Cast bool, unsigned int, and int to float64 by default if dtype is None and issubclass(arr.dtype.type, (nt.integer, nt.bool_)): @@ -79,7 +79,8 @@ def _var(a, axis=None, dtype=None, out=None, ddof=0, keepdims=False): rcount = _count_reduce_items(arr, axis) # Make this warning show up on top. if ddof >= rcount: - warnings.warn("Degrees of freedom <= 0 for slice", RuntimeWarning) + warnings.warn("Degrees of freedom <= 0 for slice", RuntimeWarning, + stacklevel=2) # Cast bool, unsigned int, and int to float64 by default if dtype is None and issubclass(arr.dtype.type, (nt.integer, nt.bool_)): -- cgit v1.2.1