o
    _~#gw                     @   s  d dl Zd dlZd dlZd dlmZ d dlmZ ej	
dddgdd Zej	
dd	d
gdd Zdd Zdd Zdd Zej	
dd	d
gdd Zdd Zdd Zej	
dejejgej	
ddd	ide igdd Zd d! Zd"d# Zd$d% Zd&d' Zd(d) Zd*d+ ZdS ),    N)Serieszoperation, expected)mina)maxbc                 C   s,   t ddgdd}t||  }||ksJ d S )Nr   r   stringdtype)r   getattr)	operationexpectedserres_operation_serie r   /var/www/static.ux5.de/https/Moving-Object-Detection-with-OpenCV/env/lib/python3.10/site-packages/pandas/tests/series/test_reductions.pytest_reductions_series_strings	   s   r   	as_periodTFc                 C   s^   t dd tddD }| r|jd}n|jd}| }|j|jks'J t|| d S )Nc                 S   s   g | ]	}t d d|qS )i     )pd	Timestamp).0nr   r   r   
<listcomp>   s    z-test_mode_extension_dtype.<locals>.<listcomp>      Dz
US/Central)	r   rangedt	to_periodtz_localizemoder	   tmassert_series_equal)r   r   resr   r   r   test_mode_extension_dtype   s   r$   c                 C   s   t dddtjddtjg| d}|jdd}t ddtjg| d}t|| |jdd}t ddg| d}t|| tj|d< |jdd}t ddg| d}t|| |jdd}t tjg| d}t|| d S )	Nr         r   F)dropnaT)r   r   NAr    r!   r"   )any_numeric_ea_dtyper   resultr   r   r   r   test_mode_nullable_dtype    s   
r,   c                  C   sn   t d tddgtd} tdd |  }W d    n1 s"w   Y  tddgtd}t|| d S )Npyarrowr   r   r   zfuture.infer_stringT)	pytestimportorskipr   objectr   option_contextr    r!   r"   )r   r+   r   r   r   r   test_mode_infer_string6   s   

r2   c                  C   sN   t dtjgdd} | d }|  |ksJ |  |ksJ |  |ks%J d S )Nr   zm8[ns]r   )r   r   NaTmedianr   r   )r   expr   r   r   test_reductions_td64_with_nat@   s
   r6   skipnac                 C   s>   t g dd}|j| d}t|tjsJ |tdksJ d S )Nztimedelta64[ns]r   )r7   r   )r   sum
isinstancer   	Timedelta)r7   r   r+   r   r   r   test_td64_sum_emptyI   s   r;   c                  C   s(  t tjdddd} | d  td7  < | |    }tt| |   jt|  	 }t
|jd |jd s>J d}tjt|d	 | |   	  W d    n1 sZw   Y  | dd
 }tjt|d	 ||  	  W d    n1 sw   Y  | dd }||  	  d S )N20130101i h)periodsfreqr   z1s 1msi  zoverflow in timedelta operationmatchi'  )r   r   
date_ranger:   r   meanTimedeltaIndexasi8lenr8   npallclose_valuer.   raises
ValueError)r   r+   r   msgs1s2r   r   r   test_td64_summation_overflowS   s   &rO   c                  C   s.   t g dtdd} |  }t|t rJ d S )N)      ?rP   rP   r%   )index)r   r   prodr9   )r   r+   r   r   r   test_prod_numpy16_bugl   s   rS   funckwargskeepdimsoutc                 C   st   t ddg}tt| }|j}d| d| d}tjt|d ||fi |  W d    d S 1 s3w   Y  d S )Nr   r&   zthe 'z=' parameter is not supported in the pandas implementation of z\(\)r@   )r   nextiter__name__r.   rJ   rK   )rU   rT   r   paramnamerL   r   r   r   )test_validate_any_all_out_keepdims_raisess   s   "r]   c                  C   R   t ddg} d}tjt|d tj| dd W d    d S 1 s"w   Y  d S )Nr   r&   zPthe 'initial' parameter is not supported in the pandas implementation of sum\(\)r@   
   )initialr   r.   rJ   rK   rG   r8   r   rL   r   r   r   test_validate_sum_initial      "rc   c                  C   sP   t ddg} d}tjt|d | jdd W d    d S 1 s!w   Y  d S )Nr   r&   z[the 'overwrite_input' parameter is not supported in the pandas implementation of median\(\)r@   T)overwrite_input)r   r.   rJ   rK   r4   rb   r   r   r   test_validate_median_initial   s   "rf   c                  C   r^   )Nr   r&   zQthe 'keepdims' parameter is not supported in the pandas implementation of sum\(\)r@   T)rV   ra   rb   r   r   r   test_validate_stat_keepdims   rd   rg   c                 C   s   t ddg}|r&d}tjt|d |  W d    n1 s w   Y  n| dks.J d}tjt|d |  W d    n1 sFw   Y  | }| sSd}tjt|d |  W d    d S 1 sjw   Y  d S )N12zdoes not supportr@   12z9Could not convert string '12' to numeric|does not supportz6Could not convert \['12'\] to numeric|does not support)r   r.   rJ   	TypeErrorr8   rC   to_frame)using_array_managerusing_infer_stringr   rL   dfr   r   r   (test_mean_with_convertible_string_raises   s$   


"rp   c                 C   s  t dddg}| rd}nd}tjt|d |  W d    n1 s&w   Y  tjt|d |d W d    n1 sBw   Y  d}tjt|d |d	   W d    n1 saw   Y  d
}tjt|d t|d	 dj	 W d    d S 1 sw   Y  d S )NJ{   )dbnumericz'Could not convert string 'J' to numericz5Could not convert \['J'\] to numeric|does not supportr@   rC   z8Could not convert string 'J' to numeric|does not supportrs   z6Could not convert string 'J' to numeric|ufunc 'divide'r   )
r   	DataFramer.   rJ   rk   rC   aggrG   astypearray)rm   ro   rL   r   r   r   #test_mean_dont_convert_j_to_complex   s$   
"ry   c                 C   s   d}t g d}tjt|d |  W d    n1 sw   Y  | s'd}| }tjt|d |  W d    d S 1 sBw   Y  d S )Nz:Cannot convert \['1' '2' '3'\] to numeric|does not support)rh   ri   3r@   z>Cannot convert \[\['1' '2' '3'\]\] to numeric|does not support)r   r.   rJ   rk   r4   rl   )rm   rL   r   ro   r   r   r   *test_median_with_convertible_string_raises   s   

"r{   )numpyrG   r.   pandasr   r   pandas._testing_testingr!   markparametrizer   r$   r,   r2   r6   r;   rO   rS   anyallr0   r]   rc   rf   rg   rp   ry   r{   r   r   r   r   <module>   s2    


	
	