
    .i4&                     |    d dl Zd dlZd dlm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)Pandas4Warning)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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        i/var/www/app/trading-bot/venv/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                    d}t        j                  t        |      5  t        g d      }d d d        t        j	                         d      }|j                  |      }t        j                  ||       |d d j                  |      }t        j                  ||       |j                  |j                  k(  sJ y # 1 sw Y   xY w)Nz:'d' is deprecated and will be removed in a future version.)match)3d1d2dinferr   r   )r   assert_produces_warningr   r   sort_valuesr   r   r   )r   msgidxorderedr"   s        r$   test_union_coveragez&TestTimedeltaIndex.test_union_coverage.   s    J''cB 	5 !34C	5 !2As#
fg.!""7+
fg.{{gll***	5 	5s   B<<C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_1730;   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   rB   rC   r   r   r   r-   r.   r"   rF   s        r$   test_union_bug_1745z&TestTimedeltaIndex.test_union_bug_1745C   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   rB   rC   r   r   rI   s        r$   test_union_bug_4564z&TestTimedeltaIndex.test_union_bug_4564M   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(   rS   r   )r   r   r   r   r   )r   r,   r-   r.   r"   s        r$   test_union_freq_inferz(TestTimedeltaIndex.test_union_freq_inferU   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   rS   z1 day 01:00:00r(   )	r   rN   rO   r   intersectionlenr   r   r   )r   index_1index_2r"   r#   s        r$   test_intersection_bug_1708z-TestTimedeltaIndex.test_intersection_bug_1708d   s    !'13?BJJOOA..%%g.6{a!'13?BJJOOA..%%g."#3QSI
fh/{{hmm+++r&   c                 8   t        ddd      }t        ddd      }|j                  ||      }|$t        j                  ||j	                                t        j                  ||       |j                  ||      }||usJ t        j                  ||       y )Nr   r>   rV   r@   r)   )r   rW   r   r   r8   )r   r*   firstsecond	intersectinters         r$   test_intersection_equalz*TestTimedeltaIndex.test_intersection_equals   s      = !#>&&vD&9	<!!)V-?-?-AB
i0 ""5t"4E!!!
eU+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   rV   r@   r   r)   )r   rW   r   r   )r   period_1period_2r*   rY   rZ   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   rV   r@   r(   r)   )r   rW   r   assert_copy)r   r*   rY   rZ   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   rV   r:   r   r   namer>   otherNr   zm8[us])r   rj   r   c                    t        dddd      }|j                  ||      }||j                         }t        j                  ||       |j
                  |j
                  k(  sJ |j                  |j                  k(  sJ y )Nr   r>   rV   r:   ri   r)   )r   rW   r8   r   r   rj   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rj   rr   rs   )rr   rq   rq   1 hourru   ru   rr   rs   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 )Nrv   r:   rt   r)   rw   )
r   rW   r8   r   r   rj   all
isinstancer   r   rm   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/   r<   rG   rJ   rQ   rT   r[   ra   pytestmarkparametrizere   rh   r   r   rp   r{    r&   r$   r	   r	      s   
0 ++++",, [[1FF3CD0 E0( [[  5I5I  7K4H  #EJ12Nr%xH	
(,)(, [[ 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   r6   1 days4 daysr   2 days)r   r   
differencer   r   assert_attr_equal)r   r*   indexrk   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   r6   r   r   r   r   )r   r   r   r8   r   r   r   )r   r*   r   rk   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)r|   r}   r~   r   r   r   r&   r$   r   r      s    9&9r&   r   )numpyr   r   pandas.errorsr   pandasrN   r   r   r   pandas._testing_testingr   pandas.tseries.offsetsr   r	   r   r   r&   r$   <module>r      s:      (  
  'D' D'N,9 ,9r&   