o
    Ti                     @   s   d Z ddlmZmZmZm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mZmZmZmZmZmZ ddlmZ ddlmZmZmZ ddlmZmZmZ ddlm Z  dd	l!m"Z" dd
l#m$Z$ e%dZ&G dd dZ'dddZ(dS )z< Test cases for time series specific (freq conversion, etc)     )datedatetimetime	timedeltaN)
BaseOffset	to_offset)	DataFrameIndexNaTSeriesconcatisnato_datetime)DatetimeIndexbdate_range
date_range)PeriodPeriodIndexperiod_range)timedelta_range)_check_ticks_props)WeekOfMonthZ
matplotlibc                	   @   s  e Zd Zejddd Zdd Zdd Zdd	 Z	d
d Z
dd Z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ejdddgdd Zdd  Zd!d" Z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jdg dd+d, Zejd%g d&d-d. Zejd/ejdg dd0d1 Zejdg dd2d3 Zd4d5 Zd6d7 Zd8d9 Zd:d; Zejj d<d=d>d? Z!d@dA Z"dBdC Z#dDdE Z$dFdG Z%dHdI Z&dJdK Z'dLdM Z(dNdO Z)ejdPejdQe*+ e,e*+ e*+ dR dSgdTdU Z-dVdW Z.dXdY Z/dZd[ Z0d\d] Z1d^d_ Z2d`da Z3ejj4dbdc Z5ddde Z6dfdg Z7dhdi Z8djdk Z9dldm Z:dndo Z;dpdq Z<drds Z=dtdu Z>dvdw Z?dxdy Z@dzd{ ZAd|d} ZBd~d ZCdd ZDdd ZEdd ZFdd ZGdd ZHdd ZIdd ZJdd ZKdd ZLejd/dd ZMdd ZNdd ZOejj dd=dd ZPdd ZQdd ZRdd ZSejdddgdd ZTejdddgdd ZUdd ZVdd ZWdd ZXdd ZYdd ZZdd Z[dd Z\dd Z]dd Z^dd Z_dd Z`dd Zadd ZbddÄ Zcddń Zdejj d<d=ddǄ ZeddɄ Zfdd˄ Zgdd̈́ Zhddτ Ziddф Zjddӄ ZkddՄ Zlddׄ Zmddل Znddۄ Zodd݄ Zpdd߄ Zqdd Zrdd Zsdd Ztejj dd=dd Zudd Zvdd Zwdd Zxdd Zydd ZzdS )
TestTSPlotzignore::UserWarningc                 C   s   |}t ddd|d}tddg|d}t|j | }tt|  }|d j|d j	fd	ks3J |d
 j|d
 j	fdksAJ d S )N1/1/2011   H)periodsfreqtzg     g@g     t@indexr   r   r   )   r   )
r   r   _check_plot_worksplotnextiter	get_lines	get_xdatahourminute)selfZtz_aware_fixturer   r    tsaxxdata r0   g/var/www/html/evchargy.com/venv/lib/python3.10/site-packages/pandas/tests/plotting/test_datetimelike.pytest_ts_plot_with_tz/   s   
 zTestTSPlot.test_ts_plot_with_tzc                 C   sd   t tjddtdd}tj \}}|j	d|d |
 |  D ]
}| dks/J q%d S )Nr   )
   	   r3   r   Zfontsizer.   )r   nprandomdefault_rngstandard_normalrangemplpyplotsubplotsr%   get_xticklabelsZget_yticklabelsZget_fontsize)r,   df_r.   labelr0   r0   r1   test_fontsize_set_correctly<   s   z&TestTSPlot.test_fontsize_set_correctlyc                 C   s   t dddd}t|jd d}ttjdt|df|d}t	|j
 |d	d
 |dd }ttjdt|df|d}t	|j
 d S )N1/1/1987ZMSd   r   r   r   r      r   r   (   -   c   )r   r   valuesr   r6   r7   r8   r9   lenr$   r%   union)r,   idxr?   df2r0   r0   r1   test_frame_inferredF   s   
zTestTSPlot.test_frame_inferredc                 C   sL   t dddd}t|jd d}ttjdt|df|d}t	|j
 d S )	Nz2008-1-1 00:15:00Z15Tr3   rE   rF   r   rG   r   )r   r   rK   r   r6   r7   r8   r9   rL   r$   r%   r,   rN   r?   r0   r0   r1   test_frame_inferred_n_gt_1W   s   z%TestTSPlot.test_frame_inferred_n_gt_1c                 C   s:   t g d}t||d}t|j|d t|j|d d S )Nr#   r   rG   r   )Zxerr)Zyerr)r6   arrayr   r$   r%   )r,   iar0   r0   r1   test_is_error_nozeroindex`   s   z$TestTSPlot.test_is_error_nozeroindexc                 C   sd   t dddd}tg dg dd|}tj \}}|j|d t| d	ks*J tj| d S )
NrC   ArG   rE   xyzrS   rX   Br.   r#   )	r   r   r;   r<   r=   r%   rL   r(   close)r,   rN   r?   figr.   r0   r0   r1   test_nonnumeric_excludeg   s   z"TestTSPlot.test_nonnumeric_excludec                 C   sj   t dddd}tg dg dd|}d}tjt|d	 |d   W d    d S 1 s.w   Y  d S )
NrC   rX   rG   rE   rY   rS   r]   zno numeric data to plotmatch)r   r   pytestraises	TypeErrorr%   )r,   rN   r?   msgr0   r0   r1   test_nonnumeric_exclude_errorp   s   "z(TestTSPlot.test_nonnumeric_exclude_errorr   )STr   DWMQrX   c                 C   J   t d|dd}ttjdt||}tj	 \}}t
|j|d d S N
12/31/1999rD   rE   r   r_   )r   r   r6   r7   r8   r9   rL   r;   r<   r=   r$   r%   r,   r   rN   serr@   r.   r0   r0   r1   test_tsplot_periodw      zTestTSPlot.test_tsplot_period)	rj   rk   r   rl   rm   rn   zQ-DECrX   Z1B30Minc                 C   rp   rq   )r   r   r6   r7   r8   r9   rL   r;   r<   r=   r$   r%   rs   r0   r0   r1   test_tsplot_datetime~   s   zTestTSPlot.test_tsplot_datetimec                 C   sD   t  }tj \}}|jd|d d}|| d  ks J d S )Nkstyler.   )        r{   r{   r#   r   )tmmakeTimeSeriesr;   r<   r=   r%   r(   	get_color)r,   r-   r@   r.   colorr0   r0   r1   test_tsplot   s
   zTestTSPlot.test_tsplotc                 C   s   t  }d}tjt|d |jddd W d    n1 sw   Y  |jdd}tjt|d |jddd W d    d S 1 sDw   Y  d S )NzCannot pass 'style' string with a color symbol and 'color' keyword argument. Please use one or the other or pass 'style' without a color symbolrc   zb-z#000099)rz   r   T)Zdrop)r|   r}   re   rf   
ValueErrorr%   Zreset_index)r,   r-   rh   sr0   r0   r1   test_both_style_and_color   s   "z$TestTSPlot.test_both_style_and_colormsusc                 C   sJ   t j \}}tdd|d}ttjdt	||}t
|j|d d S )N1/1/2012rD   r   r   r   r_   )r;   r<   r=   r   r   r6   r7   r8   r9   rL   r$   r%   )r,   r   r@   r.   rngrt   r0   r0   r1   test_high_freq   s   zTestTSPlot.test_high_freqc                 C   sn   ddl m} |d dd u sJ |dddksJ |tdddtddjks(J |ddtd	djks5J d S )
Nr   )get_datevaluerl     rX   rn   z1987-12rC   z1987-1-1)%pandas.plotting._matplotlib.converterr   r   ordinal)r,   r   r0   r0   r1   test_get_datevalue   s
    zTestTSPlot.test_get_datevaluec                 C   sr   dd }t dtddddd}tj \}}|j|d	 ||d
 t dtddddd}|j|d	 ||d d S )Nc                 S   s>   |   d }| d j}| d }|| ||ksJ d S )Nr   )r(   r)   r   	get_ydataZformat_coord)r.   Zexpected_string
first_lineZfirst_xZfirst_yr0   r0   r1   check_format_of_first_point   s   zITestTSPlot.test_ts_plot_format_coord.<locals>.check_format_of_first_pointr#   z
2014-01-01rG   zA-DECr   r   r_   zt = 2014  y = 1.000000rl   zt = 2014-01-01  y = 1.000000)r   r   r;   r<   r=   r%   )r,   r   Zannualr@   r.   Zdailyr0   r0   r1   test_ts_plot_format_coord   s   
z$TestTSPlot.test_ts_plot_format_coordc                 C   s>   t d|dd}ttjdt||}t|j|j	j
 d S Nrr   rD   rE   r   )r   r   r6   r7   r8   r9   rL   r$   r%   r    r   r,   r   rN   rt   r0   r0   r1   test_line_plot_period_series   s   z'TestTSPlot.test_line_plot_period_seriesfrqncy)Z1SZ3SZ5TZ7HZ4DZ8WZ11MZ3Ac                 C   @   t d|dd}ttjdt||}t|j|j	j
j d S r   )r   r   r6   r7   r8   r9   rL   r$   r%   r    r   	rule_code)r,   r   rN   r   r0   r0   r1    test_line_plot_period_mlt_series   s   z+TestTSPlot.test_line_plot_period_mlt_seriesc                 C   r   r   )r   r   r6   r7   r8   r9   rL   r$   r%   r    r   r   r   r0   r0   r1   test_line_plot_datetime_series   s   z)TestTSPlot.test_line_plot_datetime_seriesc                 C   sJ   t d|dd}ttjdt|df|g dd}t|j|j	j
 d S Nrr   rD   rE   r   rG   )rX   r^   Cr    columns)r   r   r6   r7   r8   r9   rL   r$   r%   r    r   r,   r   rN   r?   r0   r0   r1   test_line_plot_period_frame   s   z&TestTSPlot.test_line_plot_period_framec                 C   sZ   t d|dd}ttjdt|df|g dd}|j|jj	j
j	}t|j| d S r   )r   r   r6   r7   r8   r9   rL   r    asfreqr   r   r$   r%   )r,   r   rN   r?   r   r0   r0   r1   test_line_plot_period_mlt_frame   s   z*TestTSPlot.test_line_plot_period_mlt_framez3ignore:PeriodDtype\[B\] is deprecated:FutureWarningc                 C   sZ   t d|dd}ttjdt|df|g dd}|j|jj	j
j	}t|j| d S r   )r   r   r6   r7   r8   r9   rL   r    	to_periodr   r   r$   r%   r   r0   r0   r1   test_line_plot_datetime_frame   s   z(TestTSPlot.test_line_plot_datetime_framec                 C   sn   t d|dd}ttjdt||}t|jtt	|j
}t|j|j
j |jg d }t|j d S )Nrr   rD   rE   r   )r   rG         )r   r   r6   r7   r8   r9   rL   rK   r	   Zasarrayr    r$   r%   Zinferred_freqilocr   r0   r0   r1   test_line_plot_inferred_freq   s   z'TestTSPlot.test_line_plot_inferred_freqc                 C   sf   t j \}}tdd}ttt||d}t|d d |dd  g}|j|d t	|dr1J d S )Nz2001-1-1z	2001-1-10r   rG   r   r_   r   )
r;   r<   r=   r   r   r:   rL   r   r%   hasattr)r,   r@   r.   r   r-   r0   r0   r1   test_fake_inferred_business	  s   
z&TestTSPlot.test_fake_inferred_businessc                 C   s   t  }t|j d S )N)r|   r}   r$   r%   )r,   rt   r0   r0   r1   test_plot_offset_freq  s   z TestTSPlot.test_plot_offset_freqc                 C   s:   t dddd}ttjdt||d}t|j d S )Nz
2023-01-01ZBQSr3   rE   r   r   )	r   r   r6   r7   r8   r9   rL   r$   r%   r,   Zdrrt   r0   r0   r1   test_plot_offset_freq_business  s   z)TestTSPlot.test_plot_offset_freq_businessc                 C   sR   t tdddtdddtdddg}ttjdt||d}t|j	 d S )N  r#   r      r   r   )
r	   r   r   r6   r7   r8   r9   rL   r$   r%   r   r0   r0   r1    test_plot_multiple_inferred_freq  s   &z+TestTSPlot.test_plot_multiple_inferred_freqzApi changed in 3.6.0)reasonc                 C   s   dd l m  m  m} tdddd}ttjd	t
|df|d}tj \}}|j|d | }| }| }t||D ]\}	}
||	d	}t|
 }t
|r^||ks^J qBd S )
Nr   z2012-6-22 21:59:51.960928L  rE   r   r   r_   %H:%M:%S.%f)r   plotting_matplotlib	converterr   r   r6   r7   r8   r9   rL   r;   r<   r=   r%   	get_xaxisZget_ticklocsget_ticklabelszipZ_from_ordinalstrftimestrget_text)r,   convrN   r?   r@   r.   ZaxisZtlocsZtlabelslocrA   xprsr0   r0   r1   test_uhf  s"   zTestTSPlot.test_uhfc                 C   s   t dddd}ttjdt|df|d}|jg d }tj	
 \}}|j|d t| d	  d d d	f  }d
}t|dd  ||d |g dk  sVJ d S )N2012-6-22 21:59:51rj   r3   rE   r   r   )r   r#   rG      r_   r   )QΠE>r#   :0yE>)r   r   r6   r7   r8   r9   rL   r   r;   r<   r=   r%   r   r(   
get_xydatadifffabsall)r,   rN   r?   irregr@   r.   diffssecr0   r0   r1   test_irreg_hf4  s   $0zTestTSPlot.test_irreg_hfc                 C   s   t dddd}ttjdt|df|d}tj	 \}}|j
t|_
|j|d t| d  d d df  }d	}t|d
d  | dk  sQJ d S )Nr   rj   r3   rE   r   r   r_   r   r   r#   r   )r   r   r6   r7   r8   r9   rL   r;   r<   r=   r    astypeobjectr%   r   r(   r   r   r   r   )r,   rN   rO   r@   r.   r   r   r0   r0   r1   test_irreg_hf_objectB  s   $&zTestTSPlot.test_irreg_hf_objectc                 C   sn   t  }|jg d }tj \}}|j|d}|d usJ t| d 	 |j
D ]
\}}||ks4J q*d S )N)r   r#   r      r_   r   )r|   r}   r   r;   r<   r=   r%   r   r(   r)   r    )r,   rt   r@   r.   retr   r   r0   r0   r1   "test_irregular_datetime64_repr_bugN  s    z-TestTSPlot.test_irregular_datetime64_repr_bugc                 C   s   t  }d}|jd  }t jt|d t|t|dd|_W d    n1 s)w   Y  tj	
 \}}|j|d | d  d |jd jksMJ | d  }t jt|d t|djdksgJ W d    d S 1 srw   Y  d S )	NPeriodDtype\[B\] is deprecatedr   rc   r^   startr   r   r_   r!   data)r|   ZmakePeriodSeriesr    to_timestampassert_produces_warningFutureWarningr   rL   r;   r<   r=   r%   r(   r   r   r)   r   freqstr)r,   btsrh   dtr@   r.   rN   r0   r0   r1   test_business_freqZ  s   $"zTestTSPlot.test_business_freqc                 C   s   t dd}|d}tj \}}|j|d | d 	 d |j
d jks,J | d  }t|djdks>J d S )Ni,  ZBMrn   r_   r   r!   r   )r|   r}   r   r   r;   r<   r=   r%   r(   r   r    r   r)   r   r   )r,   r   r-   r@   r.   rN   r0   r0   r1   test_business_freq_convertg  s   
$z%TestTSPlot.test_business_freq_convertc                 C   s   t  }td|}tj \}}|j|d | d 	 }d}t
jt|d t|d W d    d S 1 s:w   Y  d S )Nr   r_   r   z)freq not specified and cannot be inferredrc   r   )r   r|   r}   r   r;   r<   r=   r%   r(   r)   re   rf   r   r   )r,   r   r   r@   r.   rN   rh   r0   r0   r1   test_freq_with_no_period_aliasp  s   "z)TestTSPlot.test_freq_with_no_period_aliasc                 C   sf   t ddddtdd }ttd|d}tj \}}|j|d |	 d	 
 }t|jr1J d S )
Nz
2012-12-20   r   r      minutesr   r_   r   )r   r   r   r6   aranger;   r<   r=   r%   r(   r)   r	   is_normalized)r,   rN   r?   r@   r.   r   r0   r0   r1   test_nonzero_base|  s   zTestTSPlot.test_nonzero_basec                 C   s   t dt i}tj \}}|j|d | d  }d}tj	t
|d t|j t| W d    d S 1 s=w   Y  d S )NrV   r_   r   r   rc   )r   r|   r}   r;   r<   r=   r%   r(   r)   r   r   assert_index_equalr    r   r   )r,   r   r@   r.   rN   rh   r0   r0   r1   test_dataframe  s   "zTestTSPlot.test_dataframez8ignore:Period with BDay freq is deprecated:FutureWarningobjr#   rV   bc                 C   s^  t j \}}|j|d | }||d d |d d  | }|d |d d ks/J |d |d d ks;J td|jtd|jf}|dd | }t|d |d j	ks^J t|d |d j	kskJ td|jtd|jf}|t
dddt
dd	d | }t|d |d j	ksJ t|d |d j	ksJ | }t j| d S )
Nr_   r   r   r#   r3   1/1/2000z4/1/2000r   r   )r;   r<   r=   r%   get_xlimset_xlimr   r   intr   r   
get_figurer`   )r,   r   r@   r.   Zxlimresultexpectedra   r0   r0   r1   test_axis_limits  s&   zTestTSPlot.test_axis_limitsc                 C   s   dd l m  m  m} |td|jksJ |td|jks$J |td|jks0J |td|jks<J |td|j	ksHJ |td|jksTJ d S )Nr   r^   rl   rn   ro   rX   rm   )
r   r   r   r   Z
get_finderr   Z_daily_finderZ_monthly_finderZ_quarterly_finderZ_annual_finder)r,   r   r0   r0   r1   test_get_finder  s   zTestTSPlot.test_get_finderc                 C   s  g d}d}t jt|d tdddjgt|  }}W d    n1 s&w   Y  g }g }|D ]O}td|d}ttj	
dt||}	tj \}
}|	j|d	 | }|| d
  | \}}||d | || d
  tj|  q1||ksJ ||ksJ d S )N)r3   rH      i  i  i
  '  z#Period with BDay freq is deprecatedrc   z1999-1-1r^   rF   r   r   r_   r   ?)r|   r   r   r   r   rL   r   r   r6   r7   r8   r9   r;   r<   r=   r%   r   appendget_majorticklocsr   r   r`   r   )r,   Zday_lstrh   xpl1xpl2rs1rs2nr   rt   r@   r.   xaxisvminvmaxr0   r0   r1   test_finder_daily  s(   zTestTSPlot.test_finder_dailyc                 C   s   ddg}t djgt|  }}g }g }|D ]T}tdt|d dd}ttjd	t||}t
j \}	}
|j|
d	 |
 }|| d
  |
 \}}|
|d | || d
  t
j|
  q||ksqJ ||kswJ d S )Ng      @r   1988Q11987Q2r   ro   r   r   r_   r   r   r   r   rL   r   r   r   r6   r7   r8   r9   r;   r<   r=   r%   r   r   r   r   r   r`   r   r,   Zyrsr   r   r   r  r  r   rt   r@   r.   r  r  r  r0   r0   r1   test_finder_quarterly  "   z TestTSPlot.test_finder_quarterlyc                 C   s   g d}t djgt|  }}g }g }|D ]T}tdt|d dd}ttjd	t||}t
j \}	}
|j|
d |
 }|| d	  |
 \}}|
|d
 | || d	  t
j|
  q||ksqJ ||kswJ d S )N)gffffff?g      @r   r   zJan 1988r     rn   r   r   r_   r   r   r	  r
  r0   r0   r1   test_finder_monthly  r  zTestTSPlot.test_finder_monthlyc                 C   st   t dddd}ttjdt||}tj	 \}}|j
|d | }| d }tddj}||ks8J d S )	Nr  i   rn   r   r   r_   r   Z1989Q1)r   r   r6   r7   r8   r9   rL   r;   r<   r=   r%   r   r   r   r   )r,   r   rt   r@   r.   r  r   r   r0   r0   r1   test_finder_monthly_long  s   z#TestTSPlot.test_finder_monthly_longc           	      C   s   g d}dd |D }g }dD ]9}t d|dd}ttjdt||}tj	 \}}|j
|d	 | }|| d
  tj|  q||ksOJ d S )N)r   i    r    i  i  iz  c                 S   s   g | ]	}t |d djqS )rX   rF   )r   r   .0rZ   r0   r0   r1   
<listcomp>  s    z1TestTSPlot.test_finder_annual.<locals>.<listcomp>)r   r3      1   rJ      iW  i  Z1987rX   r   r   r_   r   )r   r   r6   r7   r8   r9   rL   r;   r<   r=   r%   r   r   r   r`   r   )	r,   r   r   Znyearsr   rt   r@   r.   r  r0   r0   r1   test_finder_annual	  s   zTestTSPlot.test_finder_annualc           	      C   z   d}t dd|d}ttjdt||}tj	 \}}|j
|d | }| d }tdddj}||ks;J d S )	Ni@ 1/1/1999ZMinrE   r   r_   r   rF   r   r   r6   r7   r8   r9   rL   r;   r<   r=   r%   r   r   r   r   )	r,   Znminutesr   rt   r@   r.   r  r   r   r0   r0   r1   test_finder_minutely  s   zTestTSPlot.test_finder_minutelyc           	      C   r  )	N   r  r   rE   r   r_   r   rF   r  )	r,   Znhoursr   rt   r@   r.   r  r   r   r0   r0   r1   test_finder_hourly%  s   zTestTSPlot.test_finder_hourlyc                 C   s   t  }tj|jdd< tj \}}|j|d |	 }t
|dks%J |d }| }tjj|t|tjd}t|tjjjsCJ |j}|dddf  sRJ tj|  d S )Nr      r_   r#   r   maskZ
fill_value)r|   r}   r6   nanr   r;   r<   r=   r%   r(   rL   r   maMaskedArrayr   
isinstancecorer!  r   r`   r   r,   r-   r@   r.   linesliner   r!  r0   r0   r1   	test_gaps1  s   zTestTSPlot.test_gapsc                 C   s   t  }|jg d }tj|jdd< tj \}}|j|d}|	 }t
|dks,J |d }| }tjj|t|tjd}t|tjjjsJJ |j}|dddf  sYJ tj|  d S N)	r   r#   r   r   r   r4   r        r   r   r_   r#   r   r   )r|   r}   r   r6   r"  r;   r<   r=   r%   r(   rL   r   r#  r$  r   r%  r&  r!  r   r`   r   r'  r0   r0   r1   test_gaps_irregularB  s   zTestTSPlot.test_gaps_irregularc           	      C   s   g d}t tjdt||}tj|jdd< tj	
 \}}|j|d | }t|dks3J |d }| }tjj|t|tjd}t|tjjjsQJ |j}|dddf  s`J d S r+  )r   r6   r7   r8   r9   rL   r"  r   r;   r<   r=   r%   r(   r   r#  r$  r   r%  r&  r!  r   )	r,   rN   rt   r@   r.   r(  r)  r   r!  r0   r0   r1   test_gaps_non_tsU  s   zTestTSPlot.test_gaps_non_tsc           
      C   s   t  }tj|jdd< tj \}}|j|d t	|j
d |j
d dd}ttjdt||}|jd	d
 | }t|dksFJ t|j dksQJ |d }| }tjj|t|tjd}t|tjjjsoJ |j}	|	dddf  s~J d S )Nr   r  r_   r   r"   Z12hrF   r   Tsecondary_yr#   r   )r|   r}   r6   r"  r   r;   r<   r=   r%   r   r    r   r7   r8   r9   rL   r(   right_axr   r#  r$  r   r%  r&  r!  r   )
r,   lowr@   r.   idxhr   r(  r)  r   r!  r0   r0   r1   test_gap_upsamplef  s    zTestTSPlot.test_gap_upsamplec                 C   s   t tjdd}tj \}}|jdd}t	|dsJ t	|dr&J |
 }| d }t | | }t|| |  dksIJ |d   rSJ tj| d S )	Nr   r3   Tr0  left_axr2  r   right)r   r6   r7   r8   r9   r;   r<   r=   r%   r   get_axesr(   r   r)   r|   assert_series_equal	get_yaxisget_ticks_positionget_visibler`   )r,   rt   ra   r@   r.   axesr)  r   r0   r0   r1   test_secondary_y{  s   zTestTSPlot.test_secondary_yc                 C   sn   t tjdd t tjdd}tj \}}|j|d |	 
 dks-J tj|  d S )Nr   r3   r_   left)r   r6   r7   r8   r9   r;   r<   r=   r%   r:  r;  r`   r   )r,   ser2r@   ax2r0   r0   r1   test_secondary_y_yaxis  s   z!TestTSPlot.test_secondary_y_yaxisc                 C   s   t tjdd}t tjdd}| }|jdd}|  s(J t|dr/J t|ds6J t|ds=J t|drDJ d S )Nr   r3   Tr0  r6  r2  )	r   r6   r7   r8   r9   r%   r:  r<  r   )r,   rt   r@  r.   rA  r0   r0   r1   test_secondary_both  s   zTestTSPlot.test_secondary_bothc           	      C   s   t ddd}ttjdd|}tj \}}|j	dd}t
|ds&J t
|dr-J | }| d	 }t| |  }t|| |  d
ksRJ |d	   r\J tj| d S )Nr   r3   r   r   Tr0  r6  r2  r   r7  )r   r   r6   r7   r8   r9   r;   r<   r=   r%   r   r8  r(   r   r)   r   r|   r9  r:  r;  r<  r`   )	r,   rN   rt   ra   r@   r.   r=  r)  r   r0   r0   r1   test_secondary_y_ts  s   zTestTSPlot.test_secondary_y_tsc                 C   sf   t ddd}ttjdd|}tj \}}|j	|d |
  dks)J tj|  d S )Nr   r3   r   r   r_   r?  )r   r   r6   r7   r8   r9   r;   r<   r=   r%   r:  r;  r`   r   )r,   rN   r@  r@   rA  r0   r0   r1   test_secondary_y_ts_yaxis  s   z$TestTSPlot.test_secondary_y_ts_yaxisc                 C   s@   t ddd}ttjdd|}| }|  sJ d S )Nr   r3   r   r   )	r   r   r6   r7   r8   r9   r%   r:  r<  )r,   rN   r@  r.   r0   r0   r1   test_secondary_y_ts_visible  s   z&TestTSPlot.test_secondary_y_ts_visiblec                 C   s~   t d ttjdd}tj	 \}}|j
dd|d}t|ds&J t|dr-J | }|d	   d
ks=J d S )NZscipyr   r3   TZdensityr1  kindr.   r6  r2  r#   r7  )re   importorskipr   r6   r7   r8   r9   r;   r<   r=   r%   r   r8  r:  r;  r,   rt   ra   r.   r=  r0   r0   r1   test_secondary_kde  s   
zTestTSPlot.test_secondary_kdec                 C   sX   t tjdd}tj \}}|jdd|d |	 }|d 
  dks*J d S )Nr   r3   TbarrG  r#   r7  )r   r6   r7   r8   r9   r;   r<   r=   r%   r8  r:  r;  rJ  r0   r0   r1   test_secondary_bar  s
   zTestTSPlot.test_secondary_barc                 C   s|   t tjddg dd}|jddgdd}|d	   d
ks$J |d   dks0J |d   d
ks<J d S )Nr   r   rG   rV   r   cr   rV   rP  T)r1  r=   r   r7  r#   r?  r   r6   r7   r8   r9   r%   r:  r;  r,   r?   r=  r0   r0   r1   test_secondary_frame  s   zTestTSPlot.test_secondary_framec                 C   s~   t tjddg dd}|jdddgdd	}|d
   dks%J |d   dks1J |d   dks=J d S )Nr   rN  rO  rQ  rL  rV   rP  T)rH  r1  r=   r   r7  r#   r?  rR  rS  r0   r0   r1   test_secondary_bar_frame  s   z#TestTSPlot.test_secondary_bar_framec                 C   s   t  }|jg d }tj \}}|j|d |jd|d}| }d}t jt	|d7 t
|d  }t
|d  }	t ||jd	 t |	|jd	 | \}
}|j }W d    n1 sfw   Y  |
|d jkstJ ||d
 jks}J d S Nr   r   r3   r   r        r,  r_   gry   r   rc   r   r#   r^   r"   )r|   r}   r   r;   r<   r=   r%   r(   r   r   r   r)   r   r    r   r   r   r,   s1s2r@   r.   rA  r(  rh   idx1idx2r?  r7  Zpidxr0   r0   r1   test_mixed_freq_regular_first  s"   	z(TestTSPlot.test_mixed_freq_regular_firstc                 C   s   t  }|jg d }tj \}}|jd|d |j|d t|dr&J | }|d 	 }t 
||jtj |d 	 }t 
||jtj d S NrW  rZ  ry   r_   r   r   r#   )r|   r}   r   r;   r<   r=   r%   r   r(   r)   assert_numpy_array_equalr    r   r   rK   r,   r\  r]  r@   r.   r(  x1Zx2r0   r0   r1   test_mixed_freq_irregular_first  s   z*TestTSPlot.test_mixed_freq_irregular_firstc                 C   s  t   }|jg dd d f }tj \}}|j|d |jd|d}| }d}t j	t
|d9 t|d  }t|d  }	||jd	sNJ |	|jd	sYJ | \}
}|j }W d    n1 snw   Y  |
|d jks|J ||d
 jksJ d S rV  )r|   r}   to_framer   r;   r<   r=   r%   r(   r   r   r   r)   equalsr    r   r   r   r[  r0   r0   r1    test_mixed_freq_regular_first_df  s"   z+TestTSPlot.test_mixed_freq_regular_first_dfc                 C   s   t   }|jg dd d f }tj \}}|jd|d |j|d t|dr,J |	 }|d 
 }t ||jtj |d 
 }t ||jtj d S ra  )r|   r}   rf  r   r;   r<   r=   r%   r   r(   r)   rb  r    r   r   rK   rc  r0   r0   r1   "test_mixed_freq_irregular_first_df  s   z-TestTSPlot.test_mixed_freq_irregular_first_dfc                 C   s   t dddd}t dddd}ttjdt||}ttjdt||}tj	 \}}|j
|d |j
|d | D ]}t| d	jdksOJ qAd S )
Nr  m  rl   r   r  rn   r   r_   r   r   r   r6   r7   r8   r9   rL   r;   r<   r=   r%   r(   r   r)   r   r,   r4  idxlhighr3  r@   r.   r)  r0   r0   r1   test_mixed_freq_hf_first"     z#TestTSPlot.test_mixed_freq_hf_firstc                 C   s   t dddd}tjdd}t||d}|d }tj	
 \}}|j|d	}|jd
|d |jd  d |jd  d ksEJ d S )Nz2012-01-01 13:00
2012-01-02r   rF   r   r  r   rk   r_   rry   r   r#   )r   r6   r7   r8   r9   r   r   Zinterpolater;   r<   r=   r%   r(  r)   )r,   Zts_indZts_datar-   Zts2r@   r.   r0   r0   r1   test_mixed_freq_alignment-  s   ,z$TestTSPlot.test_mixed_freq_alignmentc           	      C   s   t dddd}t dddd}ttjdt||}ttjdt||}tj	 \}}|j
d|d	 |j
d|d	 | D ]}t| d
jdksQJ qC| }t|jdks_J tj|  d S )Nr  rj  rl   r   r  rn   r   T)Zlegendr.   r   )r   r   r6   r7   r8   r9   rL   r;   r<   r=   r%   r(   r   r)   r   
get_legendZtextsr`   r   )	r,   r4  rm  rn  r3  r@   r.   r)  legr0   r0   r1   test_mixed_freq_lf_first:  s   z#TestTSPlot.test_mixed_freq_lf_firstc                 C   s   t dddd}t dddd}ttjdt||}ttjdt||}tj	 \}}|j
|d |j
|d | D ]}t| d	jdksOJ qAd S )
Nr     rk   r   r   r   r   r_   r   rk  rl  r0   r0   r1   test_mixed_freq_lf_first_hourlyH  rp  z*TestTSPlot.test_mixed_freq_lf_first_hourlyc                 C   s   t  }|jg d }d}t jt|d tdddd}W d    n1 s&w   Y  ttj	d
t||}tj \}}|j|d	 |j|d	 d S )
N)r   r#   r   rG   r   r   r   r      r4   r3   r,              r   rc   z1/3/2000r   r^   r   r   r_   )r|   r}   r   r   r   r   r   r6   r7   r8   r9   rL   r;   r<   r=   r%   )r,   r-   r   rh   r   Zpsr@   r.   r0   r0   r1   test_mixed_freq_irreg_periodS  s   z'TestTSPlot.test_mixed_freq_irreg_periodc                 C   s   t dddd}|d d |dd  }ttt||}ttt||}tjjddd\}\}}|j|d	 |j|d	 |j	dksEJ |j	dksLJ |j
d
  d |j
d
  d ks`J d S )N
2015-01-01rG   rn   r   r#   r   T)Znrowssharexr_   r   r!   )r   rM   r   r:   rL   r;   r<   r=   r%   r   r(  r   r,   r^  r_  r\  r]  r@   Zax1rA  r0   r0   r1   test_mixed_freq_shared_ax_  s   ,z$TestTSPlot.test_mixed_freq_shared_axc                 C   s   t dddd}|d d |dd  }ttt||}ttt||}tj \}}| }|j	|d |j	|d |j
d  d	 |j
d  d	 ksQJ d S 
Nr  rG   rn   r   r#   r   r_   r   r!   r   rM   r   r:   rL   r;   r<   r=   Ztwinxr%   r(  r   r  r0   r0   r1    test_mixed_freq_shared_ax_twin_xn  s   ,z+TestTSPlot.test_mixed_freq_shared_ax_twin_xzTODO (GH14330, GH14322)c                 C   s   t dddd}|d d |dd  }ttt||}ttt||}tj \}}| }|j	|d |j	|d |j
d  d	 |j
d  d	 ksQJ d S r  r  r  r0   r0   r1   0test_mixed_freq_shared_ax_twin_x_irregular_first|  s   ,z;TestTSPlot.test_mixed_freq_shared_ax_twin_x_irregular_firstc                 C   s   t j \}}tdtdg}ttt||}|j|d |	 d 
 }|j t| ks2J t| |j ks?J d S )Nr  z
2015-01-03r_   r   )r;   r<   r=   r   r
   r   r:   rL   r%   r(   r)   r    minmax)r,   r@   r.   Zdtir   r/   r0   r0   r1   test_nat_handling  s   zTestTSPlot.test_nat_handlingc                 C   s   t dddd}t dddd}ttjdt||}ttjdt||}tj	 \}}|j
|d |j
|d | D ]}t| d	j|jksPJ qAd S )
Nr  4   rm   r   r  rn   r   r_   r   rk  rl  r0   r0   r1   test_to_weekly_resampling  s   z$TestTSPlot.test_to_weekly_resamplingc                 C   s   t dddd}t dddd}ttjdt||}ttjdt||}tj	 \}}|j
|d |j
|d | jtj}tjg d	tjd
}| D ](}	t|	 dj|jkscJ |	jdd}
t|
dkrvt|
| qTt|
| qTd S )Nr  r  rm   r   r  rn   r   r_   i  i  i  i  i  i   i  i  i  i  i  i  Zdtyper   Forig)r   r   r6   r7   r8   r9   rL   r;   r<   r=   r%   r   asi8r   float64rT   r(   r   r)   r   r|   rb  )r,   r4  rm  rn  r3  r@   r.   Z
expected_hZ
expected_lr)  r/   r0   r0   r1   test_from_weekly_resampling  s&   z&TestTSPlot.test_from_weekly_resamplingzkind1, kind2)r)  area)r  r)  c                 C   s  t dddd}t dddd}ttjdt|df|g d	d
}ttjdt|df|g d	d
}tj \}}|j	|d|d |j	|d|d tj
g dtjd}	tjt|	tjd}
tdD ].}|j| }t| j|jksxJ t|jdd|	 |
|| j7 }
t|jdd|
 qe| jtj}	tjt|	tjd}
tdD ]1}|jd|  }t| dj|jksJ t|jdd|	 |
|| j7 }
t|jdd|
 qd S )Nr  r  rm   r   r  rn   r   rG   r   r#   r   r   TrH  Zstackedr.   r  r  Fr  r   )r   r   r6   r7   r8   rL   r;   r<   r=   r%   rT   r  zerosr:   r(  r   r)   r   r|   rb  rK   r   r   r  r   )r,   kind1kind2r4  rm  rn  r3  r@   r.   
expected_x
expected_yrU   r)  r0   r0   r1   $test_from_resampling_area_line_mixed  sF   
z/TestTSPlot.test_from_resampling_area_line_mixedc                 C   s  t dddd}t dddd}ttjdt|df|g d	d
}ttjdt|df|g d	d
}tj \}}|j	|d|d |j	|d|d |
 jtj}	tjt|	tjd}
tdD ]/}|j| }t| dj|jksxJ t|jdd|	 |
|| j7 }
t|jdd|
 qdtjg dtjd}	tjt|	tjd}
tdD ]1}|jd|  }t| dj|jksJ t|jdd|	 |
|| j7 }
t|jdd|
 qd S )Nr  r  rm   r   r  rn   r   rG   r  r   Tr  r  r   Fr  r  )r   r   r6   r7   r8   rL   r;   r<   r=   r%   r   r  r   r  r  r:   r(  r   r)   r   r|   rb  rK   r   rT   )r,   r  r  r4  rm  rn  r3  r@   r.   r  r  rU   r)  r(  r0   r0   r1   0test_from_resampling_area_line_mixed_high_to_low  sF   
z;TestTSPlot.test_from_resampling_area_line_mixed_high_to_lowc                 C   s   t dddd}t dddd}ttjdt||}ttjdt||}tj	 \}}|j
|d |j
|d t| dksGJ | D ]}t| d	jd
ksYJ qKd S Nz2014-07-01 09:00rj   2   rE   Z100Lr   r   r_   r   r   rk  rl  r0   r0   r1   "test_mixed_freq_second_millisecond#     z-TestTSPlot.test_mixed_freq_second_millisecondc                 C   s   t dddd}t dddd}ttjdt||}ttjdt||}tj	 \}}|j
|d |j
|d t| dksGJ | D ]}t| d	jd
ksYJ qKd S r  rk  rl  r0   r0   r1   .test_mixed_freq_second_millisecond_low_to_high1  r  z9TestTSPlot.test_mixed_freq_second_millisecond_low_to_highc                 C   sX   t dddt dddt dddg}ttjdt|dft|td}t	|j
 d S )Nr   r#   r   r-  r   rG   r  )r   r   r6   r7   r8   r9   rL   r	   r   r$   r%   rQ   r0   r0   r1   test_irreg_dtypes?  s   "
zTestTSPlot.test_irreg_dtypesc                 C   s^   t ddd}|g d t}ttjdt|df|}t	j
 \}}t|j|d d S )Nr   r3   r   )r   r   r   r4   r   rG   r_   )r   r   r   r   r6   r7   r8   r9   rL   r;   r<   r=   r$   r%   )r,   rN   r?   r@   r.   r0   r0   r1   test_irreg_dtypes_dt64H  s
    z!TestTSPlot.test_irreg_dtypes_dt64c                    s*  t dddddd tjdddd }t fdd|D }ttjdt	|tjdt	|d	|d
}t
j \}}|j|d | }| }t||D ];\}}	tt|d\}
}t|
d\}}
|	 }t	|dkr|dkrt||
|d}n	t||
|d}||ksJ qWd S )Nr#   rG   r   r   r   r-  c                    "   g | ]} t t|d   qS r   r   r   r   r  tr0   r1   r  S     " z(TestTSPlot.test_time.<locals>.<listcomp>r   r   r_   <   %H:%M:%S%H:%M)r   r6   r7   r8   integerscumsumrT   r   r9   rL   r;   r<   r=   r%   
get_xticksr>   r   divmodr   r   r   r   r,   deltasr-   r?   r@   r.   tickslabels_tick_labelmr   hr   r   r0   r  r1   	test_timeP  s0   zTestTSPlot.test_timec                    s  t dddddd tjdddd }t fdd|D }ttjdt	|tjdt	|d	|d
}t
j \}}|j|d | }| }t||D ];\}}	tt|d\}
}t|
d\}}
|	 }t	|dkr|dkrt||
|d}n	t||
|d}||ksJ qW|dd | }| }t||D ];\}}	tt|d\}
}t|
d\}}
|	 }t	|dkr|dkrt||
|d}n	t||
|d}||ksJ qd S )Nr#   rG   r   r   r   r-  c                    r  r  r  r  r  r0   r1   r  o  r  z4TestTSPlot.test_time_change_xlim.<locals>.<listcomp>r   r   r_   r  r  r  z1:30z5:00)r   r6   r7   r8   r  r  rT   r   r9   rL   r;   r<   r=   r%   r  r>   r   r  r   r   r   r   r   r  r0   r  r1   test_time_change_xliml  sJ   z TestTSPlot.test_time_change_xlimc                    s  t dddddd tjdddd }t fdd|D }ttjdt	|tjdt	|d	|d
}t
j \}}|j|d}| }| }t||D ]m\}}	tt|d\}
}t|t| d }t|
d\}}
|	 }t	|dkr|d dkrt||
||d}n.|d dkrt||
||dd d }n|dkrt||
||d}n
t||
||d}||ksJ qWd S )Nr#   rG   r   r   r   r-  c                    r  ))microsecondsr  r  r  r0   r1   r    r  z.TestTSPlot.test_time_musec.<locals>.<listcomp>r   r   r_   r  g    .Ai  r   r  r  )r   r6   r7   r8   r  r  rT   r   r9   rL   r;   r<   r=   r%   r  r>   r   r  r   roundr   r   r   )r,   r  r-   r?   r@   r.   r  r  r  r  r  r   r   r  r   r   r0   r  r1   test_time_musec  s:   zTestTSPlot.test_time_musecc                 C   s   t dddd}t dddd}ttjdt||}ttjdt||}tj	 \}}|j
|d |j
d	|d
}| D ]}t| jdksOJ qBt|dsWJ t|dr^J |j D ]}t| jdkspJ qcd S )Nr  rj  rl   r   r  rn   r   r_   Tr1  r.   r6  r2  )r   r   r6   r7   r8   r9   rL   r;   r<   r=   r%   r(   r   r)   r   r   r6  rl  r0   r0   r1   test_secondary_upsample  s   z"TestTSPlot.test_secondary_upsamplec                 C   s   t j }|d}t }|jddg|d | }t|	 dks%J |
 d  dks1J |
 d  d	ks=J |
 d
  dksIJ |
 d  dksUJ |j d u s^J t }|	 D ]	}||  qet|dkswJ t j| d S )N   rX   r^   r  r   r   	A (right)r#   z	B (right)r   r   rG   rl   )r;   r<   figureadd_subplotr|   makeTimeDataFramer%   rt  rL   r(   	get_textsr   r2  setaddr~   r`   )r,   ra   r.   r?   ru  colorsr)  r0   r0   r1   test_secondary_legend  s    

z TestTSPlot.test_secondary_legendc                 C   s   t  }tj }|d}|jddgd|d | }t|	 dks&J |
 d  dks2J |
 d  d	ks>J |
 d
  dksJJ |
 d  dksVJ tj| d S )Nr  rX   r   F)r1  
mark_rightr.   r   r   r#   r^   r   rG   rl   )r|   r  r;   r<   r  r  r%   rt  rL   r(   r  r   r`   r,   r?   ra   r.   ru  r0   r0   r1   test_secondary_legend_right  s   

z&TestTSPlot.test_secondary_legend_rightc                 C   sp   t  }tj \}}|jddg|d | }| d  dks$J | d  dks0J tj	| d S )NrL  rX   )rH  r1  r.   r   r  r#   r^   
r|   r  r;   r<   r=   r%   rt  r  r   r`   r  r0   r0   r1   test_secondary_legend_bar  s   z$TestTSPlot.test_secondary_legend_barc                 C   sr   t  }tj \}}|jddgd|d | }| d  dks%J | d  dks1J tj	| d S )NrL  rX   F)rH  r1  r  r.   r   r#   r^   r  r  r0   r0   r1   test_secondary_legend_bar_right  s   z*TestTSPlot.test_secondary_legend_bar_rightc                 C   s   t  }tj }|d}t  }|jddg|d}| }t|	 dks)J |j
 d u s2J t }|	 D ]	}||  q9t|dksKJ tj| d S Nr  r   rl   r  r   )r|   r  r;   r<   r  r  r%   rt  rL   r(   r2  r  r  r~   r`   r,   r?   ra   r.   ru  r  r)  r0   r0   r1   test_secondary_legend_multi_col   s   

z*TestTSPlot.test_secondary_legend_multi_colc                 C   s   t  }tj }|d}|jddg|d}| }t|	 dks%J |j
 d u s.J t }|	 D ]	}||  q5t|dksGJ tj  d S )Nr  rX   r^   r  r   )r|   makeDataFramer;   r<   r  r  r%   rt  rL   r(   r2  r  r  r~   r`   r  r0   r0   r1   test_secondary_legend_nonts  s   

z&TestTSPlot.test_secondary_legend_nontsc                 C   s   t  }tj }|d}|jddg|d}| }t|	 dks%J |j
 d u s.J t }|	 D ]	}||  q5t|dksGJ d S r  )r|   r  r;   r<   r  r  r%   rt  rL   r(   r2  r  r  r~   r  r0   r0   r1   %test_secondary_legend_nonts_multi_col"  s   

z0TestTSPlot.test_secondary_legend_nonts_multi_colc                 C   s   t dddd}ttjdt|df|}tj	 \}}|j
|d}| }| D ]}t| dkr>| d	ks>J q,d S )
Nr   r  rn   r   r   rG   r_   r   r   )r   r   r6   r7   r8   r9   rL   r;   r<   r=   r%   r   r   r   Zget_rotation)r,   r   r?   r@   r.   r  r)  r0   r0   r1   test_format_date_axis2  s    z TestTSPlot.test_format_date_axisc                 C   sX   t dddd}ttt|}tj \}}|j||dd}t	t
|d  | d S )Nrq  r3   rl   r   Y)rA   r   )r   listr:   rL   r;   r<   r=   r%   r|   r   r   r)   )r,   rZ   r[   r@   r.   r(  r0   r0   r1   test_ax_plot=  s
   zTestTSPlot.test_ax_plotc           
      C   s  t dddt dddg}tddd}tdd	d}d
dd}tj \}}|jdd |D |fi | |jdd |D |fi | | \}}tjdd |D tj	d}	t
| d d df |	 tjdd |D tj	d}	t
| d d df |	 d S )N  r     i  r#   g      $@g      &@g      ?g      (@-r   )fmtZlwc                 S      g | ]}|  qS r0   	toordinalr  r0   r0   r1   r  L      z0TestTSPlot.test_mpl_nopandas.<locals>.<listcomp>c                 S   r  r0   r  r  r0   r0   r1   r  M  r  c                 S   r  r0   r  r  r0   r0   r1   r  Q  r  r  r   c                 S   r  r0   r  r  r0   r0   r1   r  S  r  )r   r6   r   r;   r<   r=   Z	plot_dater(   rT   r  r|   rb  r   )
r,   datesZvalues1Zvalues2kwr@   r.   line1line2expr0   r0   r1   test_mpl_nopandasD  s   
 zTestTSPlot.test_mpl_nopandasc                 C   s   ddl m} t d d }|jg d }tj \}}|d d j|d |dd  j|d |	 \}}||
|j d|ksDJ ||
|j d|ksRJ d S )Nr   DatetimeConverterr-  r#   r   r   r   ry  r4   r3   r  rX  rY  r,  r{  r|  r   r_    r   r  r|   r}   r   r;   r<   r=   r%   r   convertr    r  r  r,   r  r-   Zts_irregularr@   r.   r?  r7  r0   r0   r1    test_irregular_ts_shared_ax_xlimV  s    z+TestTSPlot.test_irregular_ts_shared_ax_xlimc                 C   s   g d}g d}t d|d}t d|d}tj \}}|j|d | \}}|jd|d | \}	}
||	ks:J ||
k s@J d S )	N)r#   r   rG   r   )r   r   r   ry  r#   r   r   r_   Tr  )r   r;   r<   r=   r%   r   r,   Zindex_1Zindex_2r\  r]  r@   r.   left_beforeright_before
left_afterright_afterr0   r0   r1   test_secondary_y_non_ts_xlimg  s   z'TestTSPlot.test_secondary_y_non_ts_xlimc                 C   s   t dddd}t dddd}td|d}td|d}tj \}}|j|d	 | \}}|jd
|d | \}	}
||	ks@J ||
k sFJ d S )N
2000-01-01r   rl   r   z
2000-01-05r#   r   r   r_   Tr  )r   r   r;   r<   r=   r%   r   r  r0   r0   r1    test_secondary_y_regular_ts_xlimw  s   z+TestTSPlot.test_secondary_y_regular_ts_xlimc           	      C   s   t dddd}td|d}tj \}}|j|d | \}}|d jd	|d
 | \}}||ks8J ||ks>J d S )Nr  r   r  r   r#   r   r_   rl   Tr  )	r   r   r;   r<   r=   r%   r   Zresamplemean)	r,   r   r-   r@   r.   r  r  r  r  r0   r0   r1   #test_secondary_y_mixed_freq_ts_xlim  s   z.TestTSPlot.test_secondary_y_mixed_freq_ts_xlimc                 C   s   ddl m} t d d }|jg d }tj \}}|d d j|d |dd  jd|d |d d j|d |	 \}}||
|j d	|ksOJ ||
|j d	|ks]J d S )
Nr   r  r-  r  r   r_   Tr  r  r  r  r0   r0   r1   "test_secondary_y_irregular_ts_xlim  s    z-TestTSPlot.test_secondary_y_irregular_ts_xlimc                 C   sZ   t dddt dddg}tj \}}|| tddddtddddg}|| d S )Ni  r#   r   r  )r   r;   r<   r=   r%   r   )r,   rK   r@   r.   r0   r0   r1   test_plot_outofbounds_datetime  s
   
z)TestTSPlot.test_plot_outofbounds_datetimec                 C   s   dd t dD }tdddd}tt jdt|df|}tj	
 \}}|jd|d	 tj	  | }d
d |D }t|t|ksIJ ||ksOJ d S )Nc                 S   s   g | ]}d |dqS )z00:00:00.0000000z0>2dr0   )r  rU   r0   r0   r1   r    s    zATestTSPlot.test_format_timedelta_ticks_narrow.<locals>.<listcomp>r3   0nsr   r   rG   r5   c                 S   r  r0   r   r  r0   r0   r1   r    r  )r6   r   r   r   r7   r8   r9   rL   r;   r<   r=   r%   drawr>   r,   Zexpected_labelsr   r?   r@   r.   r  Zresult_labelsr0   r0   r1   "test_format_timedelta_ticks_narrow  s    
z-TestTSPlot.test_format_timedelta_ticks_narrowc                 C   s   g d}t dddd}ttjdt|df|}tj	 \}}|j
d|d}tj  | }d	d
 |D }t|t|ksCJ ||ksIJ d S )N)	z00:00:00z1 days 03:46:40z2 days 07:33:20z3 days 11:20:00z4 days 15:06:40z5 days 18:53:20z6 days 22:40:00z8 days 02:26:40z9 days 06:13:20r  r3   1 dr   r   rG   r5   c                 S   r  r0   r  r  r0   r0   r1   r    r  z?TestTSPlot.test_format_timedelta_ticks_wide.<locals>.<listcomp>)r   r   r6   r7   r8   r9   rL   r;   r<   r=   r%   r   r>   r  r0   r0   r1    test_format_timedelta_ticks_wide  s    
z+TestTSPlot.test_format_timedelta_ticks_widec                 C   s6   t tdtddd}tj \}}t|j|d d S )Nr   Z1dayr   r_   )r   r:   r   r;   r<   r=   r$   r%   )r,   r   r@   r.   r0   r0   r1   test_timedelta_plot  s   zTestTSPlot.test_timedelta_plotc                 C   J   t dddd}ttjdt||}tj	 \}}t
|j|d d S )N1 day 2 hr 30 min 10 sr3   r  r   r   r_   r   r   r6   r7   r8   r9   rL   r;   r<   r=   r$   r%   r,   r    r   r@   r.   r0   r0   r1   test_timedelta_long_period  rv   z%TestTSPlot.test_timedelta_long_periodc                 C   r  )Nr  r3   z1 nsr   r   r_   r  r	  r0   r0   r1   test_timedelta_short_period  rv   z&TestTSPlot.test_timedelta_short_periodc                 C   s`   t dddd}|}tddd}tdddd d d }tj \}}|j||g||gd	 d S )
Nr   r3   r   r   r   r#   g?r"   )weights)r   r6   r   r;   r<   r=   hist)r,   r   rZ   Zw1Zw2r@   r.   r0   r0   r1   	test_hist  s   zTestTSPlot.test_histc                 C   s   t g dtdddtdddtdddgd}t g dtdddtd	ddtd
ddgd}tj \}}|j|d |j|d |j|d d S )NrS   r  r  r  r   i  r   i  i  r  r_   )r   r   r;   r<   r=   r%   )r,   r\  r]  r@   r.   r0   r0   r1   test_overlapping_datetime  s$   





z$TestTSPlot.test_overlapping_datetimez1GH9053 matplotlib does not use ax.xaxis.converterc                 C   s   t tjddtdddd}| }tt	 |j|j
|jdd W d    n1 s/w   Y  |j\}}t| |  d S )Nr   r3   z
1970-01-02r   r   rZ  )r   )r   r6   r7   r8   r9   r   r%   r|   r   DeprecationWarningr    rK   r(  rb  r   )r,   r   r.   l1l2r0   r0   r1   test_add_matplotlib_datetime64  s   

z)TestTSPlot.test_add_matplotlib_datetime64c                 C   s|   t tjddddgd}tdddd	|d
< tj \}}|jd
d|d tj	  |
 d }d}| |ks<J d S )Nr   )r3   r   rZ   r[   rQ  z
2018-01-01r3   rl   r   r   )rZ   r[   r   r   )r   r6   r7   r8   r   r;   r<   r=   Zscatterr   r>   r   )r,   r?   r@   r.   rA   r   r0   r0   r1   "test_matplotlib_scatter_datetime64  s   
z-TestTSPlot.test_matplotlib_scatter_datetime64c                 C   <   t g d}t|g dd}|jddd}t|dd d S )N)
2020-05-01
2020-05-02z
2020-05-03rS   rZ   r[   rZ   r[   r   Zxrotr   r   r%   r   r,   rZ   r?   r=  r0   r0   r1   test_check_xticks_rot)  s   z TestTSPlot.test_check_xticks_rotc                 C   r  )Nr  r  z
2020-05-04rS   r  rZ   r[   r   r  r  r  r0   r0   r1   test_check_xticks_rot_irregular1  s   z*TestTSPlot.test_check_xticks_rot_irregularc                 C   sb   t g d}t|g dd}|djddd}t|dd	 |djdd
d}t|dd	 d S )Nr  rS   r  rZ   r[   T)r[   Z	use_indexr   r  Fr   )r   r   Z	set_indexr%   r   r  r0   r0   r1   test_check_xticks_rot_use_idx8  s   z(TestTSPlot.test_check_xticks_rot_use_idxc                 C   s^   t g d}t|g dd}|jddddd}t|dd	 |jdddd
d}t|dd	 d S )Nr  rS   r  rZ   r[   T)rZ   r[   r=   r  r   r  Fr   r  r  r0   r0   r1   test_check_xticks_rot_sharexB  s   z'TestTSPlot.test_check_xticks_rot_sharexN){__name__
__module____qualname__re   markfilterwarningsr2   rB   rP   rR   rW   rb   ri   Zparametrizeru   rw   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   Zxfailr   r   r   r   r   r   r   r   r   r|   r}   r   r   r   r  r  r  r  r  Zslowr  r  r*  r.  r/  r5  r>  rB  rC  rD  rE  rF  rK  rM  rT  rU  r`  re  rh  ri  ro  rs  rv  rx  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  r  r  r
  r  r  r  r  r  r  r  r  r   r0   r0   r0   r1   r   .   s2   


		






	



	
			



		



7
5	-#		

		

r   c              	   O   s  dd l m} | }z|  |d}|d| }t|dd }	| |i |}
|
d us/J |d| }|d urR|jj	}t
|trG|j}|	d u rR|j	|ksRJ |d ura|	d u ra|j	|ksaJ |d}||d< | |i |}
|
d uswJ tjdd}|| W d    n1 sw   Y  tjdd}t|| W d    n1 sw   Y  W || d S W || d S || w )Nr   r  r.   r      T)Zreturn_filelike)Zmatplotlib.pyplotr<   ZgcfZclfr  popZgcagetattrr    r   r%  r   r   r|   Zensure_cleanZsavefigpickledumpr`   )fr   ZseriesargskwargsZpltra   r.   Zorig_axZorig_axfreqr   Zdfreqpathr0   r0   r1   r$   M  s>   


r$   )NN))__doc__r   r   r   r   r)  numpyr6   re   Zpandas._libs.tslibsr   r   Zpandasr   r	   r
   r   r   r   r   Zpandas._testingZ_testingr|   Zpandas.core.indexes.datetimesr   r   r   Zpandas.core.indexes.periodr   r   r   Zpandas.core.indexes.timedeltasr   Zpandas.tests.plotting.commonr   Zpandas.tseries.offsetsr   rI  r;   r   r$   r0   r0   r0   r1   <module>   s8    $	
            +