U
    sVco                     @   sZ   d dl m Z  d dlZd dlZd dlZd dlmZmZmZm	Z	 d dl
mZ G dd dZdS )    )datetimeN)Series	Timestampisnanotnac                
   @   s   e Zd Zdd Zdd Zdd Zdd Zd	d
 Zej	
dddgej	
ddddgedddggdd Zdd Zdd Zdd ZdS )TestSeriesClipc                 C   sp   |  }|j|d |ks t|j|d |ks8t|dd}t|dd}t|| t|t	sltd S )Nlowerupperg      g      ?)
ZmedianclipminAssertionErrormaxnptmassert_series_equal
isinstancer   )selfZdatetime_seriesvalresultexpected r   I/tmp/pip-unpacked-wheel-xj8nt62q/pandas/tests/series/methods/test_clip.py	test_clip   s    zTestSeriesClip.test_clipc                 C   s   t tjdddgt d dddgt tjtjddd	gd
dg}|D ]}|d }|j|d}|j|d}|t|  |ks|t|t| 	 |kstt
t|t
t|kstt
t|t
t|ks@tq@d S )N      ?       @      @abc         D)unitr   r
   )r   r   nanpdZto_datetimer   r   r   r   r   listr   )r   ZserssZthreshr	   r   r   r   r   test_clip_types_and_nulls   s    z(TestSeriesClip.test_clip_types_and_nullsc                 C   sx   |t jkrd S t|ddg|d}|jdd}|jdd}t|ddg|d}t|ddg|d}t|| t|| d S )Nr   r   Zdtyper   r
   r   )r'   ZNaTr   r   r   r   )r   Zany_numeric_ea_dtypeZnulls_fixtureserZs_clipped_upperZs_clipped_lowerZexpected_upperZexpected_lowerr   r   r   #test_series_clipping_with_na_values-   s    
z2TestSeriesClip.test_series_clipping_with_na_valuesc                 C   s   t dddg}t|tjt dddg t|jtjtjdt dddg t|jddtjgdt dddg t|jdtjdgdt dddg t dddg}|dtjtjtjg}t|| d	S )
z&Should process np.nan argument as Noner!   r"   r#   )r   r	   r      r   r
   N)r   r   r   r   r   r&   )r   r)   r   r   r   r   test_clip_with_na_args@   s    $&&z%TestSeriesClip.test_clip_with_na_argsc                 C   sj   t dddg}t dddg}t dddg}t|||t dddg t|d|t dddg d S )Nr   g      @r   r   g      ?g      @g      @)r   r   r   r   )r   r)   r	   r   r   r   r   test_clip_against_seriesQ   s
    z'TestSeriesClip.test_clip_against_seriesinplaceTFr   r!   r"   r#   c                 C   sF   t dddg}|j||d}t dddg}|r2|}tj||dd	 d S )
N         )r   r1   r!   r"   r#   T)Zcheck_exact)r   r   r   r   )r   r1   r   originalr   r   r   r   r   test_clip_against_list_like\   s    z*TestSeriesClip.test_clip_against_list_likec                 C   s   t d}tt dt dg}|j|d}tt dt dg}t|| t ddd}tt dddt dddg}|j|d}tt dddt dddg}t|| d S )Nz2015-12-01 09:30:30z2015-12-01 09:30:00z2015-12-01 09:31:00r
   z
US/Eastern)tz)r   r   r   r   r   )r   tr)   r   r   r   r   r   test_clip_with_datetimesh   s(    



z'TestSeriesClip.test_clip_with_datetimesc                 C   sR   t tdddtdddg}|jtjtjd}t tjtjgdd}t|| d S )Nr!   i'  	   )r	   r   objectr+   )r   r   r   r   r   r   r   r   )r   r,   r   r   r   r   r   +test_clip_with_timestamps_and_oob_datetimes   s    z:TestSeriesClip.test_clip_with_timestamps_and_oob_datetimesc              	   C   sX   t dddg}d}tjt|d |ddd}W 5 Q R X t dddg}t|| d S )Nr!   r"   r#   z|In a future version of pandas all arguments of Series.clip except for the arguments 'lower' and 'upper' will be keyword-only)matchr   )r   r   Zassert_produces_warningFutureWarningr   r   )r   r,   msgr   r   r   r   r   test_clip_pos_args_deprecation   s    z-TestSeriesClip.test_clip_pos_args_deprecationN)__name__
__module____qualname__r   r*   r-   r/   r0   pytestmarkZparametrizer   Zasarrayr6   r9   r<   r@   r   r   r   r   r      s   "
	r   )r   Znumpyr   rD   Zpandasr'   r   r   r   r   Zpandas._testingZ_testingr   r   r   r   r   r   <module>   s   