U
    ÃmœdÒ  ã                   @   st   d dl Zd dlmZmZ d dlmZ d dlZd dlm	Z	m
Z
 zd dlmZ W n ek
r`   Y nX G dd„ dƒZdS )é    N)Úassert_equalÚassert_raises)ÚSeries)Ú_recodeÚinteraction_plotc                   @   s’   e Zd Zedd„ ƒZejjdd„ ƒZejjdd„ ƒZ	ejjej 
ddd	g¡d
d„ ƒƒZejjdd„ ƒZejjdd„ ƒZejjdd„ ƒZdd„ ZdS )ÚTestInteractionPlotc                 C   sR   t j d¡ t jjdddd�| _t jjdddd�| _t  t jjdddd�¡| _d S )Ni90  é   é   é<   )Úsizeé   é   )ÚnpÚrandomÚseedÚrandintÚweightÚdurationÚlogÚdays)Úcls© r   úd/home/sam/Atlas/atlas_env/lib/python3.8/site-packages/statsmodels/graphics/tests/test_factorplots.pyÚsetup_class   s    zTestInteractionPlot.setup_classc                 C   s&   t | j| j| jddgddgdd�}d S )NÚredÚblueÚDú^é
   )ÚcolorsÚmarkersÚms©r   r   r   r   ©ÚselfÚclose_figuresÚfigr   r   r   Útest_plot_both   s
      ÿz"TestInteractionPlot.test_plot_bothc                 C   s    t | j| j| jddgdd�}d S )Nr   r   r   ©r    r!   r"   r#   r   r   r   Útest_plot_rainbow   s     ÿz%TestInteractionPlot.test_plot_rainbowÚastypeÚstrÚintc           	      C   sŠ   t | jdd� |¡}t | jdd�}t | jdd�}t|||ddgdd�}|jd	 }| ¡  ¡  	¡ }t
|dƒ t
| ¡ d
ƒ t
| ¡ dƒ d S )NZWeight)ÚnameZDurationZDaysr   r   r   r(   r   zmean of Days)r   r   r*   r   r   r   ZaxesZ
get_legendZ	get_titleZget_textr   Z
get_ylabelZ
get_xlabel)	r$   r*   r%   r   r   r   r&   ZaxÚtracer   r   r   Útest_plot_pandas!   s     ÿ

z$TestInteractionPlot.test_plot_pandasc                 C   s6   t | j| j| jddgddgd�}tt|tjƒdƒ d S )NÚrÚgú--ú-.)r   Ú
linestylesT)r   r   r   r   r   Ú
isinstanceÚpltÚFigurer#   r   r   r   Útest_formatting/   s     z#TestInteractionPlot.test_formattingc              	   C   s`   t tt| j| j| jdgd� t tt| j| j| jdddgd� t tt| j| j| jddd	gd
� d S )Nr   )r    Úbr0   r1   )r   r2   r3   ú:)r4   )r   Ú
ValueErrorr   r   r   r   )r$   r%   r   r   r   Útest_formatting_errors4   s     z*TestInteractionPlot.test_formatting_errorsc                 C   sn   t | j| j| jdd�}tt|tjƒdƒ t | j| j| jdd�}tt|tjƒdƒ tt	t | j| j| jdd� d S )NÚline)ZplottypeTZscatterÚunknown)
r   r   r   r   r   r5   r6   r7   r   r;   r#   r   r   r   Útest_plottype:   s
    z!TestInteractionPlot.test_plottypec                 C   sJ   t ddgd t ddd¡dd�}t|dd	d
œƒ}t|jj|jjdd� d S )NÚar9   r   r   é(   é   Z
index_test)Úindexr-   r   )r@   r9   z_recode changed the index)Úerr_msg)r   r   Zaranger   r   rC   Úvalues)r$   ZseriesZseries_r   r   r   Útest_recode_seriesB   s    ÿÿz&TestInteractionPlot.test_recode_seriesN)Ú__name__Ú
__module__Ú__qualname__Úclassmethodr   ÚpytestÚmarkZ
matplotlibr'   r)   Zparametrizer/   r8   r<   r?   rF   r   r   r   r   r      s    





r   )Únumpyr   Znumpy.testingr   r   Zpandasr   rK   Z statsmodels.graphics.factorplotsr   r   Zmatplotlib.pyplotZpyplotr6   ÚImportErrorr   r   r   r   r   Ú<module>   s   