
    dn                         d Z ddlZddlZddlmc mZ ddlm	Z	m
Z
mZ ddlmZ ddlmZ ej         G d de                      ZdS )z Test cases for GroupBy.plot     N)	DataFrameIndexSeries)TestPlotBasec                       e Zd Zd Zd Zd Zd Zd Zej	        
                    dddg          d	             Zej	        
                    d
ddg          d             Zd Zd ZdS )TestDataFrameGroupByPlotsc                    d}t          t          j                            dd|                    }t          t          j                            dd|                    }t          j                            d                              ddg|          }|                    |                                           t          j	                     |                    |          
                                 t          j	                     |                    |                              d	
           t          j	                     d S )N
         )size<   *   malefemaleg      ?)alpha)r   nprandomnormalRandomStatechoicegroupbyplottmclosehist)selfnweightheightgenders        ^/var/www/html/t/fyr/venv311/lib/python3.11/site-packages/pandas/tests/plotting/test_groupby.py,test_series_groupby_plotting_nominally_workszFTestDataFrameGroupByPlots.test_series_groupby_plotting_nominally_works   s    	((bq(99::	((Ra(8899&&r**11682D11MMv##%%%



v##%%%



v####...





    c                 t   t          g dt          j                            d          dg d          }|                    d          d                                          t          j                     |                    d          d                             d            t          j                     d S )	N)	   r&   r&      r'   r'      r(   r(   	   )defval)	      ?       @      @r,   r-   r.   r,   r-   r.   )indexr*   r+   c                 *    |                                  S )N)r   )xs    r"   <lambda>zPTestDataFrameGroupByPlots.test_plotting_with_float_index_works.<locals>.<lambda>+   s     r$   )	r   r   r   randnr   r   r   r   applyr   dfs     r"   $test_plotting_with_float_index_worksz>TestDataFrameGroupByPlots.test_plotting_with_float_index_works"   s    ///	8J8JKK???
 
 

 	

5% %%'''






5% &&'9'9:::





r$   c                    t          j        ddd          }t          ddgddgddgd	          }|d
                             |d         |           t          dgdgdgd	          }|d
                             |d         |           d S )NP   f   r&   AAABBBr'   U   Y   )NameByColMarkrA   r@   )bybins)r   aranger   r   )r   rC   r6   s      r"   test_hist_single_rowz.TestDataFrameGroupByPlots.test_hist_single_row.   s    yWa((!Q"bRRSS
6
2g;T2221#tDDEE
6
2g;T22222r$   c                 Z   t          g dg dt          d          d          }|                    d          j                            dd           t          j                     |                    d          d         j                                         t          j                     d S )Nr&   r'   r(         r&   r'   r(   r'   r&   ababar1   yzrN   r1   rM   )r   listr   r   scatterr   r   liner5   s     r"   test_plot_submethod_worksz3TestDataFrameGroupByPlots.test_plot_submethod_works6   s    ___???gWWXX


3$$S#...






3!&&(((





r$   c                    t          g dg dt          d          d          }|                    d                              ddd	          }t	          |d
         j                  dk    sJ |                    d          j                            dd          }t	          |d
         j                  dk    sJ d S )NrG   rJ   rK   rL   rN   rP   r1   rM   )kindr1   rM   ar&   )r1   rM   )r   rO   r   r   lencollectionsrP   )r   r6   ress      r"   test_plot_kwargsz*TestDataFrameGroupByPlots.test_plot_kwargs=   s    ___???gWWXXjjoo""	SC"@@ 3s8'((A----jjoo"**SC*883s8'((A------r$   zcolumn, expected_axes_num)Nr'   )br&   c                    d|f}|pdgdgg}t          ddgz  ddgz  z   d          }t          t          j                            d	d
          |ddg          }|                    d          }|                    d|          D ]L}|                     |||           t          |d         |          D ]\  }	}
| 	                    |	|
           Md S )Nr&   rU   rZ      12cname   r'   r/   columnsT)legendcolumnaxes_numlayoutr   )
r   r   r   r   r3   r   r   _check_axes_shapezip_check_legend_labels)r   rf   expected_axes_numexpected_layoutexpected_labelsr/   r6   gaxesaxexpected_labels              r"   #test_groupby_hist_frame_with_legendz=TestDataFrameGroupByPlots.test_groupby_hist_frame_with_legendH   s    /0 2cUSENbC5j2:-C888ryr1--US#JOOOJJsOOFF$vF66 	> 	>D""0 #    '*$q'?&C&C > >"N))"n====>		> 	>r$   rf   NrZ   c                 d   t          ddgz  ddgz  z   d          }t          t          j                            dd          |dd	g
          }|                    d          }t          j        t          d          5  |	                    d|d           d d d            d S # 1 swxY w Y   d S )Nr\   r]   r^   r_   r`   rb   r'   rU   rZ   rc    Cannot use both legend and labelmatchTd)re   rf   label
r   r   r   r   r3   r   pytestraises
ValueErrorr   )r   rf   r/   r6   rp   s        r"   *test_groupby_hist_frame_with_legend_raiseszDTestDataFrameGroupByPlots.test_groupby_hist_frame_with_legend_raisesY   s     bC5j2:-C888ryr1--US#JOOOJJsOO]:-OPPP 	: 	:FF$vSF999	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	:s   ?B%%B),B)c                 j   t          ddgz  ddgz  z   d          }t          t          j                            dd          |dd	g
          }|                    d          }|d                             d          D ]2}|                     |dd           |                     |ddg           3d S )Nr\   r]   r^   r_   r`   rb   r'   rU   rZ   rc   T)re   r&   )r&   r&   rg   )	r   r   r   r   r3   r   r   rj   rl   )r   r/   r6   rp   rr   s        r"   $test_groupby_hist_series_with_legendz>TestDataFrameGroupByPlots.test_groupby_hist_series_with_legendc   s    bC5j2:-C888ryr1--US#JOOOJJsOOC&++T+** 	6 	6B""2&"AAA%%b3*5555	6 	6r$   c                 b   t          ddgz  ddgz  z   d          }t          t          j                            dd          |dd	g
          }|                    d          }t          j        t          d          5  |	                    dd           d d d            d S # 1 swxY w Y   d S )Nr\   r]   r^   r_   r`   rb   r'   rU   rZ   rc   rv   rw   Try   )re   rz   r{   )r   r/   r6   rp   s       r"   +test_groupby_hist_series_with_legend_raiseszETestDataFrameGroupByPlots.test_groupby_hist_series_with_legend_raisesm   s    bC5j2:-C888ryr1--US#JOOOJJsOO]:-OPPP 	+ 	+FF$cF***	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+s   ?B$$B(+B()__name__
__module____qualname__r#   r7   rE   rR   rY   r|   markparametrizert   r   r   r    r$   r"   r   r      s          
 
 
3 3 3  	. 	. 	. [89h:OPP> > QP>  [Xc{33: : 43:6 6 6+ + + + +r$   r   )__doc__numpyr   r|   pandas.util._test_decoratorsutil_test_decoratorstdpandasr   r   r   pandas._testing_testingr   pandas.tests.plotting.commonr   skip_if_no_mplr   r   r$   r"   <module>r      s    # #      ) ) ) ) ) ) ) ) )         
       5 5 5 5 5 5 a+ a+ a+ a+ a+ a+ a+ a+ a+ a+r$   