summaryrefslogtreecommitdiff
path: root/numpy/lib/twodim_base.py
diff options
context:
space:
mode:
authorStephan Hoyer <shoyer@google.com>2019-06-11 22:47:05 -0400
committerStephan Hoyer <shoyer@google.com>2019-06-11 22:47:05 -0400
commitd8b3091c3bfd406bd9d40303960f6461afe65fc6 (patch)
tree5f96c77351ec31356b921bc607ba51764a6dfcac /numpy/lib/twodim_base.py
parentebb0c5d3e4fc3835c1b71434845f03ae7bbaae0c (diff)
downloadnumpy-d8b3091c3bfd406bd9d40303960f6461afe65fc6.tar.gz
MAINT: check bins length in histogram2d_dispatcher
Diffstat (limited to 'numpy/lib/twodim_base.py')
-rw-r--r--numpy/lib/twodim_base.py15
1 files changed, 11 insertions, 4 deletions
diff --git a/numpy/lib/twodim_base.py b/numpy/lib/twodim_base.py
index 1928aa10c..0b4e3021a 100644
--- a/numpy/lib/twodim_base.py
+++ b/numpy/lib/twodim_base.py
@@ -567,11 +567,18 @@ def _histogram2d_dispatcher(x, y, bins=None, range=None, normed=None,
weights=None, density=None):
yield x
yield y
- if hasattr(bins, 'shape'): # same condition as used in histogramdd
- yield bins
+
+ # This terrible logic is adapted from the checks in histogram2d
+ try:
+ N = len(bins)
+ except TypeError:
+ N = 1
+ if N != 1 and N != 2:
+ yield from bins # bins=[x, y]
else:
- yield from bins
- return weights
+ yield bins
+
+ yield weights
@array_function_dispatch(_histogram2d_dispatcher)