
    h*                         d dl Z d dlZd dlZd dlmZ d dlmZ d dl	m
Z
mZmZmZ  ej                  d       ej                  d        Z G d d      Z G d d	      Zy)
    N)	DataFrame)_check_axes_shape_check_plot_works
get_x_axis
get_y_axis
matplotlibc                  L   t        t        j                  j                  d      j	                  d      ddg      } t        j                  j                  d      j                  g dd      | d<   t        j                  j                  d      j                  g dd      | d	<   | S )
N   )   r
   ABcolumnsabcr   CD)r   nprandomdefault_rngstandard_normalchoice)dfs    QD:\jyotish\venv\Lib\site-packages\pandas/tests/plotting/frame/test_hist_box_by.pyhist_dfr      s    	
		a 009C:
B ii##A&--orBBsGii##A&--orBBsGI    c                   T   e Zd Zej                  j
                  ej                  j                  dddg ddggdz  fdddgg dddggdz  fddg dddggdz  fddgdg d	dggdz  fddgddgg d	ddggdz  fddgdg d	ddggdz  fg      d
               Zej                  j                  dddg ddggdz  fddg dddggdz  fddgdg d	dggdz  fg      d        Zej                  j                  dg dgfg ddgfddddgfg      d        Z	ej                  j
                  ej                  j                  ddgdddfddgdgddfddddgddfddgdddfddgdddfddgdgddfddgddgddfddgdddfddgddgddfg      d               Z
ej                  j                  ddddgdf ej                  d      ddfd g      d!        Zej                  j
                  d"        Zej                  j
                  d#        Zej                  j                  d$d%d&g      d'        Zy)(TestHistWithByzby, column, titles, legendsr   r   r      r   Nr   z(a, a)z(b, b)z(c, c)c           	      J   t        |j                  j                  ||d      }|D cg c]  }|j                          }}|D 	cg c]8  }|j	                         j
                  D 	cg c]  }	|	j                          c}	: }
}}	|
|k(  sJ ||k(  sJ y c c}w c c}	w c c}	}w )NT)columnbydefault_axes)r   plothist	get_title
get_legendtextsget_text)selfr%   r$   titleslegendsr   axesaxresult_titleslegendresult_legendss              r   test_hist_plot_by_argumentz)TestHistWithBy.test_hist_plot_by_argument   s    R !LLf$
 377$B$7NR
NRR]]_-B-BC-B6V__-BCd 	 
 (((&&& 8C
s   B!B'B>BBr   c           	         |j                         }|j                  ddi      }t        |j                  j                  d||      }|D cg c]  }|j                          }	}|D 
cg c]8  }|j                         j                  D 
cg c]  }
|
j                          c}
: }}}
||k(  sJ |	|k(  sJ y c c}w c c}
w c c}
}w Nr   r   r   Tr&   r$   r%   )	copyrenamer   r'   r(   r)   r*   r+   r,   )r-   r%   r$   r.   r/   r   r   r0   r1   r2   r3   r4   s               r   test_hist_plot_by_0z"TestHistWithBy.test_hist_plot_by_0Q   s    & \\^YYQxY( DTVW267$B$7NR
NRR]]_-B-BC-B6V__-BCd 	 
 (((&&& 8C
s   B9*!CB>"C>C
by, column) Nr=   c                     d}t        j                  t        |      5  t        |j                  j
                  d||       d d d        y # 1 sw Y   y xY wNzNo group keys passedmatchTr8   )pytestraises
ValueErrorr   r'   r(   r-   r%   r$   r   msgs        r   )test_hist_plot_empty_list_string_tuple_byz8TestHistWithBy.test_hist_plot_empty_list_string_tuple_byp   s>     %]]:S1!!V 211   $AAby, column, layout, axes_numr
   r
   )r   r   rJ   r!   )   r!   )r   Nr!   rK   r!   rL   )	   rK   )r!   r!   )   r
   c                     t        j                  t        d      5  t        |j                  j
                  |||      }d d d        t        ||       y # 1 sw Y   xY w)NF)check_stacklevelr$   r%   layoutaxes_numrR   )tmassert_produces_warningUserWarningr   r'   r(   r   r-   r%   r$   rR   rT   r   r0   s          r   test_hist_plot_layout_with_byz,TestHistWithBy.test_hist_plot_layout_with_by   sO    ( ''eL$!!&RD M 	$&A	 MLs   $AA msg, by, layoutlarger than required sizerK   rK   )Layout must be a tuple of (rows, columns)rK   z1At least one dimension of layout must be positiver   )r`   c                     t        j                  t        |      5  |j                  j	                  ddg||       d d d        y # 1 sw Y   y xY wNr@   r   r   rQ   )rB   rC   rD   r'   r(   r-   rF   r%   rR   r   s        r   ,test_hist_plot_invalid_layout_with_by_raisesz;TestHistWithBy.test_hist_plot_invalid_layout_with_by_raises   s;     ]]:S1LLc3ZBvF 211   !AAc                    |j                   j                  ddd      \  }}}t        |      j                  ||      sJ t        |      j                  ||      sJ t        |      j                  ||      sJ t        |      j                  ||      sJ t	        |      j                  ||      rJ t	        |      j                  ||      rJ t	        |      j                  ||      rJ t	        |      j                  ||      rJ y )Nr   r   T)r$   r%   sharex)r'   r(   r   joinedr   r-   r   ax1ax2ax3s        r   test_axis_share_x_with_byz(TestHistWithBy.test_axis_share_x_with_by         ))T)JS# #%%c3///#%%c3///#%%c3///#%%c3/// c?))#s333c?))#s333c?))#s333c?))#s3333r   c                    |j                   j                  ddd      \  }}}t        |      j                  ||      sJ t        |      j                  ||      sJ t        |      j                  ||      sJ t        |      j                  ||      sJ t	        |      j                  ||      rJ t	        |      j                  ||      rJ t	        |      j                  ||      rJ t	        |      j                  ||      rJ y )Nr   r   T)r$   r%   sharey)r'   r(   r   rh   r   ri   s        r   test_axis_share_y_with_byz(TestHistWithBy.test_axis_share_y_with_by   rn   r   figsize         
   c                 \    |j                   j                  dd|      }t        |d|       y )Nr   r   r$   r%   rr   r!   rT   rr   )r'   r(   r   r-   rr   r   r0   s       r   test_figure_shape_hist_with_byz-TestHistWithBy.test_figure_shape_hist_with_by   s+     ||  W E$G<r   )__name__
__module____qualname__rB   markslowparametrizer5   r;   rG   rY   reescaperd   rm   rq   r}   r=   r   r   r    r       sT   [[[[%##!43*oc
|a/?@$3*)9:c

 !	 c
c

 sq 	 c

 sq 	1"	
%L'M% N' [[%_ugk2oc
|a'78C
 !		
"'#"' [[#K#s#s		
 [[[[&UC#!USE61%"3*fa(3Zfa(3Zfa(3Z#*3Z#sVQ/3Zvq)3Z#sVQ/	
 B! "B [[(3*f=RYYBCS$OP	
GG [[4 4  [[4 4  [[Y((;<= ==r   r    c                   *   e Zd Zej                  j                  ddddgg dgfddgddgg dgfdddgddgg dgdz  fddgddgddgg dgdz  fdgd	ddgg dgdz  fg      d
        Zej                  j                  ddddgg dgfddgddgg dgfdd	ddgg dgdz  fg      d        Zej                  j                  dg dgfdg d	fdddgfg      d        Zej                  j                  ej                  j                  ddgdddfdddddgddfddgdddfddgd	ddfg      d               Z
ej                  j                  ddddgdf ej                  d      ddfdg      d        Zej                  j                  ddd g      d!        Zy	)"TestBoxWithByzby, column, titles, xticklabelsr   r   r   r   r"   r   r
   Nc           	      6   t        |j                  j                  d||      }|D cg c]  }|j                          }}|D 	cg c].  }|j	                         D 	cg c]  }	|	j                          c}	0 }
}}	|
|k(  sJ ||k(  sJ y c c}w c c}	w c c}	}w )NTr8   )r   r'   boxr)   get_xticklabelsr,   )r-   r%   r$   r.   xticklabelsr   r0   r1   r2   labelresult_xticklabelss              r   test_box_plot_by_argumentz'TestBoxWithBy.test_box_plot_by_argument   s    F !LL42
 377$B$7KO
KOR2+=+=+?@+?%U^^+?@4 	 
 "[000&&& 8@
s   BBB4BBr   c           	      ~   |j                         }|j                  ddi      }t        |j                  j                  d||      }|D cg c]  }|j                          }	}|D 
cg c].  }|j                         D 
cg c]  }
|
j                          c}
0 }}}
||k(  sJ |	|k(  sJ y c c}w c c}
w c c}
}w r7   )r9   r:   r   r'   r   r)   r   r,   )r-   r%   r$   r.   r   r   r   r0   r1   r2   r   r   s               r   test_box_plot_by_0z TestBoxWithBy.test_box_plot_by_0  s    * \\^YYQxY( 4SUV267$B$7KO
KOR2+=+=+?@+?%U^^+?@4 	 
 "[000&&& 8@
s   B/*B9B4B94B9r<   )r=   r   r=   c                     d}t        j                  t        |      5  t        |j                  j
                  d||       d d d        y # 1 sw Y   y xY wr?   )rB   rC   rD   r   r'   r   rE   s        r   %test_box_plot_with_none_empty_list_byz3TestBoxWithBy.test_box_plot_with_none_empty_list_by"  s<     %]]:S1gll..T&UWX 211rH   rI   r\   rK   )r   r   r\   rK   )r   N)r
   rK   r
   )rK   r
   c                 h    t        |j                  j                  d|||      }t        |||       y )NT)r&   r$   r%   rR   rS   )r   r'   r   r   rX   s          r   test_box_plot_layout_with_byz*TestBoxWithBy.test_box_plot_layout_with_by1  s1     !LL42f
 	$&Ar   rZ   r[   r]   r^   r_   c                     t        j                  t        |      5  |j                  j	                  ddg||       d d d        y # 1 sw Y   y xY wrb   )rB   rC   rD   r'   r   rc   s        r   +test_box_plot_invalid_layout_with_by_raisesz9TestBoxWithBy.test_box_plot_invalid_layout_with_by_raisesD  s;     ]]:S1LLS#J2fE 211re   rr   rs   rv   c                 \    |j                   j                  dd|      }t        |d|       y )Nr   r   rz   rK   r{   )r'   r   r   r|   s       r   r}   z,TestBoxWithBy.test_figure_shape_hist_with_byR  s+     ||ssGD$G<r   )r~   r   r   rB   r   r   r   r   r   r   r   r   r   r   r}   r=   r   r   r   r      s   [[)#u/0c
	 3*sCj?*;a*?@c
c
c
 	 UD3*&7!&;<9	
 B'C B' [[)cU_-.C	 sCj?"3a"78	
&''&' [[#KJ#s		
YY [[[[&UC#!"3*fa(3Zfa(3Zvq)	

B
 B [[(3*f=RYYBCS$OP	
FF [[Y((;<= ==r   r   )r   numpyr   rB   pandasr   pandas._testing_testingrU   pandas.tests.plotting.commonr   r   r   r   importorskipfixturer   r    r   r=   r   r   <module>r      sa    	        L !  s= s=lD= D=r   