a
    nÝEb¢  ã                   @   st   d Z ddlZddlZddlm  mZ ddlm	Z	m
Z
mZ ddlmZ ddlmZ ejjZejG dd„ deƒƒZdS )z Test cases for GroupBy.plot é    N)Ú	DataFrameÚIndexÚSeries)ÚTestPlotBasec                   @   sx   e Zd Zdd„ Zdd„ Zdd„ Zdd„ Zd	d
„ Zej	 
dddg¡dd„ ƒZej	 
dddg¡dd„ ƒZdd„ Zdd„ ZdS )ÚTestDataFrameGroupByPlotsc                 C   s¸   d}t tjjdd|d�ƒ}t tjjdd|d�ƒ}t d¡�$ tjjddg|d�}W d   ƒ n1 sd0    Y  | |¡ ¡  t 	¡  | |¡ 
¡  t 	¡  | |¡jd	d
� t 	¡  d S )Né
   é¦   é   )Úsizeé<   é*   ZmaleZfemaleg      à?)Úalpha)r   ÚnpÚrandomÚnormalÚtmZ
RNGContextÚchoiceÚgroupbyÚplotÚcloseÚhist)ÚselfÚnÚweightÚheightZgender© r   úb/home/ja/django-apps/lartica_env/lib/python3.9/site-packages/pandas/tests/plotting/test_groupby.pyÚ,test_series_groupby_plotting_nominally_works   s    2zFTestDataFrameGroupByPlots.test_series_groupby_plotting_nominally_worksc                 C   s`   t g d¢tj d¡dœg d¢d�}| d¡d  ¡  t ¡  | d¡d  dd	„ ¡ t ¡  d S )
N)	é   r   r   é   r   r   é   r    r    é	   )ÚdefÚval)	ç      ð?ç       @ç      @r$   r%   r&   r$   r%   r&   )Úindexr"   r#   c                 S   s   |   ¡ S )N)r   )Úxr   r   r   Ú<lambda>.   ó    zPTestDataFrameGroupByPlots.test_plotting_with_float_index_works.<locals>.<lambda>)	r   r   r   Úrandnr   r   r   r   Úapply©r   Údfr   r   r   Ú$test_plotting_with_float_index_works%   s    þz>TestDataFrameGroupByPlots.test_plotting_with_float_index_worksc                 C   sp   t  ddd¡}tddgddgddgd	œƒ}|d
 j|d |d� tdgdgdgd	œƒ}|d
 j|d |d� d S )NéP   éf   r   ZAAAZBBBr   éU   éY   )ÚNameÚByColÚMarkr6   r5   )ZbyÚbins)r   Zaranger   r   )r   r7   r.   r   r   r   Útest_hist_single_row1   s
    z.TestDataFrameGroupByPlots.test_hist_single_rowc                 C   sX   t g d¢g d¢tdƒdœƒ}| d¡j dd¡ t ¡  | d¡d j ¡  t ¡  d S )N©r   r   r    é   é   ©r   r   r    r   r   Úababa©r(   ÚyÚzr@   r(   r?   )r   Úlistr   r   Úscatterr   r   Úliner-   r   r   r   Útest_plot_submethod_works9   s
    z3TestDataFrameGroupByPlots.test_plot_submethod_worksc                 C   sx   t g d¢g d¢tdƒdœƒ}| d¡jdddd	�}t|d
 jƒdksHJ ‚| d¡jjddd�}t|d
 jƒdkstJ ‚d S )Nr9   r<   r=   r>   r@   rB   r(   r?   )Úkindr(   r?   Úar   )r(   r?   )r   rA   r   r   ÚlenÚcollectionsrB   )r   r.   Úresr   r   r   Útest_plot_kwargs@   s
    z*TestDataFrameGroupByPlots.test_plot_kwargszcolumn, expected_axes_num)Nr   )Úbr   c                 C   s¦   d|f}|pdgdgg}t ddg ddg  dd�}ttj d	d
¡|ddgd�}| d¡}|jd|d�D ]8}| j|||d� t|d |ƒD ]\}	}
|  	|	|
¡ qŠqhd S )Nr   rF   rK   é   Ú1Ú2Úc©Únameé   r   ©r'   ÚcolumnsT)ÚlegendÚcolumn©Zaxes_numZlayoutr   )
r   r   r   r   r+   r   r   Ú_check_axes_shapeÚzipÚ_check_legend_labels)r   rV   Zexpected_axes_numZexpected_layoutZexpected_labelsr'   r.   ÚgZaxesÚaxZexpected_labelr   r   r   Ú#test_groupby_hist_frame_with_legendL   s    
ÿz=TestDataFrameGroupByPlots.test_groupby_hist_frame_with_legendrV   NrK   c                 C   s„   t ddg ddg  dd�}ttj dd¡|dd	gd
�}| d¡}tjtdd��  |j	d|dd� W d   ƒ n1 sv0    Y  d S )NrL   rM   rN   rO   rP   rR   r   rF   rK   rS   ú Cannot use both legend and label©ÚmatchTÚd)rU   rV   Úlabel©
r   r   r   r   r+   r   ÚpytestZraisesÚ
ValueErrorr   )r   rV   r'   r.   r[   r   r   r   Ú*test_groupby_hist_frame_with_legend_raises]   s
    
zDTestDataFrameGroupByPlots.test_groupby_hist_frame_with_legend_raisesc                 C   s|   t ddg ddg  dd�}ttj dd¡|dd	gd
�}| d¡}|d jdd�D ]$}| j|ddd� |  |ddg¡ qRd S )NrL   rM   rN   rO   rP   rR   r   rF   rK   rS   T)rU   r   )r   r   rW   )	r   r   r   r   r+   r   r   rX   rZ   )r   r'   r.   r[   r\   r   r   r   Ú$test_groupby_hist_series_with_legendg   s    
z>TestDataFrameGroupByPlots.test_groupby_hist_series_with_legendc                 C   s‚   t ddg ddg  dd�}ttj dd¡|dd	gd
�}| d¡}tjtdd�� |j	ddd� W d   ƒ n1 st0    Y  d S )NrL   rM   rN   rO   rP   rR   r   rF   rK   rS   r^   r_   Tra   )rU   rb   rc   )r   r'   r.   r[   r   r   r   Ú+test_groupby_hist_series_with_legend_raisesq   s
    
zETestDataFrameGroupByPlots.test_groupby_hist_series_with_legend_raises)Ú__name__Ú
__module__Ú__qualname__r   r/   r8   rD   rJ   rd   ÚmarkZparametrizer]   rf   rg   rh   r   r   r   r   r      s   

	
r   )Ú__doc__Únumpyr   rd   Zpandas.util._test_decoratorsÚutilZ_test_decoratorsÚtdZpandasr   r   r   Zpandas._testingZ_testingr   Zpandas.tests.plotting.commonr   rl   ZslowZ
pytestmarkZskip_if_no_mplr   r   r   r   r   Ú<module>   s   