From 0033161ec65311c600dffc6d7af8daf4116b760f Mon Sep 17 00:00:00 2001 From: Tyler Reddy Date: Sun, 14 Oct 2018 16:03:00 -0700 Subject: [PATCH] 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 --- numpy/lib/tests/test_histograms.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/numpy/lib/tests/test_histograms.py b/numpy/lib/tests/test_histograms.py index a71060a46d11..fa6ad989f680 100644 --- a/numpy/lib/tests/test_histograms.py +++ b/numpy/lib/tests/test_histograms.py @@ -119,6 +119,13 @@ def test_outliers(self): 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