3
®ybr  ã               @   sd   d Z ddlZddlZddljjZddlm	Z	m
Z
mZ ddlj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	j
dddgƒdd„ ƒZej	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ƒ� tjjddg|d�}W d Q R X |j|ƒjƒ  tj	ƒ  |j|ƒj
ƒ  tj	ƒ  |j|ƒjd	d
� tj	ƒ  d S )Né
   é¦   é   )Úsizeé<   é*   ZmaleZfemaleg      à?)Úalpha)r   ÚnpÚrandomÚnormalÚtmZ
RNGContextÚchoiceÚgroupbyÚplotÚcloseÚhist)ÚselfÚnZweightÚheightZgender© r   úF/tmp/pip-install-4cy230dp/pandas/pandas/tests/plotting/test_groupby.pyÚ,test_series_groupby_plotting_nominally_works   s    zFTestDataFrameGroupByPlots.test_series_groupby_plotting_nominally_worksc             C   s|   t dddddddddg	tjjdƒdœdddddddddg	d	�}|jd
ƒd jƒ  tjƒ  |jd
ƒd jdd„ ƒ tjƒ  d S )Né   é   é   é	   )ÚdefÚvalg      ð?g       @g      @)Úindexr!   r"   c             S   s   | j ƒ 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 j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 )NéP   éd   r   r   ZAAAZBBBéU   éY   )ÚNameÚByColÚMarkr0   r/   )ZbyÚbinséf   )r   Zaranger   r   )r   r1   r(   r   r   r   Útest_hist_single_row+   s
    z.TestDataFrameGroupByPlots.test_hist_single_rowc             C   sd   t dddddgdddddgtdƒdœƒ}|jdƒjjd	d
ƒ tjƒ  |jdƒd	 jjƒ  tjƒ  d S )Nr   r   r   é   é   Úababa)r$   ÚyÚzr8   r$   r7   )r   Úlistr   r   Úscatterr   r   Úline)r   r(   r   r   r   Útest_plot_submethod_works3   s
    (z3TestDataFrameGroupByPlots.test_plot_submethod_worksc             C   s„   t dddddgdddddgtdƒdœƒ}|jdƒjd	d
dd�}t|d jƒdksTt‚|jdƒjjd
dd�}t|d jƒdks€t‚d S )Nr   r   r   r4   r5   r6   )r$   r7   r8   r8   r:   r$   r7   )Úkindr$   r7   Úa)r$   r7   )r   r9   r   r   ÚlenÚcollectionsÚAssertionErrorr:   )r   r(   Úresr   r   r   Útest_plot_kwargs:   s
    (z*TestDataFrameGroupByPlots.test_plot_kwargszcolumn, expected_axes_numNr   Úbr   c             C   s®   d|f}|pdgdgg}t ddg ddg  dd�}ttjjd	d
ƒ|ddgd�}|jdƒ}xN|jd|d�D ]<}| j|||d� x&t|d |ƒD ]\}	}
| j	|	|
ƒ qŽW qjW d S )Nr   r>   rD   é   Ú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   rM   Zexpected_axes_numZexpected_layoutZexpected_labelsr#   r(   ÚgZaxesÚaxZexpected_labelr   r   r   Ú#test_groupby_hist_frame_with_legendF   s    
z=TestDataFrameGroupByPlots.test_groupby_hist_frame_with_legendrM   c             C   sp   t ddg ddg  dd�}ttjjddƒ|dd	gd
�}|jdƒ}tjtdd�� |j	d|dd� W d Q R X d S )NrE   rF   rG   rH   )rI   rJ   r   r>   rD   )r#   rK   z Cannot use both legend and label)ÚmatchTÚd)rL   rM   Úlabel)
r   r   r   r   r&   r   ÚpytestÚraisesÚ
ValueErrorr   )r   rM   r#   r(   rS   r   r   r   Ú*test_groupby_hist_frame_with_legend_raisesW   s
    
zDTestDataFrameGroupByPlots.test_groupby_hist_frame_with_legend_raisesc             C   s€   t ddg ddg  dd�}ttjjddƒ|dd	gd
�}|jdƒ}x8|d jdd�D ]$}| j|ddd� | j|ddgƒ qTW d S )NrE   rF   rG   rH   )rI   rJ   r   r>   rD   )r#   rK   T)rL   r   )rN   rO   )r   r   )	r   r   r   r   r&   r   r   rP   rR   )r   r#   r(   rS   rT   r   r   r   Ú$test_groupby_hist_series_with_legenda   s    
z>TestDataFrameGroupByPlots.test_groupby_hist_series_with_legendc             C   sn   t ddg ddg  dd�}ttjjddƒ|dd	gd
�}|jdƒ}tjtdd�� |j	ddd� W d Q R X d S )NrE   rF   rG   rH   )rI   rJ   r   r>   rD   )r#   rK   z Cannot use both legend and label)rV   TrW   )rL   rX   )
r   r   r   r   r&   r   rY   rZ   r[   r   )r   r#   r(   rS   r   r   r   Ú+test_groupby_hist_series_with_legend_raisesk   s
    
zETestDataFrameGroupByPlots.test_groupby_hist_series_with_legend_raises)Nr   )rD   r   )Ú__name__Ú
__module__Ú__qualname__r   r)   r3   r<   rC   rY   ÚmarkZparametrizerU   r\   r]   r^   r   r   r   r   r      s   

r   )Ú__doc__Znumpyr   rY   Zpandas.util._test_decoratorsÚutilZ_test_decoratorsÚtdZpandasr   r   r   Zpandas._testingZ_testingr   Zpandas.tests.plotting.commonr   Zskip_if_no_mplr   r   r   r   r   Ú<module>   s   
