U
    W7b                     @   s   d dl Zd dlZd dlZd dlmZmZ d dlm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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S )    N)
MultiIndexSeries	as_periodTFc                 C   s^   t dd tddD }| r*|jd}n|jd}| }|j|jksNtt	|| d S )Nc                 S   s   g | ]}t d d|qS )i     )pdZ	Timestamp).0n r	   G/tmp/pip-unpacked-wheel-rhjceu4d/pandas/tests/series/test_reductions.py
<listcomp>   s     z-test_mode_extension_dtype.<locals>.<listcomp>      Dz
US/Central)
r   rangedtZ	to_periodZtz_localizemodedtypeAssertionErrortmassert_series_equal)r   serresr	   r	   r
   test_mode_extension_dtype   s    r   c                  C   sN   t dtjgdd} | d }|  |ks*t|  |ks:t|  |ksJtd S )Nr   zm8[ns]r   )r   r   ZNaTmedianr   minmax)r   expr	   r	   r
   test_reductions_td64_with_nat   s
    r   skipnac                 C   s>   t g dd}|j| d}t|tjs(t|tdks:td S )Nztimedelta64[ns]r   )r   r   )r   sum
isinstancer   	Timedeltar   )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|td}tjt|d	 | |   	  W 5 Q R X | dd
 }tjt|d	 ||  	  W 5 Q R X | 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   ZmeanZTimedeltaIndexZasi8lenr    npZallclosevaluer   pytestraises
ValueError)r   r#   expectedmsgs1s2r	   r	   r
   test_td64_summation_overflow.   s    &r3   c                  C   s0   t dddgtdd} |  }t|t r,td S )Ng      ?   index)r   r   prodr!   r   )r   r#   r	   r	   r
   test_prod_numpy16_bugG   s    r8   c               	   C   sX   t dgtdgd} tt | jdd}W 5 Q R X t dgdgd}t|| d S )Ng      $@)   r4   r5   r   )levelr9   )r   r   from_tuplesr   Zassert_produces_warningFutureWarningr    r   )objr#   r/   r	   r	   r
   test_sum_with_levelN   s
    r>   funckwargskeepdimsoutc              	   C   sZ   t ddg}t| d }|j}d| d| d}tjt|d ||f|  W 5 Q R X d S )Nr   r9   r   zthe 'z=' parameter is not supported in the pandas implementation of z\(\)r'   )r   list__name__r,   r-   r.   )r@   r?   r   paramnamer0   r	   r	   r
   )test_validate_any_all_out_keepdims_raisesW   s    rG   c               	   C   s<   t ddg} d}tjt|d tj| dd W 5 Q R X d S )Nr   r9   zPthe 'initial' parameter is not supported in the pandas implementation of sum\(\)r'   
   )initialr   r,   r-   r.   r*   r    r   r0   r	   r	   r
   test_validate_sum_initialg   s
    rL   c               	   C   s:   t ddg} d}tjt|d | jdd W 5 Q R X d S )Nr   r9   z[the 'overwrite_input' parameter is not supported in the pandas implementation of median\(\)r'   T)Zoverwrite_input)r   r,   r-   r.   r   rK   r	   r	   r
   test_validate_median_initialr   s
    rM   c               	   C   s<   t ddg} d}tjt|d tj| dd W 5 Q R X d S )Nr   r9   zQthe 'keepdims' parameter is not supported in the pandas implementation of sum\(\)r'   T)rA   rJ   rK   r	   r	   r
   test_validate_stat_keepdims   s
    rN   )Znumpyr*   r,   Zpandasr   r   r   Zpandas._testingZ_testingr   markZparametrizer   r   r$   r3   r8   r>   anyallobjectrG   rL   rM   rN   r	   r	   r	   r
   <module>   s$   
	
		