a
    Pfg                     @   sT   d Z ddlZddlZddlmZmZmZ ddlm	Z	m
Z
 ed G dd dZdS )z Test cases for GroupBy.plot     N)	DataFrameIndexSeries)_check_axes_shape_check_legend_labelsZ
matplotlibc                   @   s   e Z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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   sL   d}t tjdjdd|d}tjdjddg|d}||  d S )N
            sizemalefemaler   nprandomdefault_rngnormalchoicegroupbyplot)selfnweightgender r   [/var/www/ai-form-bot/venv/lib/python3.9/site-packages/pandas/tests/plotting/test_groupby.py,test_series_groupby_plotting_nominally_works   s    zFTestDataFrameGroupByPlots.test_series_groupby_plotting_nominally_worksc                 C   sL   d}t tjdjdd|d}tjdjddg|d}||  d S )Nr   r	   <   r   r   r   )r   r   r   r   r   r   r   histr   r   heightr   r   r   r   1test_series_groupby_plotting_nominally_works_hist   s    zKTestDataFrameGroupByPlots.test_series_groupby_plotting_nominally_works_histc                 C   sP   d}t tjdjdd|d}tjdjddg|d}||jdd d S )	Nr   r	   r   r   r   r   g      ?)alphar   r!   r   r   r   2test_series_groupby_plotting_nominally_works_alpha"   s    zLTestDataFrameGroupByPlots.test_series_groupby_plotting_nominally_works_alphac                 C   s>   t g dtjdddg dd}|dd   d S )	N	   r'   r'   r	   r	   r	      r(   r(   r	   	   defval	      ?       @      @r.   r/   r0   r.   r/   r0   indexr+   r,   )r   r   r   r   standard_normalr   r   r   dfr   r   r   $test_plotting_with_float_index_works)   s    z>TestDataFrameGroupByPlots.test_plotting_with_float_index_worksc                 C   sD   t g dtjdddg dd}|dd d	d
  d S )Nr&   r	   r)   r*   r-   r1   r+   r,   c                 S   s   |   S )N)r   )xr   r   r   <lambda>>       zVTestDataFrameGroupByPlots.test_plotting_with_float_index_works_apply.<locals>.<lambda>)r   r   r   r   r3   r   applyr4   r   r   r   *test_plotting_with_float_index_works_apply5   s    zDTestDataFrameGroupByPlots.test_plotting_with_float_index_works_applyc                 C   sD   t ddd}tddgddgddgd	}|d
 j|d |d d S )NP   f   r'   AAAZBBBr	   U   Y   NameByColMarkrD   rC   Zbybinsr   Zaranger   r    r   rF   r5   r   r   r   test_hist_single_row@   s    z.TestDataFrameGroupByPlots.test_hist_single_rowc                 C   s>   t ddd}tdgdgdgd}|d j|d |d	 d S )
Nr<   r=   r'   r>   r?   rA   rD   rC   rE   rG   rH   r   r   r   !test_hist_single_row_single_bycolF   s    z;TestDataFrameGroupByPlots.test_hist_single_row_single_bycolc                 C   s4   t g dg dtdd}|djdd d S )Nr'   r	   r(         r'   r	   r(   r	   r'   ababar7   yzrR   r7   rQ   )r   listr   r   scatterr4   r   r   r   test_plot_submethod_worksL   s    z3TestDataFrameGroupByPlots.test_plot_submethod_worksc                 C   s4   t g dg dtdd}|dd j  d S )NrK   rN   rO   rP   rR   r7   )r   rS   r   r   liner4   r   r   r   test_plot_submethod_works_lineP   s    z8TestDataFrameGroupByPlots.test_plot_submethod_works_linec                 C   sL   t g dg dtdd}|djdddd	}t|d
 jdksHJ d S )NrK   rN   rO   rP   rR   rT   r7   rQ   )kindr7   rQ   ar'   )r   rS   r   r   lencollectionsr   r5   resr   r   r   test_plot_kwargsT   s    z*TestDataFrameGroupByPlots.test_plot_kwargsc                 C   sL   t g dg dtdd}|djjddd}t|d	 jd
ksHJ d S )NrK   rN   rO   rP   rR   r7   rQ   )r7   rQ   rY   r'   )r   rS   r   r   rT   rZ   r[   r\   r   r   r   test_plot_kwargs_scatter\   s    z2TestDataFrameGroupByPlots.test_plot_kwargs_scatterz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 ]4}t|||d t	|d |D ]\}	}
t
|	|
 qqld S )Nr'   rY   r`      12cnamer	      r	   r2   columnsT)legendcolumnZaxes_numZlayoutr   )r   r   r   r   r   r3   r   r    r   zipr   )r   rl   Zexpected_axes_numZexpected_layoutZexpected_labelsr2   r5   gZaxesaxZexpected_labelr   r   r   #test_groupby_hist_frame_with_legenda   s    
z=TestDataFrameGroupByPlots.test_groupby_hist_frame_with_legendrl   Nr`   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 sz0    Y  d S )Nra   rb   rc   rd   re   r	   rg   rY   r`   ri    Cannot use both legend and labelmatchTd)rk   rl   labelr   r   r   r   r   r3   r   pytestZraises
ValueErrorr    )r   rl   r2   r5   ro   r   r   r   *test_groupby_hist_frame_with_legend_raisest   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 ] }t|ddd t	|ddg qVd S )Nra   rb   rc   rd   re   r	   rg   rY   r`   ri   T)rk   r'   )r'   r'   rm   )
r   r   r   r   r   r3   r   r    r   r   )r   r2   r5   ro   rp   r   r   r   $test_groupby_hist_series_with_legend   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 sx0    Y  d S )Nra   rb   rc   rd   re   r	   rg   rY   r`   ri   rr   rs   Tru   )rk   rv   rw   )r   r2   r5   ro   r   r   r   +test_groupby_hist_series_with_legend_raises   s    
zETestDataFrameGroupByPlots.test_groupby_hist_series_with_legend_raises)__name__
__module____qualname__r   r#   r%   r6   r;   rI   rJ   rU   rW   r^   r_   rx   markZparametrizerq   rz   r{   r|   r   r   r   r   r      s"   

r   )__doc__numpyr   rx   Zpandasr   r   r   Zpandas.tests.plotting.commonr   r   Zimportorskipr   r   r   r   r   <module>   s   
