Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 22c6c7f

Browse filesBrowse files
author
Umair Idris
committed
Fix hexbin to use len instead of any. Fix hist to pass in bin_range and not overwrite weights on empty input.
1 parent 2bf9777 commit 22c6c7f
Copy full SHA for 22c6c7f

File tree

Expand file treeCollapse file tree

1 file changed

+5
-7
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+5
-7
lines changed

‎lib/matplotlib/axes/_axes.py

Copy file name to clipboardExpand all lines: lib/matplotlib/axes/_axes.py
+5-7Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3846,8 +3846,8 @@ def hexbin(self, x, y, C=None, gridsize=100, bins=None,
38463846
if extent is not None:
38473847
xmin, xmax, ymin, ymax = extent
38483848
else:
3849-
xmin, xmax = (np.amin(x), np.amax(x)) if x.any() else (0, 1)
3850-
ymin, ymax = (np.amin(y), np.amax(y)) if y.any() else (0, 1)
3849+
xmin, xmax = (np.amin(x), np.amax(x)) if len(x) else (0, 1)
3850+
ymin, ymax = (np.amin(y), np.amax(y)) if len(y) else (0, 1)
38513851

38523852
# to avoid issues with singular data, expand the min/max pairs
38533853
xmin, xmax = mtrans.nonsingular(xmin, xmax, expander=0.1)
@@ -5641,9 +5641,7 @@ def hist(self, x, bins=10, range=None, normed=False, weights=None,
56415641

56425642
# We need to do to 'weights' what was done to 'x'
56435643
if weights is not None:
5644-
if input_empty:
5645-
w = np.array([])
5646-
elif isinstance(weights, np.ndarray) or not iterable(weights[0]):
5644+
if isinstance(weights, np.ndarray) or not iterable(weights[0]):
56475645
w = np.array(weights)
56485646
if w.ndim == 2:
56495647
w = w.T
@@ -5669,7 +5667,7 @@ def hist(self, x, bins=10, range=None, normed=False, weights=None,
56695667
# If bins are not specified either explicitly or via range,
56705668
# we need to figure out the range required for all datasets,
56715669
# and supply that to np.histogram.
5672-
if not binsgiven:
5670+
if not binsgiven and not input_empty:
56735671
xmin = np.inf
56745672
xmax = -np.inf
56755673
for xi in x:
@@ -5681,7 +5679,7 @@ def hist(self, x, bins=10, range=None, normed=False, weights=None,
56815679
#hist_kwargs = dict(range=range, normed=bool(normed))
56825680
# We will handle the normed kwarg within mpl until we
56835681
# get to the point of requiring numpy >= 1.5.
5684-
hist_kwargs = dict(range=bin_range) if not input_empty else dict()
5682+
hist_kwargs = dict(range=bin_range)
56855683

56865684
n = []
56875685
mlast = None

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.