B
    0ufN.                 @   s  d Z ddlZddlZddlZddlmZ ddlm	Z	 ddl
mZ ddlmZ ddlmZ G dd dZG dd	 d	ZG d
d dZe	je	je	jgZdddgZG dd dZG dd dZdd ZG dd dZG dd dZG dd dZej !dedgddd Z"d d! Z#d"d# Z$dS )$z#Catch all for categorical functions    N)MatplotlibDeprecationWarning)Axes)check_figures_equalc            	   @   s   e Zd Zddgdgffddgdgffdddd	d
dgdddddgffgZee \ZZejj	deeddd Z
dd ZddejfdddgfdddgfgZee \ZZejj	deeddd Zejj	deeddd  Zd!S )"TestUnitDatasinglezhello worldr   unicodeu   Здравствуйте мирmixedAznp.nanBz3.14u   мир            z
data, locs)idsc             C   s:   t |}t|j |ks tt|j |ks6td S )N)catUnitDatalist_mappingkeysAssertionErrorvalues)selfdatalocsunit r   `/home/ankuromar296_gmail_com/myenv/lib/python3.7/site-packages/matplotlib/tests/test_category.py	test_unit   s    
zTestUnitData.test_unitc             C   s   ddg}ddg}dddg}ddddg}ddddg}t |}t|j |ksRtt|j |ksht|| t|j |kstt|j |kstd S )	Nadr   r   ber   r   )r   r   r   r   r   r   r   update)r   r   r   Zdata_updateZunique_dataZupdated_locsr   r   r   r   test_update   s    


zTestUnitData.test_update)numbergQ	@nanr   gQ	@   z
mixed typefdatac          	   C   s$   t t t| W d Q R X d S )N)pytestraises	TypeErrorr   r   )r   r'   r   r   r   test_non_string_fails/   s    z"TestUnitData.test_non_string_failsc          	   C   s,   t  }tt || W d Q R X d S )N)r   r   r(   r)   r*   r"   )r   r'   Zunitdatar   r   r   test_non_string_update_fails4   s    z)TestUnitData.test_non_string_update_failsN)__name__
__module____qualname__
test_caseszipr   r   r(   markparametrizer   r#   npr%   failing_test_casesfidsr'   r+   r,   r   r   r   r   r      s   
r   c               @   s   e Zd Zdd ZdS )FakeAxisc             C   s
   || _ d S )N)units)r   r8   r   r   r   __init__<   s    zFakeAxis.__init__N)r-   r.   r/   r9   r   r   r   r   r7   ;   s   r7   c               @   s2  e Zd ZdZddgfddgfdddd	gfd
ddgfdddddddddddddddddddd d!d"d#d$d%d&d'gfgZee \ZZd(d)dej	gfd*d+d,gfgZ
ee
 \ZZejd-d.d/d0 Zejjd1eed2d3d4 Zejjd5d6d7gddgd2d8d9 Zd:d; Zd<d= Zejjd>eed2d?d@ ZdAdB ZdCdD ZdES )FTestStrCategoryConverterz
    Based on the pandas conversion and factorization tests:

    ref: /pandas/tseries/tests/test_converter.py
         /pandas/tests/test_algos.py:TestFactorize
    r   u   Здравствуйте мирasciizhello worldr   r   r    czinteger string12zsingle + values>10r	   r
   CDEFGHIJKLMNOPQRSTUVWXYZr   gQ	@zstring integer42*   T)Zautousec             C   s$   t  | _t  | _t| j| _d S )N)r   ZStrCategoryConverterccr   r   r7   ax)r   requestr   r   r   	mock_axisW   s    

z"TestStrCategoryConverter.mock_axisvals)r   c             C   s,   t j| j|| jj| jtt| d S )N)	r4   testingassert_allcloserY   convertrZ   r8   rangelen)r   r]   r   r   r   test_convert^   s    z%TestStrCategoryConverter.test_convertvaluehiu   мирc             C   s    | j || j| jdkstd S )Nr   )rY   r`   r   rZ   r   )r   rd   r   r   r   test_convert_one_stringd   s    z0TestStrCategoryConverter.test_convert_one_stringc          	   C   sD   t t | jd| j| j}W d Q R X tj	|t
dg d S )Ng        )r(   warnsr   rY   r`   r   rZ   r4   r^   r_   array)r   actualr   r   r   test_convert_one_numberh   s    z0TestStrCategoryConverter.test_convert_one_numberc          	   C   s\   t jdddgtd}tt | j|| j| j	}W d Q R X t j
|t dddg d S )Nr   r   r   )Zdtypeg      ?g       @g      @)r4   rh   floatr(   rg   r   rY   r`   r   rZ   r^   r_   )r   r   ri   r   r   r   test_convert_float_arraym   s    z1TestStrCategoryConverter.test_convert_float_arrayfvalsc          	   C   s.   t t | j|| j| j W d Q R X d S )N)r(   r)   r*   rY   r`   r   rZ   )r   rm   r   r   r   test_convert_fails   s    z*TestStrCategoryConverter.test_convert_failc             C   s:   | j | j| j}t|jtjs$tt|j	tj
s6td S )N)rY   Zaxisinfor   rZ   
isinstanceZmajlocr   StrCategoryLocatorr   ZmajfmtStrCategoryFormatter)r   axisr   r   r   test_axisinfox   s    z&TestStrCategoryConverter.test_axisinfoc             C   s"   t | jdg| jtjstd S )Nr   )ro   rY   Zdefault_unitsrZ   r   r   r   )r   r   r   r   test_default_units}   s    z+TestStrCategoryConverter.test_default_unitsN)r-   r.   r/   __doc__r0   r1   r   r   r4   infr5   r6   fvaluesr(   fixturer\   r2   r3   rc   rf   rj   rl   rn   rs   rt   r   r   r   r   r:   @   s*   
"r:   scatterplotbarc               @   s.   e Zd Zdd Zejjdeeddd Z	dS )TestStrCategoryLocatorc             C   sT   ddddddddd	d
dg}t dd |D }t |j}tj|d d | d S )Nr   r   r   r   r               	   
   c             S   s   g | ]}t |qS r   )str).0jr   r   r   
<listcomp>   s    zBTestStrCategoryLocator.test_StrCategoryLocator.<locals>.<listcomp>)r   r   rp   r   r4   r^   assert_array_equalZtick_values)r   r   r   ticksr   r   r   test_StrCategoryLocator   s    z.TestStrCategoryLocator.test_StrCategoryLocatorplotter)r   c             C   sB   t   }||dddgdddg tj|jj t	d d S )Nr   r   r   r   r    r<   )
pltfiguresubplotsr4   r^   r   yaxismajorlocatorra   )r   r   rZ   r   r   r   test_StrCategoryLocatorPlot   s    z2TestStrCategoryLocator.test_StrCategoryLocatorPlotN)
r-   r.   r/   r   r(   r2   r3   	PLOT_LISTPLOT_IDSr   r   r   r   r   r|      s   r|   c               @   sx   e Zd ZddddgfdddgfgZee \ZZejj	deed	d
d Z
ejj	deed	ejj	deed	dd ZdS )TestStrCategoryFormatterr;   helloworldre   r   u   Здравствуйтеu   приветydata)r   c             C   sT   t |}t |j}x8t|D ],\}}||||ks:t||d |ks tq W d S )N)r   r   rq   r   	enumerater   )r   r   r   labelsir   r   r   r   test_StrCategoryFormatter   s
    
z2TestStrCategoryFormatter.test_StrCategoryFormatterr   c             C   sj   t   }||tt|| x*t|D ]\}}|jj||ks*t	q*W |jj|d dksft	d S )Nr    )
r   r   r   ra   rb   r   r   r   	formatterr   )r   r   r   rZ   r   r   r   r   r   test_StrCategoryFormatterPlot   s
    z6TestStrCategoryFormatter.test_StrCategoryFormatterPlotN)r-   r.   r/   r0   r1   r   Zcasesr(   r2   r3   r   r   r   r   r   r   r   r   r      s   r   c                s   t tt|}tj  |  fdd|D }|dd |D ksJtt  jj	
 dd |D ksltt  jj	 |kstd S )Nc                s   g | ]} j ||qS r   )r   r   )r   r   )rr   r   r   r      s    zaxis_test.<locals>.<listcomp>c             S   s   g | ]}t j|qS r   )r   rq   _text)r   lr   r   r   r      s    c             S   s   g | ]}|qS r   r   )r   r   r   r   r   r      s    )r   ra   rb   r4   r^   r   Zget_majorticklocsr   r8   r   r   r   )rr   r   r   Zgraph_labelsr   )rr   r   	axis_test   s    "r   c               @   sr   e Zd Zddddgfddddgfd	edddgfgZee \ZZe	j
jd
eede	j
jdeeddd ZdS )TestPlotByteszstring listr   r    r<   z
bytes list   a   b   czbytes ndarrayr   )r   bdatac             C   s8   t   }tdddg}|||| t|j| d S )Nr   r~   r}   )r   r   r   r4   rh   r   xaxis)r   r   r   rZ   countsr   r   r   test_plot_bytes   s    zTestPlotBytes.test_plot_bytesN)r-   r.   r/   r4   rh   Zbytes_casesr1   Z	bytes_ids
bytes_datar(   r2   r3   r   r   r   r   r   r   r   r      s   r   c            	   @   s   e Zd Zddddgfdedddgfdddd	gfd
eddd	gfgZee \ZZe	j
jdeede	j
jdeeddd ZdS )TestPlotNumlikezstring listr=   Z113zstring ndarrayz
bytes list   1s   11   3zbytes ndarrayr   )r   ndatac             C   s8   t   }tdddg}|||| t|j| d S )Nr   r~   r}   )r   r   r   r4   rh   r   r   )r   r   r   rZ   r   r   r   r   test_plot_numlike   s    z!TestPlotNumlike.test_plot_numlikeN)r-   r.   r/   r4   rh   Znumlike_casesr1   Znumlike_idsZnumlike_datar(   r2   r3   r   r   r   r   r   r   r   r      s   r   c               @   sh  e Zd Zejjdeeddd Zej	dd Z
ejdejjdeeddd	 Zejdejjdeedd
d Zejdejjdeeddd Zejjdeeddd ZdddgfdddgfdddgfddejgfgZee \ZZejejejejejjdgZejdeejjdeeddd Zejdeejjdeeddd  Zd!S )"TestPlotTypesr   )r   c             C   s4   t   }ddg}|||ddg t|j| d S )Nu   Здравствуйтеu   приветr   r   )r   r   r   r   r   )r   r   rZ   wordsr   r   r   test_plot_unicode   s    zTestPlotTypes.test_plot_unicodec             C   s4   dddg| _ dddg| _ddd	g| _dd
dg| _d S )Nr   Zhappyr   r   r~   r   PythonisZfunr   r}   )xxyyyx)r   r   r   r   	test_data   s    zTestPlotTypes.test_datar   c             C   s.   t   }||| j| j t|j| j d S )N)r   r   r   r   r   r   r   )r   r   r   rZ   r   r   r   test_plot_xaxis   s    zTestPlotTypes.test_plot_xaxisc             C   s.   t   }||| j| j t|j| j d S )N)r   r   r   r   r   r   r   )r   r   r   rZ   r   r   r   test_plot_yaxis   s    zTestPlotTypes.test_plot_yaxisc             C   s<   t   }||| j| j t|j| j t|j| j d S )N)r   r   r   r   r   r   r   r   )r   r   r   rZ   r   r   r   test_plot_xyaxis   s    zTestPlotTypes.test_plot_xyaxisc             C   s   t   }||ddgddg ||dddgdddg ||dddgdddg t|jddddg t|jddddddg d S )Nr   r    r!   gr   fr<   )r   r   r   r   r   r   )r   r   rZ   r   r   r   test_update_plot   s    zTestPlotTypes.test_update_plotr   r	   gQ	@znumber integerr=   r   zstring integerrW   rX   missingZ12)Zmarksxdatac          	   C   s6   t   }tt |||ddg W d Q R X d S )Nr   r   )r   r   r   r(   r)   r*   )r   r   r   rZ   r   r   r   test_mixed_type_exception  s    z'TestPlotTypes.test_mixed_type_exceptionc          	   C   sJ   t   }tt* ||ddgddg |||ddg W d Q R X d S )Nr   r   r   r   )r   r   r   r(   r)   r*   )r   r   r   rZ   r   r   r    test_mixed_type_update_exception  s    z.TestPlotTypes.test_mixed_type_update_exceptionN)r-   r.   r/   r(   r2   r3   r   r   r   rx   r   Zusefixturesr   r   r   r   r4   r%   r5   r1   r6   rw   r   ry   r{   paramrz   ZxfailZplottersr   r   r   r   r   r   r      s(   


	


r   defaultZpng)
extensionsc             C   s   ddl m } |ddd}|ddd}|ddd}|ddd}|  }| }xt||gi td d dfD ]h\}	}
|	j||gd	d
gf|
 |	jj}|	jj}|	j||gd	d
gf|
 ||	jjkst||	jjkshtqhW d S )Nr   )datetimei  r   r   r   r   )ZxunitsZyunitsZV1ZV2)	r   r   r1   dictrz   r   r8   r   r   )Zfig_testZfig_refr   t0t1t2t3Zax_testZax_refrZ   kwargsZx_unitsZy_unitsr   r   r   test_overriding_units_in_plot  s    
r   c              C   s,   t  \} }|jddg |g g  dS )zQ
    Smoke test to check that no deprecation warning is emitted. See #22640.
    r   r    N)r   r   r   Zupdate_unitsrz   )r   rZ   r   r   r   !test_no_deprecation_on_empty_data6  s    r   c              C   sZ   t  \} }|dddddg\}}}|jdks4ttj|ddddddddddg
 d S )	Nr   r    r<   ff)r   g       @g        g      ?)r   r   histshaper   r4   r^   r_   )ZfigrZ   nZbinsZpatchesr   r   r   	test_hist?  s    r   )%ru   r(   numpyr4   Z
matplotlibZmplZmatplotlib._apir   Zmatplotlib.axesr   Zmatplotlib.pyplotZpyplotr   Zmatplotlib.categorycategoryr   Zmatplotlib.testing.decoratorsr   r   r7   r:   ry   rz   r{   r   r   r|   r   r   r   r   r   stylecontextr   r   r   r   r   r   r   <module>   s.   .A

H
	