@@ -300,19 +300,6 @@ def test_drange():
300
300
assert mdates .num2date (daterange [- 1 ]) == (end - delta )
301
301
302
302
303
- def test_empty_date_with_year_formatter ():
304
- # exposes sf bug 2861426:
305
- # https://sourceforge.net/tracker/?func=detail&aid=2861426&group_id=80706&atid=560720
306
-
307
- # update: I am no longer believe this is a bug, as I commented on
308
- # the tracker. The question is now: what to do with this test
309
-
310
- fig , ax = plt .subplots ()
311
- ax .xaxis .set_major_formatter (mdates .DateFormatter ('%Y' ))
312
- with pytest .raises (ValueError ):
313
- fig .canvas .draw ()
314
-
315
-
316
303
@_new_epoch_decorator
317
304
def test_auto_date_locator ():
318
305
def _create_auto_date_locator (date1 , date2 ):
@@ -759,8 +746,8 @@ def _test_date2num_dst(date_range, tz_convert):
759
746
760
747
dt_utc = date_range (start = dtstart , freq = interval , periods = N )
761
748
dt_bxl = tz_convert (dt_utc , BRUSSELS )
762
-
763
- expected_ordinalf = [735322.0 + (i * interval_days ) for i in range (N )]
749
+ t0 = 735322.0 + mdates . date2num ( np . datetime64 ( '0000-12-31' ))
750
+ expected_ordinalf = [t0 + (i * interval_days ) for i in range (N )]
764
751
actual_ordinalf = list (mdates .date2num (dt_bxl ))
765
752
766
753
assert actual_ordinalf == expected_ordinalf
@@ -885,10 +872,11 @@ def test_yearlocator_pytz():
885
872
locator .create_dummy_axis ()
886
873
locator .set_view_interval (mdates .date2num (x [0 ])- 1.0 ,
887
874
mdates .date2num (x [- 1 ])+ 1.0 )
888
-
889
- np .testing .assert_allclose ([733408.208333 , 733773.208333 , 734138.208333 ,
890
- 734503.208333 , 734869.208333 ,
891
- 735234.208333 , 735599.208333 ], locator ())
875
+ t = np .array ([733408.208333 , 733773.208333 , 734138.208333 ,
876
+ 734503.208333 , 734869.208333 , 735234.208333 , 735599.208333 ])
877
+ # convert to new epoch from old...
878
+ t = t + mdates .date2num (np .datetime64 ('0000-12-31' ))
879
+ np .testing .assert_allclose (t , locator ())
892
880
expected = ['2009-01-01 00:00:00-05:00' ,
893
881
'2010-01-01 00:00:00-05:00' , '2011-01-01 00:00:00-05:00' ,
894
882
'2012-01-01 00:00:00-05:00' , '2013-01-01 00:00:00-05:00' ,
@@ -926,18 +914,19 @@ def test_num2timedelta(x, tdelta):
926
914
def test_datetime64_in_list ():
927
915
dt = [np .datetime64 ('2000-01-01' ), np .datetime64 ('2001-01-01' )]
928
916
dn = mdates .date2num (dt )
929
- np .testing .assert_equal (dn , [730120. , 730486. ])
917
+ # convert fixed values from old to new epoch
918
+ t = (np .array ([730120. , 730486. ]) +
919
+ mdates .date2num (np .datetime64 ('0000-12-31' )))
920
+ np .testing .assert_equal (dn , t )
930
921
931
922
932
923
def test_change_epoch ():
933
924
date = np .datetime64 ('2000-01-01' )
934
- # old epoch (style=Classic)
935
- np .testing .assert_equal (mdates .date2num (date ), 730120.0 )
936
925
937
926
with pytest .raises (RuntimeError ):
938
927
# this should fail here because there is a sentinel on the epoch
939
928
# if the epoch has been used then it cannot be set.
940
- mdates .set_epoch ('1970 -01-01' )
929
+ mdates .set_epoch ('0000 -01-01' )
941
930
942
931
# use private method to clear the epoch and allow it to be set...
943
932
mdates ._reset_epoch_test_example ()
0 commit comments