a
    nÝEb  ã                   @   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                   @   sÆ  e Zd Zdd„ Zdd„ Zdd„ Zdd„ Zd	d
„ Zej	 
de d¡e d¡e d¡eg d¢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g d¢dƒ¡g¡dd„ ƒZej	 
deed�edgƒ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%ej	 
d,d-eg¡d.d/„ ƒZ&ej	 
d,d0d1g¡d2d3„ ƒZ'd4d5„ Z(e)d6ƒd7d8„ ƒZ*d9d:„ Z+ej	 
d;g d<¢¡d=d>„ ƒZ,d?d@„ Z-dAdB„ Z.d0S )CÚTestSeriesMiscc                 C   s@   t tdƒƒ}dt|ƒv sJ ‚dt|ƒvs,J ‚dt|ƒvs<J ‚d S )NÚabcdÚstrÚdtÚcat©r   ÚlistÚdir©ÚselfÚs© r   ú\/home/ja/django-apps/lartica_env/lib/python3.9/site-packages/pandas/tests/series/test_api.pyÚtest_tab_completion   s    z"TestSeriesMisc.test_tab_completionc                 C   sD   t tddd�ƒ}dt|ƒv s J ‚dt|ƒvs0J ‚dt|ƒvs@J ‚d S )Nú1/1/2015é   ©Úperiodsr
   r	   r   )r   r   r   r   r   r   r   Útest_tab_completion_dt   s    z%TestSeriesMisc.test_tab_completion_dtc                 C   sD   t tdƒdd�}dt|ƒv s J ‚dt|ƒv s0J ‚dt|ƒvs@J ‚d S )NZabbcdÚcategory©Údtyper   r	   r
   r   r   r   r   r   Útest_tab_completion_cat#   s    z&TestSeriesMisc.test_tab_completion_catc                 C   sJ   t tddd�ƒ d¡}dt|ƒv s&J ‚dt|ƒvs6J ‚dt|ƒv sFJ ‚d S )Nr   r   r   r   r   r	   r
   )r   r   Úastyper   r   r   r   r   Útest_tab_completion_cat_str+   s    z*TestSeriesMisc.test_tab_completion_cat_strc                 C   sJ   g d¢}t tdƒƒ d¡}tdd„ |j ¡ 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_unorderedZaabbcder   c                 S   s   h | ]}|  d ¡s|’qS )Ú_)Ú
startswith)Ú.0Úrr   r   r   Ú	<setcomp>C   ó    zFTestSeriesMisc.test_tab_completion_with_categorical.<locals>.<setcomp>)	r   r   r   Úsortedr   Ú__dir__ÚtmÚassert_almost_equalÚset)r   Z
ok_for_catr   Úresultsr   r   r   Ú$test_tab_completion_with_categorical2   s    z3TestSeriesMisc.test_tab_completion_with_categoricalÚindexé
   )ÚfooÚbarZbazé   TFc                 C   s   g | ]}d |› �‘qS )Úar   )r$   Úir   r   r   Ú
<listcomp>U   r'   zTestSeriesMisc.<listcomp>ée   ÚABCDZEFGH)r   é   r3   é   c                 C   sh   t |td�}t|ƒ}t|jjdd�ƒD ]<\}}|dk rVt|tƒrb| ¡ rb||v sbJ ‚q&||vs&J ‚q&d S )N©r/   r   r   )Úleveléd   )	r   Úobjectr   Ú	enumerater/   ÚuniqueÚ
isinstancer	   Úisidentifier)r   r/   r   Zdir_sr5   Úxr   r   r   Útest_index_tab_completionF   s     z(TestSeriesMisc.test_index_tab_completionÚserr   r9   c                 C   s>   d}t jt|d�� t|ƒ W d   ƒ n1 s00    Y  d S )Nzunhashable type: 'Series'©Úmatch)ÚpytestÚraisesÚ	TypeErrorÚhash©r   rE   Úmsgr   r   r   Útest_not_hashabled   s    z TestSeriesMisc.test_not_hashablec                 C   s   t  |j|¡ d S ©N)r*   Zassert_contains_allr/   )r   Údatetime_seriesr   r   r   Útest_containsj   s    zTestSeriesMisc.test_containsc                 C   sj   t ddtjgƒ}t |jdd�|jdd�¡ | ¡  d¡dksBJ ‚| d¡dksTJ ‚| d¡dksfJ ‚d S )Nr9   r3   Úrows)Zaxisr/   r:   r   )	r   ÚnpÚnanr*   Úassert_series_equalZdropnaÚsumZ_get_axis_numberZ_get_axis_namer   r   r   r   Útest_axis_aliasm   s
    zTestSeriesMisc.test_axis_aliasc                 C   s   t  tj¡sJ ‚d S rO   )ÚpydocÚgetdocr   r/   )r   r   r   r   Útest_class_axist   s    zTestSeriesMisc.test_class_axisc                 C   sN   t tj dd¡g d¢tddd�d�}dd„ }| |¡}| ¡ }t ||¡ d S )	Niè  r:   )ÚAÚBÚCz1/1/2000r   )Úcolumnsr/   c                 S   s   | |   ¡  S rO   )Zidxmax)rC   r   r   r   Úf‚   s    z-TestSeriesMisc.test_ndarray_compat.<locals>.f)	r   rS   ÚrandomÚrandnr   ÚapplyÚmaxr*   rU   )r   Ztsdfr_   ÚresultÚexpectedr   r   r   Útest_ndarray_compaty   s    
ý
z"TestSeriesMisc.test_ndarray_compatc                 C   s@   t tj d¡ƒ}t t |¡ƒ}t dtdƒdd�}t ||¡ d S )Nr0   r9   Zfloat64r;   )r   rS   r`   ra   Z	ones_likeÚranger*   rU   )r   r   rd   re   r   r   r   Útest_ndarray_compat_like_func‰   s    z,TestSeriesMisc.test_ndarray_compat_like_funcc                 C   s2   t tj d¡ƒ}t |jdd�|jjdd�¡ d S )Nr0   ÚF)Úorder)r   rS   r`   ra   r*   r+   ZravelÚvaluesr   r   r   r   Útest_ndarray_compat_ravel�   s    z(TestSeriesMisc.test_ndarray_compat_ravelc                 C   s   t td�}|jsJ ‚d S ©Nr   )r   r>   Úempty)r   Zs_emptyr   r   r   Útest_empty_method•   s    
z TestSeriesMisc.test_empty_methodr   Zint64c                 C   s   t dg|d�}|jrJ ‚d S )Nr9   r;   )r   rn   )r   r   Zfull_seriesr   r   r   Útest_empty_method_full_series™   s    z,TestSeriesMisc.test_empty_method_full_seriesNZInt64c                 C   s"   t tdƒ|d�}|jdksJ ‚d S )Né	   r   )r   rg   Úsize)r   r   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J ‚d|jd< |d }|jddiksBJ ‚d S )Nr   r9   Úabc)ÚnameÚversion)r   Úattrs)r   r   rd   r   r   r   Ú
test_attrs¤   s
    
zTestSeriesMisc.test_attrsZjinja2c                 C   sB   t td�}t d ¡� t |¡ W d   ƒ n1 s40    Y  d S rm   )r   r>   r*   Zassert_produces_warningÚinspectÚ
getmembers©r   rE   r   r   r   Útest_inspect_getmembers«   s    
z&TestSeriesMisc.test_inspect_getmembersc                 C   st   t jdddd�}ttjjdd�|d�}d|j ¡ vs8J ‚d}tj	t
|d	�� |j W d   ƒ n1 sf0    Y  d S )
Nr   r0   Z1s)Ústartr   Úfreq)rr   )r/   r1   z&'Series' object has no attribute 'foo'rF   )ÚpdZtimedelta_ranger   rS   r`   ÚnormalÚ__dict__ÚkeysrH   rI   ÚAttributeErrorr1   )r   ZtdirE   rM   r   r   r   Útest_unknown_attribute²   s    z%TestSeriesMisc.test_unknown_attributeÚop)ÚyearÚdayÚsecondÚweekdayc                 C   sH   d|› d�}t jt|d�� t||ƒ W d   ƒ n1 s:0    Y  d S )Nz"'Series' object has no attribute 'ú'rF   )rH   rI   rƒ   Úgetattr)r   r…   rP   rM   r   r   r   Ú&test_datetime_series_no_datelike_attrs»   s    z5TestSeriesMisc.test_datetime_series_no_datelike_attrsc                 C   s>   t ddddœƒ}|jdksJ ‚|jdks,J ‚|jdks:J ‚d S )NéÐ  r9   r0   ©r†   Úmonthr‡   )r   r†   r�   r‡   r{   r   r   r   Ú)test_series_datetimelike_attribute_accessÂ   s    z8TestSeriesMisc.test_series_datetimelike_attribute_accessc                 C   sL   t ddddœƒ}d}tjt|d�� |j W d   ƒ n1 s>0    Y  d S )Nr�   r9   r0   rŽ   z*'Series' object has no attribute 'weekday'rF   )r   rH   rI   rƒ   r‰   rL   r   r   r   Ú1test_series_datetimelike_attribute_access_invalidÉ   s    z@TestSeriesMisc.test_series_datetimelike_attribute_access_invalid)/Ú__name__Ú
__module__Ú__qualname__r   r   r   r   r.   rH   ÚmarkZparametrizer*   ZmakeUnicodeIndexZmakeStringIndexZmakeCategoricalIndexr   ZmakeDateIndexZmakePeriodIndexZmakeTimedeltaIndexZmakeIntIndexZmakeUIntIndexZmakeFloatIndexrg   r   Z
MultiIndexÚfrom_tuplesÚziprD   r   r>   rN   rQ   rW   rZ   rf   rh   rl   ro   rp   rs   rx   r   r|   r„   rŒ   r�   r‘   r   r   r   r   r      s\   
ñþ





	
r   )ry   rX   ÚnumpyrS   rH   Zpandas.util._test_decoratorsr   Zpandasr   r   r   r   r   Zpandas._testingZ_testingr*   r   r   r   r   r   Ú<module>   s   