o
    _~#g%                     @   sd   d dl Z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 G dd dZG dd dZdS )    N)IndexTimedeltaIndextimedelta_range)Hourc                   @   sf  e Zd Zdd Zdd Zdd Zdd Zd	d
 Zdd Zdd Z	dd Z
dd Zejdddgdd Zdd Zejdedddddedd dddfedddd!dedd dd"dfedd#ddddd" eg ddd$fgd%d& Zejdeg d'dd(ed)d*gdd(feg d+d!d(ed,d)gd"d(feg d-dd(d"d"d. eg d-dd(fgd/d0 Zd"S )1TestTimedeltaIndexc                 C   sx   t ddd}t ddd}||}t ddd}t|| ttjdddtjd	}t d
ddd}|| || d S )N1day   periods3day   r         )dtype1 day
   D)startr
   freq)r   uniontmassert_index_equalr   nparangeint64)selfi1i2resultexpected r    /var/www/static.ux5.de/https/Moving-Object-Detection-with-OpenCV/env/lib/python3.10/site-packages/pandas/tests/indexes/timedeltas/test_setops.py
test_union   s   

zTestTimedeltaIndex.test_unionc                 C   sr   t ddd}|dd  }|d d }||sJ ||}t|| |j|dd}tg d}t|| d S )Nr   r   r	      Fsort)z4 Daysz5 Daysz1 Daysz2 Dayz3 Days)r   _can_fast_unionr   r   r   r   )r   tdileftrightr   r   r    r    r!   test_union_sort_false   s   
z(TestTimedeltaIndex.test_union_sort_falsec                 C   sd   t g d}t | dd}||}t|| |d d |}t|| |j|jks0J d S )N)3d1d2dinferr   r   )r   sort_valuesr   r   r   r   )r   idxorderedr   r    r    r!   test_union_coverage,   s   
z&TestTimedeltaIndex.test_union_coveragec                 C   sN   t dddd}t dddd}||}ttt|t|B }t|| d S )Nr      3hr
   r   4h)r   r   r   sortedsetr   r   )r   rng_arng_br   expr    r    r!   test_union_bug_17306   s
   
z&TestTimedeltaIndex.test_union_bug_1730c                 C   sH   t dg}t g d}||}t tt|t|B }t|| d S )Nz1 day 15:19:49.695000)z2 day 13:04:21.322000z1 day 15:27:24.873000z1 day 15:31:05.350000)r   r   r8   r9   r   r   r   r(   r)   r   r<   r    r    r!   test_union_bug_1745>   s   

z&TestTimedeltaIndex.test_union_bug_1745c                 C   sL   t dd}|tjd }||}ttt|t|B }t	|| d S )Nr   30d   )
r   pdoffsetsMinuter   r   r8   r9   r   r   r>   r    r    r!   test_union_bug_4564H   s
   

z&TestTimedeltaIndex.test_union_bug_4564c                 C   sh   t ddd}|g d }|g d }|jd u sJ |jd u s J ||}t|| |jdks2J d S )Nz1 Dayr   r	   )r      r#   r4   )r   r#   rF   r   )r   r   r   r   r   )r   r'   r(   r)   r   r    r    r!   test_union_freq_inferP   s   
z(TestTimedeltaIndex.test_union_freq_inferc                 C   s   t dddd}|tjd }||}t|dksJ t dddd}|tjd }||}t dd	dd}t|| |j|jksEJ d S )
Nr   r4   hr6   r   r   rF   z1 day 01:00:00r#   )	r   rB   rC   r   intersectionlenr   r   r   )r   index_1index_2r   r   r    r    r!   test_intersection_bug_1708_   s   

z-TestTimedeltaIndex.test_intersection_bug_1708c                 C   sl   t dddd}t dddd}|j||d}|d u r!t||  t|| |j||d}||u s4J d S )Nr   r4   rH   r6   r$   )r   rI   r   r   r0   )r   r%   firstsecond	intersectinterr    r    r!   test_intersection_equaln   s   z*TestTimedeltaIndex.test_intersection_equalzperiod_1, period_2)r   r4   )r4   r   c                 C   sH   t d|dd}t d|dd}t dddd}|j||d}t|| d S )Nr   rH   r6   r   r$   )r   rI   r   r   )r   period_1period_2r%   rK   rL   r   r   r    r    r!   test_intersection_zero_length|   s
   z0TestTimedeltaIndex.test_intersection_zero_lengthc                 C   sR   t dddd}t dddd}|j||d}||usJ ||us!J t|| d S )Nr   r   rH   r6   r#   r$   )r   rI   r   assert_copy)r   r%   rK   rL   r   r    r    r!   test_zero_length_input_index   s   z/TestTimedeltaIndex.test_zero_length_input_indexzrng, expectedr   r   rH   r1   r
   r   namer4   otherNr   )r   rY   c                 C   s^   t ddddd}|j||d}|d u r| }t|| |j|jks%J |j|jks-J d S )Nr   r4   rH   r1   rX   r$   )r   rI   r0   r   r   rY   r   r   rngr   r%   baser   r    r    r!   test_intersection   s   z$TestTimedeltaIndex.test_intersection)5 hour2 hour4 hourz9 hourrY   r`   ra   )r`   r_   r_   1 hourrc   rc   r`   ra   z3 hourc                 C   s   t g ddd}|j||d}|d u r| }t|| |j|jks%J t||d d d kr>|d u r>t|jt	s<J d S |jd u sEJ d S )Nrd   r1   rb   r$   re   )
r   rI   r0   r   r   rY   all
isinstancer   r   r[   r    r    r!   test_intersection_non_monotonic   s   z2TestTimedeltaIndex.test_intersection_non_monotonic)__name__
__module____qualname__r"   r*   r3   r=   r?   rE   rG   rM   rR   pytestmarkparametrizerU   rW   r   r   r^   rh   r    r    r    r!   r      sV    


	

r   c                   @   s   e Zd Zdd Zdd ZdS )TestTimedeltaIndexDifferencec                 C   s   t dddd}t dddd}tddgd d}|||}t|| td|| t dddd}|||}tddgdd}t|| td|| d S )	N0 days5 daysr   r/   1 days4 daysr   2 days)r   r   
differencer   r   assert_attr_equal)r   r%   indexrZ   r   idx_diffr    r    r!   test_difference_freq   s   z1TestTimedeltaIndexDifference.test_difference_freqc                 C   s   t g d}tdddd}|||}t ddgd d}|d u r#| }t|| td|| td	ddd}|||}t ddgd d}|d u rM| }t|| td|| d S )
N)rq   z3 daysrt   rs   rr   rp   rr   rs   r   r/   rq   rp   r   rt   )r   r   ru   r0   r   r   rv   )r   r%   rw   rZ   rx   r   r    r    r!   test_difference_sort   s"   z1TestTimedeltaIndexDifference.test_difference_sortN)ri   rj   rk   ry   rz   r    r    r    r!   ro      s    ro   )numpyr   rl   pandasrB   r   r   r   pandas._testing_testingr   pandas.tseries.offsetsr   r   ro   r    r    r    r!   <module>   s     D