Skip to content

Commit 29082fc

Browse files
committed
TST: add test for fix of #12405
1 parent 79ac0c9 commit 29082fc

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

pandas/tests/plotting/test_datetimelike.py

+18-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from pandas.compat import lrange, zip
55

66
import numpy as np
7-
from pandas import Index, Series, DataFrame
7+
from pandas import Index, Series, DataFrame, NaT
88

99
from pandas.tseries.index import date_range, bdate_range
1010
from pandas.tseries.offsets import DateOffset
@@ -813,6 +813,23 @@ def test_mixed_freq_shared_ax(self):
813813
# self.assertEqual(ax1.lines[0].get_xydata()[0, 0],
814814
# ax2.lines[0].get_xydata()[0, 0])
815815

816+
def test_nat_handling(self):
817+
818+
import matplotlib.pyplot as plt
819+
820+
fig = plt.gcf()
821+
plt.clf()
822+
ax = fig.add_subplot(111)
823+
824+
dti = DatetimeIndex(['2015-01-01', NaT, '2015-01-03'])
825+
s = Series(range(len(dti)), dti)
826+
s.plot(ax=ax)
827+
xdata = ax.get_lines()[0].get_xdata()
828+
# plot x data is bounded by index values
829+
self.assertLessEqual(s.index.min(), Series(xdata).min())
830+
self.assertLessEqual(Series(xdata).max(), s.index.max())
831+
_check_plot_works(s.plot)
832+
816833
@slow
817834
def test_to_weekly_resampling(self):
818835
idxh = date_range('1/1/1999', periods=52, freq='W')

0 commit comments

Comments
 (0)