summaryrefslogtreecommitdiff
path: root/numpy/lib/twodim_base.py
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/twodim_base.py
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/twodim_base.py')
-rw-r--r--numpy/lib/twodim_base.py3
1 files changed, 3 insertions, 0 deletions
diff --git a/numpy/lib/twodim_base.py b/numpy/lib/twodim_base.py
index 811faff79..3e5ad31ff 100644
--- a/numpy/lib/twodim_base.py
+++ b/numpy/lib/twodim_base.py
@@ -804,6 +804,9 @@ def histogram2d(x, y, bins=10, range=None, normed=None, weights=None,
>>> plt.show()
"""
from numpy import histogramdd
+
+ if len(x) != len(y):
+ raise ValueError('x and y must have the same length.')
try:
N = len(bins)