summaryrefslogtreecommitdiff
path: root/numpy/lib/histograms.py
diff options
context:
space:
mode:
authorStephan Hoyer <shoyer@gmail.com>2019-05-20 09:37:18 -0700
committerGitHub <noreply@github.com>2019-05-20 09:37:18 -0700
commitf9c1502e7ace9b48f0256a77c560aae43763a1f2 (patch)
tree1b04f2a79f979f6039a794173560da7153093ac9 /numpy/lib/histograms.py
parentbdd75dff0aa8b77be5784923befb6410fc2f4837 (diff)
downloadnumpy-f9c1502e7ace9b48f0256a77c560aae43763a1f2.tar.gz
BUG: Increment stacklevel for warnings to account for NEP-18 overrides (#13589)
* Increment stacklevel for warnings to account for NEP-18 overrides For NumPy functions that make use of `__array_function__`, the appropriate the stack level for warnings should generally be increased by 1 to account for the override function defined in numpy.core.overrides. Fixes GH-13329 * Update numpy/lib/type_check.py Co-Authored-By: Sebastian Berg <sebastian@sipsolutions.net>
Diffstat (limited to 'numpy/lib/histograms.py')
-rw-r--r--numpy/lib/histograms.py11
1 files changed, 6 insertions, 5 deletions
diff --git a/numpy/lib/histograms.py b/numpy/lib/histograms.py
index ee9a3053c..5bcedc7f4 100644
--- a/numpy/lib/histograms.py
+++ b/numpy/lib/histograms.py
@@ -148,7 +148,8 @@ def _hist_bin_stone(x, range):
nbins_upper_bound = max(100, int(np.sqrt(n)))
nbins = min(_range(1, nbins_upper_bound + 1), key=jhat)
if nbins == nbins_upper_bound:
- warnings.warn("The number of bins estimated may be suboptimal.", RuntimeWarning, stacklevel=2)
+ warnings.warn("The number of bins estimated may be suboptimal.",
+ RuntimeWarning, stacklevel=3)
return ptp_x / nbins
@@ -279,7 +280,7 @@ def _ravel_and_check_weights(a, weights):
if a.dtype == np.bool_:
warnings.warn("Converting input from {} to {} for compatibility."
.format(a.dtype, np.uint8),
- RuntimeWarning, stacklevel=2)
+ RuntimeWarning, stacklevel=3)
a = a.astype(np.uint8)
if weights is not None:
@@ -888,7 +889,7 @@ def histogram(a, bins=10, range=None, normed=None, weights=None,
warnings.warn(
"The normed argument is ignored when density is provided. "
"In future passing both will result in an error.",
- DeprecationWarning, stacklevel=2)
+ DeprecationWarning, stacklevel=3)
normed = None
if density:
@@ -904,7 +905,7 @@ def histogram(a, bins=10, range=None, normed=None, weights=None,
"density=True will produce the same result anyway. "
"The argument will be removed in a future version of "
"numpy.",
- np.VisibleDeprecationWarning, stacklevel=2)
+ np.VisibleDeprecationWarning, stacklevel=3)
# this normalization is incorrect, but
db = np.array(np.diff(bin_edges), float)
@@ -915,7 +916,7 @@ def histogram(a, bins=10, range=None, normed=None, weights=None,
warnings.warn(
"Passing normed=False is deprecated, and has no effect. "
"Consider passing the density argument instead.",
- DeprecationWarning, stacklevel=2)
+ DeprecationWarning, stacklevel=3)
return n, bin_edges