o
    i                     @   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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edg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"d+d, Z#ed-gd.d/ Z$d0d1 Z%d2d3 Z&d4d5 Z'e!d6d7 Z(e!d8d9 Z)d:d; Z*d<d= Z+d>d? Z,d@dA Z-dBdC Z.edDgdEdF Z/dGdH Z0dIdJ Z1dKdL Z2dMdN Z3dOdP Z4ejj5dQdR Z6ejj5dSdT Z7dUdV Z8dWdX Z9ejdYde j:ddZfdd[ge j:ddZe j:d[dZgfgd\d] Z;d^d_ Z<d`da Z=dbdc Z>ddde Z?dS )f    N)
rc_context)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 )days)datetime	timedelta).0xbase V/var/www/edux/Edux_v2/venv/lib/python3.10/site-packages/matplotlib/tests/test_dates.py
<listcomp>   s    z$test_date_numpyx.<locals>.<listcomp>r      datetime64[ns]dtype)               @      ?)
      )figsizeF)orig)r   rangenparraypltfigureadd_subplotplottestingassert_equal	get_xdata	get_ydata)timetimenpdatafigaxh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   

r4   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   r0   r1   r   nanr   r#   assert_array_equal)r   r/   tmplr2   r3   r   r   r   test_date2num_NaT6   s
   
r9   units)smsusnsc                 C   s$   t td| }t|sJ d S )Nr5   )r0   r1   r   
datetime64isnan)r:   r8   r   r   r   test_date2num_NaT_scalarB   s   rA   zdate_empty.pngc                  C   s"   t  } | ddd}|  d S )Nr   )r   r    r!   
xaxis_date)r*   r+   r   r   r   test_date_emptyH   s   rC   zdate_axhspan.pngc                  C   sx   t  ddd} t  ddd}t }|ddd}|j| |ddd || t jdd	 |t jdd	  |jdd
 d S )N  r         blue      ?	facecoloralpha   r   left)r   r   r    r!   axhspanset_ylimr	   subplots_adjustr/   tfr*   r+   r   r   r   test_date_axhspanR   s   rT   zdate_axvspan.pngc                  C   st   t  ddd} t  ddd}t }|ddd}|j| |ddd || t jd	d
 |t jd	d
  |  d S )N  r   rE     rF   rG   rH   rI   i  r   )r   r   r    r!   axvspanset_xlimr	   autofmt_xdaterR   r   r   r   test_date_axvspan_   s   rZ   zdate_axhline.pngc                  C   sv   t  ddd} t  ddd}t }|ddd}|j| ddd || t jdd	 |t jdd	  |jd
d d S NrD   r   rE      rG   r   colorlwrL   r   rH   rM   )r   r   r    r!   axhlinerP   r	   rQ   rR   r   r   r   test_date_axhlinel   s   ra   zdate_axvline.pngc                  C   sr   t  ddd} t  ddd}t }|ddd}|j| ddd || t jdd	 |t jdd	  |  d S )
NrU   r   rE   rF   redr   r]   rL   r   )r   r   r    r!   axvlinerX   r	   rY   rR   r   r   r   test_date_axvliney   s   rd   c                 C   s
  |  d tddd}tddd}t }|ddd}tt$}|j||fdd t	|dks5J dt
|d jv s@J W d    n1 sJw   Y  |g g  |jt  |j  }t	|d	kskJ | jrxtd
d | jD szJ t	| jdksJ d S )NWARNINGrU   r   rE   T)autoz)Attempting to set identical left == rightr     c                 s   s$    | ]}|j d ko|jdkV  qdS )zmatplotlib.tickerre   N)name	levelname)r
   recordr   r   r   	<genexpr>   s
    
z+test_too_many_date_ticks.<locals>.<genexpr>)	set_levelr   r   r    r!   pytestwarnsUserWarningrX   lenstrmessager"   xaxisset_major_locatorr0   
DayLocatorget_major_locatorrecordsall)caplogr/   rS   r*   r+   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)r0   _reset_epoch_test_example	set_epochr   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}|d |j	||gddgd	d
 t
jtjjdd}t
|}|j| |jt
| |  |  d S )Nr   rg   r   ip  o   Tr   r   omarkeri  interval)matplotlib.testing.jpl_unitsr#   	jpl_unitsregisterr   r   r    subplotset_autoscale_onr"   r0   rrulewrapperdateutilrruleYEARLYRRuleLocatorrs   rt   set_major_formatterAutoDateFormatterautoscale_viewrY   )r:   r/   rS   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daytzinfo   )r0   ru   r   UTCtick_values)locx1y1r   r   r   test_RRuleLocator_dayrange   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}|d |j	||gddgdd	 |
  |  d S )
Nr   i  r   r   Tr   r   r   r   )r   r#   r   r   r   r   r    r   r   r"   r   rY   )r:   r/   rS   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)rL   7   )      )   -   c                 S   r   r   r   r   r   r   r   r     r   minor)which)z30 08:15z30 08:45z30 09:15z30 09:45z30 10:15N)r   rcParamsr   subplotsr"   rs   rt   r0   MinuteLocatorcanvasdrawget_xticklabelsmtickerNullLocatorset_minor_locatorset_minor_formatterr   )tr   r*   r+   
ticklabelsexpected	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_unit	  s    z8test_date_formatter_callable.<locals>._Locator._get_unitN)__name__
__module____qualname__r   r   r   r   r   _Locator  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         zVtest_date_formatter_callable.<locals>.callable_formatting_function.<locals>.<listcomp>r   )dates_r   r   r   callable_formatting_function  s   zBtest_date_formatter_callable.<locals>.callable_formatting_functioni  r      z25-12//2014)r0   r   scaledr   )r   r   	formatterr   r   r   test_date_formatter_callable  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dtjd}t jd	d}t| ||}t|d
ks[J t|d || kshJ dS )zj
    This test should check if drange works as expected, and if all the
    rounding errors are fixed
    i  r   r   r   hours   microsecondsr         N)r   r0   r   r	   rp   drangenum2date)startenddelta	dateranger   r   r   test_drange  s   r   c               
   C   s   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 qWd S )Nc                 S   0   t jdd}|  |t | t | |S )NFinterval_multiplesr0   AutoDateLocatorcreate_dummy_axisset_view_intervalr1   date1date2r   r   r   r   _create_auto_date_locator1     z9test_auto_date_locator.<locals>._create_auto_date_locatori  r   (  weeks)
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:00rE   minutes)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:00r   r	   listmaprq   r0   r   )r   d1resultst_deltar   d2r   r   r   r   test_auto_date_locator/  s@   







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   y  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:00z2020-01-01 00:00:00+00:00z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-22 00:00:00+00:00r	  z1997-02-22 00:00:00+00:00r
  z1997-03-22 00:00:00+00:00r  z1997-04-22 00:00:00+00:00r  z1997-05-22 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:00rE   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   test_auto_date_locator_intmultw  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     r   zMtest_concise_formatter.<locals>._create_auto_date_locator.<locals>.<listcomp>r   r   r0   r   ConciseDateFormatteryaxisrt   r   rP   r   r   get_yticklabelsr   r   r*   r+   r   r   stsr   r   r   r     s   

z9test_concise_formatter.<locals>._create_auto_date_locatorr  r   r   r   c                 S      g | ]}t |qS r   rq   r
   r   r   r   r   r     r   z*test_concise_formatter.<locals>.<listcomp>    rE   r   )1997FebMarAprMayJunJulAugSepOctNovDecr   r   )
Jan22r  r)  r  r)  r  r)  r   r)  r   )r(  05091317212529r  r*  r+  r   )zJan-0104:0008:0012:0016:0020:00zJan-02r1  r2  r3  r4  r   )00:0000:0500:1000:1500:20r   )	r6  r*  101520r/  303540r   )59.5r6  00.501.001.502.002.5r   r	   r   r   r  r  r  r   r  stringsr   r   r   test_concise_formatter  s@   








rJ  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)z%Yz%m/%Yzday: %d%H hr %M minrL  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  rN  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  rE   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: 22rP  rU  rQ  rU  rR  rU  rS  rU  r   )rT  day: 05day: 09zday: 13zday: 17zday: 21zday: 25zday: 29rP  rV  rW  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: 02rX  rY  rZ  r[  r   )00 hr 00 minz00 hr 05 minz00 hr 10 minz00 hr 15 minz00 hr 20 minr   )	r\  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 secr\  z00.500000 secz01.000000 secz01.500000 secz02.000000 secz02.500000 secrG  rH  r   rN  r   test_concise_formatter_formats  s&    
r]  c               
      rK  )N) z'%yz%Bz%m-%dz%Sz%S.%fc                    rM  )NTr   zero_formatsc                 S   r   r   r   r  r   r   r   r   9  r   zVtest_concise_formatter_zformats.<locals>._create_auto_date_locator.<locals>.<listcomp>r  r  r_  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  rE   r   )z'97r  r  r  r   r!  r"  r#  r$  r%  r&  r'  r   r   )
Januaryr)  Februaryr)  Marchr)  Aprilr)  r   r)  r   )ra  r*  r+  r,  r-  r.  r/  r0  rb  r*  r+  r   )z01-01r1  r2  r3  r4  r5  z01-02r1  r2  r3  r4  r   )00r7  r8  r9  r:  r   )	re  r*  r;  r<  r=  r/  r>  r?  r@  r   )rA  z00.0rB  rC  rD  rE  rF  rG  rH  r   r_  r   test_concise_formatter_zformats,  sB   








rf  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   j  r   zPtest_concise_formatter_tz.<locals>._create_auto_date_locator.<locals>.<listcomp>)r   r   r0   r   r  r  rt   r   rP   r   r   r  get_offset_textr   )r   r   rh  r*   r+   r   r   r  r   r   r   r   a  s   
z<test_concise_formatter_tz.<locals>._create_auto_date_locatorr  r   r   r   r   )03:0007:0011:0015:0019:00z23:00rj  rk  rl  rm  rn  z1997-Jan-02rE   r   )rj  z03:05z03:10z03:15z03:20z1997-Jan-01r   )	rj  r*  r;  r<  r=  r/  r>  r?  r@  z1997-Jan-01 03:00r   )rA  rj  rB  rC  rD  rE  rF  r   )r   replacetimezoneutcr	   )
r   r  r  new_tzr  expected_stringsexpected_offsetr  rI  offsetr   r   r   test_concise_formatter_tz`  s4   



rv  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   s2   t jd|d}|  |t | t | |S )NTr   rh  r   )r   r   rh  r   r   r   r   r     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   )
rx  z1997-01-22 00:00:00-08:00ry  z1997-02-22 00:00:00-08:00rz  z1997-03-22 00:00:00-08:00r{  z1997-04-22 00:00:00-07:00r|  z1997-05-22 00:00:00-07:00r   )rx  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:00ry  z1997-02-05 00:00:00-08:00z1997-02-09 00:00:00-08:00r   )rx  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:00rE   r   )rx  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   )	rx  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   r   z_internal.classic_modeFrg  )r   r	   r   rh  gettzr   r  r  rq   r0   r   )	r   r  rh  r  r  r   r  r   r  r   r   r   !test_auto_date_locator_intmult_tz  sD   






5r~  zdate_inverted_limit.pngc                  C   s~   t  ddd} t  ddd}t }|ddd}|j| ddd || t jdd	 |t jdd	  |  |jd
d d S r[   )	r   r   r    r!   r`   rP   r	   invert_yaxisrQ   rR   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	}d
 d}| |||d}|||}dtt	d  fddt
|D }	tt|}
|
|	ksNJ d S )NzEurope/Brusselsr   r   r   r   r   !   r   )r   r   g      ?r   r   freqperiodsg    p&A
0000-12-31c                    s   g | ]}|   qS r   r   r
   iinterval_daysr/   r   r   r         z&_test_date2num_dst.<locals>.<listcomp>)r   rh  r}  r0   r   r   r	   r1   r   r?   r   r  )
date_range
tz_convertBRUSSELSr   dtstartr   Ndt_utcdt_bxlexpected_ordinalf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 )Nr   	normalize)super__sub__getattrr  
isinstancer   
mk_tzaware)r   otherrr   	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   r   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   hourminutesecondmicrosecondr   r   )r  )cls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   r  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
   dr   r   r   r   0  r   z9test_date2num_dst.<locals>.tz_convert.<locals>.<listcomp>r   )dt_listr   r   r   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  )DatetimeIndexr  astypeobject)argspdr   r   r  9  r  z,test_date2num_dst_pandas.<locals>.tz_convert)r  r  )r  r  r   r  r   test_date2num_dst_pandas5  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 )NzAustralia/Sydneyr   r   r   r   )r  r     r   r      )	r   r0   r   r   r   DAILYbetweenrh  tzutc)	attach_tzget_tzSYDr  dtendruleactexpr   r   r   _test_rrulewrapper?  s   r  c                  C   s   dd } t | tjj d S )Nc                 S   s   | j |dS )Nr   )ro  r   zir   r   r   r  O  s   z$test_rrulewrapper.<locals>.attach_tz)r  r   rh  r}  )r  r   r   r   test_rrulewrapperN  s   r  c                  C   s"   t d} dd }t|| j d S )Npytzc                 S   s
   | | S r  )localizer  r   r   r   r  Z  s   
z)test_rrulewrapper_pytz.<locals>.attach_tz)rm   importorskipr  rp  )r  r  r   r   r   test_rrulewrapper_pytzU  s   
r  c                     s   t d} | d  fddtdD }tjd d}|  |t|d d	 t|d
 d	  t	
g d}|tt	d }t	j||  g d}ttttj|  d}||ksdJ d S )Nr  zAmerica/New_Yorkc              	      s*   g | ]}  td ddt| qS )rV   r   )r  r   r	   r  rg  r   r   r   e  s
    z)test_yearlocator_pytz.<locals>.<listcomp>rU   Trw  r   r   r   )g{ja&Ag{jd&Ag{jtg&Ag{jNj&Ag{j*m&Ag{jp&Ag{jr&Ar  )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:00rg  )rm   r  rp  r   r0   r   r   r   r1   r   r   r?   r#   assert_allcloser  r  rq   r   )r  r   r   r   r   r  r   rg  r   test_yearlocator_pytz`  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   )rm   raises
ValueErrorr0   ru   r   r   r   r   test_DayLocatorx  s   r  c                  C   s    t j dddtjd} |   d S )Ni  r   r   )r   r0   r   tzname)r   r   r   r   test_tz_utc  s   r  z	x, tdeltar   g      ?c                 C   s   t | }||ksJ d S r  )r0   num2timedelta)r   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&Ar  )r   r?   r0   r1   r   r#   r$   )r   dnr   r   r   r   test_datetime64_in_list  s   
r  c                  C   s  t d} 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-01z
1970-01-01zdatetime64[D]intr  r  z1970-01-01T01:00:00gUUUUUU?1970-01-01T00:00:00z1970-01-01T12:00:00g      ?)r   r?   rm   r  RuntimeErrorr0   r   r~   r  r#   r$   r1   floatr  )dater   r   r   r   test_change_epoch  s*   





r  c                   C   p   t   t d t ddksJ t ddksJ t   t d t ddks-J t ddks6J d S )	Nr  iQ     x%A    z%Ai  r  r   r   )r0   r~   r   	epoch2num	num2epochr   r   r   r   test_epoch2num  s   

r  c                   C   r  )	Nr  g   @ƞBAr  r  g   ƞBAr  r   r   )r0   r~   r   
julian2num
num2julianr   r   r   r   test_julian2num  s   

r  )@r   dateutil.tzr   dateutil.rruler   numpyr   rm   
matplotlibr   matplotlib.datesr   r0   matplotlib.pyplotpyplotr   matplotlib.testing.decoratorsr   matplotlib.tickertickerr   r.   markparametrizer4   r9   rA   rC   rT   rZ   ra   rd   r|   r   r   r   r   r   r   r   r  r  rJ  r]  rf  rv  r~  r  r  r  r  r  r  r  r  r  r  r  r	   r  r  r  r  r  r   r   r   r   <module>   s    	


	






 
G
L174)G
A





	