o
    ҷh>                     @   sR   d dl Zd dlZd dlmZmZmZ d dlmZ	 d dl
mZmZ G dd dZdS )    N)	Timedeltatimedelta_rangeto_timedelta)DaySecondc                   @   sz   e Zd Zdd Zdd Zejdg ddd Zejd	g d
dd Z	dd Z
ejdg ddd Zdd ZdS )TestTimedeltasc                 C   sB   t ddddd}tjdddd d	d
}t| | d S )Nz0 Days
   100000Ds)periodsfrequniti8)dtypei zm8[D]zm8[s])r   nparangeviewastypetmassert_numpy_array_equalto_numpy)selftdiexp_arr r   g/var/www/html/venv/lib/python3.10/site-packages/pandas/tests/indexes/timedeltas/test_timedelta_range.pytest_timedelta_range_unit   s   z(TestTimedeltas.test_timedelta_range_unitc                 C   s   t tddd}tdddd}t|| t tddd}tdddd}t|| t tdddtd	 t  }td
ddd}t|| t g dddtd	 }td
ddd}t|| t tdddd }tdddd}t|| d S )N   Dr   0 days)r   r      z10 days)r      z1 days, 00:00:02z5 days, 00:00:02)      r      	   2D2   min   30min)r   r   )r   r   r   r   r   assert_index_equalr   r   )r   expectedresultr   r   r   test_timedelta_range   s    z#TestTimedeltas.test_timedelta_rangezdepr_unit, unit))Tminute)tr1   )Lmillisecond)lr4   c                 C   sp   d| d}t td|d}tjt|d t td|d}t|| W d    d S 1 s1w   Y  d S )NzUnit 'z' is deprecated.r   r   match)r   r   r   r   assert_produces_warningFutureWarningr,   )r   	depr_unitr   depr_msgr-   r.   r   r   r   #test_timedelta_units_T_L_deprecated-   s   
"z2TestTimedeltas.test_timedelta_units_T_L_deprecatedzperiods, freq))r$   r'   )r   r   )   19H12T)r%   16H)r&   12Hc                 C   s,   t dd|d}t dd|d}t|| d S )Nr    z4 days)startendr   rA   rB   r   )r   r   r,   )r   r   r   r.   r-   r   r   r   test_linspace_behavior>   s   z%TestTimedeltas.test_linspace_behaviorc                 C   s$  d}t jt|d tdd W d    n1 sw   Y  t jt|d tdd W d    n1 s5w   Y  t jt|d tdd W d    n1 sQw   Y  t jt|d t  W d    n1 skw   Y  t jt|d tddd	d
d W d    d S 1 sw   Y  d S )NzVOf the four parameters: start, end, periods, and freq, exactly three must be specifiedr6   r    )rA   z5 days)rB   r"   r   r   H)rA   rB   r   r   )pytestraises
ValueErrorr   )r   msgr   r   r   test_errorsG   s"   "zTestTimedeltas.test_errorsz"start, end, freq, expected_periods))1D10Dr'   r   )r'   30D3Dr   )2s50s5sr   )4D16DrO   r   )8DrT   40siC  c                 C   sJ   t |||d}t||d ksJ t||d ksJ t||ks#J d S )NrC   r   )r   r   len)r   rA   rB   r   expected_periodsresr   r   r   $test_timedelta_range_freq_divide_end]   s   z3TestTimedeltas.test_timedelta_range_freq_divide_endc                 C   s    t dddd}|jd u sJ d S )N0s1s   rE   )r   r   )r   r.   r   r   r   test_timedelta_range_infer_freqo   s   z.TestTimedeltas.test_timedelta_range_infer_freqN)__name__
__module____qualname__r   r/   rG   markparametrizer<   rD   rK   r[   r_   r   r   r   r   r      s&    
	

r   )numpyr   rG   pandasr   r   r   pandas._testing_testingr   pandas.tseries.offsetsr   r   r   r   r   r   r   <module>   s    