a
    dg                     @   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nZweightgender r   k/var/www/html/stable-diffusion-webui/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.   r/   r-   r.   r/   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,   r0   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   r2   r   applyr3   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   r4   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r6   yzrQ   r6   rP   )r   listr   r   scatterr3   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 )NrJ   rM   rN   rO   rQ   r6   )r   rR   r   r   liner3   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 )NrJ   rM   rN   rO   rQ   rS   r6   rP   )kindr6   rP   ar&   )r   rR   r   r   lencollectionsr   r4   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 )NrJ   rM   rN   rO   rQ   r6   rP   )r6   rP   rX   r&   )r   rR   r   r   rS   rY   rZ   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&   rX   r_      12cnamer	      r	   r1   columnsT)legendcolumnZaxes_numZlayoutr   )r   r   r   r   r   r2   r   r   r   zipr   )r   rk   Zexpected_axes_numZexpected_layoutZexpected_labelsr1   r4   gZaxesaxZexpected_labelr   r   r   #test_groupby_hist_frame_with_legenda   s    
z=TestDataFrameGroupByPlots.test_groupby_hist_frame_with_legendrk   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 )Nr`   ra   rb   rc   rd   r	   rf   rX   r_   rh    Cannot use both legend and labelmatchTd)rj   rk   labelr   r   r   r   r   r2   r   pytestZraises
ValueErrorr   )r   rk   r1   r4   rn   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 )Nr`   ra   rb   rc   rd   r	   rf   rX   r_   rh   T)rj   r&   )r&   r&   rl   )
r   r   r   r   r   r2   r   r   r   r   )r   r1   r4   rn   ro   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 )Nr`   ra   rb   rc   rd   r	   rf   rX   r_   rh   rq   rr   Trt   )rj   ru   rv   )r   r1   r4   rn   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$   r5   r:   rH   rI   rT   rV   r]   r^   rw   markZparametrizerp   ry   rz   r{   r   r   r   r   r      s"   

r   )__doc__numpyr   rw   Zpandasr   r   r   Zpandas.tests.plotting.commonr   r   Zimportorskipr   r   r   r   r   <module>   s   
