o
    5ce0                     @   s   d dl Z d dlZd dlZd dlm  mZ d dlm	Z	 d dl
mZ d dlmZmZ ejdd ZejG dd deZejG dd	 d	eZdS )
    N)	DataFrame)TestPlotBase_check_plot_worksc                  C   sV   t jd tt jddddgd} t jg dd| d< t jg dd| d	< | S )
Nr         ABcolumnsabcCD)nprandomseedr   randnchoice)df r   b/var/www/html/gps/gps/lib/python3.10/site-packages/pandas/tests/plotting/frame/test_hist_box_by.pyhist_df   s
   r   c                   @   sp  e Zd Zejjejdddg ddggd fdddgg dddggd fddg dddggd fddgdg d	dggd
 fddgddgg d	ddggd
 fddgdg d	ddggd
 fgdd Zejdddg ddggd fddg dddggd fddgdg d	dggd
 fgdd Zejdg dgfg ddgfddddgfgdd Z	ejje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d Z
ejd d!ddgd"fed#dd$fd%gd&d' Zejjd(d) Zejjd*d+ Zejd,d-d.gd/d0 ZdS )1TestHistWithByzby, column, titles, legendsr   r   r      r   Nr   	z(a, a)z(a, b)z(a, c)z(b, a)z(b, b)z(b, c)z(c, a)z(c, b)z(c, c)	   c           	      C   sL   t |jj||dd}dd |D }dd |D }||ksJ ||ks$J d S )NT)columnbydefault_axesc                 S      g | ]}|  qS r   	get_title.0axr   r   r   
<listcomp>Y       z=TestHistWithBy.test_hist_plot_by_argument.<locals>.<listcomp>c                 S       g | ]}d d |  jD qS )c                 S   r!   r   get_textr%   legendr   r   r   r'   [   r(   zHTestHistWithBy.test_hist_plot_by_argument.<locals>.<listcomp>.<listcomp>
get_legendtextsr$   r   r   r   r'   Z       )r   plothist)	selfr   r   titleslegendsr   axesresult_titlesresult_legendsr   r   r   test_hist_plot_by_argument   s   ;z)TestHistWithBy.test_hist_plot_by_argumentr   c           
      C   d   |  }|jddid}t|jjd||d}dd |D }dd |D }	|	|ks*J ||ks0J d S )	Nr   r   r	   Tr    r   r   c                 S   r!   r   r"   r$   r   r   r   r'   ~   r(   z6TestHistWithBy.test_hist_plot_by_0.<locals>.<listcomp>c                 S   r)   )c                 S   r!   r   r*   r,   r   r   r   r'      r(   zATestHistWithBy.test_hist_plot_by_0.<locals>.<listcomp>.<listcomp>r.   r$   r   r   r   r'      r1   )copyrenamer   r2   r3   )
r4   r   r   r5   r6   r   r   r7   r8   r9   r   r   r   test_hist_plot_by_0a   s   z"TestHistWithBy.test_hist_plot_by_0
by, column)r   Nr   c                 C   L   d}t jt|d t|jjd||d W d    d S 1 sw   Y  d S NzNo group keys passedmatchTr<   )pytestraises
ValueErrorr   r2   r3   r4   r   r   r   msgr   r   r   )test_hist_plot_empty_list_string_tuple_by   s   "z8TestHistWithBy.test_hist_plot_empty_list_string_tuple_byby, column, layout, axes_numr   r   )r   r   rL   r   )   r   )r   Nr   rM   r   rN   )r   rM   )r   r   )   r   c                 C   sV   t jtdd t|jj|||d}W d    n1 sw   Y  | j|||d d S )NF)check_stacklevelr   r   layoutaxes_numrR   )tmassert_produces_warningUserWarningr   r2   r3   _check_axes_shaper4   r   r   rR   rT   r   r7   r   r   r   test_hist_plot_layout_with_by   s   z,TestHistWithBy.test_hist_plot_layout_with_bymsg, by, layoutlarger than required sizerM   rM   )Layout must be a tuple of (rows, columns)rM   z1At least one dimension of layout must be positiver   )ra   c                 C   J   t jt|d |jjddg||d W d    d S 1 sw   Y  d S NrC   r   r   rQ   )rE   rF   rG   r2   r3   r4   rI   r   rR   r   r   r   r   ,test_hist_plot_invalid_layout_with_by_raises      "z;TestHistWithBy.test_hist_plot_invalid_layout_with_by_raisesc                 C      |j jdddd\}}}| |||sJ | |||s"J | |||s-J | |||s8J | |||rCJ | |||rNJ | |||rYJ | |||rdJ d S )Nr   r   T)r   r   sharex)r2   r3   
get_x_axisjoined
get_y_axisr4   r   ax1ax2ax3r   r   r   test_axis_share_x_with_by      z(TestHistWithBy.test_axis_share_x_with_byc                 C   rg   )Nr   r   T)r   r   sharey)r2   r3   rk   rj   ri   rl   r   r   r   test_axis_share_y_with_by   rq   z(TestHistWithBy.test_axis_share_y_with_byfigsize         
   c                 C   &   |j jdd|d}| j|d|d d S )Nr   r   r   r   rt   r   rT   rt   )r2   r3   rX   r4   rt   r   r7   r   r   r   test_figure_shape_hist_with_by      z-TestHistWithBy.test_figure_shape_hist_with_by)__name__
__module____qualname__rE   markslowparametrizer:   r?   rJ   rZ   reescapere   rp   rs   r   r   r   r   r   r      s    
8




		


r   c                   @   s  e Zd Ze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 fddgddgddgg dgd fdgd	ddgg dgd fgd
d Ze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 fgdd Zejdg dgfdg d	fdddgfgdd Zejj	e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d Z
ejddddgdfedddfd gd!d" Zejd#d$d%gd&d' Zd	S )(TestBoxWithByzby, column, titles, xticklabelsr   r   r   r   r   r   r   Nc           	      C   sL   t |jjd||d}dd |D }dd |D }||ksJ ||ks$J d S )NTr<   c                 S   r!   r   r"   r$   r   r   r   r'     r(   z;TestBoxWithBy.test_box_plot_by_argument.<locals>.<listcomp>c                 S      g | ]}d d |  D qS )c                 S   r!   r   r*   r%   labelr   r   r   r'     r(   zFTestBoxWithBy.test_box_plot_by_argument.<locals>.<listcomp>.<listcomp>get_xticklabelsr$   r   r   r   r'         )r   r2   box)	r4   r   r   r5   xticklabelsr   r7   r8   result_xticklabelsr   r   r   test_box_plot_by_argument   s   /z'TestBoxWithBy.test_box_plot_by_argumentr   c           
      C   r;   )	Nr   r   r	   Tr<   c                 S   r!   r   r"   r$   r   r   r   r'   C  r(   z4TestBoxWithBy.test_box_plot_by_0.<locals>.<listcomp>c                 S   r   )c                 S   r!   r   r*   r   r   r   r   r'   E  r(   z?TestBoxWithBy.test_box_plot_by_0.<locals>.<listcomp>.<listcomp>r   r$   r   r   r   r'   D  r   )r=   r>   r   r2   r   )
r4   r   r   r5   r   r   r   r7   r8   r   r   r   r   test_box_plot_by_0$  s   z TestBoxWithBy.test_box_plot_by_0r@   )r   r   r   c                 C   rA   rB   )rE   rF   rG   r   r2   r   rH   r   r   r   %test_box_plot_with_none_empty_list_byK  s   "z3TestBoxWithBy.test_box_plot_with_none_empty_list_byrK   r]   rM   )r   r   r]   rM   )r   N)r   rM   r   )rM   r   c                 C   s*   t |jjd|||d}| j|||d d S )NT)r    r   r   rR   rS   )r   r2   r   rX   rY   r   r   r   test_box_plot_layout_with_byZ  s   z*TestBoxWithBy.test_box_plot_layout_with_byr[   r\   r^   r_   r`   c                 C   rb   rc   )rE   rF   rG   r2   r   rd   r   r   r   +test_box_plot_invalid_layout_with_by_raisesm  rf   z9TestBoxWithBy.test_box_plot_invalid_layout_with_by_raisesrt   ru   rx   c                 C   r{   )Nr   r   r|   rM   r}   )r2   r   rX   r~   r   r   r   r   {  r   z,TestBoxWithBy.test_figure_shape_hist_with_by)r   r   r   rE   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r      s    
-


	
r   )r   numpyr   rE   pandas.util._test_decoratorsutil_test_decoratorstdpandasr   pandas._testing_testingrU   pandas.tests.plotting.commonr   r   fixturer   skip_if_no_mplr   r   r   r   r   r   <module>   s    
 O