o
    թZhw                     @   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)Z	operationexpectedserZres_operation_serie r   Z/var/www/html/lang_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dtZ	to_periodZ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)ZdropnaT)r   r   ZNAr   r   r   )Z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 )NZpyarrowr   r   r   zfuture.infer_stringT)	pytestZimportorskipr   objectr   Zoption_contextr   r   r   )r   r$   r   r   r   r   test_mode_infer_string6   s   

r(   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   ZNaTmedianr   r   )r   expr   r   r   test_reductions_td64_with_nat@   s
   r+   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   )r,   r   )r   sum
isinstancer   	Timedelta)r,   r   r$   r   r   r   test_td64_sum_emptyI   s   r0   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 )NZ20130101i h)Zperiodsfreqr   z1s 1msi  zoverflow in timedelta operationmatchi'  )r   r   Z
date_ranger/   r   meanZTimedeltaIndexZasi8lenr-   npZallclose_valuer&   raises
ValueError)r   r$   r   msgs1s2r   r   r   test_td64_summation_overflowS   s   &r>   c                  C   s.   t g dtdd} |  }t|t rJ d S )N)      ?r?   r?   r!   )index)r   r   prodr.   )r   r$   r   r   r   test_prod_numpy16_bugl   s   rB   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\(\)r3   )r   nextiter__name__r&   r9   r:   )rD   rC   r   paramnamer;   r   r   r   )test_validate_any_all_out_keepdims_raisess   s   "rL   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\(\)r3   
   )initialr   r&   r9   r:   r7   r-   r   r;   r   r   r   test_validate_sum_initial      "rR   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\(\)r3   T)Zoverwrite_input)r   r&   r9   r:   r)   rQ   r   r   r   test_validate_median_initial   s   "rT   c                  C   rM   )Nr   r"   zQthe 'keepdims' parameter is not supported in the pandas implementation of sum\(\)r3   T)rE   rP   rQ   r   r   r   test_validate_stat_keepdims   rS   rU   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 supportr3   Z12z9Could not convert string '12' to numeric|does not supportz6Could not convert \['12'\] to numeric|does not support)r   r&   r9   	TypeErrorr-   r5   to_frame)using_array_managerZusing_infer_stringr   r;   dfr   r   r   (test_mean_with_convertible_string_raises   s$   


"r\   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 supportr3   r5   z8Could not convert string 'J' to numeric|does not supportr_   z6Could not convert string 'J' to numeric|ufunc 'divide'r   )
r   Z	DataFramer&   r9   rX   r5   Zaggr7   Zastypearray)rZ   r[   r;   r   r   r   #test_mean_dont_convert_j_to_complex   s$   
"rb   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)rV   rW   3r3   z>Cannot convert \[\['1' '2' '3'\]\] to numeric|does not support)r   r&   r9   rX   r)   rY   )rZ   r;   r   r[   r   r   r   *test_median_with_convertible_string_raises   s   

"rd   )numpyr7   r&   Zpandasr   r   Zpandas._testingZ_testingr   markZparametrizer   r    r%   r(   r+   r0   r>   rB   anyallr'   rL   rR   rT   rU   r\   rb   rd   r   r   r   r   <module>   s2    


	
	