o
    Gf+                     @   s:  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 d dlmZ d dlmZ d dlmZ d dlmZ dd Zejde  dddd dde  dddd dde  ddddddge  dddd dde  ddddddge  dddd	dde  dddd
ddgggejdg ddd Zejdg ddd Zejdg ddd Zdd Zdd Zdd Zdd Z edgdd Z!ed gd!d" Z"ed#gd$d% Z#ed&gd'd( Z$d)d* Z%d+d, Z&ed-gd.d/ Z'd0d1 Z(d2d3 Z)ed4gd5d6 Z*d7d8 Z+d9d: Z,ejd;e j-d<d=d>d? e.d@dAdBD fe j-dCdDdEd? e.ddFd
D fe j-dBdGdHd? e.d dId	D fe j-dJdKdLd? e.d dMD fgdNdO Z/dPdQ Z0e&dRdS Z1e&dTdU Z2dVdW Z3dXdY Z4ejdZe j-d[d\d]fe j-ddKd^fe j-ddGd_fe j-ddDd`fe j-dd=dafe j-dbd=dcfe j-ddd=dcfgdedf Z5dgdh Z6didj Z7ejdZe j-d<d=dkd? e.dldmdBD fe j-dndDg dofe j-dndGg dpfe j-d	d\g dqfgdrds Z8dtdu Z9dvdw Z:dxdy Z;dzd{ Z<ed|gd}d~ Z=dd Z>dd Z?dd Z@dd ZAdd ZBejjCdd ZDejjCdd ZEdd ZFdd ZGdd ZHejdde j-ddDfddge j-ddDe j-ddDgfgdd ZIdd ZJdd ZKdd ZLdd ZMdd ZNdd ZOdd ZPdd ZQejdddd ZRdd ZSdd ZTejdddd ZUdd ZVdd ZWdS )    N)
rc_contextstyle)image_comparisonc                     s   t  ddd  fddtddD } tj| dd}tg d	}tjd
d}|ddd}|| |\}|||\}tj	|j
dd|j
dd tjd
d}|ddd}||| \}|||\}tj	|jdd|jdd d S )N     c                    s   g | ]
} t j|d  qS )Zdaysdatetime	timedelta).0xbase ;lib/python3.10/site-packages/matplotlib/tests/test_dates.py
<listcomp>   s    z$test_date_numpyx.<locals>.<listcomp>r      datetime64[ns]dtype)               @      ?)
      )ZfigsizeF)Zorig)r	   rangenparraypltfigureadd_subplotplottestingassert_equalZ	get_xdataZ	get_ydata)timeZtimenpdatafigaxhZhnpr   r   r   test_date_numpyx   s   "r)   t0r   r   r   r   r   )zdatetime64[s]zdatetime64[us]zdatetime64[ms]r   c                 C   s4   t | }tj| |d}t |}tj|| d S )Nr   )mdatesdate2numr   r   r"   r#   )r*   r   r$   tnpnptimer   r   r   test_date_date2num_numpy#   s   

r/   c                 C   sR   t  dddddd}t|tjg}tj|dg| d}t|}tj|| d S )Nr   r   r   NaTr   )r	   r+   r,   r   nanr   r"   assert_array_equal)r   r*   tmplr-   r.   r   r   r   test_date2num_NaT7   s
   
r4   units)smsusnsc                 C   s$   t td| }t|sJ d S )Nr0   )r+   r,   r   
datetime64Zisnan)r5   r3   r   r   r   test_date2num_NaT_scalarC   s   r;   c                     s   t  ddd tjj fddtdD g dd} t| }tjtj	|d	 t j dddtj
d
 tjj fddtdD g dd} t| }tjtj	|d	 d S )N        c                        g | ]} t jd | d qS r   r   r   r   ir   r   r   r   L       z(test_date2num_masked.<locals>.<listcomp>   )r   r   r   r   r   r   r   )mask)FTTFFFTtzinfoc                    r?   r@   r   rA   r   r   r   r   U   rC   )r	   r   mar   r   r+   r,   r"   r2   ZgetmaskUTC)datesZnpdatesr   r   r   test_date2num_maskedI   s(   

rK   c               	   C   s   t  \} }|  |   tj| t	t
dt	t
dg t  td t  \} }|  |   tj| t	t
dt	t
dg t  d S )N
1970-01-01z
1970-01-02
0000-12-31)r   subplotsZ
xaxis_datedraw_without_renderingr   r"   assert_allcloseget_xlimr+   r,   r:   _reset_epoch_test_example	set_epochr&   r'   r   r   r   test_date_empty]   s&   
rU   c                  C   sH   t  } |  }|ddgddg |j  tj|	 ddg d S )N2   F   r   r   )
r   r   r    r!   xaxisZ	axis_dater   r"   rP   rQ   rT   r   r   r   test_date_not_emptys   s
   
rY   c               	   C   s   t  \} }|d |tdtdgddg tj| t	
tdt	
tdg t	  t	d t  \} }|d |tdtdgddg tj| t	
tdt	
tdg t	  d S )N      ?z
2016-01-01z
2016-01-02r   r   rM   )r   rN   axhliner!   r   r:   r"   rP   rQ   r+   r,   rR   rS   rT   r   r   r   test_axhline|   s&   
 

 r\   zdate_axhspan.pngc                  C   sn   t  ddd} t  ddd}t \}}|j| |ddd || t jdd	 |t jdd	  |jdd
 d S )N  r         blue      ?Z	facecolorZalpha   r   left)r	   r   rN   Zaxhspanset_ylimr
   subplots_adjustr*   tfr&   r'   r   r   r   test_date_axhspan   s   rj   zdate_axvspan.pngc                  C   sj   t  ddd} t  ddd}t \}}|j| |ddd || t jd	d
 |t jd	d
  |  d S )N  r   r^     r_   r`   ra   rb   i  r   )r	   r   rN   Zaxvspanset_xlimr
   autofmt_xdaterh   r   r   r   test_date_axvspan   s   ro   zdate_axhline.pngc                  C   sl   t  ddd} t  ddd}t \}}|j| ddd || t jdd	 |t jdd	  |jd
d d S Nr]   r   r^      r`   r   ZcolorZlwrc   r   ra   rd   )r	   r   rN   r[   rf   r
   rg   rh   r   r   r   test_date_axhline   s   rs   zdate_axvline.pngc                  C   sh   t  ddd} t  ddd}t \}}|j| ddd || t jdd	 |t jdd	  |  d S )
Nrk   r   r^   r_   Zredr   rr   rc   r   )r	   r   rN   Zaxvlinerm   r
   rn   rh   r   r   r   test_date_axvline   s   rt   c                 C   s   |  d tddd}tddd}t \}}tt$}|j||fdd t|dks0J dt	|d j
v s;J W d    n1 sEw   Y  |g g  |jt  |j  }t|d	ksfJ | jrstd
d | jD suJ t| jdks~J d S )NWARNINGrk   r   r^   T)autoz.Attempting to set identical low and high xlimsr     c                 s   s$    | ]}|j d ko|jdkV  qdS )zmatplotlib.tickerru   N)nameZ	levelname)r   recordr   r   r   	<genexpr>   s
    
z+test_too_many_date_ticks.<locals>.<genexpr>)Z	set_levelr	   r   rN   pytestwarnsUserWarningrm   lenstrmessager!   rX   set_major_locatorr+   
DayLocatorZget_major_locatorZrecordsall)Zcaplogr*   ri   r&   r'   Zrecvr   r   r   test_too_many_date_ticks   s&   

r   c                    s   t   fdd}|S )Nc                      s$   t   t d    t   d S )N
2000-01-01)r+   rR   rS   r   thefuncr   r   wrapper   s   
z%_new_epoch_decorator.<locals>.wrapper)	functoolswraps)r   r   r   r   r   _new_epoch_decorator   s   r   zRRuleLocator_bounds.pngc                  C   s   dd l m  m}  |   tddd}tddd}t }t }|d |j	||gddgdd	 t
jtjjd
d}t
|}|j| |jt
| |  |  d S )Nr   rw   r   ip  Tr   r   oZmarker  interval)matplotlib.testing.jpl_unitsr"   	jpl_unitsregisterr	   r   r   subplotset_autoscale_onr!   r+   rrulewrapperdateutilrruleZYEARLYRRuleLocatorrX   r   set_major_formatterAutoDateFormatterautoscale_viewrn   )r5   r*   ri   r&   r'   r   locatorr   r   r   test_RRuleLocator   s   

r   c                  C   s@   t  } tjdddt jd}tjdddt jd}| || d S )Nr   )yearmonthdayrG      )r+   r   r	   rI   tick_values)locZx1Zy1r   r   r   test_RRuleLocator_dayrange   s   r   c               	   C   sn   t jtjjdd} t | }tjdddd}tjddddd}ddg}ttt	t 
||||ks5J d S )	Nrc   r     r   r   r   r   )r   r   r   microsecond2020-01-01 00:00:00+00:00z 2020-01-01 00:00:00.000001+00:00)r+   r   r   r   ZSECONDLYr   r	   listmapr   num2dater   )r   r   d1d2expectedr   r   r   test_RRuleLocator_close_minmax  s   
(r   z#DateFormatter_fractionalSeconds.pngc                  C   s   dd l m  m}  |   tdddddd}tdddddd}t }t }|d |j	||gddgdd |
  |  d S )	Nr   i  r   Tr   r   r   r   )r   r"   r   r   r	   r   r   r   r   r!   r   rn   )r5   r*   ri   r&   r'   r   r   r   test_DateFormatter  s   
r   c               	   C   s(  dt jd< tdddddtdddddtdddd	dg} g d
}t  \}}|| | |jtd |j	
  dd | D }g d}||ksPJ |jt  |jtd td}|jt| |jtd |j	
  dd |jddD }g d}||ksJ dS )zh
    Test if setting the locator only will update the AutoDateFormatter to use
    the new locator.
    z%d %H:%Mzdate.autoformatter.minutei  	         r   ;   r   )r   r   r   )r   r   c                 S      g | ]}|  qS r   get_textr   tlr   r   r   r   :      z.test_locator_set_formatter.<locals>.<listcomp>)z30 08:00z30 08:30z30 09:00z30 09:30z30 10:00z30 10:30)rc   7   )r=      )r>   -   c                 S   r   r   r   r   r   r   r   r   F  r   minor)which)z30 08:15z30 08:45z30 09:15z30 09:45z30 10:15N)r   rcParamsr	   rN   r!   rX   r   r+   ZMinuteLocatorcanvasdrawget_xticklabelsmtickerZNullLocatorZset_minor_locatorZset_minor_formatterr   )tr   r&   r'   Z
ticklabelsr   Z	decoy_locr   r   r   test_locator_set_formatter+  s,   



r   c                  C   sN   G dd d} dd }t |  }||jd< |tdddgd	gks%J d S )
Nc                   @   s   e Zd Zdd ZdS )z.test_date_formatter_callable.<locals>._Locatorc                 S   s   dS )Nir   )selfr   r   r   	_get_unitN  s    z8test_date_formatter_callable.<locals>._Locator._get_unitN)__name__
__module____qualname__r   r   r   r   r   _LocatorM  s    r   c                 S   s   dd | D S )Nc                 S   s   g | ]}| d qS )z	%d-%m//%Y)strftime)r   dtr   r   r   r   Q      zVtest_date_formatter_callable.<locals>.callable_formatting_function.<locals>.<listcomp>r   )rJ   _r   r   r   callable_formatting_functionP  s   zBtest_date_formatter_callable.<locals>.callable_formatting_functioni  r=      z25-12//2014)r+   r   Zscaledr	   )r   r   	formatterr   r   r   test_date_formatter_callableK  s
   
"r   zdelta, expected(  Zweeksc                 C      g | ]}d | qS z$\mathdefault{%d}$r   )r   r   r   r   r   r   Z  r   r     i{  r^   r   r   c                 C   r   )z $\mathdefault{1990{-}01{-}%02d}$r   )r   r   r   r   r   r   \  r       Zhoursc                 C   r   )z$\mathdefault{01{-}01\;%02d}$r   )r   hourr   r   r   r   ^  r   r_   r   minutesc                 C   r   )z$\mathdefault{01\;00{:}%02d}$r   )r   Zminur   r   r   r   `  r      c                    s|   t d tddd}||  }tjdd}|  |jt|t| tj	|dd  fdd	| D |ks<J d S )
Ndefaultr   r   Finterval_multiplesTZusetexc                    s   g | ]} |qS r   r   )r   r   r   r   r   r   m  r   z.test_date_formatter_usetex.<locals>.<listcomp>)
r   Zuser	   r+   AutoDateLocatorcreate_dummy_axisaxisset_view_intervalr,   r   )deltar   r   r   r   r   r   r   test_date_formatter_usetexX  s   
 r   c                  C   s   t j dddtjd} t j dddtjd}t jdd}tt| ||dks'J |t jdd }tt| ||dks<J |t jdd }tt| ||dksQJ t j dddtjd}t jd	d}t| ||}t|d
kspJ t|d || ks}J dS )zj
    This test should check if drange works as expected, and if all the
    rounding errors are fixed
      r   rF   r   r      Zmicrosecondsr         N)r	   r+   rI   r
   r~   Zdranger   )startendr   Z	dateranger   r   r   test_drangep  s   r   c               
   C   sr  dd } t  ddd}t jddg dgt jddg d	gt jd
dg dgt jddg dgt jddg dgt jddg dgt jddg dgt jddg dgf}|D ]\}}|| }| ||}tttt| |kssJ qWtjdd}|jddddddddksJ tjt	j
jdid }|jddddddddksJ tjdd }|jddddddddksJ d S )!Nc                 S   .   t jdd}|  |jjt | |g  |S )NFr   r+   r   r   r   r   r,   date1date2r   r   r   r   _create_auto_date_locator     z9test_auto_date_locator.<locals>._create_auto_date_locatorr   r   r   r   )
1990-01-01 00:00:00+00:00z2010-01-01 00:00:00+00:00z2030-01-01 00:00:00+00:00z2050-01-01 00:00:00+00:00z2070-01-01 00:00:00+00:00z2090-01-01 00:00:00+00:00z2110-01-01 00:00:00+00:00z2130-01-01 00:00:00+00:00z2150-01-01 00:00:00+00:00z2170-01-01 00:00:00+00:004   )r   z1990-02-01 00:00:00+00:00z1990-03-01 00:00:00+00:00z1990-04-01 00:00:00+00:00z1990-05-01 00:00:00+00:00z1990-06-01 00:00:00+00:00z1990-07-01 00:00:00+00:00z1990-08-01 00:00:00+00:00z1990-09-01 00:00:00+00:00z1990-10-01 00:00:00+00:00z1990-11-01 00:00:00+00:00z1990-12-01 00:00:00+00:00   r   )z1990-01-05 00:00:00+00:00z1990-01-26 00:00:00+00:00z1990-02-16 00:00:00+00:00z1990-03-09 00:00:00+00:00z1990-03-30 00:00:00+00:00z1990-04-20 00:00:00+00:00z1990-05-11 00:00:00+00:00(   )z1990-01-03 00:00:00+00:00z1990-01-10 00:00:00+00:00z1990-01-17 00:00:00+00:00z1990-01-24 00:00:00+00:00z1990-01-31 00:00:00+00:00z1990-02-07 00:00:00+00:00r   )r   z1990-01-01 04:00:00+00:00z1990-01-01 08:00:00+00:00z1990-01-01 12:00:00+00:00z1990-01-01 16:00:00+00:00z1990-01-01 20:00:00+00:00z1990-01-02 00:00:00+00:00z1990-01-02 04:00:00+00:00z1990-01-02 08:00:00+00:00z1990-01-02 12:00:00+00:00z1990-01-02 16:00:00+00:00r^   r   )r   z1990-01-01 00:05:00+00:00z1990-01-01 00:10:00+00:00z1990-01-01 00:15:00+00:00z1990-01-01 00:20:00+00:00seconds)	r   z1990-01-01 00:00:05+00:00z1990-01-01 00:00:10+00:00z1990-01-01 00:00:15+00:00z1990-01-01 00:00:20+00:00z1990-01-01 00:00:25+00:00z1990-01-01 00:00:30+00:00z1990-01-01 00:00:35+00:00z1990-01-01 00:00:40+00:00  r   )z 1989-12-31 23:59:59.999500+00:00r   z 1990-01-01 00:00:00.000500+00:00z 1990-01-01 00:00:00.001000+00:00z 1990-01-01 00:00:00.001500+00:00z 1990-01-01 00:00:00.002000+00:00Fr   r   r=   r   )r   r   r   r   rc   r   rD   rc   )maxticks)r	   r
   r   r   r   r+   r   r   r  r   r   ZMONTHLY)r   r   resultst_deltar   r   r   r   r   r   test_auto_date_locator  sJ   







8
 "r  c               
   C   s   dd } t jddg dgt jddg dgt jdd	g d
gt jdd	g dgt jddg dgt jddg dgt jddg dgt jddg dgf}t  ddd}|D ]\}}|| }| ||}tttt| |kssJ qWd S )Nc                 S   r   )NTr   r   r   r   r   r   r     r   zAtest_auto_date_locator_intmult.<locals>._create_auto_date_locatorr   r   z1980-01-01 00:00:00+00:00z2000-01-01 00:00:00+00:00r   z2040-01-01 00:00:00+00:00z2060-01-01 00:00:00+00:00z2080-01-01 00:00:00+00:00z2100-01-01 00:00:00+00:00z2120-01-01 00:00:00+00:00z2140-01-01 00:00:00+00:00z2160-01-01 00:00:00+00:00z2180-01-01 00:00:00+00:00z2200-01-01 00:00:00+00:00r   )1997-01-01 00:00:00+00:001997-02-01 00:00:00+00:001997-03-01 00:00:00+00:001997-04-01 00:00:00+00:001997-05-01 00:00:00+00:00z1997-06-01 00:00:00+00:00z1997-07-01 00:00:00+00:00z1997-08-01 00:00:00+00:00z1997-09-01 00:00:00+00:00z1997-10-01 00:00:00+00:00z1997-11-01 00:00:00+00:00z1997-12-01 00:00:00+00:00r   r   )
r
  z1997-01-15 00:00:00+00:00r  z1997-02-15 00:00:00+00:00r  z1997-03-15 00:00:00+00:00r  z1997-04-15 00:00:00+00:00r  z1997-05-15 00:00:00+00:00r  )r
  z1997-01-05 00:00:00+00:00z1997-01-09 00:00:00+00:00z1997-01-13 00:00:00+00:00z1997-01-17 00:00:00+00:00z1997-01-21 00:00:00+00:00z1997-01-25 00:00:00+00:00z1997-01-29 00:00:00+00:00r  z1997-02-05 00:00:00+00:00z1997-02-09 00:00:00+00:00r   )r
  z1997-01-01 04:00:00+00:00z1997-01-01 08:00:00+00:00z1997-01-01 12:00:00+00:00z1997-01-01 16:00:00+00:00z1997-01-01 20:00:00+00:00z1997-01-02 00:00:00+00:00z1997-01-02 04:00:00+00:00z1997-01-02 08:00:00+00:00z1997-01-02 12:00:00+00:00z1997-01-02 16:00:00+00:00r^   r   )r
  z1997-01-01 00:05:00+00:00z1997-01-01 00:10:00+00:00z1997-01-01 00:15:00+00:00z1997-01-01 00:20:00+00:00r  )	r
  z1997-01-01 00:00:05+00:00z1997-01-01 00:00:10+00:00z1997-01-01 00:00:15+00:00z1997-01-01 00:00:20+00:00z1997-01-01 00:00:25+00:00z1997-01-01 00:00:30+00:00z1997-01-01 00:00:35+00:00z1997-01-01 00:00:40+00:00r  r   )z 1996-12-31 23:59:59.999500+00:00r
  z 1997-01-01 00:00:00.000500+00:00z 1997-01-01 00:00:00.001000+00:00z 1997-01-01 00:00:00.001500+00:00z 1997-01-01 00:00:00.002000+00:00  r   r	   r
   r   r   r   r+   r   )r   r  r   r  r   r   r   r   r   r   test_auto_date_locator_intmult  s@   







=
 r  c                  C   sR   t jdd} t | }d}|||dt j  |dt j  g}|g dks'J d S )NTr   g    B@r   i  )00:00z00.0005z00.0009)r+   r   ConciseDateFormatterformat_ticksZMUSECONDS_PER_DAY)r   r   Z	year_1996stringsr   r   r    test_concise_formatter_subsecond,  s   
r  c               
   C   s   dd } t  ddd}t jdddd td	d
dD gt jddg dgt jddg dgt jddg dgt jddg dgt jddg dgt jddg dgt jddg dgf}|D ]\}}|| }| ||}||ksqJ q^d S )Nc                 S   sf   t  \}}tjdd}t|}|j| |j| || | |j	
  dd | D }|S )NTr   c                 S   r   r   r   r   str   r   r   r   A  r   zMtest_concise_formatter.<locals>._create_auto_date_locator.<locals>.<listcomp>r   rN   r+   r   r  yaxisr   r   rf   r   r   get_yticklabelsr   r   r&   r'   r   r   stsr   r   r   r   8  s   

z9test_concise_formatter.<locals>._create_auto_date_locatorr  r   r   r   c                 S      g | ]}t |qS r   r   r   r   r   r   r   r   F  r   z*test_concise_formatter.<locals>.<listcomp>    r^   r   )1997FebMarAprMayJunJulAugSepOctNovDecr   r   )
Jan15r$  r0  r%  r0  r&  r0  r'  r0  r  )r/  05091317212529r$  r1  r2  r   )zJan-0104:0008:0012:0016:0020:00zJan-02r8  r9  r:  r;  r   )r  00:0500:1000:1500:20r  )	r  r1  10r0  20r6  303540r   )59.5r  00.501.001.502.002.5r	   r
   r   r   r   r  r  r   r   r  r   r   r   test_concise_formatter7  s@   








rN  zt_delta, expectedg{Gz?r  z1997-Jan-01 00:00z1997-Jan-01 00:011997-Jan-011997-Jan-021997-Jan      c                 C   s~   t  ddd}||  }t \}}t }t|}|j| |j| |	||gddg |j
  | |ks=J d S )Nr  r   r   )r	   r   rN   r+   r   r  rX   r   r   r!   r   r   
get_offset)r  r   r   r   r&   r'   r   r   r   r   r   "test_concise_formatter_show_offseth  s   


rV  c                  C   sz   t  dddt  dddg} ddg}t \}}|| | t  |j_}|jjd u s.J |j	|   |jj|ks;J d S )Nrk   r   r   r   r^   r   )
r	   r   rN   r!   r+   ZConciseDateConverterrX   Z	converterr5   rm   )r   yr&   r'   convr   r   r   test_concise_converter_stays  s   

rY  c                  C   s   t  \} }tddd}|tjdd }t }t|}|j| |j	| |
||gddg |   | dks@J |||tjdd  |   | dksXJ ||tjd	d |tjd
d  |   | dksvJ |||tjdd  |   | dksJ d S )Nr  r   rT  r   r   rS  r   rQ  rD   r   r#  )r   rN   r	   r
   r+   r   r  rX   r   r   r!   rO   rU  rm   )r&   r'   r   r   r   r   r   r   r   test_offset_changes  s*   
rZ  c                 C   s   g | ]}d |f qS r   r   r   r   r   r   r     r   r!  r"  r  )r/  $\mathdefault{05}$$\mathdefault{09}$z$\mathdefault{13}$z$\mathdefault{17}$z$\mathdefault{21}$z$\mathdefault{25}$z$\mathdefault{29}$r$  r[  r\  )zJan$\mathdefault{{-}01}$$\mathdefault{04{:}00}$$\mathdefault{08{:}00}$$\mathdefault{12{:}00}$$\mathdefault{16{:}00}$z$\mathdefault{20{:}00}$zJan$\mathdefault{{-}02}$r]  r^  r_  r`  )z$\mathdefault{59.5}$z$\mathdefault{00{:}00}$z$\mathdefault{00.5}$z$\mathdefault{01.0}$z$\mathdefault{01.5}$z$\mathdefault{02.0}$z$\mathdefault{02.5}$c                 C   sj   t  ddd}||  }tjdd}|  |jt|t| tj|dd}|| |ks3J d S )Nr  r   Tr   r   )	r	   r+   r   r   r   r   r,   r  r  )r  r   r   r   r   r   r   r   r   test_concise_formatter_usetex  s   ra  c               
         g d  fdd} t  ddd}t jdddd	 td
ddD gt jddg dgt jddg dgt jddg dgt jddg dgt jddg dgt jddg dgt jddg dgf}|D ]\}}|| }| ||}||kswJ qdd S )N)%Yz%m/%Yzday: %d%H hr %M minrd  z	%S.%f secc                    j   t  \}}tjdd}tj| d}|j| |j| || | |j	
  dd | D }|S )NTr   formatsc                 S   r   r   r   r  r   r   r   r     r   zUtest_concise_formatter_formats.<locals>._create_auto_date_locator.<locals>.<listcomp>r  r  rf  r   r   r     s   
zAtest_concise_formatter_formats.<locals>._create_auto_date_locatorr  r   r   r   c                 S   r  r   r  r   r   r   r   r     r   z2test_concise_formatter_formats.<locals>.<listcomp>r!  r"  r^   r   )r#  02/199703/199704/199705/1997z06/1997z07/1997z08/1997z09/1997z10/1997z11/1997z12/1997r   r   )
01/1997day: 15rh  rm  ri  rm  rj  rm  rk  rm  r  )rl  day: 05day: 09zday: 13zday: 17zday: 21zday: 25zday: 29rh  rn  ro  r   )zday: 0104 hr 00 min08 hr 00 min12 hr 00 min16 hr 00 minz20 hr 00 minzday: 02rp  rq  rr  rs  r   )00 hr 00 minz00 hr 05 minz00 hr 10 minz00 hr 15 minz00 hr 20 minr  )	rt  z05.000000 secz10.000000 secz15.000000 secz20.000000 secz25.000000 secz30.000000 secz35.000000 secz40.000000 secr   )z59.500000 secrt  z00.500000 secz01.000000 secz01.500000 secz02.000000 secz02.500000 secrL  rM  r   rf  r   test_concise_formatter_formats  s&    
ru  c               
      rb  )N)rS  z'%yz%Bz%m-%dz%Sz%S.%fc                    re  )NTr   zero_formatsc                 S   r   r   r   r  r   r   r   r     r   zVtest_concise_formatter_zformats.<locals>._create_auto_date_locator.<locals>.<listcomp>r  r  rv  r   r   r   
  s   
zBtest_concise_formatter_zformats.<locals>._create_auto_date_locatorr  r   r   r   c                 S   r  r   r  r   r   r   r   r     r   z3test_concise_formatter_zformats.<locals>.<listcomp>r!  r"  r^   r   )z'97r$  r%  r&  r'  r(  r)  r*  r+  r,  r-  r.  r   r   )
Januaryr0  Februaryr0  ZMarchr0  ZAprilr0  r'  r0  r  )rx  r1  r2  r3  r4  r5  r6  r7  ry  r1  r2  r   )z01-01r8  r9  r:  r;  r<  z01-02r8  r9  r:  r;  r   )00r=  r>  r?  r@  r  )	rz  r1  rA  r0  rB  r6  rC  rD  rE  r   )rF  z00.0rG  rH  rI  rJ  rK  rL  rM  r   rv  r   test_concise_formatter_zformats  sB   








r{  c            
      C   s   dd } t  dddjt jjd}t jddg dd	gt jd
dg ddgt jddg ddgt jddg ddgf}t t jdd}|D ]\}}}|| }| |||\}}	||ks]J |	|kscJ qFd S )Nc                 S   sx   t  \}}tjdd}tj||d}|j| |j| || | |j	
  dd | D }||j  fS )NTr   tzc                 S   r   r   r   r  r   r   r   r   E  r   zPtest_concise_formatter_tz.<locals>._create_auto_date_locator.<locals>.<listcomp>)r   rN   r+   r   r  r  r   r   rf   r   r   r  Zget_offset_textr   )r   r   r}  r&   r'   r   r   r  r   r   r   r   <  s   
z<test_concise_formatter_tz.<locals>._create_auto_date_locatorr  r   rF   r  r   )03:0007:0011:0015:0019:00z23:00r~  r  r  r  r  rP  r^   r   )r~  z03:05z03:10z03:15z03:20rO  r  )	r~  r1  rA  r0  rB  r6  rC  rD  rE  z1997-Jan-01 03:00r   )rF  r~  rG  rH  rI  rJ  rK  r   )r	   replacetimezoneutcr
   )
r   r   r  Znew_tzr  Zexpected_stringsZexpected_offsetr   r  offsetr   r   r   test_concise_formatter_tz;  s4   



r  c            	   	   C   s   dd } t jddg dgt jddg dgt jdd	g d
gt jdd	g dgt jddg dgt jddg dgt jddg dgf}tjd}t j ddd|d}|D ]7\}}tddi% || }| |||}tttt	j
| |d}||ks~J W d    n1 sw   Y  qVd S )Nc                 S   s0   t jd|d}|  |jjt | |g  |S )NTr   r}  r   )r   r   r}  r   r   r   r   r   e  s   zDtest_auto_date_locator_intmult_tz.<locals>._create_auto_date_locatorr   r   )z1980-01-01 00:00:00-08:00z2000-01-01 00:00:00-08:00z2020-01-01 00:00:00-08:00z2040-01-01 00:00:00-08:00z2060-01-01 00:00:00-08:00z2080-01-01 00:00:00-08:00z2100-01-01 00:00:00-08:00z2120-01-01 00:00:00-08:00z2140-01-01 00:00:00-08:00z2160-01-01 00:00:00-08:00z2180-01-01 00:00:00-08:00z2200-01-01 00:00:00-08:00r   )1997-01-01 00:00:00-08:001997-02-01 00:00:00-08:001997-03-01 00:00:00-08:001997-04-01 00:00:00-08:001997-05-01 00:00:00-07:00z1997-06-01 00:00:00-07:00z1997-07-01 00:00:00-07:00z1997-08-01 00:00:00-07:00z1997-09-01 00:00:00-07:00z1997-10-01 00:00:00-07:00z1997-11-01 00:00:00-08:00z1997-12-01 00:00:00-08:00r   r   )
r  z1997-01-15 00:00:00-08:00r  z1997-02-15 00:00:00-08:00r  z1997-03-15 00:00:00-08:00r  z1997-04-15 00:00:00-07:00r  z1997-05-15 00:00:00-07:00r  )r  z1997-01-05 00:00:00-08:00z1997-01-09 00:00:00-08:00z1997-01-13 00:00:00-08:00z1997-01-17 00:00:00-08:00z1997-01-21 00:00:00-08:00z1997-01-25 00:00:00-08:00z1997-01-29 00:00:00-08:00r  z1997-02-05 00:00:00-08:00z1997-02-09 00:00:00-08:00r   )r  z1997-01-01 04:00:00-08:00z1997-01-01 08:00:00-08:00z1997-01-01 12:00:00-08:00z1997-01-01 16:00:00-08:00z1997-01-01 20:00:00-08:00z1997-01-02 00:00:00-08:00z1997-01-02 04:00:00-08:00z1997-01-02 08:00:00-08:00z1997-01-02 12:00:00-08:00z1997-01-02 16:00:00-08:00r^   r   )r  z1997-01-01 00:05:00-08:00z1997-01-01 00:10:00-08:00z1997-01-01 00:15:00-08:00z1997-01-01 00:20:00-08:00r  )	r  z1997-01-01 00:00:05-08:00z1997-01-01 00:00:10-08:00z1997-01-01 00:00:15-08:00z1997-01-01 00:00:20-08:00z1997-01-01 00:00:25-08:00z1997-01-01 00:00:30-08:00z1997-01-01 00:00:35-08:00z1997-01-01 00:00:40-08:00zCanada/Pacificr  r   rF   z_internal.classic_modeFr|  )r	   r
   r   r}  gettzr   r   r   r   r+   r   )	r   r  r}  r   r  r   r   r   r  r   r   r   !test_auto_date_locator_intmult_tzd  sD   






5r  zdate_inverted_limit.pngc                  C   st   t  ddd} t  ddd}t \}}|j| ddd || t jdd	 |t jdd	  |  |jd
d d S rp   )r	   r   rN   r[   rf   r
   Zinvert_yaxisrg   rh   r   r   r   test_date_inverted_limit  s   r  c                    s   t jd}tj}tjddddd|d}tjddd	}|jd
  d}| |||d}|||}dtt	
d  fddt|D }	tt|}
|
|	ksQJ d S )NzEurope/Brusselsr   r   r   r   rF   !   r   )r   r  iQ r   r   freqZperiodsg    p&ArM   c                    s   g | ]}|   qS r   r   rA   Zinterval_daysr*   r   r   r         z&_test_date2num_dst.<locals>.<listcomp>)r   r}  r  r+   rI   r	   r
   r  r,   r   r:   r   r   )
date_range
tz_convertZBRUSSELSrI   dtstartr   NZdt_utcZdt_bxlZexpected_ordinalfZactual_ordinalfr   r  r   _test_date2num_dst  s   

r  c                     s4   G dd dt j   fdd} dd }t| | d S )Nc                       sD   e Zd ZdZ fddZ fddZ fddZedd	 Z  Z	S )
z%test_date2num_dst.<locals>.dt_tzawarez
        This bug specifically occurs because of the normalization behavior of
        pandas Timestamp objects, so in order to replicate it, we need a
        datetime-like object that applies timezone normalization after
        subtraction.
        c                    sX   t  |}t|dd }|d urt|dd }|d ur||}t|tjr*| |}|S )NrG   	normalize)super__sub__getattrr  
isinstancer	   
mk_tzaware)r   otherrrG   Z	localizer	__class__r   r   r    s   

z-test_date2num_dst.<locals>.dt_tzaware.__sub__c                    s   |  t |S N)r  r  __add__)r   r  r  r   r   r       z-test_date2num_dst.<locals>.dt_tzaware.__add__c                    s   t  |}| |S r  )r  
astimezoner  )r   rG   r   r  r   r   r    s   
z0test_date2num_dst.<locals>.dt_tzaware.astimezonec                 S   s<   i }d}|D ]}t ||d }|d ur|||< q| di |S )N)r   r   r   r   Zminutesecondr   rG   r   )r  )clsZdatetime_objkwargsattrsattrvalr   r   r   r    s   	z0test_date2num_dst.<locals>.dt_tzaware.mk_tzaware)
r   r   r   __doc__r  r  r  classmethodr  __classcell__r   r   r  r   
dt_tzaware  s    r  c                    s"    |   fddt|D S )Nc                    s   g | ]} |  qS r   r   rA   r  r  r   r   r     r  z9test_date2num_dst.<locals>.date_range.<locals>.<listcomp>)r  r   r  r  r  r   r    s   
z%test_date2num_dst.<locals>.date_rangec                    s    fdd| D S )Nc                    s   g | ]}|  qS r   )r  )r   drF   r   r   r   	  r   z9test_date2num_dst.<locals>.tz_convert.<locals>.<listcomp>r   )Zdt_listrG   r   rF   r   r    r  z%test_date2num_dst.<locals>.tz_convert)r	   r  )r  r  r   r  r   test_date2num_dst  s   1r  c                    s    fdd}t  j| d S )Nc                     s    j j|  tS r  )ZDatetimeIndexr  astypeobject)argspdr   r   r    r  z,test_date2num_dst_pandas.<locals>.tz_convert)r  r  )r  r  r   r  r   test_date2num_dst_pandas  s   r  c                 C   s   |d}| t  dddd|}| t  dddd|}tjtjj|d}|||}t j ddddtj dt j ddd	d
tj dg}||ksIJ d S )NAustralia/Sydneyr   r   r   r   )r  r     rF   r      )	r	   r+   r   r   r   DAILYZbetweenr}  Ztzutc)	attach_tzZget_tzSYDr  dtendruleZactZexpr   r   r   _test_rrulewrapper  s   r  c               	   C   s   dd } t | tjj tjd}tdddd}tdddd}tjtjj|||d}|	|tjddd	dd|d
ks>J |
|tjddddd|d
ksPJ |j|ksWJ |jdks^J d S )Nc                 S   s   | j |dS )NrF   )r  r   Zzir   r   r   r  (  s   z$test_rrulewrapper.<locals>.attach_tzr  r   r   r   r   )r  r  rG   Zuntilr   rF   r   )r  r   r}  r  r	   r+   r   r   r  ZafterZbeforeZ_base_tzinfoZ	_interval)r  r  r  r  r  r   r   r   test_rrulewrapper'  s    r  c                  C   s"   t d} dd }t|| j d S )Npytzc                 S   s
   | | S r  )localizer  r   r   r   r  A  s   
z)test_rrulewrapper_pytz.<locals>.attach_tz)r{   importorskipr  r  )r  r  r   r   r   test_rrulewrapper_pytz<  s   
r  c                     s2  t d} | d  fddtdD }tjd d}|  |jt	|d d	 t	|d
 d	  t
g d}|t	t
d }t
j||  g d}ttttj|  d}||kseJ t
||d |d t
g dszJ t
||d |d |d |d t
g dsJ d S )Nr  zAmerica/New_Yorkc              	      s*   g | ]}  td ddt| qS )rl   r   )r  r	   r
   rA   r|  r   r   r   L  s
    z)test_yearlocator_pytz.<locals>.<listcomp>rk   Tr  r   r   r   )g{ja&Ag{jd&Ag{jtg&Ag{jNj&Ag{j*m&Ag{jp&Ag{jr&ArM   )z2009-01-01 00:00:00-05:00z2010-01-01 00:00:00-05:00z2011-01-01 00:00:00-05:00z2012-01-01 00:00:00-05:00z2013-01-01 00:00:00-05:00z2014-01-01 00:00:00-05:00z2015-01-01 00:00:00-05:00r|  r   )	g@g*@g:@gJ@gZ@gj@gz@g@g@)r{   r  r  r   r+   r   r   r   r   r,   r   r   r:   r"   rP   r   r   r   r   Zallcloser   Zget_locator)r  r   r   r   r   r  r   r|  r   test_yearlocator_pytzG  s0   



&r  c                  C   s   dd } t  ddd}t jddddddg d	gt jdddd
ddg dgt jddddddddggf}|D ]!\}}}|| }| ||fi |}tttt| |ksZJ q9d S )Nc                 [   s6   t jdi |}|  |jt | t | |S )Nr   )r+   ZYearLocatorr   r   r   r,   )r   r   r  r   r   r   r   _create_year_locatori  s   z.test_YearLocator.<locals>._create_year_locatorr   r   r   r   r^   )r   r   r   r	  rc   r   )z1980-05-16 00:00:00+00:00z2000-05-16 00:00:00+00:00z2020-05-16 00:00:00+00:00z2040-05-16 00:00:00+00:00z2060-05-16 00:00:00+00:00z2080-05-16 00:00:00+00:00z2100-05-16 00:00:00+00:00z2120-05-16 00:00:00+00:00z2140-05-16 00:00:00+00:00z2160-05-16 00:00:00+00:00z2180-05-16 00:00:00+00:00z2200-05-16 00:00:00+00:00i  r   r   z1980-09-25 00:00:00+00:00z2000-09-25 00:00:00+00:00r  )r  r   r  r   Z	argumentsr   r   r   r   r   r   test_YearLocatorh  s(   


	

	
 r  c                   C   s   t t tjdd W d    n1 sw   Y  t t tjdd W d    n1 s1w   Y  t t tjdd W d    n1 sLw   Y  t t tjdd W d    n1 sgw   Y  tjdd d S )Nr   r   g      r   g?r   )r{   raises
ValueErrorr+   r   r   r   r   r   test_DayLocator  s   r  c                  C   s(   t j dddtjd} |  dksJ d S )N  r   rF   rI   )r	   r+   rI   tznamer   r   r   r   test_tz_utc  s   r  z	x, tdeltarZ   c                 C   s   t | }||ksJ d S r  )r+   Znum2timedelta)r   Ztdeltar   r   r   r   test_num2timedelta  s   
r  c                  C   sN   t dt dg} t| }t ddgtt d }t j|| d S )Nr   z
2001-01-01    H&Ag    J&ArM   )r   r:   r+   r,   r   r"   r#   )r   Zdnr   r   r   r   test_datetime64_in_list  s   
r  c                  C   s  t d} t  t  tt td W d    n1 s"w   Y  t  td | t d 	d}|	d}t j
t| t| t  td t j
t| d t  td t j
t| |d	  t  td
 t j
tt dd d S )Nr   z
0000-01-01rL   datetime64[D]intrM   r  z1970-01-01T01:00:00gUUUUUU?1970-01-01T00:00:00z1970-01-01T12:00:00g      ?)r   r:   r+   rR   Z	get_epochr{   r  RuntimeErrorrS   r  r"   r#   r,   floatrP   )dater   r   r   r   test_change_epoch  s.   





r  c                  C   s   t jdddd} tjdd}dg|jd< |  |jt| d	 t| d
  t	j
tdd | }W d    d S 1 s?w   Y  d S )Nz
2001-01-10z
2001-03-04r  r   Fr   r   r   r   r   zAutoDateLocator was unablematch)r   aranger+   r   Z	intervaldr   r   r   r,   r{   r|   r}   )rJ   r   Zlocsr   r   r   test_warn_notintervals  s   "r  c                  C   s  dt jd< tjdddd} t  \}}|| tt|  |j  |	 d 
 dks/J |	 d	 
 d
ks;J dt jd< t  \}}|| tt|  |j  |	 d 
 dksbJ |	 d	 
 dksnJ tt dt jd< W d    d S 1 sw   Y  d S )NZconcisezdate.converterz
2020-01-01
2020-05-01r  r   r   r/  r   r0  rv   zJan 01 2020Jan 15 2020Zboo)r   r   r   r  rN   r!   r~   r   r   r   r   r{   r  r  rJ   r&   r'   r   r   r   test_change_converter  s    



"r  c                  C   s   dt jd< tjdddd} t  \}}|| tt|  |j  |	 d 
 dks/J |	 d	 
 d
ks;J dt jd< t  \}}|| tt|  |j  |	 d 
 dksbJ |	 d	 
 dksnJ d S )NFzdate.interval_multiplesz
2020-01-10r  r  r   r   zJan 10 2020r   zJan 24 2020Truer  zFeb 01 2020)r   r   r   r  rN   r!   r~   r   r   r   r   r  r   r   r   test_change_interval_multiples  s   



r  c                   C   s   t   t d ttj t ddksJ t ddks"J W d    n1 s,w   Y  t   t d ttj t ddksJJ t ddksSJ W d    d S 1 s^w   Y  d S )	NrM   g   @ƞBAg    x%Ag    z%Ag   ƞBAr  r   r   )	r+   rR   rS   r{   r|   mplZMatplotlibDeprecationWarningZ
julian2numZ
num2julianr   r   r   r   test_julian2num  s   

"r  c               
   C   s  t  } | dtjdksJ | dddksJ | dddks#J | dddks-J |   |  tjdddddtjj	dtjdddddtjj	dfksQJ | j
t jksYJ d}tj
|}| j
|kshJ | d | j
|kstJ |   | jjt d	d
g  |  tjddddd|dtjddddd|dfksJ |tjd< t  } | j
|ksJ tjtdd t jdd W d    n1 sw   Y  tjtdd t jdd W d    d S 1 sw   Y  d S )Nr   r   r   r   )r   r  rF   r   ZIceland
2022-01-10z
2022-01-08r<   r   r   r  z Aiceland is not a valid timezoner  ZAicelandr|  z%tz must be string or tzinfo subclass.)r+   ZDateLocatorZnonsingularr   infr   Zdatalim_to_dtr	   r  r  r}  rI   r   r  
set_tzinfor   Zset_data_intervalr,   r   r   r{   r  r  	TypeError)r   Ztz_strZ
iceland_tzr   r   r   test_DateLocator  sF   



"r  c                  C   s   t ddks	J tjdddd} t jd| ddksJ tt jdd	g| dtdd
gks1J t g jdks;J t g tjddddjdksLJ d S )Nr      @r<   r   r   r   z2022-01)r   z2022-02g    @@r   )r+   Zdatestr2numr	   r  r   r   r   sizer  r   r   r   test_datestr2numC  s   
r  kwarg)rg  rw  Zoffset_formatsc                 C   sd   t  }| ddgi}|  d}tjt|d t j|fi | W d    d S 1 s+w   Y  d S )NrS  rc  z argument must be a listr  )r+   r   r{   r  r  r  )r  r   r  r  r   r   r   !test_concise_formatter_exceptionsO  s   
"r  c                  C   s8   t  } t | }|ddksJ |ddksJ d S )Nr  Z2022z2022-01-10 00:00:00)r+   r   r  Zformat_data_short)r   r   r   r   r   test_concise_formatter_callY  s   
r  c                  C   sb   t dd tddD } t g d}t j|d}t \}}|| | | dks/J d S )Nc                 S   s   g | ]	}t  d d|qS )r   r   )r	   )r   nr   r   r   r   c  s    z(test_datetime_masked.<locals>.<listcomp>r   r   )r   r   r   r   rc   r   r  )	r   r   r   rH   Zmasked_greaterr   rN   r!   rQ   )r   rW  mr&   r'   r   r   r   test_datetime_masked`  s   r  r  )ii c                 C   sF   t jtd|  dd t|  W d    d S 1 sw   Y  d S )NzDate ordinal z	 convertsr  )r{   r  r  r+   r   )r  r   r   r   test_num2date_errorl  s   "r  c                   C   sZ   t dtjdddddddtjjdksJ t d	tjdddddd
tjjdks+J d S )Ngj<  j@i  r      r   r   i,B rF   gq<  j@rc   )r+   r   r	   r  r  r   r   r   r   test_num2date_roundoffr  s   r  c               
   C   sV   t tjdddddt jd} t d}|| dksJ |d || dks)J d S )	Nr   r   r   rF   z%Y-%b-%d %H:%Mz2011-Jan-01 00:00zPacific/Kiritimatiz2011-Jan-01 14:00)r+   r,   r	   rI   ZDateFormatterr  )r$   r   r   r   r   test_DateFormatter_settzz  s   

r  )Xr	   Zdateutil.tzr   Zdateutil.rruler   Znumpyr   r{   Z
matplotlibr  r   r   Zmatplotlib.datesrJ   r+   Zmatplotlib.pyplotZpyplotr   Zmatplotlib.testing.decoratorsr   Zmatplotlib.tickerZtickerr   r)   ZmarkZparametrizer/   r4   r;   rK   rU   rY   r\   rj   ro   rs   rt   r   r   r   r   r   r   r   r   r
   r   r   r   r  r  r  rN  rV  rY  rZ  ra  ru  r{  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r   r   r   r   <module>   s$   	

	






 





 
O
K1
	




74)F
A



 '

	 .

