o
    Ehg                     @   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   Blib/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   Z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      ?)Z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*   r.   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   r0   r   Zapplyr1   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Markr?   r>   Zbybinsr   Zaranger   r   r   rA   r2   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 )
Nr7   r8   r$   r9   r:   r<   r?   r>   r@   rB   rC   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r4   yzrM   r4   rL   )r   listr   r   scatterr1   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 )NrF   rI   rJ   rK   rM   r4   )r   rN   r   r   liner1   r   r   r   test_plot_submethod_works_lineP   rQ   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 )NrF   rI   rJ   rK   rM   rO   r4   rL   )kindr4   rL   ar$   )r   rN   r   r   lencollectionsr   r2   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 )NrF   rI   rJ   rK   rM   r4   rL   )r4   rL   rU   r$   )r   rN   r   r   rO   rV   rW   rX   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$   rU   r\      12cnamer	      r	   r/   columnsT)legendcolumnZaxes_numZlayoutr   )r   r   r   r   r   r0   r   r   r   zipr   )r   rh   Zexpected_axes_numZexpected_layoutZexpected_labelsr/   r2   gZaxesaxZexpected_labelr   r   r   #test_groupby_hist_frame_with_legenda   s   
z=TestDataFrameGroupByPlots.test_groupby_hist_frame_with_legendrh   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 )Nr]   r^   r_   r`   ra   r	   rc   rU   r\   re    Cannot use both legend and labelmatchTd)rg   rh   labelr   r   r   r   r   r0   r   pytestZraises
ValueErrorr   )r   rh   r/   r2   rk   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 )Nr]   r^   r_   r`   ra   r	   rc   rU   r\   re   T)rg   r$   )r$   r$   ri   )
r   r   r   r   r   r0   r   r   r   r   )r   r/   r2   rk   rl   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 )Nr]   r^   r_   r`   ra   r	   rc   rU   r\   re   rn   ro   Trq   )rg   rr   rs   )r   r/   r2   rk   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"   r3   r6   rD   rE   rP   rS   rZ   r[   rt   ZmarkZparametrizerm   rv   rw   rx   r   r   r   r   r      s$    

r   )__doc__Znumpyr   rt   Zpandasr   r   r   Zpandas.tests.plotting.commonr   r   Zimportorskipr   r   r   r   r   <module>   s    
