o
    %j=(                     @   s   d dl Z d dlZd dlZd dlZd dlZd dlmZmZm	Z	m
Z
mZmZ d dlmZ G dd dZejdeeegdd ZdS )    N)	DataFrameIndexSeries
date_rangeperiod_rangetimedelta_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edd ddedd edD eg dd edddeddddedddeedejdeedejdeedej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/d0 Z"d1d2 Z#d3d4 Z$ej	
d5d6egd7d8 Z%ej	
d5d9d:gd;d< Z&d=d> Z'd?d@ Z(dAdB Z)ej	
dCg dDdEdF Z*dGdH Z+dIdJ Z,ej	-dKej	
dLg dMej	
d5e.e/e0egdNdO Z1d9S )P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   ]/var/www/html/Deteccion_Ine/venv/lib/python3.10/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sJ 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 sJ 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sJ dt|v s#J 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codes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   s    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abr   r   r   c                 C   s   g | ]}t |qS r   )r
   r&   ir   r   r   
<listcomp>J   s    zTestSeriesMisc.<listcomp>
   )foobarZbaz   z
2020-01-01r   D)r   freqz1 dayTFc                 C   s   g | ]}d | qS )ar   r2   r   r   r   r4   S   s    e   ZABCDZEFGH)r      r8      c                 C   sh   t |td}t|}t|jjddD ]\}}|dk r+t|tr*| r*||v s*J q||vs1J qd S )Nr0   r   r   )leveld   )	r   objectr   	enumerater0   unique
isinstancer
   isidentifier)r   r0   r   Zdir_sr3   xr   r   r   test_index_tab_completionF   s   z(TestSeriesMisc.test_index_tab_completionserr=   c                 C   s@   d}t jt|d t| W d    d S 1 sw   Y  d S )Nzunhashable type: 'Series'match)pytestraises	TypeErrorhashr   rI   msgr   r   r   test_not_hashableb   s   
"z TestSeriesMisc.test_not_hashablec                 C   s   t |j| d S N)r+   Zassert_contains_allr0   )r   datetime_seriesr   r   r   test_containsh   s   zTestSeriesMisc.test_containsc                 C   sj   t ddtjg}t|jdd|jdd | ddks!J |ddks*J |ddks3J d S )Nr=   r8   rows)Zaxisr0   r>   r   )	r   npnanr+   assert_series_equalZdropnasumZ_get_axis_numberZ_get_axis_namer   r   r   r   test_axis_aliask   s
   zTestSeriesMisc.test_axis_aliasc                 C   s   t tjsJ d S rS   )pydocgetdocr   r0   )r   r   r   r   test_class_axisr   s   zTestSeriesMisc.test_class_axisc                 C   sR   t tjddg dtdddd}dd	 }||}| }t	|| d S )
Nr8   )  r>   )ABCz1/1/2000r_   r   )columnsr0   c                 S   s   | |    S rS   )idxmax)rG   r   r   r   f   s   z-TestSeriesMisc.test_ndarray_compat.<locals>.f)
r   rW   randomdefault_rngstandard_normalr   applymaxr+   rY   )r   Ztsdfre   resultexpectedr   r   r   test_ndarray_compatw   s   

z"TestSeriesMisc.test_ndarray_compatc                 C   sF   t tjdd}t t|}t dtddd}t|| d S )Nr8   r5   r=   float64r?   )	r   rW   rf   rg   rh   Z	ones_likeranger+   rY   )r   r   rk   rl   r   r   r   test_ndarray_compat_like_func   s   z,TestSeriesMisc.test_ndarray_compat_like_funcc                 C   sj   t tjdd}tjtdd |jdd}W d    n1 s#w   Y  t	||j
jdd d S )Nr8   r5   zravel is deprecatedrJ   F)order)r   rW   rf   rg   rh   r+   assert_produces_warningFutureWarningZravelr,   valuesr   r   rk   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   rB   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 )Nr=   r?   )r   rx   )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   ro   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s!J d S )Nr   r=   abc)nameversion)r   attrsrv   r   r   r   
test_attrs   s
   
zTestSeriesMisc.test_attrsc                 C   sN   t td}d}tjt|dd t| W d    d S 1 s w   Y  d S )Nr   zSeries._data is deprecatedF)rK   Zcheck_stacklevel)r   rB   r+   rs   DeprecationWarninginspect
getmembersrP   r   r   r   test_inspect_getmembers   s   
"z&TestSeriesMisc.test_inspect_getmembersc                 C   sv   t dddd}ttjdjdd|d}d|jvsJ d	}tjt	|d
 |j
 W d    d S 1 s4w   Y  d S )Nr   r5   Z1s)startr   r:   r8   )r}   )r0   r6   z&'Series' object has no attribute 'foo'rJ   )r   r   rW   rf   rg   normal__dict__rL   rM   AttributeErrorr6   )r   ZtdirI   rQ   r   r   r   test_unknown_attribute   s   "z%TestSeriesMisc.test_unknown_attributeop)yeardaysecondweekdayc                 C   sJ   d| d}t jt|d t|| W d    d S 1 sw   Y  d S )Nz"'Series' object has no attribute ''rJ   )rL   rM   r   getattr)r   r   rT   rQ   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  r=   r5   r   monthr   )r   r   r   r   )r   rI   r   r   r   )test_series_datetimelike_attribute_access   s   z8TestSeriesMisc.test_series_datetimelike_attribute_accessc                 C   sN   t dddd}d}tjt|d |j W d    d S 1 s w   Y  d S )Nr   r=   r5   r   z*'Series' object has no attribute 'weekday'rJ   )r   rL   rM   r   r   rP   r   r   r   1test_series_datetimelike_attribute_access_invalid   s
   "z@TestSeriesMisc.test_series_datetimelike_attribute_access_invalidz4ignore:Downcasting object dtype arrays:FutureWarningzkernel, has_numeric_only)$)ZskewT)varT)allF)prodT)anyF)ZidxminF)quantileF)rd   F)minT)ZsemT)meanT)ZnuniqueF)rj   T)rZ   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}n7|dkr|f}n/|dkr |f}n'|dkr'd}n |dkr.d	}n|dkr5d
}n|dkr>dgf}n	|dkrEd}nd}t||}|sqd}tjt|d ||ddi W d    d S 1 sjw   Y  d S |tu rd| d}tjt|d ||ddi W d    d S 1 sw   Y  d S ||ddi}||ddi}	t|	t rt||	 d S ||	ksJ d S )N)r   r=   r=   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)rJ   Znumeric_onlyTzSeries.z2 does not allow numeric_only=True with non-numericF)	r   r   rL   rM   rN   rB   rE   r+   rY   )
r   ZkernelZhas_numeric_onlyr   rI   argsmethodrQ   rk   rl   r   r   r   test_numeric_only   sF   -

""
z TestSeriesMisc.test_numeric_only)2__name__
__module____qualname__r   r   r   r    r/   rL   markparametrizer   r   ro   r   r   r   rW   ZarangeZuint64rz   rn   pdZ
MultiIndexfrom_tuplesziprH   r   rB   rR   rU   r[   r^   rm   rp   rw   ry   r{   r~   r   r   r   r   r   r   filterwarningsboolintfloatr   r   r   r   r   r      sf    







		

)r   	converterc                 C   sJ   t t | tdg| dksJ W d    d S 1 sw   Y  d S )Nr=   )r+   rs   rt   r   )r   r   r   r   test_float_int_deprecated'  s   "r   )r   r\   numpyrW   rL   Zpandasr   r   r   r   r   r   r   Zpandas._testingZ_testingr+   r   r   r   r   r   complexr   r   r   r   r   <module>   s       