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 287a815

Browse filesBrowse files
author
Umair Idris
committed
Fix hist raising ValueError on empty dataset
1 parent e864d94 commit 287a815
Copy full SHA for 287a815

File tree

Expand file treeCollapse file tree

2 files changed

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

2 files changed

+5
-0
lines changed

‎lib/matplotlib/axes/_axes.py

Copy file name to clipboardExpand all lines: lib/matplotlib/axes/_axes.py
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5605,6 +5605,8 @@ def hist(self, x, bins=10, range=None, normed=False, weights=None,
56055605

56065606
# basic input validation
56075607
flat = np.ravel(x)
5608+
if len(flat) == 0:
5609+
return [], [], cbook.silent_list('No Patches')
56085610

56095611
# Massage 'x' for processing.
56105612
# NOTE: Be sure any changes here is also done below to 'weights'

‎lib/matplotlib/tests/test_axes.py

Copy file name to clipboardExpand all lines: lib/matplotlib/tests/test_axes.py
+3Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1005,6 +1005,9 @@ def test_hist_log():
10051005
ax.hist(data, fill=False, log=True)
10061006

10071007

1008+
def test_hist_empty():
1009+
ax.hist([])
1010+
10081011
@image_comparison(baseline_images=['hist_steplog'], remove_text=True)
10091012
def test_hist_steplog():
10101013
np.random.seed(0)

0 commit comments

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