U
    _{fGx                     @   s   d Z ddlmZ ddlmZ ddlZddlZddlmZ ddl	m
Z
 ddlm  mZ ddlZddlmZmZmZmZ ddlmZ ddlmZmZ ejd	d
 Zejdd Zejdd ZejG dd deZ dS )z Test cases for Series.plot     )datetime)chainN)is_platform_linux)np_version_gte1p24)	DataFrameSeries
date_rangeplotting)TestPlotBase_check_plot_worksc                   C   s   t jddS )Ntsname)tmZmakeTimeSeries r   r   `/var/www/html/Darija-Ai-API/env/lib/python3.8/site-packages/pandas/tests/plotting/test_series.pyr      s    r   c                   C   s   t jddS )Nseriesr   )r   ZmakeStringSeriesr   r   r   r   r      s    r   c                   C   s   t jddS )Niseriesr   )r   ZmakePeriodSeriesr   r   r   r   r   $   s    r   c                
   @   s  e Zd Zejjdd Zdd Zejddddej	d	e
jd
ddgdd Zdd Zdd Zdd Zdd Zdd Zdd Zdd Zdd Zdd  Zd!d" Zejd#d$ejd%d&gd'd( Zd)d* Zejjeoe d+d,d-d.d/ Zd0d1 Zd2d3 Z d4d5 Z!d6d7 Z"d8d9 Z#d:d; Z$d<d= Z%d>d? Z&ejd@dAdBgdCdD Z'dEdF Z(e
jdGdH Z)e
jdIdJ Z*ejjdKdLdMdN Z+e
jejde,j-j.e,j-j/ dOdP Z0ejde,j-j.dQdR Z1e
jejde,j-j.dSdT Z2ejde,j-j.dUdV Z3dWdX Z4dYdZ Z5d[d\ Z6ejjd]d^ Z7ejjd_d` Z8ejje
jdadb Z9ejdcdddedfdggdhdi Z:djdk Z;dldm Z<dndo Z=dpdq Z>drds Z?dtdu Z@dvdw ZAejjdxdLdydz ZBejddd{gd|d} ZCd~d ZDdd ZEejddddd%gddddgfddddgddddgfgdd ZFdd ZGejddddgejddd{dddgdd ZHejd#eIjJddddeIjKddeIjKddggdd ZLd$S )TestSeriesPlotsc                 C   s   t |jdd t |jdd t |jdd}| j|dd t |jdd	d
}| j|dd t |jdd	d}| j|dd t |jdd	d}| j|ddd t |d d jj t |jjdd d S )NZfoo)labelF)	use_indexr   )rotZxrot.T)stylelogylogyaxis)r   Zlogx)xaxis)r   Zloglog)r   r   
   stacked)r   plot_check_ticks_props_check_ax_scalesbararea)selfr   axesaxr   r   r   	test_plot+   s    zTestSeriesPlots.test_plotc                 C   s   t |j d S Nr   r#   )r(   r   r   r   r   test_plot_iseries>   s    z!TestSeriesPlots.test_plot_iserieskindliner&   barhkde)Zmarkshistboxc                 C   s   t |d d j|d d S )N   r/   r-   )r(   r   r/   r   r   r   test_plot_series_kindsA   s    z&TestSeriesPlots.test_plot_series_kindsc                 C   s   t |d d jj d S )Nr    )r   r#   r1   r(   r   r   r   r   test_plot_series_barhO   s    z%TestSeriesPlots.test_plot_series_barhc                 C   s8   t ttjdjjdd}| j|jd gdgd d S )Nr    blackcolorr   Z
facecolors)	r   r   nprandomrandnr#   r&   _check_colorspatches)r(   r*   r   r   r   test_plot_series_bar_axR   s    z'TestSeriesPlots.test_plot_series_bar_axc                 C   sb   t |jdd}| j|ddd t |jddd}| j|ddd t |jddd}| j|ddd d S )	NT)subplots   rE   rE   )axes_numlayout)rE   )rD   rH   )rE   rI   )r   r#   _check_axes_shape)r(   r   r*   r   r   r   test_plot_6951V   s    zTestSeriesPlots.test_plot_6951c                 C   sB   | j  \}}|jdd|d}| |jd | j|dddd d S )NZTest)      )titlefigsizer*   rE   rF   )rG   rH   rO   )pltrD   r#   _check_text_labelsrN   rJ   )r(   r   _r*   r   r   r   test_plot_figsize_and_title`   s    z+TestSeriesPlots.test_plot_figsize_and_titlec                 C   sL   d}| j j| }| j  \}}tdddgj|d || j j| ksHtd S )Nzaxes.prop_cyclerE         r*   )rP   rcParamsrD   r   r#   AssertionError)r(   keycolorsrR   r*   r   r   r   test_dont_modify_rcParamsg   s
    z)TestSeriesPlots.test_dont_modify_rcParamsc                 C   s   | j  \}}|j|d}| \}}| }||d jddd d ksNt||d jddd d ksntt  |jd|d}| \}}| }||d jddd d kst||d jddd d kstd S )NrV   r   ForigrI   Tsecondary_yr*   )	rP   rD   r#   get_xlim	get_linesget_datarX   r   close)r(   r   figr*   xminxmaxlinesr   r   r   test_ts_line_limo   s       z TestSeriesPlots.test_ts_line_limc                 C   s  | j  \}}|jjd|d}| \}}| d jddd }||d ksRt||d ksbt| j|dd t	
  | j  \}}|jjdd|d}| \}}| d jddd }||d kst||d kst| j|d	d t	
  | }|d
d|_| j  \}}|jjdd|d}| \}}| d jddd }||d ksbt||d kstt| j|dd t	
  | j  \}}|jjdd|d}| \}}| d jddd }||d kst||d kst| j|dd d S )NF)r"   r*   r   r\   rI   r   T)r"   Zx_compatr*      GMTZCET)r"   r_   r*   )rP   rD   r#   r'   r`   ra   rb   rX   r$   r   rc   copyZtz_localizeZ
tz_convertindex)r(   r   rR   r*   re   rf   r0   Ztz_tsr   r   r   test_ts_area_lim~   sB    z TestSeriesPlots.test_ts_area_limc                 C   sn   | j jdddd\}\}}t|j|dd t|j|dd | |||sTt| |||sjtd S )NrE   rT   T)Zshareyr'   )r*   r/   )rP   rD   absr#   Z
get_y_axisZjoinedrX   )r(   r   rd   ax1ax2r   r   r   test_area_sharey_dont_overwrite   s
    z/TestSeriesPlots.test_area_sharey_dont_overwritec                 C   s:  t ddg}| j \}}|jdd|d}| j|dgd | j  | j \}}|jd|d}| j|dgd | j  d	|_| j \}}|jd|d}| j|d	gd | j  | j \}}|jdd|d
}| j|dgd | j  | j \}}|jdd|d
}| d kst|	  | j|dgd d S )NrE   rT   ZLABELT)r   legendr*   labelsrr   r*    NAME)rr   r   r*   F)
r   rP   rD   r#   _check_legend_labelsrc   r   Z
get_legendrX   rr   )r(   srR   r*   r   r   r   
test_label   s.    



zTestSeriesPlots.test_labelc              	   C   sH   t dddg}t|jdd d}tjt|d t|j W 5 Q R X d S )NFT)Zinclude_boolno numeric data to plotmatch)r   r   r#   pytestraises	TypeError)r(   ry   msgr   r   r   test_boolean   s
    zTestSeriesPlots.test_booleanrl   N   )kc              	   C   s  ddt jdg}t||d}t|j}|jd  }t jdddgt jd}t	
t |jd| t	
|jt ddddg t jddddgt jd}t|jdd	}t	
|jd  | t|jj}t	
|jd  | t|jjdd	}t	
|jd  | d S )
NrE   rT   rU   rl   r   ZdtypeFTr!   )r>   nanr   r   r#   rg   	get_ydataarrayZfloat64r   assert_numpy_array_equaldeletedatamaskr'   )r(   rl   valuesdr*   Zmaskedexpexpectedr   r   r   test_line_area_nan_series   s    
z)TestSeriesPlots.test_line_area_nan_seriesc                 C   s   t dddgdddgd}d|j_| j \}}|jd	|d
}| }|dksPt| j \}}|jjd	|d
}| }|dkstd S )NrE   rT   rU   abcr   z	The IndexFr   r*   rv   )	r   rl   r   rP   rD   r#   
get_xlabelrX   r&   )r(   ry   rR   r*   r   rp   label2r   r   r   test_line_use_index_false   s    z)TestSeriesPlots.test_line_use_index_falsezWeird rounding problemsF)reasonstrictc              	   C   s  t ddddddg}| j \}}tddgjjd	|d
}t|j	
 | t  | j \}}tddgjjd	|d
}t|j
 | t  t dddddddg}| j \}}tdddgjd	d|d}d}d}| }t|d | t|d | t|j	
 | t  | j \}}tdddgjd	d|d}| }t|d | t|d | t|j
 | d S )Ng?      ?g      $@g      Y@g     @@g     @   i  T)r   r*   gh㈵>g-C6?gMbP?g{Gz?r&   )r   r/   r*   g!,NJ?gЄ-??r   rE   r1   )r>   r   rP   rD   r   r#   r&   r   r   r   get_ticklocsrc   r1   r   Zget_ylimZassert_almost_equalr`   )r(   r   rR   r*   Zyminymaxresr   r   r   test_bar_log   s2    zTestSeriesPlots.test_bar_logc                 C   sV   t ddddgddddgd	}| j \}}|jjd
|d}| | ddddg d S )NrE   rT   rU   r   r   r   r   r   r   Fr   0123)r   rP   rD   r#   r&   rQ   get_xticklabels)r(   dfrR   r*   r   r   r   test_bar_ignore_index  s    z%TestSeriesPlots.test_bar_ignore_indexc                 C   sR   t ddddg}|jjddddgd}dd	 |jD }d
ddd
g}||ksNtd S )NrE   rT   rU   r   redbluer;   c                 S   s   g | ]}|  qS r   )Zget_facecolor).0pr   r   r   
<listcomp>"  s     z8TestSeriesPlots.test_bar_user_colors.<locals>.<listcomp>)r           r   r   )r   r   r   r   )r   r#   r&   rB   rX   )r(   ry   r*   resultr   r   r   r   test_bar_user_colors  s    z$TestSeriesPlots.test_bar_user_colorsc                 C   sh   t tjdd}| j \}}|j|d}| j|dd | j \}}|jd|d}| j|dd d S )Nr5   rV   r   r   ri   )r   r*   )r   r>   r?   r@   rP   rD   r#   r$   )r(   r   rR   r*   r)   r   r   r   test_rotation+  s    zTestSeriesPlots.test_rotationc              
   C   s   ddl m} tdd}|dddddd	d
ddg	 }ttjt||}| j	 \}}|j
|d}|tdddd|}|dd || d kst| j|dd d S )Nr   )DatetimeConverter1/1/2000z3/1/2000rE   rT   rU   r5   	   r          rV   i  rv   z1/1/19991/1/2001ri   r   )Z%pandas.plotting._matplotlib.converterr   r   r   r>   r?   r@   lenrP   rD   r#   convertr   Zset_xlimr`   rX   r$   )r(   r   rngserrR   r*   Zxpr   r   r   test_irregular_datetime6  s    
z'TestSeriesPlots.test_irregular_datetimec              	   C   s   t ddtjddddgddddtjddgd}| j \}}|j|d	}| \}}| }|t|d
 j	ddd
 ks|t
|t|d
 j	ddd
 kst
d S )Nr   r   g      @g      @g      @g      @g       @r   rV   r   Fr\   )r   r>   r   rP   rD   r#   r`   ra   Znanminrb   rX   Znanmax)r(   r   rR   r*   re   rf   rg   r   r   r   test_unsorted_index_xlimC  s    "z(TestSeriesPlots.test_unsorted_index_xlimc           	   	   C   s  t tjdddddddgdd	}t|jj}| |j|j	 |
 dksNtt|jjd d
}| |jdgd  dddg}t|jj|d}dddddg}| j|j|d dddddg}dddddg}t|jj||d}| |j| | j|j|d t|jj|ddd}dd |j|  D }ttt|j	|}| |j| |jD ]}| dksLtqLt dddddgdddddgd }tjtd!d" |j  W 5 Q R X t ddtjdgddddgdd	}t|jj}| |jddddg d S )#NrE   r5   r   r   r   r   eZYLABELrl   r   rs   rv   rgrZ   r=   ABCDEm)rt   rZ   z%.2f   )rZ   ZautopctZfontsizec                 S   s   g | ]}|d  dqS )d   z.2fr   )r   ry   r   r   r   r   o  s     z3TestSeriesPlots.test_pie_series.<locals>.<listcomp>rT   r   r   rI   r   z&pie plot doesn't allow negative valuesr|   )r   r>   r?   randintr   r#   pierQ   textsrl   
get_ylabelrX   rA   rB   r   sumlistr   from_iterablezipZget_fontsizer~   r   
ValueErrorr   )	r(   r   r*   Z
color_argsZcolor_expectedrt   ZpctsZexpected_textstr   r   r   test_pie_seriesO  sH      
   
  zTestSeriesPlots.test_pie_seriesc                 C   s\   t dtjddg}| j \}}|jjd|d}ddddg}dd	 |jD }||ksXtd S )
NrE   Tru   r   rv   r   r   c                 S   s   g | ]}|  qS r   )Zget_text)r   xr   r   r   r     s     z0TestSeriesPlots.test_pie_nan.<locals>.<listcomp>)	r   r>   r   rP   rD   r#   r   r   rX   )r(   ry   rR   r*   r   r   r   r   r   test_pie_nan  s    zTestSeriesPlots.test_pie_nanc                 C   sf  t tjddtdd}ttjddd}| j \}}|j|d}|jdd|d	 | j	|d
dddgd |
  s~t|j
  stt  | j \}}|j|d}|j|ddd | j	|d
dddgd |
  st|j
  stt  | j \}}|jd|d}|jdd|d	 ddddg}| j	|j|d |j
  r^t|
  sptt  | j \}}|jd|d}|j|ddd ddddg}| 	|j| |j
  rt|
  stt  | j \}}|jdd|d}|j|ddd d
dddg}| 	|j| |j
  rHt|
  sZtt  d S )Nri   rU   abc)columnsr   r   rV   T)rr   r_   r*   r   r   r   z	x (right)rs   )r*   rr   r_   r^   z	a (right)z	b (right)z	c (right)F)r_   Z
mark_rightr*   )r   r>   r?   r@   r   r   rP   rD   r#   rx   Z	get_yaxisZget_visiblerX   Zright_axr   rc   Zleft_ax)r(   r   ry   rR   r*   r   r   r   r   test_df_series_secondary_legend  sP    z/TestSeriesPlots.test_df_series_secondary_legendzinput_logy, expected_scale)Tr   )symZsymlogc                 C   s^   t tjd}t tjd}|j|d}|jd|d}| |ksJt| |ksZtd S )Nri   )r   T)r_   r   )r   r>   r?   r@   r#   Z
get_yscalerX   )r(   Z
input_logyZexpected_scales1s2ro   rp   r   r   r   test_secondary_logy  s    z#TestSeriesPlots.test_secondary_logyc              	   C   sP   t tjd}| j \}}d}tjt|d |j	dd|d W 5 Q R X d S )NrT   zCannot pass 'style' string with a color symbol and 'color' keyword argument. Please use one or the other or pass 'style' without a color symbolr|   zk--r   )r   r<   r*   )
r   r>   r?   r@   rP   rD   r~   r   r   r#   )r(   r   rR   r*   r   r   r   r   )test_plot_fails_with_dupe_color_and_style  s    z9TestSeriesPlots.test_plot_fails_with_dupe_color_and_stylec                 C   s   t ddd}t|jjddd t|jjd dd t|jjd t dd t|jjd|d t|jjd|d | j \}}|jjdd||d}| j	|d	d
 | 
|j d d S )Nir      Zscott)	bw_methodindg      ?T)r   r   r   r*   r   r   ZDensity)r>   Zlinspacer   r#   r2   int_ZdensityrP   rD   r%   rQ   r   Z	get_label)r(   r   Zsample_pointsrR   r*   r   r   r   test_kde_kwargs  s    zTestSeriesPlots.test_kde_kwargsc                 C   sJ   t tjjdd}tj|d< t|jj}tt	|j
d   sFtd S )N2   )sizer   )r   r>   r?   uniformr   r   r#   r2   anyisnanrg   	get_xdatarX   )r(   ry   r)   r   r   r   test_kde_missing_vals  s    
z%TestSeriesPlots.test_kde_missing_valszApi changed in 3.6.0)r   c                 C   sf   | j  \}}|jjd|d}| j|dd | }| ||jg | }| |dgt	|  d S )NT)r   r*   r   r   rv   )
rP   rD   r#   r4   r%   r   rQ   r   Zget_yticklabelsr   )r(   r   rR   r*   ZxlabelsZylabelsr   r   r   test_boxplot_series  s    z#TestSeriesPlots.test_boxplot_seriesc                 C   s\   t td}| j \}}|j||d | j  | j \}}t|j|  | j  d S )NrU   r/   r*   )r   rangerP   rD   r#   rc   getattr)r(   r/   ry   rR   r*   r   r   r   test_kind_both_ways   s    
z#TestSeriesPlots.test_kind_both_waysc              	   C   sJ   t td}| j \}}d}tjt|d |j||d W 5 Q R X d S )Nabcdr{   r|   r   )r   r   rP   rD   r~   r   r   r#   r(   r/   ry   rR   r*   r   r   r   r   test_invalid_plot_data  s
    z&TestSeriesPlots.test_invalid_plot_datac                 C   s"   t tdtd}t|j|d d S )Nr    r   r6   )r   r   objectr   r#   )r(   r/   ry   r   r   r   test_valid_object_plot  s    z&TestSeriesPlots.test_valid_object_plotc              	   C   sN   t ddddg}| j \}}d}tjt|d |j||d W 5 Q R X d S )Nr   r   r   rT   r{   r|   r   )r   rP   rD   r~   r   r   r#   r   r   r   r    test_partially_invalid_plot_data  s
    z0TestSeriesPlots.test_partially_invalid_plot_datac              	   C   s6   t ddg}tjtdd |jdd W 5 Q R X d S )NrE   rT   z%invalid_kind is not a valid plot kindr|   Zinvalid_kindr6   )r   r~   r   r   r#   )r(   ry   r   r   r   test_invalid_kind$  s    z!TestSeriesPlots.test_invalid_kindc                 C   sJ   t ddd}t ddd}||}tj|j}t||d}t|j d S )Nz1/1/2009r   periodsz1/2/2009r   )	r   appendr>   r?   r@   r   r   r   r#   )r(   Zdr1Zdr2rl   r   ry   r   r   r   test_dup_datetime_index_plot)  s    
z,TestSeriesPlots.test_dup_datetime_index_plotc              	   C   s   t tddd}tjdd}|j||d}tdd |jd  D }|j	t
d	dg | d	d }t|| d
t| d}tjt|d |jtjddd W 5 Q R X t  d S )Nr    r   r   rT   )yerrxerrc                 S   s   g | ]}|j d d df qS )NrE   )Zverticesr   ir   r   r   r   8  s     z>TestSeriesPlots.test_errorbar_asymmetrical.<locals>.<listcomp>rE   rI   z?Asymmetrical error bars should be provided with the shape \(2, z\)r|   r   r   )r   r>   aranger?   Zrandr#   Zvstackcollections	get_pathsTr   Zto_numpyZreshaper   r   r   r~   r   r   rc   )r(   ry   errr*   r   r   r   r   r   r   test_errorbar_asymmetrical1  s    $ z*TestSeriesPlots.test_errorbar_asymmetricalc              	   C   s  t tddd}ttjd}tttjdd|jddgd}ddg}|D ]}t|j	t ||d	}| j
|d
dd t|j	||d	}| j
|d
dd t|j	| |d	}| j
|d
dd t|j	||d	}| j
|d
dd t|j	dd|d}| j
|ddd qTt|j	|d}| j
|dd
d tdddd}t td|dd}t ttjd|d}	tttjdd|ddgd}
t|j	|	d}| j
|d
dd t|j	|
d}| j
|d
dd tt |j	tdd W 5 Q R X dgd }tt |j	|d W 5 Q R X d S )Nr    r   r   rT   y)rl   r   r0   r&   )r   r/   r   rE   )r   r   g?)r   r   r/   )r   r   r   M)freqr   r   r   r   r   zzz)r   r>   r  rn   r?   r@   r   rl   r   r#   Z_check_has_errorbarstolistr   r   Zexternal_error_raisedr   r   )r(   ry   Zs_errZd_errkindsr/   r*   Zixr   Zts_errZtd_errr   r   r   test_errorbar_plotE  sD      "
z"TestSeriesPlots.test_errorbar_plotc                 C   s    t |jdd t |j|d d S )NT)tabler-   r8   r   r   r   
test_tablep  s    zTestSeriesPlots.test_tablec                 C   s&   |  tdddgtjjtjj  d S )NrE   rT   rU   )Z_check_grid_settingsr   r	   PlotAccessor_series_kinds_common_kinds)r(   r   r   r   test_series_grid_settingsu  s    z)TestSeriesPlots.test_series_grid_settingsr   r   r   greenz#FF0000c                 C   s   ddl m} |d|d}||gks&t|d|gd}||gksBt|d|d}||gd ks`t|d|gd}||gd kstd S )Nr   get_standard_colorsrE   r;   rU   )!pandas.plotting._matplotlib.styler  rX   )r(   r   r  r   r   r   r   test_standard_colors~  s    z$TestSeriesPlots.test_standard_colorsc                 C   s  ddl m} ddlm} |jD ]x}|d|d}||gks<t|d|gd}||gksXt|d|d}||gd ksvt|d|gd}||gd kstq|jjD ]x}|d|d}||gkst|d|gd}||gkst|d|d}||gd kst|d|gd}||gd kstqd S )Nr   r   r  rE   )Z
num_colorsr<   rU   )
matplotlibrZ   r  r  ZcnamesrX   ZColorConverter)r(   rZ   r  r   r   r   r   r   test_standard_colors_all  s(    
z(TestSeriesPlots.test_standard_colors_allc                 C   sB   | j  \}}ttdd jd|d}| j| dgd d S )Nr   rE   r  r<   r*   Z
linecolors)rP   rD   r   r>   r  r#   rA   ra   r(   rR   r*   r   r   r   test_series_plot_color_kwargs  s    z-TestSeriesPlots.test_series_plot_color_kwargsc                 C   sN   | j  \}}ttdd tddddjd|d}| j| dgd d S )	Nr   rE   r   r   r   r  r  r  )	rP   rD   r   r>   r  r   r#   rA   ra   r  r   r   r   "test_time_series_plot_color_kwargs  s     z2TestSeriesPlots.test_time_series_plot_color_kwargsc           	      C   s~   dd l }| |j}tddd}ttdd|d}d}| j \}}t	|D ]}|j
|d	}qN| j| |d | d
 d S )Nr   r   r   r   rE      r   rU   rV   r  )r  Z_unpack_cyclerrW   r   r   r>   r  rP   rD   r   r#   rA   ra   )	r(   ZmplZ
def_colorsrl   ry   ZncolorsrR   r*   r   r   r   r   -test_time_series_plot_color_with_empty_kwargs  s    z=TestSeriesPlots.test_time_series_plot_color_with_empty_kwargsc                 C   sf   t tddd tdD d}| j \}}|jddddg|d	}d
d dD }| | | d S )Nr    c                 S   s   g | ]}d |dqS P02dr   r   r   r   r   r     s     z4TestSeriesPlots.test_xticklabels.<locals>.<listcomp>r   r   rU   r5   r   )xticksr*   c                 S   s   g | ]}d |dqS r"  r   r   r   r   r   r     s     )r   rU   r5   r   )	r   r>   r  r   rP   rD   r#   rQ   r   )r(   ry   rR   r*   r   r   r   r   test_xticklabels  s
     z TestSeriesPlots.test_xticklabelsc                 C   s^   t tddd tdD d}|jjtdddd}tttddd}t||	  d S )	Nr    c                 S   s   g | ]}d |dqS r"  r   r   r   r   r   r     s     z6TestSeriesPlots.test_xtick_barPlot.<locals>.<listcomp>r   r   r   rT   )r%  )
r   r   r#   r&   r>   r   r   r   r   Z
get_xticks)r(   ry   r*   r   r   r   r   test_xtick_barPlot  s    z"TestSeriesPlots.test_xtick_barPlotc                 C   s@   ddl m} ttddtjdd|dgdd	d
}t|j d S )Nr   )CustomBusinessDayr   y   z
2014-05-01z
2014-06-01z
2014-05-26)Zholidays)startendr	  r   )Zpandas.tseries.offsetsr(  r   r   pdZbdate_ranger   r#   )r(   r(  ry   r   r   r   test_custom_business_day_freq  s    
	z-TestSeriesPlots.test_custom_business_day_freqziGH#24426, see also github.com/pandas-dev/pandas/commit/ef1bd69fa42bbed5d09dd17f08c44fc8bfc2b685#r61470674c                 C   sn   t ddddg}| j \}}|j|d}|j }|jddgdd | j \}}|j }t|| d S )	NrE   rT   rU   r   rV   r   T)Zinplace)	r   rP   rD   r#   r   r   Zdropr   r   )r(   r   rR   r*   beforeafterr   r   r   %test_plot_accessor_updates_on_inplace  s    

z5TestSeriesPlots.test_plot_accessor_updates_on_inplacer'   c                 C   sT   t ddg}| j \}}|j||d | }|d dk s@t|d dksPtd S )NrT   rU   r   r   rE   )r   rP   rD   r#   r`   rX   )r(   r/   ry   rR   r*   xlimsr   r   r   test_plot_xlim_for_series  s    z)TestSeriesPlots.test_plot_xlim_for_seriesc                 C   sh   t td}|jst| }t| dks0t| d }t| dksPtt| dksdtd S )Nr   rE   r   )	r   intemptyrX   r#   r   ra   r   r   )r(   r   r*   r0   r   r   r   test_plot_no_rows  s    

z!TestSeriesPlots.test_plot_no_rowsc              	   C   s4   t dddg}tjtdd |  W 5 Q R X d S )Nr   r   r   r{   r|   )r   r~   r   r   r#   )r(   r   r   r   r   test_plot_no_numeric_data  s    z)TestSeriesPlots.test_plot_no_numeric_datazdata, indexrE   rT   rU   r   r    r   r   ri   iv  i  i  i  c                 C   sL   t ||d}|jdd}| }dd t|jdd dD }||ksHtd S )	N)r   rl   r&   r6   c                 S   s   g | ]}|  jqS r   )get_bboxr   )r   patchr   r   r   r   !  s   z3TestSeriesPlots.test_plot_order.<locals>.<listcomp>c                 S   s
   |   jS r,   )r7  rf   )r8  r   r   r   <lambda>#      z1TestSeriesPlots.test_plot_order.<locals>.<lambda>)rY   )r   r#   r  sortedrB   rX   )r(   r   rl   r   r*   r   r   r   r   r   test_plot_order  s    	zTestSeriesPlots.test_plot_orderc                 C   s4   t ddg}|jddd}|jd  dks0td S )NrE   rT   ry   ZC3)r   r<   r   )r   r#   rg   	get_colorrX   )r(   ry   r*   r   r   r   test_style_single_ok'  s    z$TestSeriesPlots.test_style_single_okz index_name, old_label, new_label)Nrv   new)oldr@  r?  )Nrv   rv   c                 C   s   t ddddg}||j_|j|d}|dkrN| dks<t| |kstnJ|dkrx| dksft| d	kstn | dkst| |kst|j|||d
}| |kst| |kstd S )NrE   rT   rU   r   r6   r1   rv   r3   Z	Frequency)r/   ZylabelZxlabel)r   rl   r   r#   r   rX   r   )r(   r/   Z
index_nameZ	old_labelZ	new_labelr   r*   r   r   r   test_xlabel_ylabel_series,  s    z)TestSeriesPlots.test_xlabel_ylabel_seriesr   )r*  r   r	  )daysc                 C   s0   d}t ddg|dj|d}| dks,td S )N)rU   rE   rE   rT   r   )Zxlim)r   r#   r`   rX   )r(   rl   r1  r*   r   r   r   test_timedelta_indexG  s    	z$TestSeriesPlots.test_timedelta_index)M__name__
__module____qualname__r~   markZslowr+   r.   ZparametrizeparamtdZskip_if_no_scipyr7   r9   rC   rK   rS   r[   rh   rm   rq   rz   r   r   ZmakeDateIndexr   r   Zxfailr   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  r2  r5  r6  r<  r>  rA  r,  Ztimedelta_rangeZ	TimedeltarC  r   r   r   r   r   )   s   


'
	

!0? 



		


*

!



r   )!__doc__r   	itertoolsr   numpyr>   r~   Zpandas.compatr   Zpandas.compat.numpyr   Zpandas.util._test_decoratorsutilZ_test_decoratorsrI  Zpandasr,  r   r   r   r	   Zpandas._testingZ_testingr   Zpandas.tests.plotting.commonr
   r   Zfixturer   r   r   Zskip_if_no_mplr   r   r   r   r   <module>   s&   


