o
    _~#gg                     @   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/static.ux5.de/https/Moving-Object-Detection-with-OpenCV/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/   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 )NP   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    
