summaryrefslogtreecommitdiff
path: root/numpy/lib/tests
diff options
context:
space:
mode:
authorJérome Eertmans <jeertmans@icloud.com>2021-11-02 16:14:03 +0100
committerGitHub <noreply@github.com>2021-11-02 08:14:03 -0700
commitae4af75cb766d3f5d6b791658ef51a9f16249e8b (patch)
treeec0b32ab4337d8f6d6c546e4163e52d070370ccd /numpy/lib/tests
parent265dd671ea6bc703a9c0adfc5388e54d1f51bd59 (diff)
downloadnumpy-ae4af75cb766d3f5d6b791658ef51a9f16249e8b.tar.gz
ENH: Check that the lengths of the inputs to histogram2d are the same. (#20228)
Improves exception message when inputs have different shapes. Closes gh-20050 Co-authored-by: Ross Barnowski <rossbar@berkeley.edu>
Diffstat (limited to 'numpy/lib/tests')
-rw-r--r--numpy/lib/tests/test_twodim_base.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/numpy/lib/tests/test_twodim_base.py b/numpy/lib/tests/test_twodim_base.py
index cce683bfe..c1c5a1615 100644
--- a/numpy/lib/tests/test_twodim_base.py
+++ b/numpy/lib/tests/test_twodim_base.py
@@ -18,6 +18,9 @@ import numpy as np
from numpy.core.tests.test_overrides import requires_array_function
+import pytest
+
+
def get_mat(n):
data = arange(n)
data = add.outer(data, data)
@@ -295,6 +298,13 @@ class TestHistogram2d:
r = histogram2d(xy, xy, weights=s_d)
assert_(r, ((ShouldDispatch,), (xy, xy), dict(weights=s_d)))
+ @pytest.mark.parametrize(("x_len", "y_len"), [(10, 11), (20, 19)])
+ def test_bad_length(self, x_len, y_len):
+ x, y = np.ones(x_len), np.ones(y_len)
+ with pytest.raises(ValueError,
+ match='x and y must have the same length.'):
+ histogram2d(x, y)
+
class TestTri:
def test_dtype(self):