
    Owg%                     p    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      Z G d d      Zy)    N)IndexTimedeltaIndextimedelta_range)Hourc                   <   e Zd Zd Zd Zd Zd Zd Zd Zd Z	d Z
d	 Zej                  j                  d
ddg      d        Zd Zej                  j                  d edddd       edddd      f edddd       edddd      f edddd      dd  eg dd      fg      d        Zej                  j                  d eg dd       eddgd      f eg dd       ed dgd      f eg d!d      ddd"    eg d!d      fg      d#        Zy)$TestTimedeltaIndexc                 `   t        dd      }t        dd      }|j                  |      }t        dd      }t        j                  ||       t	        t        j                  dddt
        j                  	            }t        d
dd      }|j                  |       |j                  |       y )N1day   periods3day   r         )dtype1 day
   D)startr   freq)r   uniontmassert_index_equalr   nparangeint64)selfi1i2resultexpecteds        b/var/www/horilla/myenv/lib/python3.12/site-packages/pandas/tests/indexes/timedeltas/test_setops.py
test_unionzTestTimedeltaIndex.test_union   s    VQ/VQ/""615
fh/299QARXX677BSA

    c                    t        dd      }|dd  }|d d }|j                  |      sJ |j                  |      }t        j                  ||       |j                  |d      }t        g d      }t        j                  ||       y )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"   s         r#   test_union_sort_falsez(TestTimedeltaIndex.test_union_sort_false   s    fa012wBQ ##E***E"
fc*E.!"ST
fh/r%   c                 ,   t        g d      }t        |j                         d      }|j                  |      }t        j                  ||       |d d j                  |      }t        j                  ||       |j
                  |j
                  k(  sJ y )N)3d1d2dinferr   r   )r   sort_valuesr   r   r   r   )r   idxorderedr!   s       r#   test_union_coveragez&TestTimedeltaIndex.test_union_coverage,   sz    /0 !2As#
fg.!""7+
fg.{{gll***r%   c                     t        ddd      }t        ddd      }|j                  |      }t        t        t	        |      t	        |      z              }t        j                  ||       y )Nr      3hr   r   4h)r   r   r   sortedsetr   r   )r   rng_arng_br!   exps        r#   test_union_bug_1730z&TestTimedeltaIndex.test_union_bug_17306   sX    >>U#VCJU$;<=
fc*r%   c                     t        dg      }t        g d      }|j                  |      }t        t        t        |      t        |      z              }t	        j
                  ||       y )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   r>   r?   r   r   r   r,   r-   r!   rB   s        r#   test_union_bug_1745z&TestTimedeltaIndex.test_union_bug_1745>   sY    678W
 E"VCIE
$:;<
fc*r%   c                     t        dd      }|t        j                  j                  d      z   }|j	                  |      }t        t        t        |      t        |      z              }t        j                  ||       y )Nr   30d   )
r   pdoffsetsMinuter   r   r>   r?   r   r   rE   s        r#   test_union_bug_4564z&TestTimedeltaIndex.test_union_bug_4564H   sa    w.rzz((,,E"VCIE
$:;<
fc*r%   c                     t        dd      }|g d   }|g d   }|j                  J |j                  J |j                  |      }t        j                  ||       |j                  dk(  sJ y )Nz1 Dayr   r   )r      r'   r:   )r   r'   rO   r   )r   r   r   r   r   )r   r+   r,   r-   r!   s        r#   test_union_freq_inferz(TestTimedeltaIndex.test_union_freq_inferP   ss     gq1< Iyy   zz!!!E"
fc*{{c!!!r%   c                    t        ddd      }|t        j                  j                  d      z   }|j	                  |      }t        |      dk(  sJ t        ddd      }|t        j                  j                  d      z   }|j	                  |      }t        dd	d      }t        j                  ||       |j                  |j                  k(  sJ y )
Nr   r:   hr<   r   r   rO   z1 day 01:00:00r'   )	r   rJ   rK   r   intersectionlenr   r   r   )r   index_1index_2r!   r"   s        r#   test_intersection_bug_1708z-TestTimedeltaIndex.test_intersection_bug_1708_   s    !'13?BJJOOA..%%g.6{a!'13?BJJOOA..%%g."#3QSI
fh/{{hmm+++r%   c                    t        ddd      }t        ddd      }|j                  ||      }|$t        j                  ||j	                                t        j                  ||       |j                  ||      }||u sJ y )Nr   r:   rR   r<   r(   )r   rS   r   r   r5   )r   r)   firstsecond	intersectinters         r#   test_intersection_equalz*TestTimedeltaIndex.test_intersection_equaln   s      = !#>&&vD&9	<!!)V-?-?-AB
i0 ""5t"4~~r%   zperiod_1, period_2)r   r:   )r:   r   c                     t        d|d      }t        d|d      }t        ddd      }|j                  ||      }t        j                  ||       y )Nr   rR   r<   r   r(   )r   rS   r   r   )r   period_1period_2r)   rU   rV   r"   r!   s           r#   test_intersection_zero_lengthz0TestTimedeltaIndex.test_intersection_zero_length|   sS     "'8#F!'8#F"7AC@%%gD%9
fh/r%   c                     t        ddd      }t        ddd      }|j                  ||      }||usJ ||usJ t        j                  ||       y )Nr   r   rR   r<   r'   r(   )r   rS   r   assert_copy)r   r)   rU   rV   r!   s        r#   test_zero_length_input_indexz/TestTimedeltaIndex.test_zero_length_input_index   s]    !'13?!'13?%%gD%9f$$$f$$$
vw'r%   zrng, expectedr   r   rR   r6   r   r   namer:   otherNr   )r   rf   c                    t        dddd      }|j                  ||      }||j                         }t        j                  ||       |j
                  |j
                  k(  sJ |j                  |j                  k(  sJ y )Nr   r:   rR   r6   re   r(   )r   rS   r5   r   r   rf   r   r   rngr"   r)   baser!   s         r#   test_intersectionz$TestTimedeltaIndex.test_intersection   sx    , w%H""3T"2<++-H
fh/{{hmm+++{{hmm+++r%   )5 hour2 hour4 hourz9 hourrf   rn   ro   )rn   rm   rm   1 hourrq   rq   rn   ro   z3 hourc                 P   t        g dd      }|j                  ||      }||j                         }t        j                  ||       |j
                  |j
                  k(  sJ t        ||d d d   k(        r|t        |j                  t              sJ y |j                  J y )Nrr   r6   rp   r(   rs   )
r   rS   r5   r   r   rf   all
isinstancer   r   ri   s         r#   test_intersection_non_monotonicz2TestTimedeltaIndex.test_intersection_non_monotonic   s    0 FUS""3T"2<++-H
fh/{{hmm+++ ts4R4y !dlfkk4000;;&&&r%   )__name__
__module____qualname__r$   r.   r8   rC   rF   rM   rP   rW   r]   pytestmarkparametrizera   rd   r   r   rl   rw    r%   r#   r   r      s   
0 ++++", [[1FF3CD0 E0( [[  5I5I  7K4H  #EJ12Nr%8	
(,)(, [[ GeT(3%@ GgV(3$? GeTbD GeT		
,'-,'r%   r   c                       e Zd Zd Zd Zy)TestTimedeltaIndexDifferencec                    t        ddd      }t        ddd      }t        ddgd       }|j                  ||      }t        j                  ||       t        j
                  d||       t        ddd      }|j                  ||      }t        ddgd      }t        j                  ||       t        j
                  d||       y )	N0 days5 daysr   r4   1 days4 daysr   2 days)r   r   
differencer   r   assert_attr_equal)r   r)   indexrg   r"   idx_diffs         r#   test_difference_freqz1TestTimedeltaIndexDifference.test_difference_freq   s      (=(=!8X"6TB##E40
h1
VXx8  (=##E40!8X"6SA
h1
VXx8r%   c                    t        g d      }t        ddd      }|j                  ||      }t        ddgd       }||j                         }t	        j
                  ||       t	        j                  d||       t        d	dd      }|j                  ||      }t        ddgd       }||j                         }t	        j
                  ||       t	        j                  d||       y )
N)r   z3 daysr   r   r   r   r   r   r   r4   r   r   r   r   )r   r   r   r5   r   r   r   )r   r)   r   rg   r   r"   s         r#   test_difference_sortz1TestTimedeltaIndexDifference.test_difference_sort   s    H
  (=##E40!8X"6TB<++-H
h1
VXx8(=##E40!8X"6TB<++-H
h1
VXx8r%   N)rx   ry   rz   r   r   r~   r%   r#   r   r      s    9&9r%   r   )numpyr   r{   pandasrJ   r   r   r   pandas._testing_testingr   pandas.tseries.offsetsr   r   r   r~   r%   r#   <module>r      s7       
  '@' @'F,9 ,9r%   