o
    Û­jv  ã                   @   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/html/CropPilot/venv/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ƒ}| ¡ dksJ ‚d}tjt|d�� | ¡  W d   ƒ n1 s&w   Y  | ¡ }| s3d}tjt|d�� | ¡  W d   ƒ d S 1 sJw   Y  d S )NÚ1Ú2Ú12zHCould not convert string '12' to numeric|does not support|Cannot performr@   zECould not convert \['12'\] to numeric|does not support|Cannot perform)r   r8   r.   rJ   Ú	TypeErrorrC   Ú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 s†w   Y  d S )NÚJé{   )ÚdbÚnumericz'Could not convert string 'J' to numericzDCould not convert \['J'\] to numeric|does not support|Cannot performr@   rC   zGCould not convert string 'J' to numeric|does not support|Cannot performrs   zECould not convert string 'J' to numeric|ufunc 'divide'|Cannot performr   )
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 )NzICannot convert \['1' '2' '3'\] to numeric|does not support|Cannot perform)rh   ri   Ú3r@   zMCannot convert \[\['1' '2' '3'\]\] to numeric|does not support|Cannot perform)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    


	
	