summaryrefslogtreecommitdiff
path: root/numpy/lib/tests
diff options
context:
space:
mode:
authorTyler Reddy <tyler.je.reddy@gmail.com>2018-10-14 16:03:00 -0700
committerTyler Reddy <tyler.je.reddy@gmail.com>2018-10-14 16:03:00 -0700
commit0033161ec65311c600dffc6d7af8daf4116b760f (patch)
tree8c620b1f0e2dedcba04cfd77c6f13e50c3e3b049 /numpy/lib/tests
parent2c4c93af0b2d20d85a7432093f31318cbf3c457f (diff)
downloadnumpy-0033161ec65311c600dffc6d7af8daf4116b760f.tar.gz
TST: add test for weighted histogram mismatch
* add a unit test for an uncovered code path where a histogram array does not match the shape of the provided array of weights
Diffstat (limited to 'numpy/lib/tests')
-rw-r--r--numpy/lib/tests/test_histograms.py7
1 files changed, 7 insertions, 0 deletions
diff --git a/numpy/lib/tests/test_histograms.py b/numpy/lib/tests/test_histograms.py
index a71060a46..fa6ad989f 100644
--- a/numpy/lib/tests/test_histograms.py
+++ b/numpy/lib/tests/test_histograms.py
@@ -119,6 +119,13 @@ class TestHistogram(object):
h, b = histogram(a, bins=8, range=[1, 9], weights=w)
assert_equal(h, w[1:-1])
+ def test_arr_weights_mismatch(self):
+ a = np.arange(10) + .5
+ w = np.arange(11) + .5
+ with assert_raises_regex(ValueError, "same shape as"):
+ h, b = histogram(a, range=[1, 9], weights=w, density=True)
+
+
def test_type(self):
# Check the type of the returned histogram
a = np.arange(10) + .5