@@ -70,14 +70,55 @@ def test_date2num_NaT_scalar(units):
70
70
assert np .isnan (tmpl )
71
71
72
72
73
- @image_comparison (['date_empty.png' ])
74
73
def test_date_empty ():
75
74
# make sure we do the right thing when told to plot dates even
76
75
# if no date data has been presented, cf
77
76
# http://sourceforge.net/tracker/?func=detail&aid=2850075&group_id=80706&atid=560720
78
77
fig , ax = plt .subplots ()
79
78
ax .xaxis_date ()
79
+ fig .draw_no_output ()
80
+ np .testing .assert_allclose (ax .get_xlim (),
81
+ [mdates .date2num (np .datetime64 ('2000-01-01' )),
82
+ mdates .date2num (np .datetime64 ('2010-01-01' ))])
80
83
84
+ mdates ._reset_epoch_test_example ()
85
+ mdates .set_epoch ('0000-12-31' )
86
+ fig , ax = plt .subplots ()
87
+ ax .xaxis_date ()
88
+ fig .draw_no_output ()
89
+ np .testing .assert_allclose (ax .get_xlim (),
90
+ [mdates .date2num (np .datetime64 ('2000-01-01' )),
91
+ mdates .date2num (np .datetime64 ('2010-01-01' ))])
92
+ mdates ._reset_epoch_test_example ()
93
+
94
+
95
+ def test_date_not_empty ():
96
+ fig = plt .figure ()
97
+ ax = fig .add_subplot ()
98
+
99
+ ax .plot ([50 , 70 ], [1 , 2 ])
100
+ ax .xaxis .axis_date ()
101
+ np .testing .assert_allclose (ax .get_xlim (), [50 , 70 ])
102
+
103
+
104
+ def test_axhline ():
105
+ # make sure that axhline doesn't set the xlimits...
106
+ fig , ax = plt .subplots ()
107
+ ax .axhline (1.5 )
108
+ ax .plot ([np .datetime64 ('2016-01-01' ), np .datetime64 ('2016-01-02' )], [1 , 2 ])
109
+ np .testing .assert_allclose (ax .get_xlim (),
110
+ [mdates .date2num (np .datetime64 ('2016-01-01' )),
111
+ mdates .date2num (np .datetime64 ('2016-01-02' ))])
112
+
113
+ mdates ._reset_epoch_test_example ()
114
+ mdates .set_epoch ('0000-12-31' )
115
+ fig , ax = plt .subplots ()
116
+ ax .axhline (1.5 )
117
+ ax .plot ([np .datetime64 ('2016-01-01' ), np .datetime64 ('2016-01-02' )], [1 , 2 ])
118
+ np .testing .assert_allclose (ax .get_xlim (),
119
+ [mdates .date2num (np .datetime64 ('2016-01-01' )),
120
+ mdates .date2num (np .datetime64 ('2016-01-02' ))])
121
+ mdates ._reset_epoch_test_example ()
81
122
82
123
@image_comparison (['date_axhspan.png' ])
83
124
def test_date_axhspan ():
0 commit comments