Skip to content

Commit 8437938

Browse files
Add regression test for histogram conversion with clamped bargap
1 parent 1130276 commit 8437938

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

plotly/matplotlylib/tests/test_renderer.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,3 +213,16 @@ def test_get_bar_gap_clamps_negative_float_noise():
213213
assert get_bar_gap([0.0, 1.0], [1.0 + 1e-15, 2.0]) == 0.0
214214
# positive gaps are unchanged
215215
assert get_bar_gap([0.0, 2.0], [1.0, 3.0]) == 1.0
216+
217+
218+
def test_histogram_converts():
219+
"""Histograms must convert without error and keep bargap in plotly's
220+
valid [0, 1] range; get_bar_gap can return a gap with floating point
221+
noise for touching bars, which plotly rejects."""
222+
fig, ax = plt.subplots()
223+
ax.hist(np.random.randn(1000), 30)
224+
225+
plotly_fig = tls.mpl_to_plotly(fig)
226+
227+
assert len(plotly_fig.data) == 1
228+
assert 0 <= plotly_fig.layout.bargap <= 1

0 commit comments

Comments
 (0)