o
    dn                     @   sl   d Z ddlZddlZddlm  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 deZdS )z Test cases for GroupBy.plot     N)	DataFrameIndexSeries)TestPlotBasec                   @   sx   e Z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   s   d}t tjjdd|d}t tjjdd|d}tjdjddg|d}||  t	  ||
  t	  ||jd	d
 t	  d S )N
         )size<   *   malefemaleg      ?)alpha)r   nprandomnormalRandomStatechoicegroupbyplottmclosehist)selfnweightheightgender r   g/var/www/html/visualizacion-main/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   s`   t g dtjddg dd}|dd   t  |dd dd	  t  d S )
N)	   r"   r"      r#   r#      r$   r$   	   )defval)	      ?       @      @r(   r)   r*   r(   r)   r*   )indexr&   r'   c                 S   s   |   S )N)r   )xr   r   r    <lambda>+   s    zPTestDataFrameGroupByPlots.test_plotting_with_float_index_works.<locals>.<lambda>)	r   r   r   randnr   r   r   r   applyr   dfr   r   r    $test_plotting_with_float_index_works"   s   z>TestDataFrameGroupByPlots.test_plotting_with_float_index_worksc                 C   sp   t ddd}tddgddgddgd	}|d
 j|d |d tdgdgdgd	}|d
 j|d |d d S )NP   f   r"   AAABBBr#   U   Y   )NameByColMarkr;   r:   )bybins)r   aranger   r   )r   r=   r1   r   r   r    test_hist_single_row.   s
   z.TestDataFrameGroupByPlots.test_hist_single_rowc                 C   sX   t g dg dtdd}|djdd t  |dd j  t  d S )Nr"   r#   r$         r"   r#   r$   r#   r"   ababar,   yzrG   r,   rF   )r   listr   r   scatterr   r   liner0   r   r   r    test_plot_submethod_works6   s
   z3TestDataFrameGroupByPlots.test_plot_submethod_worksc                 C   sx   t g dg dtdd}|djdddd	}t|d
 jdks$J |djjddd}t|d
 jdks:J d S )Nr@   rC   rD   rE   rG   rI   r,   rF   )kindr,   rF   ar"   )r,   rF   )r   rH   r   r   lencollectionsrI   )r   r1   resr   r   r    test_plot_kwargs=   s
   z*TestDataFrameGroupByPlots.test_plot_kwargsz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 ]}| j|||d t|d |D ]
\}	}
| 	|	|
 qEq4d S )Nr"   rM   rR      12cname   r#   r+   columnsT)legendcolumnaxes_numlayoutr   )
r   r   r   r   r.   r   r   _check_axes_shapezip_check_legend_labels)r   r]   expected_axes_numexpected_layoutexpected_labelsr+   r1   gaxesaxexpected_labelr   r   r    #test_groupby_hist_frame_with_legendH   s   
z=TestDataFrameGroupByPlots.test_groupby_hist_frame_with_legendr]   NrR   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 )NrS   rT   rU   rV   rW   rY   r#   rM   rR   rZ    Cannot use both legend and labelmatchTd)r\   r]   label
r   r   r   r   r.   r   pytestraises
ValueErrorr   )r   r]   r+   r1   rg   r   r   r    *test_groupby_hist_frame_with_legend_raisesY   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 ]}| j|ddd | |ddg q)d S )NrS   rT   rU   rV   rW   rY   r#   rM   rR   rZ   T)r\   r"   )r"   r"   r^   )	r   r   r   r   r.   r   r   ra   rc   )r   r+   r1   rg   ri   r   r   r    $test_groupby_hist_series_with_legendc   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 )NrS   rT   rU   rV   rW   rY   r#   rM   rR   rZ   rl   rm   Tro   )r\   rp   rq   )r   r+   r1   rg   r   r   r    +test_groupby_hist_series_with_legend_raisesm   s   
"zETestDataFrameGroupByPlots.test_groupby_hist_series_with_legend_raises)__name__
__module____qualname__r!   r2   r?   rK   rQ   rr   markparametrizerk   ru   rv   rw   r   r   r   r    r      s    

	
r   )__doc__numpyr   rr   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   r    <module>   s    