o
    թZhg                     @   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   Y/var/www/html/lang_env/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.   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>>   s    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MarkrC   rB   Zbybinsr   Zaranger   r    r   rE   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>   r@   rC   rB   rD   rF   rG   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zrQ   r7   rP   )r   listr   r   scatterr4   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 )NrJ   rM   rN   rO   rQ   r7   )r   rR   r   r   liner4   r   r   r   test_plot_submethod_works_lineP   rU   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 )NrJ   rM   rN   rO   rQ   rS   r7   rP   )kindr7   rP   ar'   )r   rR   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s$J d S )NrJ   rM   rN   rO   rQ   r7   rP   )r7   rP   rY   r'   )r   rR   r   r   rS   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 ]}t|||d t	|d |D ]	\}	}
t
|	|
 qFq6d 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    d S 1 s>w   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 q+d 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    d S 1 s=w   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:   rH   rI   rT   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    
