o
    Û­jg  ã                   @   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_labelsÚ
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/html/CropPilot/venv/lib/python3.10/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/   r0   r1   r/   r0   r1   ©Ú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.   r2   r,   r-   c                 S   s   |   ¡ S )N)r   )Úxr   r   r   Ú<lambda>>   s    zVTestDataFrameGroupByPlots.test_plotting_with_float_index_works_apply.<locals>.<lambda>)r   r   r   r   r4   r   Úapplyr5   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 )NéP   éf   r(   ÚAAAÚBBBr
   éU   éY   ©ÚNameÚByColÚMarkrE   rD   ©ÚbyÚbins©r   Úaranger   r!   ©r   rH   r6   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@   rB   rE   rD   rF   rI   rK   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©r8   ÚyÚzrU   r8   rT   )r   Úlistr   r   Úscatterr5   r   r   r   Útest_plot_submethod_worksL   ó   z3TestDataFrameGroupByPlots.test_plot_submethod_worksc                 C   s4   t g d¢g d¢tdƒdœƒ}| d¡d j ¡  d S )NrN   rQ   rR   rS   rU   r8   )r   rV   r   r   Úliner5   r   r   r   Útest_plot_submethod_works_lineP   rY   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s$J ‚d S )NrN   rQ   rR   rS   rU   rW   r8   rT   )Úkindr8   rT   Úar(   )r   rV   r   r   ÚlenÚcollections©r   r6   Ú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s$J ‚d S )NrN   rQ   rR   rS   rU   r8   rT   )r8   rT   r]   r(   )r   rV   r   r   rW   r^   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 ]}t|||d� t	|d |ƒD ]	\}	}
t
|	|
ƒ qFq6d S )Nr(   r]   rd   é   Ú1Ú2Úc©Únamer
   ©é   r
   ©r3   ÚcolumnsT)ÚlegendÚcolumn©Úaxes_numÚlayoutr   )r   r   r   r   r   r4   r   r!   r   Úzipr   )r   rp   Úexpected_axes_numÚexpected_layoutÚexpected_labelsr3   r6   ÚgÚaxesÚaxÚexpected_labelr   r   r   Ú#test_groupby_hist_frame_with_legenda   s   ý
ÿþz=TestDataFrameGroupByPlots.test_groupby_hist_frame_with_legendrp   Nrd   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   ƒ d S 1 s>w   Y  d S )Nre   rf   rg   rh   ri   r
   rk   r]   rd   rm   ú Cannot use both legend and label©ÚmatchTÚd)ro   rp   Úlabel©r   r   r   r   r   r4   r   ÚpytestÚraisesÚ
ValueErrorr!   )r   rp   r3   r6   rx   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ƒ q+d S )Nre   rf   rg   rh   ri   r
   rk   r]   rd   rm   T)ro   r(   )r(   r(   rq   )
r   r   r   r   r   r4   r   r!   r   r   )r   r3   r6   rx   rz   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   ƒ d S 1 s=w   Y  d S )Nre   rf   rg   rh   ri   r
   rk   r]   rd   rm   r}   r~   Tr€   )ro   r�   r‚   )r   r3   r6   rx   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&   r7   r;   rL   rM   rX   r[   rb   rc   rƒ   ÚmarkÚparametrizer|   r†   r‡   rˆ   r   r   r   r   r      s$    

r   )Ú__doc__Únumpyr   rƒ   Úpandasr   r   r   Úpandas.tests.plotting.commonr   r   Úimportorskipr   r   r   r   r   Ú<module>   s    
