o
    _~#gc(                     @   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/static.ux5.de/https/Moving-Object-Detection-with-OpenCV/env/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 )N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orderedset_categoriesadd_categoriesremove_categoriesrename_categoriesreorder_categoriesremove_unused_categories
as_orderedas_unordered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   
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
   r0   ir   r   r   
<listcomp>J   s    zTestSeriesMisc.<listcomp>
   )foobarbaz   z
2020-01-01r   D)r   freqz1 dayTFc                 C   s   g | ]}d | qS )ar   r=   r   r   r   r?   S   s    e   ABCDEFGH)r      rD      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r;   r   r   )leveld   )	r   objectr   	enumerater;   unique
isinstancer
   isidentifier)r   r;   r   dir_sr>   xr   r   r   test_index_tab_completionF   s   z(TestSeriesMisc.test_index_tab_completionserrK   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   rX   msgr   r   r   test_not_hashableb   s   
"z TestSeriesMisc.test_not_hashablec                 C   s   t |j| d S N)r5   assert_contains_allr;   )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 )NrK   rD   rows)axisr;   rL   r   )	r   npnanr5   assert_series_equaldropnasum_get_axis_number_get_axis_namer   r   r   r   test_axis_aliask   s
   zTestSeriesMisc.test_axis_aliasc                 C   s   t tjsJ d S rb   )pydocgetdocr   r;   )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 )
NrD   )  rL   )ABCz1/1/2000rs   r   )columnsr;   c                 S   s   | |    S rb   )idxmax)rV   r   r   r   f   s   z-TestSeriesMisc.test_ndarray_compat.<locals>.f)
r   rh   randomdefault_rngstandard_normalr   applymaxr5   rj   )r   tsdfry   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 )NrD   r@   rK   float64rM   )	r   rh   rz   r{   r|   	ones_likeranger5   rj   )r   r   r   r   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 )NrD   r@   zravel is deprecatedrY   F)order)r   rh   rz   r{   r|   r5   assert_produces_warningFutureWarningravelr6   valuesr   r   r   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   rP   empty)r   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 )NrK   rM   )r   r   )r   r   full_seriesr   r   r   test_empty_method_full_series   s   z,TestSeriesMisc.test_empty_method_full_seriesNInt64c                 C   s"   t td|d}|jdksJ d S )N	   r   )r   r   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   rK   abc)nameversion)r   attrsr   r   r   r   
test_attrs   s
   
zTestSeriesMisc.test_attrsc                 C   sX   t d ttd}d}tjt|dd t| W d    d S 1 s%w   Y  d S )Njinja2r   zSeries._data is deprecatedF)rZ   check_stacklevel)	r[   importorskipr   rP   r5   r   DeprecationWarninginspect
getmembersr_   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   r@   1s)startr   rF   rD   )r   )r;   rA   z&'Series' object has no attribute 'foo'rY   )r   r   rh   rz   r{   normal__dict__r[   r\   AttributeErrorrA   )r   tdirX   r`   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 ''rY   )r[   r\   r   getattr)r   r   rd   r`   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  rK   r@   r   monthr   )r   r   r   r   )r   rX   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   rK   r@   r   z*'Series' object has no attribute 'weekday'rY   )r   r[   r\   r   r   r_   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)$)skewT)varT)allF)prodT)anyF)idxminF)quantileF)rx   F)minT)semT)meanT)nuniqueF)r~   T)rl   T)countF)medianT)stdT)backfillF)rankT)
pct_changeF)cummaxF)shiftF)diffF)cumsumF)cumminF)cumprodF)fillnaF)ffillF)padF)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   rK   rK   r   corrwithr   r   nth)r   r   )T)r   r   r   r   )g      ?r   zP(got an unexpected keyword argument 'numeric_only'|too many arguments passed in)rY   numeric_onlyTzSeries.z2 does not allow numeric_only=True with non-numericF)	r   r   r[   r\   r]   rP   rS   r5   rj   )
r   kernelhas_numeric_onlyr   rX   argsmethodr`   r   r   r   r   r   test_numeric_only   sF   -

""
z TestSeriesMisc.test_numeric_only)2__name__
__module____qualname__r   r   r   r!   r:   r[   markparametrizer   r   r   r   r   r   rh   arangeuint64r   r   pd
MultiIndexfrom_tuplesziprW   r   rP   ra   re   ro   rr   r   r   r   r   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 )NrK   )r5   r   r   r   )r   r   r   r   test_float_int_deprecated(  s   "r   )r   rp   numpyrh   r[   pandasr   r   r   r   r   r   r   pandas._testing_testingr5   r   r   r   r   r   complexr   r   r   r   r   <module>   s       