summaryrefslogtreecommitdiff
path: root/numpy/lib/twodim_base.py
diff options
context:
space:
mode:
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)