
 m[c        *   @` s  d  Z  d d l m Z m Z m Z m Z d d l Z d d l m Z d d l	 Z	 d d l
 Z
 d d l Z d d l Z d d l Z d d l Z d d l Z d d l m Z m Z m Z m Z m Z m Z m Z m Z m Z m Z m Z m Z m Z m Z m Z d d l  m! Z! d d l" Z# d d l Z d d l$ Z% d d l& Z& d d l& m' Z' d d l( j) Z) d d l* j+ Z+ d d l, j- Z- e j. e/  Z0 dy Z1 e j. e/  Z0 d2 e j2 f d3     YZ3 e3   Z4 d4   Z5 e6 e j d5 d6 d6  j7    Z8 d7 Z9 e d6 Z: d8 Z; d9 Z< d9 Z= d: Z> d; Z? d< Z@ d= ZA e< e; ZB e= e< ZC eC e; ZD eD e? ZE d> eD ZF e e e e e e e f \ ZG ZH ZI ZJ ZK ZL ZM eG eH eI eJ eK eL eM f ZN d?   ZO e% jP eO  ZQ d@   ZR d dA  ZT e% jP eT  ZU dB eV f dC     YZW dD eW f dE     YZX e% jP e# jY jZ  Z[ d dF  Z\ dG   Z] dH   Z^ dI   Z_ d dJ  Z` dK   Za e% jP ea  Zb dL   Zc dM   Zd dN e- je f dO     YZf dP e- je f dQ     YZg dR e- je f dS     YZh dT eV f dU     YZi dV e- jj f dW     YZk dX ek f dY     YZl dZ ek f d[     YZm d\ ek f d]     YZn d^ el f d_     YZo d` el f da     YZp db el f dc     YZq dd el f de     YZr df el f dg     YZs dh el f di     YZt dj ek f dk     YZu dl dm  Zv dl dn  Zw do   Zx dp   Zy dq   Zz d dl dr  Z{ ds   Z| dt   Z} du   Z~ dv   Z dw e) j f dx     YZ e   e) j e% j <e   e) j e j <e   e) j e j <d S(z   u  
Matplotlib provides sophisticated date plotting capabilities, standing on the
shoulders of python :mod:`datetime`, the add-on modules :mod:`pytz` and
:mod:`dateutil`.


.. _date-format:

Matplotlib date format
----------------------
Matplotlib represents dates using floating point numbers specifying the number
of days since 0001-01-01 UTC, plus 1.  For example, 0001-01-01, 06:00 is 1.25,
not 0.25. Values < 1, i.e. dates before 0001-01-01 UTC are not supported.

There are a number of helper functions to convert between :mod:`datetime`
objects and Matplotlib dates:

.. currentmodule:: matplotlib.dates

.. autosummary::
   :nosignatures:

   date2num
   num2date
   num2timedelta
   epoch2num
   num2epoch
   mx2num
   drange

.. note::

   Like Python's datetime, mpl uses the Gregorian calendar for all
   conversions between dates and floating point numbers. This practice
   is not universal, and calendar differences can cause confusing
   differences between what Python and mpl give as the number of days
   since 0001-01-01 and what other software and databases yield.  For
   example, the US Naval Observatory uses a calendar that switches
   from Julian to Gregorian in October, 1582.  Hence, using their
   calculator, the number of days between 0001-01-01 and 2006-04-01 is
   732403, whereas using the Gregorian calendar via the datetime
   module we find::

     In [1]: date(2006, 4, 1).toordinal() - date(1, 1, 1).toordinal()
     Out[1]: 732401

All the Matplotlib date converters, tickers and formatters are timezone aware.
If no explicit timezone is provided, the rcParam ``timezone`` is assumend.  If
you want to use a custom time zone, pass a :class:`pytz.timezone` instance
with the tz keyword argument to :func:`num2date`, :func:`.plot_date`, and any
custom date tickers or locators you create.
See `pytz <http://pythonhosted.org/pytz/>`_ for information on :mod:`pytz` and
timezone handling.

A wide range of specific and general purpose date tick locators and
formatters are provided in this module.  See
:mod:`matplotlib.ticker` for general information on tick locators
and formatters.  These are described below.


The `dateutil module <https://dateutil.readthedocs.io/en/stable/>`_ provides
additional code to handle date ticking, making it easy to place ticks
on any kinds of dates.  See examples below.

Date tickers
------------

Most of the date tickers can locate single or multiple values.  For
example::

    # import constants for the days of the week
    from matplotlib.dates import MO, TU, WE, TH, FR, SA, SU

    # tick on mondays every week
    loc = WeekdayLocator(byweekday=MO, tz=tz)

    # tick on mondays and saturdays
    loc = WeekdayLocator(byweekday=(MO, SA))

In addition, most of the constructors take an interval argument::

    # tick on mondays every second week
    loc = WeekdayLocator(byweekday=MO, interval=2)

The rrule locator allows completely general date ticking::

    # tick every 5th easter
    rule = rrulewrapper(YEARLY, byeaster=1, interval=5)
    loc = RRuleLocator(rule)

Here are all the date tickers:

    * :class:`MicrosecondLocator`: locate microseconds

    * :class:`SecondLocator`: locate seconds

    * :class:`MinuteLocator`: locate minutes

    * :class:`HourLocator`: locate hours

    * :class:`DayLocator`: locate specified days of the month

    * :class:`WeekdayLocator`: Locate days of the week, e.g., MO, TU

    * :class:`MonthLocator`: locate months, e.g., 7 for july

    * :class:`YearLocator`: locate years that are multiples of base

    * :class:`RRuleLocator`: locate using a
      :class:`matplotlib.dates.rrulewrapper`.  The
      :class:`rrulewrapper` is a simple wrapper around a
      :class:`dateutil.rrule` (`dateutil
      <https://dateutil.readthedocs.io/en/stable/>`_) which allow almost
      arbitrary date tick specifications.  See `rrule example
      <../gallery/ticks_and_spines/date_demo_rrule.html>`_.

    * :class:`AutoDateLocator`: On autoscale, this class picks the best
      :class:`DateLocator` (e.g., :class:`RRuleLocator`)
      to set the view limits and the tick
      locations.  If called with ``interval_multiples=True`` it will
      make ticks line up with sensible multiples of the tick intervals.  E.g.
      if the interval is 4 hours, it will pick hours 0, 4, 8, etc as ticks.
      This behaviour is not guaranteed by default.

Date formatters
---------------

Here all all the date formatters:

    * :class:`AutoDateFormatter`: attempts to figure out the best format
      to use.  This is most useful when used with the :class:`AutoDateLocator`.

    * :class:`DateFormatter`: use :func:`strftime` format strings

    * :class:`IndexDateFormatter`: date plots with implicit *x*
      indexing.
i    (   t   absolute_importt   divisiont   print_functiont   unicode_literalsN(   t   zip(   t   rrulet   MOt   TUt   WEt   THt   FRt   SAt   SUt   YEARLYt   MONTHLYt   WEEKLYt   DAILYt   HOURLYt   MINUTELYt   SECONDLY(   t   relativedelta(   t   rcParamsu   date2numu   num2dateu   num2timedeltau   drangeu	   epoch2numu	   num2epochu   mx2numu   DateFormatteru   IndexDateFormatteru   AutoDateFormatteru   DateLocatoru   RRuleLocatoru   AutoDateLocatoru   YearLocatoru   MonthLocatoru   WeekdayLocatoru
   DayLocatoru   HourLocatoru   MinuteLocatoru   SecondLocatoru   MicrosecondLocatoru   rruleu   MOu   TUu   WEu   THu   FRu   SAu   SUu   YEARLYu   MONTHLYu   WEEKLYu   DAILYu   HOURLYu   MINUTELYu   SECONDLYu   MICROSECONDLYu   relativedeltau   secondsu   minutesu   hoursu   weekst   _UTCc           B` s)   e  Z d  Z d   Z d   Z d   Z RS(   u   UTCc         C` s   t  j d  S(   Ni    (   t   datetimet	   timedelta(   t   selft   dt(    (    s/   lib/python2.7/site-packages/matplotlib/dates.pyt	   utcoffset   s    c         C` s
   t  d  S(   Nu   UTC(   t   str(   R   R   (    (    s/   lib/python2.7/site-packages/matplotlib/dates.pyt   tzname   s    c         C` s   t  j d  S(   Ni    (   R   R   (   R   R   (    (    s/   lib/python2.7/site-packages/matplotlib/dates.pyt   dst   s    (   t   __name__t
   __module__t   __doc__R   R   R   (    (    (    s/   lib/python2.7/site-packages/matplotlib/dates.pyR      s   		c          C` s6   t  j d }  |  d k r t Sd d l } | j |   S(   uH   
    Retrieve the preferred timeszone from the rcParams dictionary.
    u   timezoneu   UTCi    N(   t
   matplotlibR   t   UTCt   pytzt   timezone(   t   sR$   (    (    s/   lib/python2.7/site-packages/matplotlib/dates.pyt   _get_rc_timezone   s
    i  i   g   PD:Ag      8@g      N@g      (@g      @g      >@g     v@g    .Ac         C` s   t  |  d d  } | d k	 r6 |  j t  }  t } n  t |  j    } t  |  d d      } | d k	 r t j d d | } t j j | |  } | |  | j	   t
 7} n  | S(   u   
    Convert :mod:`datetime` or :mod:`date` to the Gregorian date as UTC float
    days, preserving hours, minutes, seconds and microseconds.  Return value
    is a :func:`float`.
    u   tzinfou   datec           S` s   d  S(   N(   t   None(    (    (    s/   lib/python2.7/site-packages/matplotlib/dates.pyt   <lambda>  s    i    t   tzinfoN(   t   getattrR(   t
   astimezoneR#   t   floatt	   toordinalR   t   timet   combinet   total_secondst   SEC_PER_DAY(   R   t   tzit   baset   cdatet   midnight_timet   rdt(    (    s/   lib/python2.7/site-packages/matplotlib/dates.pyt   _to_ordinalf   s    	c         C` s   |  |  j  d  } | j  d  } t j d  j  d  } |  j  d  | j  t j  } | | j  t j  d 7} | t d } t j d  j  t j  } |  j  t j  } y t j | | | k <Wn) t k
 r | | k r t j } q n X| S(   uu  
    Convert `numpy.datetime64` or an ndarray of those types to Gregorian
    date as UTC float.  Roundoff is via float64 precision.  Practically:
    microseconds for dates between 290301 BC, 294241 AD, milliseconds for
    larger dates (see `numpy.datetime64`).  Nanoseconds aren't possible
    because we do times compared to ``0001-01-01T00:00:00`` (plus one day).
    u   datetime64[s]u   timedelta64[ns]u   0001-01-01T00:00:00g    eAg      ?u   NaT(   t   astypet   npt
   datetime64t   float64R2   t   int64t   nant	   TypeError(   t   dt   extrat   t0R   t   NaT_intt   d_int(    (    s/   lib/python2.7/site-packages/matplotlib/dates.pyt   _dt64_to_ordinalf  s    c         C` s   | d k r t   } n  t |  d  \ } } t |  } | d k  r] t d j |    n  t j j |  j d t	  } d } t t
 | t |  |  } |  d	 k  r t t
 | t   } n  | t j d |  7} | j |  S(
   ux  
    Convert Gregorian float of the date, preserving hours, minutes,
    seconds and microseconds.  Return value is a `.datetime`.

    The input date *x* is a float in ordinal days at UTC, and the output will
    be the specified `.datetime` object corresponding to that time in
    timezone *tz*, or if *tz* is ``None``, in the timezone specified in
    :rc:`timezone`.
    i   u|   Cannot convert {} to a date.  This often happens if non-datetime values are passed to an axis that expects datetime objects.R*   i   i   im  t   microsecondsNi*  (   R(   R'   t   divmodt   intt
   ValueErrort   formatR   t   fromordinalt   replaceR#   t   roundt   MUSECONDS_PER_DAYR   R,   (   t   xt   tzt   ixt	   remainderR   t
   musec_prect   remainder_musec(    (    s/   lib/python2.7/site-packages/matplotlib/dates.pyt   _from_ordinalf/  s    
	
t   strpdate2numc           B` s    e  Z d  Z d   Z d   Z RS(   u   
    Use this class to parse date strings to matplotlib datenums when
    you know the date format string of the date you are parsing.
    c         C` s   | |  _  d S(   u-    fmt: any valid strptime format is supported N(   t   fmt(   R   RW   (    (    s/   lib/python2.7/site-packages/matplotlib/dates.pyt   __init__`  s    c         C` s&   t  t j t j | |  j  d     S(   uM   s : string to be converted
           return value: a date2num float
        i   (   t   date2numR   R/   t   strptimeRW   (   R   R&   (    (    s/   lib/python2.7/site-packages/matplotlib/dates.pyt   __call__d  s    (   R   R    R!   RX   R[   (    (    (    s/   lib/python2.7/site-packages/matplotlib/dates.pyRV   [  s   	t   bytespdate2numc           B` s#   e  Z d  Z d d  Z d   Z RS(   u   
    Use this class to parse date strings to matplotlib datenums when
    you know the date format string of the date you are parsing.  See
    :file:`examples/misc/load_converter.py`.
    u   utf-8c         C` s#   t  t |   j |  | |  _ d S(   u   
        Args:
            fmt: any valid strptime format is supported
            encoding: encoding to use on byte input (default: 'utf-8')
        N(   t   superR\   RX   t   encoding(   R   RW   R^   (    (    s/   lib/python2.7/site-packages/matplotlib/dates.pyRX   q  s    c         C` s(   | j  |  j  } t t |   j |  S(   uo   
        Args:
            b: byte input to be converted
        Returns:
            A date2num float
        (   t   decodeR^   R]   R\   R[   (   R   t   bR&   (    (    s/   lib/python2.7/site-packages/matplotlib/dates.pyR[   z  s    (   R   R    R!   RX   R[   (    (    (    s/   lib/python2.7/site-packages/matplotlib/dates.pyR\   k  s   	c         C` s   t  |  t j  r4 t j j |  d | } t |  S| d k	 rn g  |  D] } t j j | d | ^ qG }  n  t j	 |   }  |  j
 s |  St t |    Sd S(   u#  
    Convert a date string to a datenum using
    :func:`dateutil.parser.parse`.

    Parameters
    ----------
    d : string or sequence of strings
        The dates to convert.

    default : datetime instance, optional
        The default date to use when fields are missing in *d*.
    t   defaultN(   t
   isinstancet   sixt   string_typest   dateutilt   parsert   parseRY   R(   R:   t   asarrayt   sizet$   _dateutil_parser_parse_np_vectorized(   R@   Ra   R   R&   (    (    s/   lib/python2.7/site-packages/matplotlib/dates.pyt   datestr2num  s    
.	c         C` s   t  |  d  r |  j }  n  t |  t j  rE t j |  j t j  sW t |  t j  ra t |   St	 j
 |   sz t |   St j |   }  |  j s |  St |   Sd S(   u#  
    Convert datetime objects to Matplotlib dates.

    Parameters
    ----------
    d : `datetime.datetime` or `numpy.datetime64` or sequences of these

    Returns
    -------
    float or sequence of floats
        Number of days (fraction part represents hours, minutes, seconds, ms)
        since 0001-01-01 00:00:00 UTC, plus one.

    Notes
    -----
    The addition of one here is a historical artifact. Also, note that the
    Gregorian calendar is assumed; this is not universal practice.
    For details see the module docstring.
    u   valuesN(   t   hasattrt   valuesRb   R:   t   ndarrayt
   issubdtypet   dtypeR;   RE   t   cbookt   iterableR8   Rh   Ri   t   _to_ordinalf_np_vectorized(   R@   (    (    s/   lib/python2.7/site-packages/matplotlib/dates.pyRY     s    *

	c         C` s)   t  j |   r! t j |   }  n  |  t S(   u   
    Convert a Julian date (or sequence) to a Matplotlib date (or sequence).

    Parameters
    ----------
    j : float or sequence of floats
        Julian date(s)

    Returns
    -------
    float or sequence of floats
        Matplotlib date(s)
    (   Rq   Rr   R:   Rh   t   JULIAN_OFFSET(   t   j(    (    s/   lib/python2.7/site-packages/matplotlib/dates.pyt
   julian2num  s    c         C` s)   t  j |   r! t j |   }  n  |  t S(   u   
    Convert a Matplotlib date (or sequence) to a Julian date (or sequence).

    Parameters
    ----------
    n : float or sequence of floats
        Matplotlib date(s)

    Returns
    -------
    float or sequence of floats
        Julian date(s)
    (   Rq   Rr   R:   Rh   Rt   (   t   n(    (    s/   lib/python2.7/site-packages/matplotlib/dates.pyt
   num2julian  s    c         C` sg   | d k r t   } n  t j |   s4 t |  |  St j |   }  |  j sP |  St |  |  j	   Sd S(   u
  
    Convert Matplotlib dates to `~datetime.datetime` objects.

    Parameters
    ----------
    x : float or sequence of floats
        Number of days (fraction part represents hours, minutes, seconds)
        since 0001-01-01 00:00:00 UTC, plus one.
    tz : string, optional
        Timezone of *x* (defaults to rcparams ``timezone``).

    Returns
    -------
    `~datetime.datetime` or sequence of `~datetime.datetime`
        Dates are returned in timezone *tz*.

        If *x* is a sequence, a sequence of :class:`datetime` objects will
        be returned.

    Notes
    -----
    The addition of one here is a historical artifact. Also, note that the
    Gregorian calendar is assumed; this is not universal practice.
    For details, see the module docstring.
    N(
   R(   R'   Rq   Rr   RU   R:   Rh   Ri   t   _from_ordinalf_np_vectorizedt   tolist(   RO   RP   (    (    s/   lib/python2.7/site-packages/matplotlib/dates.pyt   num2date  s    	c         C` s   t  j d |   S(   Nt   days(   R   R   (   RO   (    (    s/   lib/python2.7/site-packages/matplotlib/dates.pyt   _ordinalf_to_timedelta  s    c         C` sI   t  j |   s t |   St j |   }  |  j s5 |  St |   j   Sd S(   u  
    Convert number of days to a `~datetime.timedelta` object.

    If *x* is a sequence, a sequence of `~datetime.timedelta` objects will
    be returned.

    Parameters
    ----------
    x : float, sequence of floats
        Number of days. The fraction part represents hours, minutes, seconds.

    Returns
    -------
    `datetime.timedelta` or list[`datetime.timedelta`]

    N(   Rq   Rr   R}   R:   Rh   Ri   t$   _ordinalf_to_timedelta_np_vectorizedRz   (   RO   (    (    s/   lib/python2.7/site-packages/matplotlib/dates.pyt   num2timedelta  s    
	c         C` s   t  |   } t  |  } | j   t } t t j | | |   } |  | | } | | k rv | | 8} | d 8} n  t  |  } t j | | | d  S(   u  
    Return a sequence of equally spaced Matplotlib dates.

    The dates start at *dstart* and reach up to, but not including *dend*.
    They are spaced by *delta*.

    Parameters
    ----------
    dstart, dend : `~datetime.datetime`
        The date limits.
    delta : `datetime.timedelta`
        Spacing of the dates.

    Returns
    -------
    drange : `numpy.array`
        A list floats representing Matplotlib dates.

    i   (   RY   R1   R2   RH   R:   t   ceilt   linspace(   t   dstartt   dendt   deltat   f1t   f2t   stept   numt   dinterval_end(    (    s/   lib/python2.7/site-packages/matplotlib/dates.pyt   drange3  s    
t   DateFormatterc           B` s_   e  Z d  Z e j d  Z d	 d  Z d d  Z d   Z	 d   Z
 d	 d  Z d	 d  Z RS(
   uY  
    Tick location is seconds since the epoch.  Use a :func:`strftime`
    format string.

    Python only supports :mod:`datetime` :func:`strftime` formatting
    for years greater than 1900.  Thanks to Andrew Dalke, Dalke
    Scientific Software who contributed the :func:`strftime` code
    below to include dates earlier than this year.
    u   ((^|[^%])(%%)*%s)c         C` s.   | d k r t   } n  | |  _ | |  _ d S(   uk   
        *fmt* is a :func:`strftime` format string; *tz* is the
         :class:`tzinfo` instance.
        N(   R(   R'   RW   RP   (   R   RW   RP   (    (    s/   lib/python2.7/site-packages/matplotlib/dates.pyRX   j  s    	i    c         C` s@   | d k r t  d   n  t | |  j  } |  j | |  j  S(   Ni    u   DateFormatter found a value of x=0, which is an illegal date.  This usually occurs because you have not informed the axis that it is plotting dates, e.g., with ax.xaxis_date()(   RI   R{   RP   t   strftimeRW   (   R   RO   t   posR   (    (    s/   lib/python2.7/site-packages/matplotlib/dates.pyR[   t  s    c         C` s   | |  _  d  S(   N(   RP   (   R   RP   (    (    s/   lib/python2.7/site-packages/matplotlib/dates.pyt
   set_tzinfo}  s    c         C` s   d } x t  r | j | |  } | d k r1 Pn  | d } | | | t |  !| k r^ q	 n  | |  | | | t |  } | |  | | | t |  } q	 W| | f S(   u&  Helper function for replacing substrings sub1 and sub2
        located at the same indexes in strings s1 and s2 respectively,
        with the string replacement.  It is expected that sub1 and sub2
        have the same length.  Returns the pair s1, s2 after the
        substitutions.
        i    ii   (   t   Truet   findt   len(   R   t   s1t   s2t   sub1t   sub2t   replacementt   iRu   (    (    s/   lib/python2.7/site-packages/matplotlib/dates.pyt   _replace_common_substr  s    
	
 $c         C` si  | d k r |  j } n  t j d d j | j  |  } | j } d | } d | d | d } | | } | d | d d } | d } | j   } t j	 | | f | d  }	 t j	 | | f | d  }
 |  j
 |	 |
 d	 j |  d	 j |  d	 j | j   \ }	 }
 |  j
 |	 |
 d
 j | d  d
 j | d  d
 j | j d   \ }	 }
 t j |	  S(   u{  Call time.strftime for years before 1900 by rolling
        forward a multiple of 28 years.

        *fmt* is a :func:`strftime` format string.

        Dalke: I hope I did this math right.  Every 28 years the
        calendar repeats, except through century leap years excepting
        the 400 year leap years.  But only if you're using the Gregorian
        calendar.
        u   ((^|[^%])(%%)*)%fu   \g<1>{0:06d}i  i   id   i  i   i   u   {0:04d}u   {0:02d}N(   R(   RW   t   ret   subRJ   t   microsecondt   yeart	   timetupleR/   R   R   Rq   t   unicode_safe(   R   R   RW   R   R   t   offt   year1t   year2R   R   R   (    (    s/   lib/python2.7/site-packages/matplotlib/dates.pyt   strftime_pre_1900  s,    			



c         C` st   | d k r |  j } n  |  j j d |  } | j d d  } | j d k rd t j | j |   S|  j	 | |  S(   u{  
        Refer to documentation for :meth:`datetime.datetime.strftime`

        *fmt* is a :meth:`datetime.datetime.strftime` format string.

        Warning: For years before 1900, depending upon the current
        locale it is possible that the year displayed with %x might
        be incorrect. For years before 100, %y and %Y will yield
        zero-padded strings.
        u   \1u   %su   sil  N(
   R(   RW   t	   illegal_sR   RL   R   Rq   R   R   R   (   R   R   RW   (    (    s/   lib/python2.7/site-packages/matplotlib/dates.pyR     s    N(   R   R    R!   R   t   compileR   R(   RX   R[   R   R   R   R   (    (    (    s/   lib/python2.7/site-packages/matplotlib/dates.pyR   ]  s   	
			9t   IndexDateFormatterc           B` s&   e  Z d  Z d d  Z d d  Z RS(   ua   
    Use with :class:`~matplotlib.ticker.IndexLocator` to cycle format
    strings by index.
    c         C` s7   | d k r t   } n  | |  _ | |  _ | |  _ d S(   uw   
        *t* is a sequence of dates (floating point days).  *fmt* is a
        :func:`strftime` format string.
        N(   R(   R'   t   tRW   RP   (   R   R   RW   RP   (    (    s/   lib/python2.7/site-packages/matplotlib/dates.pyRX     s
    		i    c         C` sl   t  t j |   } | t |  j  k s6 | d k r: d St |  j | |  j  } t j | j	 |  j
   S(   u/   Return the label for time *x* at position *pos*i    u    (   RH   R:   RM   R   R   R{   RP   Rq   R   R   RW   (   R   RO   R   t   indR   (    (    s/   lib/python2.7/site-packages/matplotlib/dates.pyR[     s
    !N(   R   R    R!   R(   RX   R[   (    (    (    s/   lib/python2.7/site-packages/matplotlib/dates.pyR     s   t   AutoDateFormatterc           B` s)   e  Z d  Z d d d  Z d d  Z RS(   uo  
    This class attempts to figure out the best format to use.  This is
    most useful when used with the :class:`AutoDateLocator`.


    The AutoDateFormatter has a scale dictionary that maps the scale
    of the tick (the distance in days between one major tick) and a
    format string.  The default looks like this::

        self.scaled = {
            DAYS_PER_YEAR: rcParams['date.autoformat.year'],
            DAYS_PER_MONTH: rcParams['date.autoformat.month'],
            1.0: rcParams['date.autoformat.day'],
            1. / HOURS_PER_DAY: rcParams['date.autoformat.hour'],
            1. / (MINUTES_PER_DAY): rcParams['date.autoformat.minute'],
            1. / (SEC_PER_DAY): rcParams['date.autoformat.second'],
            1. / (MUSECONDS_PER_DAY): rcParams['date.autoformat.microsecond'],
            }


    The algorithm picks the key in the dictionary that is >= the
    current scale and uses that format string.  You can customize this
    dictionary by doing::


    >>> locator = AutoDateLocator()
    >>> formatter = AutoDateFormatter(locator)
    >>> formatter.scaled[1/(24.*60.)] = '%M:%S' # only show min and sec

    A custom :class:`~matplotlib.ticker.FuncFormatter` can also be used.
    The following example shows how to use a custom format function to strip
    trailing zeros from decimal seconds and adds the date to the first
    ticklabel::

        >>> def my_format_function(x, pos=None):
        ...     x = matplotlib.dates.num2date(x)
        ...     if pos == 0:
        ...         fmt = '%D %H:%M:%S.%f'
        ...     else:
        ...         fmt = '%H:%M:%S.%f'
        ...     label = x.strftime(fmt)
        ...     label = label.rstrip("0")
        ...     label = label.rstrip(".")
        ...     return label
        >>> from matplotlib.ticker import FuncFormatter
        >>> formatter.scaled[1/(24.*60.)] = FuncFormatter(my_format_function)
    u   %Y-%m-%dc         C` s   | |  _  | |  _ | |  _ t |  j |  |  _ i t d t 6t d t 6t d d 6t d d t 6t d d t	 6t d d t
 6t d d t 6|  _ d	 S(
   u   
        Autoformat the date labels.  The default format is the one to use
        if none of the values in ``self.scaled`` are greater than the unit
        returned by ``locator._get_unit()``.
        u   date.autoformatter.yearu   date.autoformatter.monthu   date.autoformatter.dayg      ?u   date.autoformatter.houru   date.autoformatter.minuteu   date.autoformatter.secondu   date.autoformatter.microsecondN(   t   _locatort   _tzt
   defaultfmtR   t
   _formatterR   t   DAYS_PER_YEARt   DAYS_PER_MONTHt   HOURS_PER_DAYt   MINUTES_PER_DAYR2   RN   t   scaled(   R   t   locatorRP   R   (    (    s/   lib/python2.7/site-packages/matplotlib/dates.pyRX   @  s    			c         ` s   t  |  j j      t   f d   t |  j j    D |  j  } t | t	 j
  r t | |  j  |  _ |  j | |  } n3 t |  r | | |  } n t d j |     | S(   Nc         3` s'   |  ] \ } } |   k r | Vq d  S(   N(    (   t   .0t   scaleRW   (   t   locator_unit_scale(    s/   lib/python2.7/site-packages/matplotlib/dates.pys	   <genexpr>X  s    	u    Unexpected type passed to {0!r}.(   R-   R   t	   _get_unitt   nextt   sortedR   t   itemsR   Rb   Rc   Rd   R   R   R   t   callableR?   RJ   (   R   RO   R   RW   t   result(    (   R   s/   lib/python2.7/site-packages/matplotlib/dates.pyR[   U  s    %N(   R   R    R!   R(   RX   R[   (    (    (    s/   lib/python2.7/site-packages/matplotlib/dates.pyR     s   /t   rrulewrapperc           B` sM   e  Z d d   Z d   Z d   Z d   Z e d  Z d   Z	 d   Z
 RS(   c         K` s$   | | d <| |  _  |  j |   d  S(   Nu   freq(   t   _base_tzinfot   _update_rrule(   R   t   freqR*   t   kwargs(    (    s/   lib/python2.7/site-packages/matplotlib/dates.pyRX   h  s    
	c         K` s$   |  j  j |  |  j |  j    d  S(   N(   t
   _constructt   updateR   (   R   R   (    (    s/   lib/python2.7/site-packages/matplotlib/dates.pyt   setn  s    c         K` s
  |  j  } d | k rq | d } | j d  k	 rq | d  k rF | j } n | j |  } | j d d   | d <qq n  d | k r | d } | j d  k	 r | d  k	 r | j |  } n t d   | j d d   | d <q n  | j   |  _ | |  _ t	 |  j   |  _
 d  S(   Nu   dtstartR*   u   untilu<   until cannot be aware if dtstart is naive and tzinfo is None(   R   R*   R(   R,   RL   RI   t   copyR   t   _tzinfoR   t   _rrule(   R   R   R*   t   dtstartt   until(    (    s/   lib/python2.7/site-packages/matplotlib/dates.pyR   s  s$    	

	c         C` s2   t  | d  r" | j | d t S| j d |  S(   Nu   localizet   is_dstR*   (   Rl   t   localizeR   RL   (   R   R   R*   (    (    s/   lib/python2.7/site-packages/matplotlib/dates.pyt   _attach_tzinfo  s    c         ` sw    j  d k r   S f d     f d    | sO     f d   } n     f d   } t j    |  S(   u>   Decorator function that allows rrule methods to handle tzinfo.c         ` s\   t  |  t j  rX |  j d  k	 rX |  j   j k	 rH |  j   j  }  n  |  j d d   S|  S(   NR*   (   Rb   R   R*   R(   R   R,   RL   (   t   arg(   R   (    s/   lib/python2.7/site-packages/matplotlib/dates.pyt   normalize_arg  s
    !c         ` sB   t    f d   |  D  }    f d   | j   D } |  | f S(   Nc         3` s   |  ] }   |  Vq d  S(   N(    (   R   R   (   R   (    s/   lib/python2.7/site-packages/matplotlib/dates.pys	   <genexpr>  s    c         ` s%   i  |  ] \ } }   |  |  q S(    (    (   R   t   kwR   (   R   (    s/   lib/python2.7/site-packages/matplotlib/dates.pys
   <dictcomp>  s   	 (   t   tupleR   (   t   argsR   (   R   (    s/   lib/python2.7/site-packages/matplotlib/dates.pyt   normalize_args  s    c          ` s7    |  |  \ }  }   |  |   }  j  |  j  S(   N(   R   R   (   R   R   R   (   t   fR   R   (    s/   lib/python2.7/site-packages/matplotlib/dates.pyt
   inner_func  s    c          ` sJ    |  |  \ }  }   |  |   } g  | D] }  j  |  j  ^ q+ S(   N(   R   R   (   R   R   t   dtsR   (   R   R   R   (    s/   lib/python2.7/site-packages/matplotlib/dates.pyR     s    N(   R   R(   t	   functoolst   wraps(   R   R   t   returns_listR   (    (   R   R   R   R   s/   lib/python2.7/site-packages/matplotlib/dates.pyt   _aware_return_wrapper  s    	c         C` s{   | |  j  k r |  j  | St |  j |  } | d d h k rK |  j |  S| d d d h k rs |  j | d t S| Sd  S(   Nu   afteru   beforeu   xafteru   xbeforeu   betweenR   (   t   __dict__R+   R   R   R   (   R   t   nameR   (    (    s/   lib/python2.7/site-packages/matplotlib/dates.pyt   __getattr__  s    c         C` s   |  j  j |  d  S(   N(   R   R   (   R   t   state(    (    s/   lib/python2.7/site-packages/matplotlib/dates.pyt   __setstate__  s    N(   R   R    R(   RX   R   R   R   t   FalseR   R   R   (    (    (    s/   lib/python2.7/site-packages/matplotlib/dates.pyR   g  s   			&	t   DateLocatorc           B` sk   e  Z d  Z i d d 6d d 6d d 6Z d d  Z d   Z d   Z d   Z d	   Z	 d
   Z
 d   Z RS(   u   
    Determines the tick locations when plotting dates.

    This class is subclassed by other Locators and
    is not meant to be used on its own.
    i    u   byhouru   byminuteu   bysecondc         C` s%   | d k r t   } n  | |  _ d S(   u5   
        *tz* is a :class:`tzinfo` instance.
        N(   R(   R'   RP   (   R   RP   (    (    s/   lib/python2.7/site-packages/matplotlib/dates.pyRX     s    c         C` s   | |  _  d S(   u%   
        Set time zone info.
        N(   RP   (   R   RP   (    (    s/   lib/python2.7/site-packages/matplotlib/dates.pyR     s    c         C` sw   |  j  j   \ } } | | k r1 | | } } n  | d k  rU t d j |    n  t | |  j  t | |  j  f S(   uA   
        Convert axis data interval to datetime objects.
        i   u   datalim minimum {} is less than 1 and is an invalid Matplotlib date value. This often happens if you pass a non-datetime value to an axis that has datetime units(   t   axist   get_data_intervalRI   RJ   R{   RP   (   R   t   dmint   dmax(    (    s/   lib/python2.7/site-packages/matplotlib/dates.pyt   datalim_to_dt  s    	c         C` sw   |  j  j   \ } } | | k r1 | | } } n  | d k  rU t d j |    n  t | |  j  t | |  j  f S(   uA   
        Converts the view interval to datetime objects.
        i   u   view limit minimum {} is less than 1 and is an invalid Matplotlib date value. This often happens if you pass a non-datetime value to an axis that has datetime units(   R   t   get_view_intervalRI   RJ   R{   RP   (   R   t   vmint   vmax(    (    s/   lib/python2.7/site-packages/matplotlib/dates.pyt   viewlim_to_dt  s    	c         C` s   d S(   uj   
        Return how many days a unit of the locator is; used for
        intelligent autoscaling.
        i   (    (   R   (    (    s/   lib/python2.7/site-packages/matplotlib/dates.pyR     s    c         C` s   d S(   u;   
        Return the number of units for each tick.
        i   (    (   R   (    (    s/   lib/python2.7/site-packages/matplotlib/dates.pyt   _get_interval  s    c         C` s_   |  j    } |  j   } t | |  d k  rU | d | | 8} | d | | 7} n  | | f S(   u   
        Given the proposed upper and lower extent, adjust the range
        if it is too close to being singular (i.e. a range of ~0).

        gư>i   (   R   R   t   abs(   R   R   R   t   unitt   interval(    (    s/   lib/python2.7/site-packages/matplotlib/dates.pyt   nonsingular  s    N(   R   R    R!   t   hms0dR(   RX   R   R   R   R   R   R   (    (    (    s/   lib/python2.7/site-packages/matplotlib/dates.pyR     s   					t   RRuleLocatorc           B` sP   e  Z d d   Z d   Z d   Z d   Z e d    Z d   Z	 d   Z
 RS(   c         C` s   t  j |  |  | |  _ d  S(   N(   R   RX   t   rule(   R   t   oRP   (    (    s/   lib/python2.7/site-packages/matplotlib/dates.pyRX   #  s    c         C` s;   y |  j    \ } } Wn t k
 r* g  SX|  j | |  S(   N(   R   RI   t   tick_values(   R   R   R   (    (    s/   lib/python2.7/site-packages/matplotlib/dates.pyR[   '  s
    c         C` s   t  | |  } y | | } Wn# t t f k
 rB t d  } n Xy | | } Wn# t t f k
 rv t d  } n X|  j j d | d |  |  j j | | t  } t |  d k r t	 | | g  S|  j
 t	 |   S(   Ng      ?g)KAR   R   i    (   R   RI   t   OverflowErrorRU   R   R   t   betweenR   R   RY   t   raise_if_exceeds(   R   R   R   R   t   startt   stopt   dates(    (    s/   lib/python2.7/site-packages/matplotlib/dates.pyR   0  s    c         C` s   |  j  j j } |  j |  S(   uj   
        Return how many days a unit of the locator is; used for
        intelligent autoscaling.
        (   R   R   t   _freqt   get_unit_generic(   R   R   (    (    s/   lib/python2.7/site-packages/matplotlib/dates.pyR   F  s    c         C` s   |  t  k r t S|  t k r  t S|  t k r0 t S|  t k r@ d S|  t k rT d t S|  t	 k rh d t
 S|  t k r| d t Sd Sd  S(   Ng      ?i(   R   R   R   R   R   t   DAYS_PER_WEEKR   R   R   R   R   R   R2   (   R   (    (    s/   lib/python2.7/site-packages/matplotlib/dates.pyR   N  s    c         C` s   |  j  j j S(   N(   R   R   t	   _interval(   R   (    (    s/   lib/python2.7/site-packages/matplotlib/dates.pyR   b  s    c         C` s  |  j    \ } } t | |  } y | | } Wn t k
 rN t d  } n Xy | | } Wn t k
 r| t d  } n X|  j j d | d |  |  j    \ } } |  j j | t  } | s | } n  |  j j | t  } | s | } n  t	 |  } t	 |  } |  j
 | |  S(   u@   
        Set the view limits to include the data range.
        g      ?g)KAR   R   (   R   R   RI   RU   R   R   t   beforeR   t   afterRY   R   (   R   R   R   R   R   R   R   R   (    (    s/   lib/python2.7/site-packages/matplotlib/dates.pyt	   autoscalee  s*    		N(   R   R    R(   RX   R[   R   R   t   staticmethodR   R   R   (    (    (    s/   lib/python2.7/site-packages/matplotlib/dates.pyR      s   					t   AutoDateLocatorc           B` sk   e  Z d  Z d d d e d  Z d   Z d   Z d   Z d   Z	 d   Z
 d   Z d	   Z d
   Z RS(   u}   
    On autoscale, this class picks the best
    :class:`DateLocator` to set the view limits and the tick
    locations.
    i   c         C` s$  t  j |  |  t   |  _ t |  _ t t t t t	 t
 t g |  _ | |  _ i d t 6d t 6d t 6d t 6d t	 6d t
 6d t 6|  _ | d' k	 r y |  j j |  Wq t k
 r t j |  j |  |  _ q Xn  | |  _ i d d d d d d	 d
 d d d d d d d d d d g t 6d d d d d g t 6d d d d d d g t 6d d d d d d g t 6d d d d d g t	 6d d d d d g t
 6d d d d d	 d d d d d d d d d d d d d  d! g t 6|  _ d' t d d"  t d d#  t d$ d%  t d$ d&  t d$ d&  d' g |  _ d' S((   u  
        *minticks* is the minimum number of ticks desired, which is used to
        select the type of ticking (yearly, monthly, etc.).

        *maxticks* is the maximum number of ticks desired, which controls
        any interval between ticks (ticking every other, every 3, etc.).
        For really fine-grained control, this can be a dictionary mapping
        individual rrule frequency constants (YEARLY, MONTHLY, etc.)
        to their own maximum number of ticks.  This can be used to keep
        the number of ticks appropriate to the format chosen in
        :class:`AutoDateFormatter`. Any frequency not specified in this
        dictionary is given a default value.

        *tz* is a :class:`tzinfo` instance.

        *interval_multiples* is a boolean that indicates whether ticks
        should be chosen to be multiple of the interval. This will lock
        ticks to 'nicer' locations. For example, this will force the
        ticks to be at hours 0,6,12,18 when hourly ticking is done at
        6 hour intervals.

        The AutoDateLocator has an interval dictionary that maps the
        frequency of the tick (a constant from dateutil.rrule) and a
        multiple allowed for that ticking.  The default looks like this::

          self.intervald = {
            YEARLY  : [1, 2, 4, 5, 10, 20, 40, 50, 100, 200, 400, 500,
                      1000, 2000, 4000, 5000, 10000],
            MONTHLY : [1, 2, 3, 4, 6],
            DAILY   : [1, 2, 3, 7, 14],
            HOURLY  : [1, 2, 3, 4, 6, 12],
            MINUTELY: [1, 5, 10, 15, 30],
            SECONDLY: [1, 5, 10, 15, 30],
            MICROSECONDLY: [1, 2, 5, 10, 20, 50, 100, 200, 500, 1000, 2000,
                           5000, 10000, 20000, 50000, 100000, 200000, 500000,
                           1000000],
            }

        The interval is used to specify multiples that are appropriate for
        the frequency of ticking. For instance, every 7 days is sensible
        for daily ticks, but for minutes/seconds, 15 or 30 make sense.
        You can customize this dictionary by doing::

          locator = AutoDateLocator()
          locator.intervald[HOURLY] = [3] # only show every 3 hours
        i   i   i   i   i   i   i   i
   i   i(   i2   id   i   i  i  i  i  i  i  i'  i   i   i   i   i   i   i   i N  iP  i i@ i  i@B i   i    i    i   i<   N(   R   RX   t   YearLocatorR   R   R   R   R   R   R   R   t   MICROSECONDLYt   _freqst   mintickst   maxticksR(   R   R?   t   dictt   fromkeyst   interval_multiplest	   intervaldt   ranget	   _byranges(   R   RP   R  R  R	  (    (    s/   lib/python2.7/site-packages/matplotlib/dates.pyRX     s6    0			$!c         C` s   |  j    |  j   S(   u!   Return the locations of the ticks(   t   refreshR   (   R   (    (    s/   lib/python2.7/site-packages/matplotlib/dates.pyR[     s    
c         C` s   |  j  | |  j | |  S(   N(   t   get_locatorR   (   R   R   R   (    (    s/   lib/python2.7/site-packages/matplotlib/dates.pyR     s    c         C` s5   | | k r+ | t  d } | t  d } n  | | f S(   Ni   (   R   (   R   R   R   (    (    s/   lib/python2.7/site-packages/matplotlib/dates.pyR     s    c         C` s$   t  j |  |  |  j j |  d  S(   N(   R   t   set_axisR   (   R   R   (    (    s/   lib/python2.7/site-packages/matplotlib/dates.pyR    s    c         C` s+   |  j    \ } } |  j | |  |  _ d S(   u5   Refresh internal information based on current limits.N(   R   R  R   (   R   R   R   (    (    s/   lib/python2.7/site-packages/matplotlib/dates.pyR    s    c         C` s.   |  j  t g k r d t St j |  j   Sd  S(   Ng      ?(   R   R  RN   R   R   (   R   (    (    s/   lib/python2.7/site-packages/matplotlib/dates.pyR     s    c         C` s4   |  j    \ } } |  j | |  |  _ |  j j   S(   u,   Try to choose the view limits intelligently.(   R   R  R   R   (   R   R   R   (    (    s/   lib/python2.7/site-packages/matplotlib/dates.pyR     s    c         C` s'  t  | |  } | | } | | k r6 | } | } n  t | j  } | t | j } | j } | t | j } | t | j	 }	 t
 j | j    }
 t
 j | j   d  } | | | | |	 |
 | g } t g d t g } d d d d d d d g } x t t |  j |   D] \ } \ } } | |  j k  rCd | | <qn  xJ |  j | D]% } | | |  j | d k rQPqQqQWt j d j |   | |  _ |  j | r|  j r|  j | d d |  | | <d } n |  j | | | <PqWt d   | t k r|  j rt |  } n | | r| \ } } } } } } } t |  j d | d	 | d
 | d | d | d | d | d | } t  | |  j!  } n@ t" | d |  j! } | j# d k r| d k  rt$ j d  n  | j% |  j&  |  j& d k	 r#| j' |  j& j(     | j) |  j& j*     n  | S(   u*   Pick the best locator based on a distance.g    .Ai   i   i    u   AutoDateLocator was unable to pick an appropriate interval for this date range. It may be necessary to add an interval value to the AutoDateLocator's intervald dictionary. Defaulting to {0}.Nu=   No sensible date limit could be found in the AutoDateLocator.R   R   R   t   bymontht
   bymonthdayt   byhourt   byminutet   bysecondRP   i   i  uw   Plotting microsecond time intervals is not well supported. Please see the MicrosecondLocator documentation for details.(+   R   R-   t   yearst   MONTHS_PER_YEARt   monthsR|   R   t   hourst   MIN_PER_HOURt   minutesR:   t   floorR1   R   R   R(   t	   enumerateR   R  R  R
  R  t   warningst   warnRJ   R   R  R	  RI   R   R  R   R   RP   t   MicrosecondLocatorR   t   _logR  R   t   set_view_intervalR   t   set_data_intervalR   (   R   R   R   R   t   tdeltat   numYearst	   numMonthst   numDayst   numHourst
   numMinutest
   numSecondst   numMicrosecondst   numst   use_rrule_locatort   byrangesR   R   R   R   R   t   _R  R  R  R  R  R   (    (    s/   lib/python2.7/site-packages/matplotlib/dates.pyR    sd    

	+

		
	N(   R   R    R!   R(   R   RX   R[   R   R   R  R  R   R   R  (    (    (    s/   lib/python2.7/site-packages/matplotlib/dates.pyR    s   	O							R  c           B` s>   e  Z d  Z d d d d d  Z d   Z d   Z d   Z RS(   u   
    Make ticks on a given day of each year that is a multiple of base.

    Examples::

      # Tick every year on Jan 1st
      locator = YearLocator()

      # Tick every 5 years on July 4th
      locator = YearLocator(5, month=7, day=4)
    i   c         C` sY   t  j |  |  t j |  |  _ i | d 6| d 6d d 6d d 6d d 6| d 6|  _ d S(	   uh   
        Mark years that are multiple of base on a given month and day
        (default jan 1).
        u   monthu   dayi    u   houru   minuteu   secondu   tzinfoN(   R   RX   t   tickert   BaseR4   t   replaced(   R   R4   t   montht   dayRP   (    (    s/   lib/python2.7/site-packages/matplotlib/dates.pyRX   u  s    
c         C` s;   y |  j    \ } } Wn t k
 r* g  SX|  j | |  S(   N(   R   RI   R   (   R   R   R   (    (    s/   lib/python2.7/site-packages/matplotlib/dates.pyR[     s
    c         C` s   |  j  j | j  } |  j  j | j  } | j d | |  j  g } xb t r | d } | j | k rq t |  S| j |  j  j   } | j	 | j d | |  j   qH Wd  S(   NR   i(
   R4   t   leR   t   geRL   R1  R   RY   t   get_baset   append(   R   R   R   t   ymint   ymaxt   ticksR   R   (    (    s/   lib/python2.7/site-packages/matplotlib/dates.pyR     s    	

c         C` s   |  j    \ } } |  j j | j  } |  j j | j  } | j d | |  j  } | j d | |  j  } t |  } t |  } |  j | |  S(   u@   
        Set the view limits to include the data range.
        R   (	   R   R4   R4  R   R5  RL   R1  RY   R   (   R   R   R   R8  R9  R   R   (    (    s/   lib/python2.7/site-packages/matplotlib/dates.pyR     s    N(   R   R    R!   R(   RX   R[   R   R   (    (    (    s/   lib/python2.7/site-packages/matplotlib/dates.pyR  i  s
   			t   MonthLocatorc           B` s#   e  Z d  Z d d d d d  Z RS(   uB   
    Make ticks on occurrences of each month, e.g., 1, 3, 12.
    i   c      	   C` s   | d k r t d d  } n= t | t j  r[ g  | j t  D] } | j   ^ q@ } n  t t	 d | d | d | |  j
 } t j |  | |  d S(   u  
        Mark every month in *bymonth*; *bymonth* can be an int or
        sequence.  Default is ``range(1,13)``, i.e. every month.

        *interval* is the interval between each iteration.  For
        example, if ``interval=2``, mark every second occurrence.
        i   i   R  R  R   N(   R(   R  Rb   R:   Rn   R9   RH   t   itemR   R   R   R   RX   (   R   R  R  R   RP   RO   R   (    (    s/   lib/python2.7/site-packages/matplotlib/dates.pyRX     s    +N(   R   R    R!   R(   RX   (    (    (    s/   lib/python2.7/site-packages/matplotlib/dates.pyR;    s   t   WeekdayLocatorc           B` s    e  Z d  Z d d d d  Z RS(   u4   
    Make ticks on occurrences of each weekday.
    i   c         C` sp   t  | t j  r; g  | j t  D] } | j   ^ q" n  t t d | d | |  j } t	 j
 |  | |  d S(   u  
        Mark every weekday in *byweekday*; *byweekday* can be a number or
        sequence.

        Elements of *byweekday* must be one of MO, TU, WE, TH, FR, SA,
        SU, the constants from :mod:`dateutil.rrule`, which have been
        imported into the :mod:`matplotlib.dates` namespace.

        *interval* specifies the number of weeks to skip.  For example,
        ``interval=2`` plots every second week.
        t	   byweekdayR   N(   Rb   R:   Rn   R9   RH   R<  R   R   R   R   RX   (   R   R>  R   RP   RO   R   (    (    s/   lib/python2.7/site-packages/matplotlib/dates.pyRX     s
    )N(   R   R    R!   R(   RX   (    (    (    s/   lib/python2.7/site-packages/matplotlib/dates.pyR=    s   t
   DayLocatorc           B` s    e  Z d  Z d d d d  Z RS(   uZ   
    Make ticks on occurrences of each day of the month.  For example,
    1, 15, 30.
    i   c         C` s   | t  |  k s | d k  r. t d   n  | d k rL t d d  } n= t | t j  r g  | j t   D] } | j   ^ qn } n  t	 t
 d | d | |  j } t j |  | |  d S(   u   
        Mark every day in *bymonthday*; *bymonthday* can be an int or
        sequence.

        Default is to tick every day of the month: ``bymonthday=range(1,32)``
        i   u*   interval must be an integer greater than 0i    R  R   N(   RH   RI   R(   R  Rb   R:   Rn   R9   R<  R   R   R   R   RX   (   R   R  R   RP   RO   R   (    (    s/   lib/python2.7/site-packages/matplotlib/dates.pyRX     s    +N(   R   R    R!   R(   RX   (    (    (    s/   lib/python2.7/site-packages/matplotlib/dates.pyR?    s   t   HourLocatorc           B` s    e  Z d  Z d d d d  Z RS(   u1   
    Make ticks on occurrences of each hour.
    i   c      
   C` sV   | d k r t d  } n  t t d | d | d d d d } t j |  | |  d S(   u  
        Mark every hour in *byhour*; *byhour* can be an int or sequence.
        Default is to tick every hour: ``byhour=range(24)``

        *interval* is the interval between each iteration.  For
        example, if ``interval=2``, mark every second occurrence.
        i   R  R   R  i    R  N(   R(   R  R   R   R   RX   (   R   R  R   RP   R   (    (    s/   lib/python2.7/site-packages/matplotlib/dates.pyRX     s
    N(   R   R    R!   R(   RX   (    (    (    s/   lib/python2.7/site-packages/matplotlib/dates.pyR@    s   t   MinuteLocatorc           B` s    e  Z d  Z d d d d  Z RS(   u3   
    Make ticks on occurrences of each minute.
    i   c         C` sP   | d k r t d  } n  t t d | d | d d } t j |  | |  d S(   u  
        Mark every minute in *byminute*; *byminute* can be an int or
        sequence.  Default is to tick every minute: ``byminute=range(60)``

        *interval* is the interval between each iteration.  For
        example, if ``interval=2``, mark every second occurrence.
        i<   R  R   R  i    N(   R(   R  R   R   R   RX   (   R   R  R   RP   R   (    (    s/   lib/python2.7/site-packages/matplotlib/dates.pyRX     s
    	N(   R   R    R!   R(   RX   (    (    (    s/   lib/python2.7/site-packages/matplotlib/dates.pyRA    s   t   SecondLocatorc           B` s    e  Z d  Z d d d d  Z RS(   u3   
    Make ticks on occurrences of each second.
    i   c         C` sJ   | d k r t d  } n  t t d | d | } t j |  | |  d S(   u  
        Mark every second in *bysecond*; *bysecond* can be an int or
        sequence.  Default is to tick every second: ``bysecond = range(60)``

        *interval* is the interval between each iteration.  For
        example, if ``interval=2``, mark every second occurrence.

        i<   R  R   N(   R(   R  R   R   R   RX   (   R   R  R   RP   R   (    (    s/   lib/python2.7/site-packages/matplotlib/dates.pyRX   %  s    	N(   R   R    R!   R(   RX   (    (    (    s/   lib/python2.7/site-packages/matplotlib/dates.pyRB  !  s   R  c           B` s\   e  Z d  Z d d
 d  Z d   Z d   Z d   Z d   Z d   Z	 d   Z
 d	   Z RS(   u  
    Make ticks on regular intervals of one or more microsecond(s).

    .. note::

        Due to the floating point representation of time in days since
        0001-01-01 UTC (plus 1), plotting data with microsecond time
        resolution does not work well with current dates.

        If you want microsecond resolution time plots, it is strongly
        recommended to use floating point seconds, not datetime-like
        time representation.

        If you really must use datetime.datetime() or similar and still
        need microsecond precision, your only chance is to use very
        early years; using year 0001 is recommended.

    i   c         C` s(   | |  _  t j |  |  _ | |  _ d S(   u   
        *interval* is the interval between each iteration.  For
        example, if ``interval=2``, mark every second microsecond.

        N(   R   R/  t   MultipleLocatort   _wrapped_locatorRP   (   R   R   RP   (    (    s/   lib/python2.7/site-packages/matplotlib/dates.pyRX   H  s    	c         C` s    |  j  j |  t j |  |  S(   N(   RD  R  R   (   R   R   (    (    s/   lib/python2.7/site-packages/matplotlib/dates.pyR  R  s    c         C` s&   |  j  j | |  t j |  | |  S(   N(   RD  R!  R   (   R   R   R   (    (    s/   lib/python2.7/site-packages/matplotlib/dates.pyR!  V  s    c         C` s&   |  j  j | |  t j |  | |  S(   N(   RD  R"  R   (   R   R   R   (    (    s/   lib/python2.7/site-packages/matplotlib/dates.pyR"  Z  s    c         C` s;   y |  j    \ } } Wn t k
 r* g  SX|  j | |  S(   N(   R   RI   R   (   R   R   R   (    (    s/   lib/python2.7/site-packages/matplotlib/dates.pyR[   ^  s
    c         C` sb   t  | | f  \ } } | t 9} | t 9} |  j j | |  } g  | D] } | t ^ qH } | S(   N(   RY   RN   RD  R   (   R   R   R   t   nmint   nmaxR:  t   tick(    (    s/   lib/python2.7/site-packages/matplotlib/dates.pyR   g  s    

c         C` s   d t  S(   uj   
        Return how many days a unit of the locator is; used for
        intelligent autoscaling.
        g      ?(   RN   (   R   (    (    s/   lib/python2.7/site-packages/matplotlib/dates.pyR   o  s    c         C` s   |  j  S(   u;   
        Return the number of units for each tick.
        (   R   (   R   (    (    s/   lib/python2.7/site-packages/matplotlib/dates.pyR   v  s    N(   R   R    R!   R(   RX   R  R!  R"  R[   R   R   R   (    (    (    s/   lib/python2.7/site-packages/matplotlib/dates.pyR  5  s   
							i   c         C` s6   | |  } t  | j   d  } | | k  s2 t  d S(   uP   
    Assert that datetimes *d1* and *d2* are within *epsilon* microseconds.
    g    .AN(   R   R1   t   AssertionError(   t   d1t   d2t   epsilonR   t   mus(    (    s/   lib/python2.7/site-packages/matplotlib/dates.pyt   _close_to_dt}  s    
c         C` s*   t  | |  t  } | | k  s& t  d S(   uY   
    Assert that float ordinals *o1* and *o2* are within *epsilon*
    microseconds.
    N(   R   RN   RH  (   t   o1t   o2RK  R   (    (    s/   lib/python2.7/site-packages/matplotlib/dates.pyt   _close_to_num  s    c         C` s   t  t j |   t S(   ue   
    Convert an epoch or sequence of epochs to the new date format,
    that is days since 0001.
    (   t   EPOCH_OFFSETR:   Rh   R2   (   t   e(    (    s/   lib/python2.7/site-packages/matplotlib/dates.pyt	   epoch2num  s    c         C` s   t  j |   t t S(   uM   
    Convert days since 0001 to epoch.  *d* can be a number or sequence.
    (   R:   Rh   RQ  R2   (   R@   (    (    s/   lib/python2.7/site-packages/matplotlib/dates.pyt	   num2epoch  s    c         C` sb   t  } t j |   s' t } |  g }  n  t g  |  D] } | j   ^ q1  } | rZ | d S| Sd S(   ui   
    Convert mx :class:`datetime` instance (or sequence of mx
    instances) to the new date format.
    i    N(   R   Rq   Rr   R   RS  R:  (   t   mxdatest   scalart   mt   ret(    (    s/   lib/python2.7/site-packages/matplotlib/dates.pyt   mx2num  s    %c         C` s  |  d k r d t  }  n  |  t } |  t  } |  } |  t } |  t } |  t } | | k r t t | |  d | }	 d }
 n| | k r t d |  }	 d }
 n | | k r t d |  }	 d }
 n | | k rt	 d t t
 j | |   d |  }	 d }
 n | | k rDt d t t
 j | |   d |  }	 d	 }
 nR | | k rt d t t
 j | |   d |  }	 d
 }
 n t d |  }	 d
 }
 t |
 d | } |	 | f S(   u   
    Create a date locator with *numticks* (approx) and a date formatter
    for *span* in days.  Return value is (locator, formatter).
    i    i   RP   u   %Yu   %b %Yu	   %a, %b %dR   u   %b %du   %H:%M
%b %du   %H:%M:%S(   R   R   R   R   R   R  RH   R;  R=  R?  t   mathR   R@  RA  R   (   t   spanRP   t   numtickst   minst   hrsR|   t   wksR  R  R   RW   t	   formatter(    (    s/   lib/python2.7/site-packages/matplotlib/dates.pyt   date_ticker_factory  s>    




			(	(			c         C` s   |  t  S(   u!   
    Return seconds as days.
    (   R2   (   R&   (    (    s/   lib/python2.7/site-packages/matplotlib/dates.pyt   seconds  s    c         C` s   |  t  S(   u!   
    Return minutes as days.
    (   R   (   RW  (    (    s/   lib/python2.7/site-packages/matplotlib/dates.pyR    s    c         C` s   |  t  S(   u   
    Return hours as days.
    (   R   (   t   h(    (    s/   lib/python2.7/site-packages/matplotlib/dates.pyR    s    c         C` s   |  t  S(   u   
    Return weeks as days.
    (   R   (   t   w(    (    s/   lib/python2.7/site-packages/matplotlib/dates.pyt   weeks  s    t   DateConverterc           B` s;   e  Z d  Z e d    Z e d    Z e d    Z RS(   u   
    Converter for datetime.date and datetime.datetime data,
    or for date/time data represented as it would be converted
    by :func:`date2num`.

    The 'unit' tag for such data is None or a tzinfo instance.
    c      
   C` sy   |  } t  d |  } t | d | } t j d d d  } t j d d d  } t j d | d | d d d	 | | f  S(
   u   
        Return the :class:`~matplotlib.units.AxisInfo` for *unit*.

        *unit* is a tzinfo instance or None.
        The *axis* argument is required but not used.
        RP   i  i   i  t   majloct   majfmtt   labelu    t   default_limits(   R  R   R   t   datet   unitst   AxisInfo(   R   R   RP   Rg  Rh  t   datemint   datemax(    (    s/   lib/python2.7/site-packages/matplotlib/dates.pyt   axisinfo  s    c         C` s
   t  |   S(   u   
        If *value* is not already a number or sequence of numbers,
        convert it with :func:`date2num`.

        The *unit* and *axis* arguments are not used.
        (   RY   (   t   valueR   R   (    (    s/   lib/python2.7/site-packages/matplotlib/dates.pyt   convert  s    c         C` sq   t  |  t j  r! |  j   }  n  y t j |   }  Wn t t f k
 rM n Xy |  j SWn t	 k
 rl n Xd S(   uT   
        Return the tzinfo instance of *x* or of its first element, or None
        N(   Rb   R:   Rn   t   ravelRq   t   safe_first_elementR?   t   StopIterationR*   t   AttributeErrorR(   (   RO   R   (    (    s/   lib/python2.7/site-packages/matplotlib/dates.pyt   default_units  s    (   R   R    R!   R   Rp  Rr  Rw  (    (    (    s/   lib/python2.7/site-packages/matplotlib/dates.pyRf    s   
(*   u   date2numu   num2dateu   num2timedeltau   drangeu	   epoch2numu	   num2epochu   mx2numu   DateFormatteru   IndexDateFormatteru   AutoDateFormatteru   DateLocatoru   RRuleLocatoru   AutoDateLocatoru   YearLocatoru   MonthLocatoru   WeekdayLocatoru
   DayLocatoru   HourLocatoru   MinuteLocatoru   SecondLocatoru   MicrosecondLocatoru   rruleu   MOu   TUu   WEu   THu   FRu   SAu   SUu   YEARLYu   MONTHLYu   WEEKLYu   DAILYu   HOURLYu   MINUTELYu   SECONDLYu   MICROSECONDLYu   relativedeltau   secondsu   minutesu   hoursu   weeks(   R!   t
   __future__R    R   R   R   Rc   t	   six.movesR   R   R/   RZ  R   R   R  t   loggingt   dateutil.rruleR   R   R   R   R	   R
   R   R   R   R   R   R   R   R   R   t   dateutil.relativedeltaR   t   dateutil.parserRe   t   numpyR:   R"   R   t   matplotlib.unitsRl  t   matplotlib.cbookRq   t   matplotlib.tickerR/  t	   getLoggerR   R   t   __all__R*   R   R#   R'   R-   R.   RQ  Rt   R  R   R  t   SEC_PER_MINR  R   R   R   R   t   SEC_PER_HOURR2   t   SEC_PER_WEEKRN   t   MONDAYt   TUESDAYt	   WEDNESDAYt   THURSDAYt   FRIDAYt   SATURDAYt   SUNDAYt   WEEKDAYSR8   t	   vectorizeRs   RE   R(   RU   Ry   t   objectRV   R\   Rf   Rg   Rj   Rk   RY   Rv   Rx   R{   R}   R~   R   R   t	   FormatterR   R   R   R   t   LocatorR   R   R  R  R;  R=  R?  R@  RA  RB  R  RM  RP  RS  RT  RY  Ra  Rb  R  R  Re  t   ConversionInterfaceRf  t   registryR;   Rk  (    (    (    s/   lib/python2.7/site-packages/matplotlib/dates.pyt   <module>   s   "d          		!





0		)	%		%			*ciPi@H					+				9