135135 * :class:`IndexDateFormatter`: date plots with implicit *x*
136136 indexing.
137137"""
138- from __future__ import (absolute_import , division , print_function ,
139- unicode_literals )
140138
141- import six
142- from six .moves import zip
143- import re
144- import time
145- import math
146139import datetime
147140import functools
148-
149- import warnings
150141import logging
142+ import math
143+ import re
144+ import time
145+ import warnings
151146
152147from dateutil .rrule import (rrule , MO , TU , WE , TH , FR , SA , SU , YEARLY ,
153148 MONTHLY , WEEKLY , DAILY , HOURLY , MINUTELY ,
154149 SECONDLY )
155150from dateutil .relativedelta import relativedelta
156151import dateutil .parser
157- import logging
158152import numpy as np
159153
160-
161154import matplotlib
162155from matplotlib import rcParams
163156import matplotlib .units as units
@@ -404,7 +397,7 @@ def datestr2num(d, default=None):
404397 default : datetime instance, optional
405398 The default date to use when fields are missing in *d*.
406399 """
407- if isinstance (d , six . string_types ):
400+ if isinstance (d , str ):
408401 dt = dateutil .parser .parse (d , default = default )
409402 return date2num (dt )
410403 else :
@@ -629,15 +622,15 @@ def __init__(self, fmt, tz=None):
629622 def __call__ (self , x , pos = 0 ):
630623 if x == 0 :
631624 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 '
633626 'you have not informed the axis that it is '
634627 '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 )
637629
638630 def set_tzinfo (self , tz ):
639631 self .tz = tz
640632
633+ @cbook .deprecated ("3.0" )
641634 def _replace_common_substr (self , s1 , s2 , sub1 , sub2 , replacement ):
642635 """Helper function for replacing substrings sub1 and sub2
643636 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):
663656
664657 return s1 , s2
665658
659+ @cbook .deprecated ("3.0" )
666660 def strftime_pre_1900 (self , dt , fmt = None ):
667661 """Call time.strftime for years before 1900 by rolling
668662 forward a multiple of 28 years.
@@ -720,6 +714,7 @@ def strftime_pre_1900(self, dt, fmt=None):
720714 "{0:02d}" .format (dt .year % 100 ))
721715 return cbook .unicode_safe (s1 )
722716
717+ @cbook .deprecated ("3.0" )
723718 def strftime (self , dt , fmt = None ):
724719 """
725720 Refer to documentation for :meth:`datetime.datetime.strftime`
@@ -764,10 +759,7 @@ def __call__(self, x, pos=0):
764759 ind = int (np .round (x ))
765760 if ind >= len (self .t ) or ind <= 0 :
766761 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 )
771763
772764
773765class AutoDateFormatter (ticker .Formatter ):
@@ -858,7 +850,7 @@ def __call__(self, x, pos=None):
858850 if scale >= locator_unit_scale ),
859851 self .defaultfmt )
860852
861- if isinstance (fmt , six . string_types ):
853+ if isinstance (fmt , str ):
862854 self ._formatter = DateFormatter (fmt , self ._tz )
863855 result = self ._formatter (x , pos )
864856 elif callable (fmt ):
0 commit comments