summaryrefslogtreecommitdiff
path: root/numpy/core/_methods.py
diff options
context:
space:
mode:
Diffstat (limited to 'numpy/core/_methods.py')
-rw-r--r--numpy/core/_methods.py5
1 files changed, 3 insertions, 2 deletions
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_)):