U
    f/e                     @   sj   d dl Z d dlZd dlZd dlZd dlmZ d dlZd dlm	Z	m
Z
mZmZ d dlmZ G dd dZdS )    N)
skip_if_no)	DataFrameIndexSeries
date_rangec                   @   s0  e Zd Zdd Zdd Zejde	de
dededdd	gd
 ededededededededdgedd edD ejeddejeddd
dgdgdd Zdd Zdd Zdd Zdd Zdd  Zd!d" Zd#d$ Zd%d& Z d'd( Z!e"d)d*d+ Z#d,S )-TestSeriesMiscc                 C   s  t td}dt|kstdt|ks,tdt|ks<tt tddd}dt|ks\tdt|ksltdt|ks|tt tdd	d
}dt|kstdt|kstdt|kstt tdddd	}dt|kstdt|kstdt|kstd S )NZabcdstrdtcatz1/1/2015   ZperiodsZabbcdcategorydtype)r   listdirAssertionErrorr   astypeselfs r   @/tmp/pip-unpacked-wheel-tiezk1ph/pandas/tests/series/test_api.pytest_tab_completion   s     z"TestSeriesMisc.test_tab_completionc                 C   sT   ddddddddd	d
dg}dd }t tdd}||}t|tt| d S )N
categoriescodesZorderedZset_categoriesZadd_categoriesZremove_categoriesZrename_categoriesZreorder_categoriesZremove_unused_categoriesZ
as_orderedZas_unorderedc                 S   s    dd | j  D }tt|S )Nc                 S   s   g | ]}| d s|qS )_)
startswith).0rr   r   r   
<listcomp>@   s     
 zXTestSeriesMisc.test_tab_completion_with_categorical.<locals>.get_dir.<locals>.<listcomp>)r
   __dir__sortedset)r   resultsr   r   r   get_dir?   s    zDTestSeriesMisc.test_tab_completion_with_categorical.<locals>.get_dirZaabbcder   )r   r   r   tmassert_almost_equalr"   r#   )r   Z
ok_for_catr%   r   r$   r   r   r   $test_tab_completion_with_categorical/   s     z3TestSeriesMisc.test_tab_completion_with_categoricalindex
   ZfoobarZbaz   TFc                 C   s   g | ]}d | qS )ar   )r   ir   r   r   r    V   s     zTestSeriesMisc.<listcomp>e   ABCDZEFGHr         c                 C   sh   t |td}t|}t|jjddD ]<\}}|dk rVt|trb| rb||ksbt	q&||ks&t	q&d S )Nr)   r   r   )leveld   )
r   objectr   	enumerater)   unique
isinstancer   isidentifierr   )r   r)   r   Zdir_sr.   xr   r   r   test_index_tab_completionG   s     z(TestSeriesMisc.test_index_tab_completionc              	   C   s`   t td}t dg}d}tjt|d t| W 5 Q R X tjt|d t| W 5 Q R X d S )Nr   r1   zunhashable type: 'Series'match)r   r6   pytestraises	TypeErrorhash)r   s_emptyr   msgr   r   r   test_not_hashablee   s    

z TestSeriesMisc.test_not_hashablec                 C   s   t |j| d S N)r&   Zassert_contains_allr)   )r   Zdatetime_seriesr   r   r   test_containsn   s    zTestSeriesMisc.test_containsc              	   C   s:   t tjd}d}tjt|d |  W 5 Q R X d S )Nr*   z''Series' object has no attribute 'info'r=   )r   nprandomrandnr?   r@   AttributeErrorinfo)r   r   rD   r   r   r   test_raise_on_infoq   s    z!TestSeriesMisc.test_raise_on_infoc                 C   sj   t ddtjg}t|jdd|jdd | ddksBt|ddksTt|	ddksftd S )Nr1   r,   Zrows)Zaxisr)   r2   r   )
r   rH   nanr&   assert_series_equalZdropnasumr   Z_get_axis_numberZ_get_axis_namer   r   r   r   test_axis_aliasw   s
    zTestSeriesMisc.test_axis_aliasc                 C   s   t tjstd S rF   )pydocgetdocr   r)   r   )r   r   r   r   test_class_axis~   s    zTestSeriesMisc.test_class_axisc                 C   s   t tjdddddgtdddd}d	d
 }||}| }t|| t	tjd}t	t
|}t	dtddd}t|| t	tjd}t|jdd|jjdd d S )Ni  r2   ABCz1/1/2000r   )columnsr)   c                 S   s   | |    S rF   )Zidxmax)r;   r   r   r   f   s    z-TestSeriesMisc.test_ndarray_compat.<locals>.fr*   r1   Zfloat64r3   F)order)r   rH   rI   rJ   r   applymaxr&   rO   r   Z	ones_likeranger'   Zravelvalues)r   ZtsdfrY   resultexpectedr   r   r   r   test_ndarray_compat   s    

z"TestSeriesMisc.test_ndarray_compatc                 C   sD   t td}|jstt dgtd}t dg|fD ]}|jr0tq0d S )Nr   r1   r3   )r   r6   emptyr   )r   rC   s2Zfull_seriesr   r   r   test_empty_method   s
    

z TestSeriesMisc.test_empty_methodc                 C   s<   t td}|jdkstt tddd}|jdks8td S )N	   ZInt64r   )r   r^   sizer   r   r   r   r   test_integer_series_size   s    z'TestSeriesMisc.test_integer_series_sizec                 C   sF   t ddgdd}|ji kstd|jd< |d }|jddiksBtd S )Nr   r1   abc)nameversion)r   attrsr   )r   r   r`   r   r   r   
test_attrs   s
    
zTestSeriesMisc.test_attrsZjinja2c              	   C   s.   t td}td  t| W 5 Q R X d S )Nr   )r   r6   r&   Zassert_produces_warninginspect
getmembers)r   Zserr   r   r   test_inspect_getmembers   s    
z&TestSeriesMisc.test_inspect_getmembersN)$__name__
__module____qualname__r   r(   r?   markZparametrizer&   ZmakeUnicodeIndexZmakeStringIndexZmakeCategoricalIndexr   ZmakeDateIndexZmakePeriodIndexZmakeTimedeltaIndexZmakeIntIndexZmakeUIntIndexZmakeFloatIndexr^   pdZ
MultiIndexfrom_tupleszipr<   rE   rG   rM   rQ   rT   rb   re   rh   rm   r   rp   r   r   r   r   r      sB   


	r   )rn   rR   ZnumpyrH   r?   Zpandas.util._test_decoratorsr   Zpandasru   r   r   r   r   Zpandas._testingZ_testingr&   r   r   r   r   r   <module>   s   