a
    d                     @   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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   l/var/www/html/stable-diffusion-webui/venv/lib/python3.9/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sNJ t|| d S )Nc                 S   s   g | ]}t d d|qS )i     )pd	Timestamp).0nr   r   r   
<listcomp>       z-test_mode_extension_dtype.<locals>.<listcomp>      Dz
US/Central)	r   rangedtZ	to_periodZtz_localizemoder	   tmZassert_series_equal)r   r   resr   r   r   test_mode_extension_dtype   s    r    c                  C   sN   t dtjgdd} | d }|  |ks*J |  |ks:J |  |ksJJ 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   resultr   r   r   test_td64_sum_empty)   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 s0    Y  | dd
 }tjt|d	  ||  	  W d    n1 s0    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_valuepytestraises
ValueError)r   r(   r   msgs1s2r   r   r   test_td64_summation_overflow3   s    &..r8   c                  C   s.   t g dtdd} |  }t|t r*J d S )N)      ?r9   r9      )index)r   r   prodr&   )r   r(   r   r   r   test_prod_numpy16_bugL   s    r=   funckwargskeepdimsoutc                 C   sr   t ddg}tt| }|j}d| d| d}tjt|d  ||fi |  W d    n1 sd0    Y  d S )Nr      zthe 'z=' parameter is not supported in the pandas implementation of z\(\)r,   )r   nextiter__name__r2   r3   r4   )r?   r>   r   paramnamer5   r   r   r   )test_validate_any_all_out_keepdims_raisesS   s    rH   c                  C   sP   t ddg} d}tjt|d tj| dd W d    n1 sB0    Y  d S )Nr   rB   zPthe 'initial' parameter is not supported in the pandas implementation of sum\(\)r,   
   )initialr   r2   r3   r4   r0   r%   r   r5   r   r   r   test_validate_sum_initialc   s
    rM   c                  C   sN   t ddg} d}tjt|d | jdd W d    n1 s@0    Y  d S )Nr   rB   z[the 'overwrite_input' parameter is not supported in the pandas implementation of median\(\)r,   T)Zoverwrite_input)r   r2   r3   r4   r!   rL   r   r   r   test_validate_median_initialn   s
    rN   c                  C   sP   t ddg} d}tjt|d tj| dd W d    n1 sB0    Y  d S )Nr   rB   zQthe 'keepdims' parameter is not supported in the pandas implementation of sum\(\)r,   T)r@   rK   rL   r   r   r   test_validate_stat_keepdims{   s
    rO   c                 C   s   t ddg}| dksJ d}tjt|d |  W d    n1 sL0    Y  | }| sfd}tjt|d |  W d    n1 s0    Y  d S )N12Z12z(Could not convert string '12' to numericr,   z%Could not convert \['12'\] to numeric)r   r%   r2   r3   	TypeErrorr.   to_frame)using_array_managerr   r5   dfr   r   r   (test_mean_with_convertible_string_raises   s    &rV   c                 C   s  t dddg}| rd}nd}tjt|d |  W d    n1 sL0    Y  tjt|d |d W d    n1 s0    Y  d}tjt|d |d   W d    n1 s0    Y  tjt|d& t|d d	j	 W d    n1 s0    Y  d S )
NJ{   )dbnumericz'Could not convert string 'J' to numericz$Could not convert \['J'\] to numericr,   r.   rY   r   )
r   Z	DataFramer2   r3   rR   r.   Zaggr0   Zastypearray)rT   rU   r5   r   r   r   #test_mean_dont_convert_j_to_complex   s    &(*r\   c                 C   s   d}t g d}tjt|d |  W d    n1 s<0    Y  | sNd}| }tjt|d |  W d    n1 s0    Y  d S )Nz)Cannot convert \['1' '2' '3'\] to numeric)rP   rQ   3r,   z-Cannot convert \[\['1' '2' '3'\]\] to numeric)r   r2   r3   rR   r!   rS   )rT   r5   r   rU   r   r   r   *test_median_with_convertible_string_raises   s    &r^   )numpyr0   r2   Zpandasr   r   Zpandas._testingZ_testingr   markZparametrizer   r    r#   r)   r8   r=   anyallobjectrH   rM   rN   rO   rV   r\   r^   r   r   r   r   <module>   s,   

	
	