o
    Ti'                     @   sz   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
 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_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'd6d7 Z(d8d9 Z)ej	
d:g d;d<d= Z*d>d? Z+d@dA Z,ej	
dBg dCej	
d,e-e.e/egdDdE Z0d0S )F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/evchargy.com/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>A   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_categorical0   s   z3TestSeriesMisc.test_tab_completion_with_categoricalindex
   )foobarZbaz   TFc                 C   s   g | ]}d | qS )ar   )r$   ir   r   r   
<listcomp>R   s    zTestSeriesMisc.<listcomp>e   ZABCDZEFGH)r      r2      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   Zdir_sr4   xr   r   r   test_index_tab_completionD   s   z(TestSeriesMisc.test_index_tab_completionserr   r7   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   rC   msgr   r   r   test_not_hashablea   s   
"z TestSeriesMisc.test_not_hashablec                 C   s   t |j| d S N)r)   Zassert_contains_allr.   )r   datetime_seriesr   r   r   test_containsg   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 )Nr7   r2   rows)Zaxisr.   r8   r   )	r   npnanr)   assert_series_equalZdropnasumZ_get_axis_numberZ_get_axis_namer   r   r   r   test_axis_aliasj   s
   zTestSeriesMisc.test_axis_aliasc                 C   s   t tjsJ d S rM   )pydocgetdocr   r.   )r   r   r   r   test_class_axisq   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 )
Nr2   )  r8   )ABCz1/1/2000rY   r   )columnsr.   c                 S   s   | |    S rM   )idxmax)rA   r   r   r   f~   s   z-TestSeriesMisc.test_ndarray_compat.<locals>.f)
r   rQ   randomdefault_rngstandard_normalr   applymaxr)   rS   )r   Ztsdfr_   resultexpectedr   r   r   test_ndarray_compatv   s   

z"TestSeriesMisc.test_ndarray_compatc                 C   sF   t tjdd}t t|}t dtddd}t|| d S )Nr2   r/   r7   Zfloat64r9   )	r   rQ   r`   ra   rb   Z	ones_likeranger)   rS   )r   r   re   rf   r   r   r   test_ndarray_compat_like_func   s   z,TestSeriesMisc.test_ndarray_compat_like_funcc                 C   s8   t tjdd}t|jdd|jjdd d S )Nr2   r/   F)order)	r   rQ   r`   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   Zint64c                 C   s   t dg|d}|jrJ d S )Nr7   r9   )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   rh   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   r7   abc)nameversion)r   attrs)r   r   re   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 )NZjinja2r   zSeries._data is deprecatedF)rE   Zcheck_stacklevel)	rF   Zimportorskipr   r<   r)   assert_produces_warningDeprecationWarninginspect
getmembersrJ   r   r   r   test_inspect_getmembers   s   

"z&TestSeriesMisc.test_inspect_getmembersc                 C   sx   t j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 s5w   Y  d S )Nr   r/   Z1s)startr   freqr2   )rr   )r.   r0   z&'Series' object has no attribute 'foo'rD   )pdZtimedelta_ranger   rQ   r`   ra   normal__dict__rF   rG   AttributeErrorr0   )r   ZtdirC   rK   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 ''rD   )rF   rG   r   getattr)r   r   rN   rK   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  r7   r/   r   monthr   )r   r   r   r   )r   rC   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   r7   r/   r   z*'Series' object has no attribute 'weekday'rD   )r   rF   rG   r   r   rJ   r   r   r   1test_series_datetimelike_attribute_access_invalid   s
   "z@TestSeriesMisc.test_series_datetimelike_attribute_access_invalidzkernel, has_numeric_only)$)ZskewT)varT)allF)prodT)anyF)ZidxminF)quantileF)r^   F)minT)ZsemT)meanT)ZnuniqueF)rd   T)rT   T)countF)ZmedianT)ZstdT)ZbackfillF)Z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   r7   r7   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)rD   Znumeric_onlyTzSeries.z2 does not allow numeric_only=True with non-numericF)	r   r   rF   rG   rH   r<   r?   r)   rS   )
r   ZkernelZhas_numeric_onlyr   rC   argsmethodrK   re   rf   r   r   r   test_numeric_only   sF   ,

""
z TestSeriesMisc.test_numeric_only)1__name__
__module____qualname__r   r   r   r   r-   rF   markparametrizer)   ZmakeStringIndexZmakeCategoricalIndexr   ZmakeDateIndexZmakePeriodIndexZmakeTimedeltaIndexZmakeIntIndexZmakeUIntIndexZmakeFloatIndexrh   r   Z
MultiIndexfrom_tuplesziprB   r   r<   rL   rO   rU   rX   rg   ri   rm   ro   rp   rs   rx   r}   r   r   r   r   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 )Nr7   )r)   ry   FutureWarningr   )r   r   r   r   test_float_int_deprecated$  s   "r   )r{   rV   numpyrQ   rF   Zpandasr   r   r   r   r   Zpandas._testingZ_testingr)   r   r   r   r   r   complexr   r   r   r   r   <module>   s      