U
    f/e^                     @   s   d Z ddlZddlZddlm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jZe	jG dd deZdS )z Test cases for GroupBy.plot     N)is_platform_windows)	DataFrameIndexSeries)TestPlotBasec                   @   s   e Zd Zejje ddd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 )TestDataFrameGroupByPlotsz(Looks like LinePlot._is_ts_plot is wrongF)reasonstrictc              	   C   s   d}t tjjdd|d}t tjjdd|d}td tjjddg|d}W 5 Q R X ||  t	  ||
  t	  ||jd	d
 t	  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-unpacked-wheel-tiezk1ph/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dddddddddddg	d	}|d
d   t  |d
d dd  t  d S )N         	   )defvalg      ?g       @g      @)indexr$   r%   c                 S   s   |   S )N)r   )xr   r   r   <lambda>4       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    ZAAAZBBBr!   U   Y   )NameByColMarkr5   r4   )Zbybins)r   Zaranger   r   )r   r6   r-   r   r   r   test_hist_single_row7   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}|djd	d
 t  |dd	 j  t  d S )Nr    r!   r"         ababar'   yzr=   r'   r<   )r   listr   r   scatterr   r   liner,   r   r   r   test_plot_submethod_works?   s
    (z3TestDataFrameGroupByPlots.test_plot_submethod_worksc                 C   s   t dddddgdddddgtdd}|djd	d
dd}t|d jdksTt|djjd
dd}t|d jdkstd S )Nr    r!   r"   r8   r9   r:   r;   r=   r?   r'   r<   )kindr'   r<   a)r'   r<   )r   r>   r   r   lencollectionsAssertionErrorr?   )r   r-   resr   r   r   test_plot_kwargsF   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 ]8}| j|||d t|d |D ]\}	}
| 	|	|
 qqhd S )Nr    rC   rI      12cname   r!   r&   columnsT)legendcolumnZaxes_numZlayoutr   )
r   r   r   r   r*   r   r   _check_axes_shapezip_check_legend_labels)r   rT   Zexpected_axes_numZexpected_layoutZexpected_labelsr&   r-   gZaxesaxZexpected_labelr   r   r   #test_groupby_hist_frame_with_legendR   s    
  z=TestDataFrameGroupByPlots.test_groupby_hist_frame_with_legendrT   NrI   c              	   C   sp   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 5 Q R X d S )NrJ   rK   rL   rM   rN   rP   r!   rC   rI   rQ    Cannot use both legend and labelmatchTd)rS   rT   label
r   r   r   r   r*   r   pytestZraises
ValueErrorr   )r   rT   r&   r-   rY   r   r   r   *test_groupby_hist_frame_with_legend_raisesc   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 qRd S )NrJ   rK   rL   rM   rN   rP   r!   rC   rI   rQ   T)rS   r    )r    r    rU   )	r   r   r   r   r*   r   r   rV   rX   )r   r&   r-   rY   rZ   r   r   r   $test_groupby_hist_series_with_legendm   s    
z>TestDataFrameGroupByPlots.test_groupby_hist_series_with_legendc              	   C   sn   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 5 Q R X d S )NrJ   rK   rL   rM   rN   rP   r!   rC   rI   rQ   r\   r]   Tr_   )rS   r`   ra   )r   r&   r-   rY   r   r   r   +test_groupby_hist_series_with_legend_raisesw   s
    
zETestDataFrameGroupByPlots.test_groupby_hist_series_with_legend_raises)__name__
__module____qualname__rb   markZxfailr   r   r.   r7   rA   rH   Zparametrizer[   rd   re   rf   r   r   r   r   r      s    


	
r   )__doc__Znumpyr   rb   Zpandas.compatr   Zpandas.util._test_decoratorsutilZ_test_decoratorstdZpandasr   r   r   Zpandas._testingZ_testingr   Zpandas.tests.plotting.commonr   rj   ZslowZ
pytestmarkZskip_if_no_mplr   r   r   r   r   <module>   s   