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

Skip to content

Commit b0decc5

Browse files
committed
TST: fix tests
1 parent d7739f3 commit b0decc5

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed
Binary file not shown.

lib/matplotlib/tests/test_dates.py

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,12 +85,31 @@ def test_date_empty():
8585
fig, ax = plt.subplots()
8686
ax.xaxis_date()
8787
fig.draw_no_output()
88-
np.testing.assert_allclose(ax.get_xlim(),
88+
np.testing.assert_allclose(ax.get_xlim(),
8989
[mdates.date2num(np.datetime64('2000-01-01')),
9090
mdates.date2num(np.datetime64('2010-01-01'))])
9191
mdates._reset_epoch_test_example()
9292

9393

94+
def test_axhline():
95+
# make sure that axhline doesn't set the xlimits...
96+
fig, ax = plt.subplots()
97+
ax.axhline(1.5)
98+
ax.plot([np.datetime64('2016-01-01'), np.datetime64('2016-01-02')], [1, 2])
99+
np.testing.assert_allclose(ax.get_xlim(),
100+
[mdates.date2num(np.datetime64('2016-01-01')),
101+
mdates.date2num(np.datetime64('2016-01-02'))])
102+
103+
mdates._reset_epoch_test_example()
104+
mdates.set_epoch('0000-12-31')
105+
fig, ax = plt.subplots()
106+
ax.axhline(1.5)
107+
ax.plot([np.datetime64('2016-01-01'), np.datetime64('2016-01-02')], [1, 2])
108+
np.testing.assert_allclose(ax.get_xlim(),
109+
[mdates.date2num(np.datetime64('2016-01-01')),
110+
mdates.date2num(np.datetime64('2016-01-02'))])
111+
mdates._reset_epoch_test_example()
112+
94113

95114
@image_comparison(['date_axhspan.png'])
96115
def test_date_axhspan():

0 commit comments

Comments
 (0)