a
    j=ic(                     @   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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-dCdD Z.ej	
dEg dFej	
d,e/e0e1egdGdH Z2d0S )I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   m/home/droni/.local/share/virtualenvs/DPS-5Je3_V2c/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>T   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   )leveld   )	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_hashablec   s    z TestSeriesMisc.test_not_hashablec                 C   s   t |j| d S N)r*   Zassert_contains_allr/   )r   datetime_seriesr   r   r   test_containsi   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_aliasl   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_axiss   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   )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_compatx   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   float64r;   )r   rS   ra   rb   Z	ones_likeranger*   rU   )r   r   re   rf   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   ra   rb   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   int64c                 C   s   t dg|d}|jrJ d S )Nr9   r;   )r   ro   )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   ri   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   re   r   r   r   
test_attrs   s
    
zTestSeriesMisc.test_attrsZjinja2c                 C   sF   t td}tjtdd t| W d    n1 s80    Y  d S )Nr   F)Zcheck_stacklevel)r   r>   r*   assert_produces_warningFutureWarning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)rt   )r/   r1   z&'Series' object has no attribute 'foo'rF   )pdZtimedelta_ranger   rS   ra   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_invalidc                 C   sD   t dg}tt t|  W d    n1 s60    Y  d S )Nr9   )r   r*   r{   r|   next	iteritemsr   r   r   r    test_series_iteritems_deprecated   s    
z/TestSeriesMisc.test_series_iteritems_deprecatedzkernel, has_numeric_only)$)ZskewT)varT)allF)prodT)anyF)ZidxminF)quantileF)r_   F)minT)ZsemT)meanT)ZnuniqueF)rd   T)rV   T)countF)ZmedianT)ZstdT)ZbackfillF)rankT)Z
pct_changeF)ZcummaxF)shiftF)diffF)ZcumsumF)ZcumminF)ZcumprodF)fillnaF)ffillF)padF)ZbfillF)sampleF)tailF)takeF)headF)covF)corrFc              	   C   s  t g d|d}|dkr |f}nn|dkr0|f}n^|dkr@|f}nN|dkrNd}n@|dkr\d	}n2|dkrjd
}n$|dkr|dgf}n|dkrd}nd}t||}|sd}tjt|d ||ddi W d    n1 s0    Y  n$|tu r|dkr8d}tjt|d ||ddi W d    n1 s,0    Y  nd| d}d| d}	tjt|dN tjt	|	d ||ddi W d    n1 s0    Y  W d    n1 s0    Y  nD||ddi}
||ddi}t
|t rt|
| n|
|ksJ d S )N)r   r9   r9   r   Zcorrwithr   r   Znth)r   r   )T)r   r   r   r   )g      ?r   zP(got an unexpected keyword argument 'numeric_only'|too many arguments passed in)rF   Znumeric_onlyTr   z;Calling Series.rank with numeric_only=True and dtype objectzCalling Series.z( with numeric_only=True and dtype objectzSeries.z  does not implement numeric_onlyF)r   r   rH   rI   rJ   r>   r*   r{   r|   NotImplementedErrorrA   rU   )r   ZkernelZhas_numeric_onlyr   rE   argsmethodrM   Zwarn_msgerr_msgre   rf   r   r   r   test_numeric_only   sP    ,

0

0
Pz TestSeriesMisc.test_numeric_only)3__name__
__module____qualname__r   r   r   r   r.   rH   markZparametrizer*   ZmakeStringIndexZmakeCategoricalIndexr   ZmakeDateIndexZmakePeriodIndexZmakeTimedeltaIndexZmakeIntIndexZmakeUIntIndexZmakeFloatIndexri   r   Z
MultiIndexfrom_tuplesziprD   r   r>   rN   rQ   rW   rZ   rg   rj   rn   rp   rr   ru   rz   r   r   r   r   r   r   r   boolintfloatr   r   r   r   r   r      sh   






	
)r   )r}   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   