Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit fd76d04

Browse files
dstansbyMeeseeksDev[bot]
authored and
MeeseeksDev[bot]
committed
Backport PR #9564: TST: add test of normed histogram with unequal bins
1 parent 187dd92 commit fd76d04

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

lib/matplotlib/tests/test_axes.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1517,6 +1517,17 @@ def test_hist_step_log_bottom():
15171517
ax.set_ylim(9e-3, 1e3)
15181518

15191519

1520+
def test_hist_unequal_bins_density():
1521+
# Test correct behavior of normalized histogram with unequal bins
1522+
# https://github.com/matplotlib/matplotlib/issues/9557
1523+
rng = np.random.RandomState(57483)
1524+
t = rng.randn(100)
1525+
bins = [-3, -1, -0.5, 0, 1, 5]
1526+
mpl_heights, _, _ = plt.hist(t, bins=bins, density=True)
1527+
np_heights, _ = np.histogram(t, bins=bins, density=True)
1528+
assert_allclose(mpl_heights, np_heights)
1529+
1530+
15201531
def contour_dat():
15211532
x = np.linspace(-3, 5, 150)
15221533
y = np.linspace(-3, 5, 120)

0 commit comments

Comments
 (0)