135
135
* :class:`IndexDateFormatter`: date plots with implicit *x*
136
136
indexing.
137
137
"""
138
- from __future__ import (absolute_import , division , print_function ,
139
- unicode_literals )
140
138
141
- import six
142
- from six .moves import zip
143
- import re
144
- import time
145
- import math
146
139
import datetime
147
140
import functools
148
-
149
- import warnings
150
141
import logging
142
+ import math
143
+ import re
144
+ import time
145
+ import warnings
151
146
152
147
from dateutil .rrule import (rrule , MO , TU , WE , TH , FR , SA , SU , YEARLY ,
153
148
MONTHLY , WEEKLY , DAILY , HOURLY , MINUTELY ,
154
149
SECONDLY )
155
150
from dateutil .relativedelta import relativedelta
156
151
import dateutil .parser
157
- import logging
158
152
import numpy as np
159
153
160
-
161
154
import matplotlib
162
155
from matplotlib import rcParams
163
156
import matplotlib .units as units
@@ -404,7 +397,7 @@ def datestr2num(d, default=None):
404
397
default : datetime instance, optional
405
398
The default date to use when fields are missing in *d*.
406
399
"""
407
- if isinstance (d , six . string_types ):
400
+ if isinstance (d , str ):
408
401
dt = dateutil .parser .parse (d , default = default )
409
402
return date2num (dt )
410
403
else :
@@ -629,15 +622,15 @@ def __init__(self, fmt, tz=None):
629
622
def __call__ (self , x , pos = 0 ):
630
623
if x == 0 :
631
624
raise ValueError ('DateFormatter found a value of x=0, which is '
632
- 'an illegal date. This usually occurs because '
625
+ 'an illegal date; this usually occurs because '
633
626
'you have not informed the axis that it is '
634
627
'plotting dates, e.g., with ax.xaxis_date()' )
635
- dt = num2date (x , self .tz )
636
- return self .strftime (dt , self .fmt )
628
+ return num2date (x , self .tz ).strftime (self .fmt )
637
629
638
630
def set_tzinfo (self , tz ):
639
631
self .tz = tz
640
632
633
+ @cbook .deprecated ("3.0" )
641
634
def _replace_common_substr (self , s1 , s2 , sub1 , sub2 , replacement ):
642
635
"""Helper function for replacing substrings sub1 and sub2
643
636
located at the same indexes in strings s1 and s2 respectively,
@@ -663,6 +656,7 @@ def _replace_common_substr(self, s1, s2, sub1, sub2, replacement):
663
656
664
657
return s1 , s2
665
658
659
+ @cbook .deprecated ("3.0" )
666
660
def strftime_pre_1900 (self , dt , fmt = None ):
667
661
"""Call time.strftime for years before 1900 by rolling
668
662
forward a multiple of 28 years.
@@ -720,6 +714,7 @@ def strftime_pre_1900(self, dt, fmt=None):
720
714
"{0:02d}" .format (dt .year % 100 ))
721
715
return cbook .unicode_safe (s1 )
722
716
717
+ @cbook .deprecated ("3.0" )
723
718
def strftime (self , dt , fmt = None ):
724
719
"""
725
720
Refer to documentation for :meth:`datetime.datetime.strftime`
@@ -764,10 +759,7 @@ def __call__(self, x, pos=0):
764
759
ind = int (np .round (x ))
765
760
if ind >= len (self .t ) or ind <= 0 :
766
761
return ''
767
-
768
- dt = num2date (self .t [ind ], self .tz )
769
-
770
- return cbook .unicode_safe (dt .strftime (self .fmt ))
762
+ return num2date (self .t [ind ], self .tz ).strftime (self .fmt )
771
763
772
764
773
765
class AutoDateFormatter (ticker .Formatter ):
@@ -858,7 +850,7 @@ def __call__(self, x, pos=None):
858
850
if scale >= locator_unit_scale ),
859
851
self .defaultfmt )
860
852
861
- if isinstance (fmt , six . string_types ):
853
+ if isinstance (fmt , str ):
862
854
self ._formatter = DateFormatter (fmt , self ._tz )
863
855
result = self ._formatter (x , pos )
864
856
elif callable (fmt ):
0 commit comments