
    Owgg                     t    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j                  d        G d d      Zy)z Test cases for GroupBy.plot     N)	DataFrameIndexSeries)_check_axes_shape_check_legend_labels
matplotlibc                       e Zd Zd Zd Zd Zd Zd Zd Zd Z	d Z
d	 Zd
 Zd Zej                  j!                  dddg      d        Zej                  j!                  dddg      d        Zd Zd Zy)TestDataFrameGroupByPlotsc                    d}t        t        j                  j                  d      j	                  dd|            }t        j                  j                  d      j                  ddg|      }|j                  |      j                          y )N
            sizemalefemaler   nprandomdefault_rngnormalchoicegroupbyplot)selfnweightgenders       Y/var/www/horilla/myenv/lib/python3.12/site-packages/pandas/tests/plotting/test_groupby.py,test_series_groupby_plotting_nominally_workszFTestDataFrameGroupByPlots.test_series_groupby_plotting_nominally_works   sp    		--a077Ra7HI&&q)00&(1C!0Lv##%    c                    d}t        t        j                  j                  d      j	                  dd|            }t        j                  j                  d      j                  ddg|      }|j                  |      j                          y )Nr   r   <   r   r   r   )r   r   r   r   r   r   r   histr   r   heightr   s       r    1test_series_groupby_plotting_nominally_works_histzKTestDataFrameGroupByPlots.test_series_groupby_plotting_nominally_works_hist   sp    		--a077BQ7GH&&q)00&(1C!0Lv##%r"   c                 "   d}t        t        j                  j                  d      j	                  dd|            }t        j                  j                  d      j                  ddg|      }|j                  |      j                  d       y )	Nr   r   r$   r   r   r   g      ?)alphar   r&   s       r    2test_series_groupby_plotting_nominally_works_alphazLTestDataFrameGroupByPlots.test_series_groupby_plotting_nominally_works_alpha"   su    		--a077BQ7GH&&q)00&(1C!0Lv####.r"   c                     t        g dt        j                  j                  d      j	                  d      dg d      }|j                  d      d   j                          y )	N	   r.   r.   r   r   r      r/   r/   r   	   defval	      ?       @      @r5   r6   r7   r5   r6   r7   indexr2   r3   )r   r   r   r   standard_normalr   r   r   dfs     r    $test_plotting_with_float_index_worksz>TestDataFrameGroupByPlots.test_plotting_with_float_index_works)   sS    2yy,,Q/??B @
 	

5% %%'r"   c                     t        g dt        j                  j                  d      j	                  d      dg d      }|j                  d      d   j                  d	        y )
Nr-   r   r0   r1   r4   r8   r2   r3   c                 "    | j                         S )N)r   )xs    r    <lambda>zVTestDataFrameGroupByPlots.test_plotting_with_float_index_works_apply.<locals>.<lambda>>   s     r"   )r   r   r   r   r:   r   applyr;   s     r    *test_plotting_with_float_index_works_applyzDTestDataFrameGroupByPlots.test_plotting_with_float_index_works_apply5   sV    2yy,,Q/??B @
 	

5% &&'9:r"   c                     t        j                  ddd      }t        ddgddgddgd	      }|d
   j                  |d   |       y )NP   f   r.   AAABBBr   U   Y   NameByColMarkrN   rM   bybinsr   aranger   r%   r   rQ   r<   s      r    test_hist_single_rowz.TestDataFrameGroupByPlots.test_hist_single_row@   sI    yyWa(!Q"bRS
6
2g;T2r"   c                     t        j                  ddd      }t        dgdgdgd      }|d   j                  |d   |	       y )
NrE   rF   r.   rG   rI   rK   rN   rM   rO   rR   rT   s      r    !test_hist_single_row_single_bycolz;TestDataFrameGroupByPlots.test_hist_single_row_single_bycolF   sC    yyWa(1#tDE
6
2g;T2r"   c                     t        g dg dt        d      d      }|j                  d      j                  j	                  dd       y )Nr.   r   r/         r.   r   r/   r   r.   ababar@   yzr`   r@   r_   )r   listr   r   scatterr;   s     r    test_plot_submethod_worksz3TestDataFrameGroupByPlots.test_plot_submethod_worksL   s5    _?gWX


3$$S#.r"   c                     t        g dg dt        d      d      }|j                  d      d   j                  j	                          y )NrY   r\   r]   r^   r`   r@   )r   ra   r   r   liner;   s     r    test_plot_submethod_works_linez8TestDataFrameGroupByPlots.test_plot_submethod_works_lineP   s6    _?gWX


3!!&&(r"   c                     t        g dg dt        d      d      }|j                  d      j                  ddd	      }t	        |d
   j
                        dk(  sJ y )NrY   r\   r]   r^   r`   rb   r@   r_   )kindr@   r_   ar.   )r   ra   r   r   lencollectionsr   r<   ress      r    test_plot_kwargsz*TestDataFrameGroupByPlots.test_plot_kwargsT   sU    _?gWXjjo""	SC"@ 3s8''(A---r"   c                     t        g dg dt        d      d      }|j                  d      j                  j	                  dd      }t        |d	   j                        d
k(  sJ y )NrY   r\   r]   r^   r`   r@   r_   )r@   r_   ri   r.   )r   ra   r   r   rb   rj   rk   rl   s      r    test_plot_kwargs_scatterz2TestDataFrameGroupByPlots.test_plot_kwargs_scatter\   sW    _?gWXjjo""**SC*83s8''(A---r"   zcolumn, expected_axes_num)Nr   )br.   c                 |   d|f}|xs dgdgg}t        ddgz  ddgz  z   d      }t        t        j                  j	                  d	      j                  d
      |ddg      }|j                  d      }|j                  d|      D ]3  }t        |||       t        |d   |      D ]  \  }	}
t        |	|
        5 y )Nr.   ri   rq      12cnamer      r   r9   columnsT)legendcolumnaxes_numlayoutr   )r   r   r   r   r   r:   r   r%   r   zipr   )r   r~   expected_axes_numexpected_layoutexpected_labelsr9   r<   gaxesaxexpected_labels              r    #test_groupby_hist_frame_with_legendz=TestDataFrameGroupByPlots.test_groupby_hist_frame_with_legenda   s     /0 2cUSENbC5j2:-C8II!!!$44W=#J

 JJsOFF$vF6 	9Dd->W&)$q'?&C 9"N$R89	9r"   r~   Nrq   c                 V   t        ddgz  ddgz  z   d      }t        t        j                  j	                  d      j                  d      |dd	g
      }|j                  d      }t        j                  t        d      5  |j                  d|d       d d d        y # 1 sw Y   y xY w)Nrs   rt   ru   rv   rw   r   ry   ri   rq   r{    Cannot use both legend and labelmatchTd)r}   r~   labelr   r   r   r   r   r:   r   pytestraises
ValueErrorr%   )r   r~   r9   r<   r   s        r    *test_groupby_hist_frame_with_legend_raiseszDTestDataFrameGroupByPlots.test_groupby_hist_frame_with_legend_raisest   s     bC5j2:-C8II!!!$44W=#J

 JJsO]]:-OP 	:FF$vSF9	: 	: 	:s   BB(c                 :   t        ddgz  ddgz  z   d      }t        t        j                  j	                  d      j                  d      |dd	g
      }|j                  d      }|d   j                  d      D ]  }t        |dd       t        |ddg         y )Nrs   rt   ru   rv   rw   r   ry   ri   rq   r{   T)r}   r.   )r.   r.   r   )
r   r   r   r   r   r:   r   r%   r   r   )r   r9   r<   r   r   s        r    $test_groupby_hist_series_with_legendz>TestDataFrameGroupByPlots.test_groupby_hist_series_with_legend   s    bC5j2:-C8II!!!$44W=#J

 JJsOC&++T+* 	1Bb1V< c3Z0	1r"   c                 T   t        ddgz  ddgz  z   d      }t        t        j                  j	                  d      j                  d      |dd	g
      }|j                  d      }t        j                  t        d      5  |j                  dd       d d d        y # 1 sw Y   y xY w)Nrs   rt   ru   rv   rw   r   ry   ri   rq   r{   r   r   Tr   )r}   r   r   )r   r9   r<   r   s       r    +test_groupby_hist_series_with_legend_raiseszETestDataFrameGroupByPlots.test_groupby_hist_series_with_legend_raises   s    bC5j2:-C8II!!!$44W=#J

 JJsO]]:-OP 	+FF$cF*	+ 	+ 	+s   BB')__name__
__module____qualname__r!   r(   r+   r=   rC   rU   rW   rc   rf   rn   rp   r   markparametrizer   r   r   r    r"   r    r
   r
      s    &&/
(	;33/)..
 [[89h:OP9 Q9$ [[Xc{3: 4:1+r"   r
   )__doc__numpyr   r   pandasr   r   r   pandas.tests.plotting.commonr   r   importorskipr
   r   r"   r    <module>r      s=    #   

   L !G+ G+r"   