
    LVf[C                    l   d dl m Z  d dlmZ d dlZd dlZd dlZd dlmZ	m
Z d dlmZmZmZmZmZ d dlmZ d dlZd dlmZmZmZmZmZmZmZmZmZm Z m!Z!m"Z"m#Z#m$Z$m%Z%m&Z&m'Z'm(Z( d dl)m*Z+ d dl,m-c m.Z d dl/m0Z0m1Z1 d dl2m-c m3Z4  G d	 d
      Z5 G d d      Z6d Z7 G d d      Z8 G d d      Z9 G d d      Z: G d d      Z; G d d      Z<d Z= G d d      Z>d Z?d Z@d ZAd ZBd ZCd  ZD G d! d"      ZE G d# d$      ZFej                  j                  d%ej                  ej                  g      d&        ZJy)'    )datetime)permutationsN)algos	hashtable)is_bool_dtypeis_complex_dtypeis_float_dtypeis_integer_dtypeis_object_dtype)CategoricalDtype)CategoricalCategoricalIndex	DataFrameDatetimeIndexIndexIntervalIndex
MultiIndexNaTPeriodPeriodIndexSeries	Timedelta	Timestampcut
date_rangetimedelta_rangeto_datetimeto_timedelta)DatetimeArrayTimedeltaArrayc                   ,
   e Zd Zej                  j                  dddg      d        Zd Zd Zd Z	d Z
d	 Zd
 Zd Zd Zd Zej                  j                  dg dg dg dfg dg dg dfg dg dg dfg      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ej                  j                  dddg      d!        Zd" Zej                  j                  d# ej:                  g d$d%&       ej:                  g d'd(&       ej:                  g d)d*&      g      d+        Zej                  j                  d, ej:                  g d-d%&      d.f ej:                  g d/d%&      d0f ej:                  g d1d(&      d2f ej:                  g d3d(&      d0f ej:                  g d4e&      d5f ej:                  g d6e&      d7f ej:                  g d8e&      d9fg      d:        Z ej                  j                  dddg      ej                  j                  d; ej:                  g d<e&       ej:                  d=d5ge&      f e!j:                  d>d0ejD                  d>gd?&       e!j:                  d>d0gd?&      fgd@dAgB      dC               Z#ej                  j                  dg dD ej:                  g dE ejH                  dF      &       ej:                  d5ejD                  d=ge&      fd5ejD                  d=d5g ej:                  g dE ejH                  dF      &       ej:                  d5ejD                  d=ge&      fg      dG        Z%ej                  j                  dg dH ej:                  g d- ejH                  dF      &       ej:                  d0ejD                  d>gdI&      fd0ejD                  d0d>g ej:                  g d- ejH                  dF      &       ej:                  d0ejD                  d>gejL                  &      fg      dJ        Z'ej                  j                  d e( e)g dK             ej:                  g dLejT                  &       e+d5d=gd5d=gdMN      f e, e)g dK             ej:                  g dLejT                  &       e+d5d=gd5d=gdMN      f e, e-dOdOgdPQ             ej:                  d.d.gejT                  &       e-dOgdPQ      fg      dR        Z.yS)TTestFactorizesortTFc                    |}|j                  |      \  }}t        }t        |t              rt        j                  }|j                         }|j                  t        j                  k(  r|j                  t        j                        } ||      }t        |t              r;|j                  t        k(  r(|j                  t        k(  r|j                  t              }|r|j                         }t        |      }	|D 
cg c]  }
|	j                  |
       }}
t        j                   |t        j"                        }t%        j&                  ||       t%        j(                  ||d       y c c}
w )Nr#   dtypeTexact)	factorizer   
isinstancer   from_tuplesuniquer'   npfloat16astypefloat32boolobjectsort_valueslistindexasarrayintptmassert_numpy_array_equalassert_index_equal)selfindex_or_series_objr#   objresult_codesresult_uniquesconstructorexpected_arrexpected_uniquesexpected_uniques_listvalexpected_codess               `/var/www/html/software/conda/envs/catlas/lib/python3.12/site-packages/pandas/tests/test_algos.pytest_factorizezTestFactorize.test_factorize5   s#   !'*}}$}'?$nc:&$00Kzz|+'..rzz:L&|4sE" &&$.		V#/66v>/;;= !%%5 6FIJs/55c:JJN"''B
##L.A
n.>dK	 Ks   >E,c                 p   t        j                  dddt         j                  g      }t        |      }|j	                  d      \  }}t        j                  g dt         j
                        }t        ddt         j                  g      }t        j                  ||       t        j                  ||       y )	N      Fuse_na_sentinelr   rJ   r   rK   r&         ?       @)
r.   arraynanr   r*   r8   r   r9   r:   r;   )r<   valuessercodesuniquesrF   rC   s          rG   +test_series_factorize_use_na_sentinel_falsez9TestFactorize.test_series_factorize_use_na_sentinel_falseT   s    1aBFF+,Vnu=w,bgg> #sBFF!34
##E>:
g'78    c                    t        j                  g dt              }t        j                  |      \  }}t        j                  |t        j                  g dt                     t        j                  |d      \  }}t        j                  g dt         j                        }t        j                  ||       t        j                  g dt              }t        j                  ||       t        j                  dt         j                        d d d   }t        j                  |      \  }}t        j                  g d	t         j                        }t        j                  ||       t        j                  g d
|j                        }t        j                  ||       t        j                  |d      \  }}t        j                  g d
t         j                        }t        j                  ||       t        j                  g d	|j                        }t        j                  ||       t        j                  d      d d d   }t        j                  |      \  }}t        j                  g d	t         j                        }t        j                  ||       t        j                  g d|j                        }t        j                  ||       t        j                  |d      \  }}t        j                  g d
t         j                        }t        j                  ||       t        j                  g d|j                        }t        j                  ||       y )N)abr[   rZ   rZ   cr\   r\   r&   rZ   r[   r\   Tr%   )r   rJ   rJ   r   r   rK   rK   rK      )r   rJ   rK         )ra   r`   rK   rJ   r         @)      @      @rP   rO           )re   rO   rP   rd   rc   )
r.   rQ   r3   r   r*   r9   r:   r8   aranger'   )r<   itemsrU   rV   exparrs         rG   
test_basiczTestFactorize.test_basic`   s:   AP/w
##GRXXoV-TUT:whh/rww?
##E3/hhf5
##GS1ii)$B$/-whhbgg6
##E3/hhcii8
##GS148whhbgg6
##E3/hhcii8
##GS1iinTrT"-whhbgg6
##E3/hh0		B
##GS148whhbgg6
##E3/hh0		B
##GS1rX   c                    t        ddt        j                  ddt        j                  g      }t	        j
                  |      \  }}t        j                  g dt        j                        }t        j                  ||       t        dddt        j                  g      }t        j                  ||       t	        j
                  |d      \  }}t        j                  g dt        j                        }t        j                  ||       t        dt        j                  ddg      }t        j                  ||       y )	NABgQ	@)r   r   r_   rJ   rK   r`   r&   Tr%   )rK   rK   r_   r`   r   rJ   )r   r.   rR   infr   r*   rQ   r8   r9   r:   r   r;   )r<   xrU   rV   rh   s        rG   
test_mixedzTestFactorize.test_mixed   s    Cbffc489+whh*"'':
##E3/S#tRVV,-
gs+6whh*"'':
##E3/T2663,-
gs+rX   c                 6   t        d      }t        d      }t        ||||||g      }t        j                  |      \  }}t	        j
                  g dt        j                        }t        j                  ||       t        ||g      }t        j                  ||       t        j                  |d      \  }}t	        j
                  g dt        j                        }t        j                  ||       t        ||g      }t        j                  ||       y )Nz20130101 09:00:00.0000420130101r   r   r   rJ   rJ   r   r&   Tr%   )rJ   rJ   rJ   r   r   rJ   )r   r   r   r*   r.   rQ   r8   r9   r:   r   r;   r<   v1v2ro   rU   rV   rh   s          rG   test_factorize_datetime64z'TestFactorize.test_factorize_datetime64   s    01z"BBB+,+whh)9
##E3/RH%
gs+6whh)9
##E3/RH%
gs+rX   c                 6   t        dd      }t        dd      }t        ||||||g      }t        j                  |      \  }}t	        j
                  g dt        j                        }t        j                  ||       t        j                  |t        ||g             t        j                  |d      \  }}t	        j
                  g dt        j                        }t        j                  ||       t        j                  |t        ||g             y )	N201302Mfreq201303rs   r&   Tr%   )r   r   r   r*   r.   rQ   r8   r9   r:   r;   r   rt   s          rG   test_factorize_periodz#TestFactorize.test_factorize_period   s    H3'H3'BBB+, +whh)9
##E3/
g{B8'<=6whh)9
##E3/
g{B8'<=rX   c           	      0   t        d      }t        d      }t        |||||||g      }t        j                  |      \  }}t	        j
                  g dt        j                        }t        j                  ||       t        j                  |t        ||g             t        j                  |d      \  }}t	        j
                  g dt        j                        }t        j                  ||       t        j                  |t        ||g             y )Nz1 day 1 min1 day)r   rJ   r   r   rJ   rJ   r   r&   Tr%   )rJ   r   rJ   rJ   r   r   rJ   )
r   r   r   r*   r.   rQ   r8   r9   r:   r;   rt   s          rG   test_factorize_timedeltaz&TestFactorize.test_factorize_timedelta   s    -('"BBBB/0+whh,BGG<
##E3/
g|RH'=>6whh,BGG<
##E3/
g|RH'=>rX   c                    t        j                  dddt         j                  gd      }t        j                  t        |            }dD ]  }|j                  ||      }t        j                  ddd|gt         j                        }t        t        |            t        t        |            k(  sJ t        j                  t        j                  |      ||k(         t        j                  ||        y )NrJ   rK   Or&   )r_      )na_sentinelr   )r.   rQ   rR   htObjectFactorizerlenr*   r8   setr9   r:   pdisna)r<   keyrizerr   idsexpecteds         rG   test_factorize_nanz TestFactorize.test_factorize_nan   s     hh1a(4##CH-# 	7K//#;/?CxxAq+ 6bggFHs3x=CH$6666''h+6MN''X6	7rX   c                    t        j                  g dd      }t        j                  g d      }t        j                  t	        |            }|j                  ||      }t        j                  g dt         j                        }t        j                  ||       t        j                  g dd      }t        j                  |j                  j                         |       y )N)rJ   rK   r`   rJ   rJ   r   int64r&   )FFFFFT)mask)r   rJ   rK   r   r   r_   rJ   rK   r`   )r.   rQ   r   Int64Factorizerr   r*   r8   r9   r:   rV   to_array)r<   datar   r   resultr   rC   s          rG   test_factorizer_with_maskz'TestFactorize.test_factorizer_with_mask   s    xx*':xxAB""3t9-D188/rww?
##FH588IW=
##EMM$:$:$<>NOrX   c                    t        j                  ddddt         j                  g      }t        j                  t        |            }|j                  |j                  t                    }t        j                  g dt         j                        }t        j                  ||       t        j                  g dt              }t        j                  |j                  j                         |       y )NrJ   rK   r`   )r   rJ   rK   r   r_   r&   r   )r.   rQ   rR   r   r   r   r*   r0   r3   r8   r9   r:   rV   r   )r<   r   r   r   r   rC   s         rG   test_factorizer_object_with_nanz-TestFactorize.test_factorizer_object_with_nan   s    xxAq!RVV,-##CI.V!4588,BGG<
##FH588IV<
##EMM$:$:$<>NOrX   z&data, expected_codes, expected_uniques)rJ   rJ   rJ   rK   r   r   r   nonsense)r   rJ   rK   rJ   r`   )r   r   r   r   )r   r   r   r   r   )r   r   r   r   )r   r   r   r   )r   rJ   rK   rJ   )r   r   r   c                 l   d}t        j                  t        |      5  t        j                  |      \  }}d d d        t        j
                  t        j                  |t        j                               t        j                  |t              }t        j
                  |       y # 1 sw Y   txY w)N0factorize with argument that is not not a Seriesmatchr&   )r9   assert_produces_warningFutureWarningr   r*   r:   r.   rQ   r8   comasarray_tuplesafer3   )r<   r   rF   rC   msgrU   rV   expected_uniques_arrays           rG   test_factorize_tuple_listz'TestFactorize.test_factorize_tuple_list   s    $ A''SA 	0\\$/NE7	0 	##E288N"''+RS!$!6!67Gv!V
##G-CD	0 	0s   B**B3c                 "   t        j                  t        d      D cg c]  }t        |       c}t              }d}t        j                  t        |      5  t        j                  |d d d   d       d d d        y c c}w # 1 sw Y   y xY w)N   r&   z,'[<>]' not supported between instances of .*r   r_   Tr%   )
r.   rQ   rangecomplexr3   pytestraises	TypeErrorr   r*   )r<   ix17r   s       rG   test_complex_sortingz"TestFactorize.test_complex_sorting  sm    hhE"I6q
6fE<]]9C0 	2OOC"ID1	2 	2 7	2 	2s   B BBc                 B   |}t        j                  g d|      }t        j                  g dt         j                        }t        j                  ddg|      }t        j                  |      \  }}t        j                  ||       t        j                  ||       y )N)rJ   rK   rK   rJ   r&   )r   rJ   rJ   r   rJ   rK   )r.   rQ   r8   r   r*   r9   r:   )r<   any_real_numpy_dtyper'   r   rF   rC   rU   rV   s           rG   test_numeric_dtype_factorizez*TestFactorize.test_numeric_dtype_factorize  ss    $xxE2,bgg>88QF%8.w
##E>:
##G-=>rX   c                    t        j                  g dt         j                        }|j                  |       t        j                  g dt         j                        }t        j                  g dt         j                        }t        j                  |      \  }}t        j                  ||       t        j                  ||       y )N)rO       חArO   :0yE>r   rO   r&   write)r   rJ   r   rK   rJ   r   )rO   r   r   )	r.   rQ   float64setflagsr8   r   r*   r9   r:   r<   writabler   rF   rC   rU   rV   s          rG   test_float64_factorizez$TestFactorize.test_float64_factorize  s    xx7rzzJH%"4BGGD88$4BJJG.w
##E>:
##G-=>rX   c                    t        j                  g dt         j                        }|j                  |       t        j                  g dt         j                        }t        j                  ddgt         j                        }t        j                  |      \  }}t        j                  ||       t        j                  ||       y )N)    rJ   r   r&   r   r   rJ   r   r   rJ   )	r.   rQ   uint64r   r8   r   r*   r9   r:   r   s          rG   test_uint64_factorizez#TestFactorize.test_uint64_factorize#  s    xx1CH%)277;88YN"))D.w
##E>:
##G-=>rX   c                    t        j                  g dt         j                        }|j                  |       t        j                  g dt         j                        }t        j                  ddgt         j                        }t        j                  |      \  }}t        j                  ||       t        j                  ||       y )N)             r   r&   r   r   r   r   )	r.   rQ   r   r   r8   r   r*   r9   r:   r   s          rG   test_int64_factorizez"TestFactorize.test_int64_factorize-  s    xx8IH%)277;88Y$9J.w
##E>:
##G-=>rX   c                 r   t        j                  g dt              }|j                  |       t        j                  g dt         j                        }t        j                  g dt              }t        j                  |      \  }}t        j                  ||       t        j                  ||       y )N)rZ   r\   rZ   r[   r\   r&   r   )r   rJ   r   rK   rJ   rZ   r\   r[   )	r.   rQ   r3   r   r8   r   r*   r9   r:   r   s          rG   test_string_factorizez#TestFactorize.test_string_factorize7  sy    xx1@H%/A88O6B.w
##E>:
##G-=>rX   c           
         t        j                  ddd t         j                  ddt        dgt              }|j                  |       t        j                  g dt         j                        }t        j                  g dt              }t        j                  |      \  }}t        j                  ||       t        j                  ||       y )NrZ   r\   r[   r&   r   )r   rJ   r_   r_   r   rK   r_   rJ   r   )r.   rQ   rR   r   r3   r   r8   r   r*   r9   r:   r   s          rG   test_object_factorizez#TestFactorize.test_object_factorizeA  s    xxc4c3DFSH%"=RWWM88O6B.w
##E>:
##G-=>rX   c                    t        j                  t        j                  d      gd      }|j                  |       t        j                  dgt         j                        }t        j                  dgd      }t        j                  |      \  }}t        j                  ||       t        j                  ||       y )Nz2020-01-01T00:00:00.000M8[ns]r&   r   r   z2020-01-01T00:00:00.000000000datetime64[ns])	r.   rQ   
datetime64r   r8   r   r*   r9   r:   r   s          rG   test_datetime64_factorizez'TestFactorize.test_datetime64_factorizeK  s    xx'@AB(SH%1#RWW588,-5E
 d+w
##E>:
##G-=>rX   c                    t         j                  j                  t        d            }t	        j
                  dt        j                        |f}t        j                  ||      }t        j                  |d   |d          t        j                  |d   |d   d       |j                  |      }t        j                  |d   |d          t        j                  |d   |d   d       y )N
   r&   r%   r   rJ   Tr(   r   
RangeIndex
from_ranger   r.   rf   r8   r   r*   r9   r:   r;   )r<   r#   rir   r   s        rG   test_factorize_rangeindexz'TestFactorize.test_factorize_rangeindexX  s     ]]%%eBi099Rrww/3$/
##F1Ix{;
fQi!DA4(
##F1Ix{;
fQi!DArX   c                 *   t         j                  j                  t        d            }t	        j
                  dt        j                        |f}|d d d   }|d   |f}|r|d   d d d   |d   d d d   f}t        j                  ||      }t        j                  |d   |d          t        j                  |d   |d   d       |j                  |      }t        j                  |d   |d          t        j                  |d   |d   d       y )	Nr   r&   r_   r   rJ   r%   Tr(   r   )r<   r#   r   r   ri2r   s         rG   $test_factorize_rangeindex_decreasingz2TestFactorize.test_factorize_rangeindex_decreasingf  s     ]]%%eBi099Rrww/32hA;#{4R4((1+dd*;;H40
##F1Ix{;
fQi!DAD)
##F1Ix{;
fQi!DArX   c                 ^   t        j                  g dt         j                        }t        j                  t
        d      5  t        j                  |d       d d d        t        j                  d      5  t        j                  |       d d d        y # 1 sw Y   =xY w# 1 sw Y   y xY w)N)            rJ   r   r&   zgot an unexpected keywordr   T)orderF)
r.   rQ   r   r   r   r   r   r*   r9   r   )r<   r   s     rG   test_deprecate_orderz"TestFactorize.test_deprecate_ordery  s     xx);]]9,GH 	.OOD-	.''. 	"OOD!	" 	"	. 	.	" 	"s   B8B#B #B,r   r   u8r&   )r   rJ   r   i8)__nan__foor   r3   c                     t        j                  |      \  }}|ddg   }t        j                  g dt        j                        }t        j                  ||       t        j                  ||       y )Nr   rJ   r   r&   )r   r*   r.   rQ   r8   r9   r:   )r<   r   rU   rV   rC   rF   s         rG   ,test_parametrized_factorize_na_value_defaultz:TestFactorize.test_parametrized_factorize_na_value_default  sY     .wA<)277;
##E>:
##G-=>rX   zdata, na_valuerN   r   )rJ   r   rJ   rK   rJ   )r   rJ   r   r   r   )rJ   r   rJ   r   )rZ    rZ   r[   rZ   ) rZ   rJ   r   rZ   rK   r   )r   r   r   r   r   c                     t        j                  ||      \  }}|ddg   }t        j                  g dt        j                        }t        j                  ||       t        j                  ||       y )N)na_valuerJ   r`   )r_   r   r_   rJ   r&   )r   factorize_arrayr.   rQ   r8   r9   r:   )r<   r   r   rU   rV   rC   rF   s          rG   $test_parametrized_factorize_na_valuez2TestFactorize.test_parametrized_factorize_na_value  s]     ..thGwA<.@
##E>:
##G-=>rX   zdata, uniques)r[   rZ   Nr[   r[   rK   Int64numpy_arrayextension_array)r   c                    t        j                  ||d      \  }}|r=t        j                  g dt        j                        }t        j
                  |      }n)t        j                  g dt        j                        }|}t        j                  ||       t        |t        j                        rt        j                  ||       y t        j                  ||       y )NT)r#   rM   )rJ   r   r_   rJ   r&   )r   rJ   r_   r   )r   r*   r.   rQ   r8   	safe_sortr9   r:   r+   ndarrayassert_extension_array_equal)r<   r#   r   rV   rU   rF   rC   s          rG   test_factorize_use_na_sentinelz,TestFactorize.test_factorize_use_na_sentinel  s      D$OwXXm277CN$w7XXm277CN&
##E>:dBJJ'''1AB++G5EFrX   )rZ   Nr[   rZ   r   rJ   rK   r   r8   c                     t        j                  t        j                  |t              d      \  }}t        j                  ||d       t        j                  ||d       y )Nr&   FrL   T
strict_nan)r   r*   r.   rQ   r3   r9   r:   r<   r   rF   rC   rU   rV   s         rG   +test_object_factorize_use_na_sentinel_falsez9TestFactorize.test_object_factorize_use_na_sentinel_false  sM    $ HHT(%
w 	##G-=$O
##E>dKrX   )rJ   NrJ   rK   r   c                     d}t        j                  t        |      5  t        j                  |d      \  }}d d d        t        j
                  |d       t        j
                  |d       y # 1 sw Y   :xY w)Nr   r   FrL   Tr   )r9   r   r   r   r*   r:   )r<   r   rF   rC   r   rU   rV   s          rG   (test_int_factorize_use_na_sentinel_falsez6TestFactorize.test_int_factorize_use_na_sentinel_false  sn    $ A''SA 	J"__T5INE7	J 	##G-=$O
##E>dK		J 	Js   A22A;)rZ   rZ   r[   )r   r   rJ   category)
categoriesr'   2017
US/Easterntzc                     t        j                  |      \  }}t        j                  ||       t        j                  ||       y N)r   r*   r9   r:   r;   r   s         rG   test_factorize_mixed_valuesz)TestFactorize.test_factorize_mixed_values  s7    , .w
##E>:
g'78rX   N)/__name__
__module____qualname__r   markparametrizerH   rW   rj   rp   rw   r~   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r.   rQ   r   r3   r   r   rR   r   r'   r   r   r   r   r   r8   r   r   r   r	  r   rX   rG   r"   r"   4   sn   [[VdE]3L 4L<
9%2N, ,$>"?7	PP [[0 =4 <3
 .|=UV	
 	E! 	E2	??????? [[VdE]3B 4B [[VdE]3B 4B$" [[BHHYd+BHH,D9BHH2(C	
?? [[RXXl$/3RXXl$/3RXX0=xHRXX)6:RXX)8#>RXX2&A2FRXX8GR	
?? [[VdE]3[[ .f=#s62
 !Q*':!Qw/		
 -.  G 4G [[0 &XRXXf-=>#rvvs+6: bffc3'XRXXf-=>#rvvs+6:	
LL [[0  XRXXf-=>!RVVQs3 BFFAq!XRXXf-=>!RVVQrzz:	
LL [[0 k/23"''2 #sc
*U {?34"''2 #sc
*U }ff%5,GH!Qrww/vh<8	
(9)(9rX   r"   c            	       x   e Zd Zd Zd Zd Zd 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 ej*                  ddge      fd ej*                  dge      fg      d        Zd Zd Zd Zej$                  j'                  dej6                  eg      d        Zd Zd Zy)
TestUniquec                     t         j                  j                  d      j                  ddd      }t	        j
                  |      }t        |t         j                        sJ y )NrK   r   d   2   size)r.   randomdefault_rngintegersr   r-   r+   r   r<   ri   r   s      rG   	test_intszTestUnique.test_ints  sJ    ii##A&//3R/@c"&"**---rX   c                     t         j                  j                  d      j                  ddd      j	                  d      }t        j                  |      }t        |t         j                        sJ y )NrK   r   r  r  r  r   )	r.   r  r  r  r0   r   r-   r+   r   r  s      rG   test_objectszTestUnique.test_objects  sU    ii##A&//3R/@GGLc"&"**---rX   c                     t        j                  g dt              }t        d      D ]   }t	        t        j                  |             " y )N)rl   rm   CDEr&     )r.   rQ   r3   r   r   r   r-   )r<   lstr   s      rG   test_object_refcount_bugz#TestUnique.test_object_refcount_bug  s7    hh0?t 	#AS!"	#rX   c                    t        j                  t        j                  d      j	                  d      t        j
                  t        j                  d      d      g      }|j                  }|j                          |j	                  d      }t        j                  |      }|j                          t        j                  ||       y )Nr^   rK   )r   from_arraysr.   rf   repeattilerS   r#   r   r-   r9   assert_almost_equal)r<   mindexr   r   s       rG   test_on_index_objectzTestUnique.test_on_index_object!  s    ''YYq\  #RWWRYYq\1%=>
 ==q!6"
vx0rX   c                    |t         j                  t         j                  z   v r	g d}ddg}nt        |      r	g d}ddg}nt	        |      r	g d}ddg}nwt        |      r<t        dd      t        dd      t        dd      g}t        dd      t        dd      g}n0t        |      r	g d}dd	g}nt        |      r	g d
}ddg}ng d}ddg}t        ||      j                         }t        j                  ||      }|t         j                  v r|j                  t              }|j                  j                   dv r-t#        |t$        t&        f      sJ t        j                  |      }t        j(                  ||       y )N)rJ   rK   rK   rJ   rK   rO   rP   r   TTFTF)rl   rm   rm   rl   rm   r&   )mrz   )r9   BYTES_DTYPESSTRING_DTYPESr
   r	   r   r   r   r   r   r-   r.   rQ   r0   r3   r'   kindr+   r   r    r:   )r<   any_numpy_dtyper   rV   r   r   s         rG   test_dtype_preservationz"TestUnique.test_dtype_preservation/  sQ   r1A1AABD!fGo.D!fGO,DCjGo.AqM71a='!Q-@Dq!}gam4G?+&DUmG_-"DCjG D!fGO4;;=88G?;b...v.H>>*,f}n&EFFFXXf%F
##FH5rX   c                 "   t        j                  ddgd      }t        g d      }t        j                  |      }t        j                  ||       |j                  |j                  k(  sJ t        |      }t        j                  |      }t        j                  ||       |j                  |j                  k(  sJ |j                  }t        j                  |      }t        j                  ||       |j                  |j                  k(  sJ y )N2015-01-03T00:00:00.0000000002015-01-01T00:00:00.000000000r   r&   )r4  r5  r5  )
r.   rQ   r   r   r-   r9   r:   r'   r   rS   )r<   r   dt_indexr   sri   s         rG   $test_datetime64_dtype_array_returnedz/TestUnique.test_datetime64_dtype_array_returnedT  s    88// 
 
 h'
##FH5||x~~---8a
##FH5||x~~---hhc"
##FH5||x~~---rX   c                     t        j                  g dd      }t        j                  |      }t        j                  ddgd      }t	        j
                  ||       y )N2000r;  2001zdatetime64[s]r&   r;  r<  r.   rQ   r   r-   r9   r:   r<   rZ   r   r   s       rG   test_datetime_non_nszTestUnique.test_datetime_non_nss  sE    HH-_E188VV,OD
##FH5rX   c                     t        j                  g dd      }t        j                  |      }t        j                  ddgd      }t	        j
                  ||       y )Nr:  ztimedelta64[s]r&   i  i  r=  r>  s       rG   test_timedelta_non_nsz TestUnique.test_timedelta_non_nsy  sF    HH-5EF188T4L0@A
##FH5rX   c                 "   t        j                  g dd      }t        g d      }t        j                  |      }t        j                  ||       |j                  |j                  k(  sJ t        |      }t        j                  |      }t        j                  ||       |j                  |j                  k(  sJ |j                  }t        j                  |      }t        j                  ||       |j                  |j                  k(  sJ y )N)y  n  '  m8[ns]r&   )rC  rD  rC  rE  rD  )
r.   rQ   r   r   r-   r9   r:   r'   r   rS   )r<   r   td_indexr   r7  ri   s         rG   %test_timedelta64_dtype_array_returnedz0TestUnique.test_timedelta64_dtype_array_returned  s    881B CDh'
##FH5||x~~---8a
##FH5||x~~---hhc"
##FH5||x~~---rX   c                     t        g dt        j                        }t        j                  g dt        j                        }t	        j
                  t        j                  |      |       y )N)rJ   rK   r   r   r&   )rJ   rK   r   )r   r.   r   rQ   r9   r:   r   r-   )r<   r7  rh   s      rG   test_uint64_overflowzTestUnique.test_uint64_overflow  s?    'ryy9hh}BII6
##ELLOS9rX   c                    dt         j                  ddg}t        j                  t        j                  |t
                    }t        j                  dt         j                  dgt
              }t        j                  ||       y )NrZ   r\   r&   )r.   rR   r   r-   rQ   r3   r9   r:   )r<   duplicated_itemsr   r   s       rG   test_nan_in_object_arrayz#TestUnique.test_nan_in_object_array  sZ    c2288$4FCD88S"&&#.f=
##FH5rX   c                    t        t        d            }t        t        d      t        d      d      }t        t        d            }|j                         }t        j                  ||       t        j                  |      }t        j                  ||       t        t        d      d      }|j                         }t        j                  ||       t        j                  |      }t        j                  ||       t        t        t        d            d      }|j                         }t        j                  ||       t        j                  |      }t        j                  ||       t        t        t        d      t        d      	            }t        |      }|j                         }t        j                  ||       t        j                  |      }t        j                  ||       y )
NbacabcTr  orderedbaabcrR  r   namer  )
r   r5   r-   r9   assert_categorical_equalr   r   r   r   r;   )r<   r   
expected_or\   r   r7  cis          rG   test_categoricalzTestUnique.test_categorical  sf    tE{+ !eedS
 W&
##FH5a
##FH5Wt4
##FJ7a
##FJ7 ;tG}-E:
##FH51
##FH5 k$w-DKPQ#H-
fh/2
fh/rX   c                    t        t        t        dd      t        dd      g            j                         }t	        j
                  t        j                  t        dd      g            }t        j                  ||       t        t        dd      t        dd      g      j                         }t        dgdd       }t        j                  ||       t        j                  t        t        t        dd      t        dd      g                  }t	        j
                  t        j                  t        dd      g            }t        j                  ||       t        j                  t        t        dd      t        dd      g            }t        dgdd       }t        j                  ||       y )	N20160101r  r  z2016-01-01 00:00:00-05002016-01-01 00:00:00datetime64[ns, US/Eastern]r'   r|   
2016-01-01)r   r   r   r-   r   _from_sequencer.   rQ   r9   r   r   r;   r   r<   r   r   s      rG   test_datetime64tz_awarez"TestUnique.test_datetime64tz_aware  s    j\:j\:
 &( 	 !//HHi :|LMN
 	''9*6*6

 &( 	 !"#+Gd
 	fh/!*>!*>	
 !//HHi>?@
 	''9j\:j\:
 !"#+Gd
 	fh/rX   c           	      t   t        j                  t        g d            }t        j                  |t        j                  g dd             t        j                  t        dgdgdz  z               }t        j                  |t        j                  ddgd             t        j                  t        t        d      t        d      g            }t        j                  d	gd
      }t        j                  ||       t        j                  t        t        dd      t        dd      g            }t        dgdd       }t        j                  ||       d}t        j                  t        |      5  t        j                  t        d            }d d d        t        j                  g dt              }t        j                  ||       t        j                  t        t        t        d                        }t        t        d            }t        j                   ||       y # 1 sw Y   xY w)N)rK   rJ   r`   r`   )rK   rJ   r`   r   r&   rK   rJ   r^   r]  z2016-01-01T00:00:00.000000000r   r  r  r^  r_  r`  z5unique with argument that is not not a Series, Index,r   aabcr]   rP  )r   r-   r   r9   r:   r.   rQ   r   r   r   r;   r   r   r5   r3   r   rX  )r<   r   r   r   s       rG   test_order_of_appearancez#TestUnique.test_order_of_appearance  s    6,/0
##FBHHYg,NO61#a-01
##FBHHaV7,KL69Z#8)J:O"PQR88<=EUV
##FH5j\:j\:
 !"#+Gd
 	fh/E''SA 	-YYtF|,F	-88O6:
##FH56+d6l";<=tE{+
##FH5	- 	-s   9H..H7zarg ,expected)1rh  2rh  ri  r&   )r   r   c                     d}t        j                  t        |      5  t        j                  |      }d d d        t        j
                  |       y # 1 sw Y    xY wN-unique with argument that is not not a Seriesr   r9   r   r   r   r-   r:   )r<   argr   r   r   s        rG   test_tuple_with_stringsz"TestUnique.test_tuple_with_strings"  sK     >''SA 	$YYs^F	$
##FH5	$ 	$   AAc                     t        j                  dd gt              }t        j                  |      }t        j                  dd gt              }t        j                  ||d       y )Nr   r&   Tr   )r.   rQ   r3   r   r-   r9   r:   r<   ri   r   r   s       rG   test_obj_none_preservationz%TestUnique.test_obj_none_preservation0  sI    hht}F3388UDM8
##FHFrX   c                     t        j                  ddg      }t        j                  |      }t        j                  dg      }t	        j
                  ||       y )Ng       re   r=  r>  s       rG   test_signed_zerozTestUnique.test_signed_zero8  sA    HHdC[!188TF#
##FH5rX   c                    t        j                  dt        j                  dd            d   }t        j                  dt        j                  dd            d   }||k7  sJ ||k7  sJ t        j                  ||g      }t        j                  |      }t        j                  t        j                  g      }t        j                  ||       y )Nd=Q          r            )
structunpackpackr.   rQ   r   r-   rR   r9   r:   )r<   NAN1NAN2rZ   r   r   s         rG   test_different_nanszTestUnique.test_different_nans?  s     }}S&++d4F"GHK}}S&++d4F"GHKt||t||HHdD\"188RVVH%
##FH5rX   el_typec                    d}d}t        j                  dt        j                  d|            d   }t        j                  dt        j                  d|            d   }||k7  sJ ||k7  sJ t        j                  ||g|      }t        j                  |      }|j                  dk(  sJ t        j                  dt        j                  d|d               d   }||k(  sJ y )Nl         rz  rw  rx  r   r&   rJ   )r{  r|  r}  r.   rQ   r   r-   r  )	r<   r  bits_for_nan1bits_for_nan2r~  r  rZ   r   result_nan_bitss	            rG   test_first_nan_keptzTestUnique.test_first_nan_keptK  s     +*}}S&++dM"BCAF}}S&++dM"BCAFt||t||HHdD\11{{a --fkk#vay.IJ1M-///rX   c                     ||u ry t        j                  ||gt              }t        j                  |      }|j
                  dk(  sJ |d   |u sJ |d   |u sJ y )Nr&   rK   r   rJ   )r.   rQ   r3   r   r-   r  )r<   unique_nulls_fixtureunique_nulls_fixture2rZ   r   s        rG   test_do_not_mangle_na_valuesz'TestUnique.test_do_not_mangle_na_values\  sj    #88HH*,AB&Q1{{at++++t,,,,rX   c                     t        dt        j                  dgdz  |      }t        j                  |      }t        j                  dt        j                  dg|      }t        j                  ||       y )NrJ   rK   r`   r&   )r   r   NAr-   rQ   r9   r   )r<   any_numeric_ea_dtyperT   r   r   s        rG   test_unique_maskedzTestUnique.test_unique_maskedf  sV    a]Q&.BC388QqM1EF
''9rX   N)r
  r  r  r  r  r#  r*  r2  r8  r?  rA  rH  rJ  rM  r[  rd  rg  r   r  r  r.   rQ   r3   ro  rs  ru  r  r   r  r  r  r   rX   rG   r  r    s    ..#
1#6J.>66.&:
6'0R50n#6J [[hbhhSz@Axrxxv67	
66G6
6 [[YV(<=0 >0 -:rX   r  c                      | t         j                  j                  d      j                  ddd            }t	        j
                  |      }t        t	        j                  |            }||k(  sJ y )NrK   r   r      )r.   r  r  r  r   nunique_intsr   r-   )index_or_series_or_arrayrS   r   r   s       rG   test_nunique_intsr  n  s[    %bii&;&;A&>&G&G2r&RSF'F5<<'(HXrX   c                   z   e Zd Zd Zd Zd Zej                  j                  dg d      ej                  j                  dg d      d               Z	d	 Z
d
 Zd Zd Zd Zd Zd Zd Zd Zej                  j                  dg  ee       ej,                  g       g      d        Zd Zd Zd Zd Zd Zd Zy)TestIsinc                    d}t        j                  t        |      5  t        j                  dd       d d d        t        j                  t        |      5  t        j                  ddg       d d d        t        j                  t        |      5  t        j                  dgd       d d d        y # 1 sw Y   xY w# 1 sw Y   QxY w# 1 sw Y   y xY w)NzOonly list-like objects are allowed to be passed to isin\(\), you passed a `int`r   rJ   )r   r   r   r   isin)r<   r   s     rG   test_invalidzTestIsin.test_invalidw  s    " 	 ]]9C0 	JJq!	]]9C0 	JJq1#	]]9C0 	JJsA	 			 		 		 	s#   B4C C4B= C	Cc                    d}t        j                  t        |      5  t        j                  ddgdg      }d d d        t        j                  ddg      }t        j                  |       t        j                  t        j                  ddg      dg      }t        j                  ddg      }t        j                  ||       t        j                  t        ddg      dg      }t        j                  ddg      }t        j                  ||       t        j                  t        ddg      t        dg            }t        j                  ddg      }t        j                  ||       t        j                  t        ddg      dh      }t        j                  ddg      }t        j                  ||       t        j                  t        |      5  t        j                  ddgdg      }d d d        t        j                  ddg      }t        j                  ||       t        j                  t        ddg      t        dg            }t        j                  ddg      }t        j                  ||       t        j                  t        ddg      dh      }t        j                  ddg      }t        j                  ||       t        j                  t        |      5  t        j                  ddgdg      }d d d        t        j                  ddg      }t        j                  ||       y # 1 sw Y   xY w# 1 sw Y   VxY w# 1 sw Y   QxY w)	N+isin with argument that is not not a Seriesr   rJ   rK   TFrZ   r[   )	r9   r   r   r   r  r.   rQ   r:   r   )r<   r   r   r   s       rG   rj   zTestIsin.test_basic  s   ;''SA 	-ZZA,F	-88T5M*
##FH5BHHaV,qc288T5M*
##FH5FAq6NQC088T5M*
##FH5FAq6NFA3K888T5M*
##FH5FAq6NQC088T5M*
##FH5''SA 	3ZZc
SE2F	388T5M*
##FH5FC:.u>88T5M*
##FH5FC:.688T5M*
##FH5''SA 	1ZZc
QC0F	188UEN+
##FH5K	- 	-*	3 	3	1 	1s#   L8M(M8MMMc                    t        dd      j                  }t        j                  ||d   g      }t	        j
                  g d      }t        j                  ||       t        j                  ||dd       }t	        j
                  g d      }t        j                  ||       t        j                  |t        |dd             }t	        j
                  g d      }t        j                  ||       t        dd      j                  }t        j                  ||d   g      }t	        j
                  g d      }t        j                  ||       t        j                  ||dd       }t	        j
                  g d      }t        j                  ||       t        j                  |t        |dd             }t	        j
                  g d      }t        j                  ||       y )	Nrr   r`   periodsr   )TFFrK   r,  r   )
r   rS   r   r  r.   rQ   r9   r:   r   r   rr  s       rG   test_i8zTestIsin.test_i8  sl   Q/66C#a&*8801
##FH5CQq*88/0
##FH5CS1X/88/0
##FH5gq188C#a&*8801
##FH5CQq*88/0
##FH5CS1X/88/0
##FH5rX   dtype1)rF  r   M8[ns, UTC]	period[D]r'   )r   f8r   c                    t        dd      j                  }|dk(  r|j                  d      }nJ|dk(  r|j                  d      }n3t	        |j                  d            j                  |      j                  }|j                  d      j                  |      }t        j                  ||      }t        j                  |j                  t        	      }t        j                  ||       y )
Nz
2013-01-01r`   r  r  r  r  UTCr   r&   )r   _values	to_periodtz_localizer   viewr0   r   r  r.   zerosshaper2   r9   r:   )r<   r'   r  dtari   compsr   r   s           rG   +test_isin_datetimelike_values_numeric_compsz4TestIsin.test_isin_datetimelike_values_numeric_comps  s    
 q199[ --$C}$//%(C$(--f5==C%%e,E3'88EKKt4
##FH5rX   c                     t        ddd      j                  }t        j                  ||dd       }t	        j
                  t        |      t              }d|d<   d|d	<   t        j                  ||       y )
N20000101i r7  )r  r|   r   rK   r&   TrJ   )
r   rS   r   r  r.   r  r   r2   r9   r:   r<   r7  r   r   s       rG   
test_largezTestIsin.test_large  sb    z7=DDAq1v&88CF$/
##FH5rX   c                 ~   t        j                  g d      }g d}t        t        dg      j	                  ||            }t        t        dg      j	                  t        j                  ddg      |            }t        j                  g d      }t        j                  ||      }t        j                  ||       y Nr   r]   rJ   r   )TTFT)	r.   rQ   r   r   
from_codesr   r  r9   r:   )r<   valscatsSdStr   r   s          rG   test_categorical_from_codesz$TestIsin.test_categorical_from_codes  s    xx%K$//d;<K$//!Q0@$GH8856B#
##Hf5rX   c                 Z   t        j                  g d      }g d}t        dg      j                  ||      }t        dg      j                  t        j                  ddg      |      }t        j                  g d      }t	        j
                  ||      }t        j                  ||       y r  )r.   rQ   r   r  r   r  r9   r:   )r<   r  r  catotherr   r   s          rG   test_categorical_isinzTestIsin.test_categorical_isin  s    xx%1#))$5QC ++BHHaV,<dC8856C'
##Hf5rX   c                 0   t         j                  g}t         j                  g}t        j                  dg      }d}t        j                  t
        |      5  t        j                  ||      }d d d        t        j                  |       y # 1 sw Y    xY w)NTr  r   )	r.   rR   rQ   r9   r   r   r   r  r:   r<   r  rS   r   r   r   s         rG   test_same_nan_is_inzTestIsin.test_same_nan_is_in  st     &&88TF#;''SA 	/ZZv.F	/
##Hf5	/ 	/s   BBc                 <   t        j                  dd      }t         j                  |d<   t        j                  |t        j
                  t         j                  dg            }t        j                  t        |      t              }t        j                  ||       y NrO   iAB r   rJ   r&   )r.   r'  rR   r   r  rQ   onesr   r2   r9   r:   r  s       rG   test_same_nan_is_in_largez"TestIsin.test_same_nan_is_in_large  sd    GGC#vv!Arxx45773q6.
##FH5rX   c                 Z   t        j                  dd      }t        |      }t         j                  |d<   |j	                  t        j
                  t         j                  dg            }t        t        j                  t        |      t                    }t        j                  ||       y r  )r.   r'  r   rR   r  rQ   r  r   r2   r9   assert_series_equal)r<   r7  seriesr   r   s        rG    test_same_nan_is_in_large_seriesz)TestIsin.test_same_nan_is_in_large_series  sp    GGC#vv!RXXrvvqk23"''#a&56
vx0rX   c                     G d d      } |        |       }}d}t        j                  t        |      5  t        j                  t	        j
                  |g|g      t        j                  dg             t        j                  t	        j
                  |g|g      t        j                  dg             d d d        y # 1 sw Y   y xY w)Nc                       e Zd ZdefdZd Zy)0TestIsin.test_same_object_is_in.<locals>.LikeNanreturnc                      y)NFr   )r<   r  s     rG   __eq__z7TestIsin.test_same_object_is_in.<locals>.LikeNan.__eq__  s    rX   c                      y)Nr   r   )r<   s    rG   __hash__z9TestIsin.test_same_object_is_in.<locals>.LikeNan.__hash__!  s    rX   N)r
  r  r  r2   r  r  r   rX   rG   LikeNanr    s    t rX   r  r  r   TF)r9   r   r   r:   r   r  r.   rQ   )r<   r  rZ   r[   r   s        rG   test_same_object_is_inzTestIsin.test_same_object_is_in  s    	 	 y')1;''SA 	Q''

A3(<bhhv>NO''

A3(<bhhw>OP		Q 	Q 	Qs   BC  C	c                    t        d      g}t        d      g}|d   |d   usJ t        j                  t        j                  |      |      }t        j                  t        j                  dg      |       t        j                  t        j                  |t              t        j                  |t                    }t        j                  t        j                  dg      |       t        j                  t        j                  |t        j                        t        j                  |t        j                              }t        j                  t        j                  dg      |       y )NrR   r   Tr&   )
floatr   r  r.   rQ   r9   r:   r7   r3   r   )r<   r  rS   r   s       rG   r  zTestIsin.test_different_nans-  s     u,Qxvay((( BHHUOV4
##BHHdV$4f= JJuF+RZZf-M
 	##BHHdV$4f= JJuBJJ/F"**1U
 	##BHHdV$4f=rX   c                     ddg}dg}t        j                  ddg      }d}t        j                  t        |      5  t        j                  ||      }d d d        t        j                  |       y # 1 sw Y    xY w)Nss*   42Fz2isin with argument that is not not a Series, Indexr   )r.   rQ   r9   r   r   r   r  r:   r  s         rG   test_no_castzTestIsin.test_no_castE  sp     r
88UEN+B''SA 	/ZZv.F	/
##Hf5	/ 	/s   A22A;emptyr&   c                     t        ddg      }t        j                  ddg      }t        j                  ||      }t        j                  ||       y )NrZ   r[   F)r   r.   rQ   r   r  r9   r:   )r<   r  r  r   r   s        rG   
test_emptyzTestIsin.test_emptyP  sD     c3Z 88UEN+D%(
##Hf5rX   c                 D   t        j                  dt         j                  dz  t        d      gt              }t        j                  t        d      gt              }t        j                  g d      }t        j                  ||      }t        j                  ||       y )NrR                 ?r&   )FFT)	r.   rQ   rR   r  r3   r   r  r9   r:   )r<   r  r  r   r   s        rG   test_different_nan_objectsz#TestIsin.test_different_nan_objectsY  sj    %"eEl;6Jxxuf58801E4(
##Hf5rX   c                    t        j                  dt        j                  dd            d   }t        j                  dt        j                  dd            d   }||k7  sJ ||k7  sJ t        j                  ||gt        j
                        }t        j                  |gt        j
                        }t        j                  ||      }t        j                  ddg      }t        j                  ||       t        j                  |gt        j
                        }t        j                  ||      }t        j                  ddg      }t        j                  ||       y )Nrw  rx  ry  r   rz  r&   T)
r{  r|  r}  r.   rQ   r   r   r  r9   r:   )r<   r~  r  ri   lookup1r   r   lookup2s           rG   test_different_nans_as_float64z'TestIsin.test_different_nans_as_float64a  s   
 }}S&++d4F"GHK}}S&++d4F"GHKt||t|| hhd|2::6((D64C)88T4L)
##FH5((D64C)88T4L)
##FH5rX   c                     t        dddgi      }|j                  dg      }t        dddgi      }t        j                  ||       y)zComparing df with int`s (1,2) with a string at isin() ("1")
        -> should not match values because int 1 is not equal str 1rS   rJ   rK   rh  FN)r   r  r9   assert_frame_equalr<   dfr   expected_falses       rG   test_isin_int_df_string_searchz'TestIsin.test_isin_int_df_string_searchw  sI     1a&)*#"Huen#=>
fn5rX   c                     t        dt        j                  dgi      }|j                  t        j                  dgt
                    }t        dddgi      }t        j                  ||       y)zComparing df with nan value (np.nan,2) with a string at isin() ("NaN")
        -> should not match values because np.nan is not equal str NaNrS   rK   NaNr&   FN)r   r.   rR   r  rQ   r3   r9   r  r  s       rG   test_isin_nan_df_string_searchz'TestIsin.test_isin_nan_df_string_search  sY     2661+./5'89"Huen#=>
fn5rX   c                     t        dddgi      }|j                  t        j                  dgt                    }t        dddgi      }t        j                  ||       y)zComparing df with floats (1.4245,2.32441) with a string at isin() ("1.4245")
        -> should not match values because float 1.4245 is not equal str 1.4245rS   gn?g#Ed@z1.4245r&   FN)r   r  r.   rQ   r3   r9   r  r  s       rG    test_isin_float_df_string_searchz)TestIsin.test_isin_float_df_string_search  sV     67"3458*F;<"Huen#=>
fn5rX   c                     t        dgt        j                        }|j                  dg      }t        d      }t	        j
                  ||       y )Nl   
G r&   l    
G F)r   r.   r   r  r9   r  r<   rT   r   r   s       rG   test_isin_unsigned_dtypez!TestIsin.test_isin_unsigned_dtype  sA    )*"))<./0%=
vx0rX   N)r
  r  r  r  rj   r  r   r  r  r  r  r  r  r  r  r  r  r  r  r   r3   r.   rQ   r  r  r  r  r  r  r  r   rX   rG   r  r  v  s    
'6R66 [[X'WX[[W&896 : Y6&666661Q,>0	6 [[Wr6+?"&NO6 P666,6661rX   r  c                       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
ej                   edf      d        Zd Zd Zy)TestValueCountsc                    t         j                  j                  d      j                  d      }t	        |d      }d}t        j                  t        |      5  t        j                  |      }d d d        g d}t        j                  |      j                  t        d            }t        g d|d	
      }t        j                  j!                         |j!                                y # 1 sw Y   ~xY w)Ni  ra   !pandas.value_counts is deprecatedr   )gV-g}?5^Ig/$ۿgףp=
?gʡE?TrT  )rJ   r   rK   rJ   countr6   rV  )r.   r  r  standard_normalr   r9   r   r   r   value_countsr   from_breaksr0   CDTr   r  
sort_index)r<   ri   factorr   r   breaksr6   r   s           rG   test_value_countsz!TestValueCounts.test_value_counts  s    ii##D)99!<S! 2''SA 	0''/F	07))&188T9JK,e'B
v002H4G4G4IJ	0 	0s   C++C4c                    g d}d}t        j                  t        |      5  t        j                  |d      }d d d        t        dgt        j                  dg      d	      }t        j                  |       t        j                  t        |      5  t        j                  |d
d      }d d d        t        d
d
gt        j                  ddg      d	      }t        j                  ||       y # 1 sw Y   xY w# 1 sw Y   QxY w)N)rJ   rK   r`   ra   r  r   rJ   binsra   )Zd;?rc   r  r  rK   F)r  r#   )r        @)r  rc   )	r9   r   r   r   r  r   r   r,   r  )r<   r7  r   r   r   s        rG   test_value_counts_binsz&TestValueCounts.test_value_counts_bins  s    1''SA 	3''2F	3C}00,@w
 	vx0''SA 	?''>F	?F++\:,FG

 	vx0	3 	3	? 	?s   C3C?3C<?Dc                    d}t        j                  t        |      5  t        j                  t        j                  ddg            }d d d        t              dk(  sJ t        j                  t        |      5  t        j                  t        j                  ddg      d      }d d d        t        |      dk(  sJ t        j                  t        |      5  t        j                  t        g d            }d d d        t        |      dk(  sJ d}t        j                  t        |      5  t        j                  t        |      5  t        j                  t        j                  d	dgt        
      d       d d d        d d d        y # 1 sw Y   KxY w# 1 sw Y   xY w# 1 sw Y   xY w# 1 sw Y   7xY w# 1 sw Y   y xY w)Nr  r   rJ   rO   r  )rJ   rO   rh  rK   z*bins argument only works with numeric datarh  r&   )r9   r   r   r   r  r.   rQ   r   r   r   r   r   r3   )r<   msg2r   r   s       rG   test_value_counts_dtypesz(TestValueCounts.test_value_counts_dtypes  s{   2''TB 	<''!S(:;F	<6{a''TB 	D''!S(:CF	D6{a''TB 	?''}(=>F	?6{a:]]9C0 	M++MF M""288S!HF#C!LM	M 	M	< 	<	D 	D	? 	?M M	M 	MsG   +F<-F!F+2G3F7GFF(+F47G 	<GGc                 Z   t        t        j                  d      t        gd      }t	        ddg      }d}||fD ]r  }t        j                  t        |      5  t        j                  |      }t        j                  |d	      }d d d        t              d
k(  sJ t              dk(  rrJ  t        t        d      d
id      }t        j                  t        |      5  t        j                  t        j                  |      |       d d d        y # 1 sw Y   xY w# 1 sw Y   y xY w)NrE  timedelta64[ns]r&   r   z
2014-01-01r  r   FdropnarJ   rK   z2014-01-01 00:00:00r  rU  )r   r.   timedelta64r   r   r9   r   r   r   r  r   r   r  )r<   tddtr   r7  vc
vc_with_naexp_dts           rG   test_value_counts_natz%TestValueCounts.test_value_counts_nat  s   R^^E*C08IJ%./1b 	(A++ME A''*"//%@
A r7a<<z?a'''	( #891=GL''SA 	C""5#5#5b#96B	C 	CA A	C 	Cs   -D"*D!D	!D*c                 :   t        t        ddd      t        ddd      t        ddd      t        ddd      t        ddd      t        ddd      g      }|j                         }t        t        ddd      t        ddd      t        ddd      gt              }t        g d|d      }t        j                  ||       t        t        d	t        j                  g      d
      }t        d	t        j                  gt              }t        j                  ||       y )Ni  rJ   i  ip  r&   r`   rK   rJ   r  r  z
2362-01-01ignore)errors)
r   r   r  r   r3   r9   r  r   r.   rR   )r<   r7  res	exp_indexrh   s        rG   &test_value_counts_datetime_outofboundsz6TestValueCounts.test_value_counts_datetime_outofbounds  s    q!$q!$q!$q!$q!$q!$	
 nndAq!8D!Q#7$19MN
	 Yig>
sC( &,!78JlBFF+6:
sC(rX   c                    t        t        t        d                  }|j                         }t        g dt	        g d      d      }t        j                  ||d       |j                  j                         }|j                         }|j                  j                         |_	        t        j                  ||d       y )Naaabbcr  r]   r  r  Tcheck_index_type)
r   r   r5   r  r   r9   r  r  
as_orderedr6   r  s       rG   r[  z TestValueCounts.test_categorical  s    ;tH~./!-o>W
 	vx$G EE!!224
vx$GrX   c           	      r   t        t        t        d                  }t        j                  |j
                  d<   |j                         }t        g dt        g dg d      d      }t        j                  ||d	       |j                  d
      }t        g dt        dddt        j                  g      d      }t        j                  ||d	       t        t        t        d      dg d            }t        j                  |j
                  d<   |j                         }t        g dt        g dg dd      d      }t        j                  ||d	       |j                  d
      }t        g dt        dddt        j                  gg dd      d      }t        j                  ||d	       y )N
aaaaabbbccrJ   )ra   r`   rK   r]   rW  r  r  Tr  Fr  )ra   r`   rK   rJ   rZ   r[   r\   )r[   rZ   r\   )rR  r  rQ  )
r   r   r5   r.   rR   ilocr  r   r9   r  r  s       rG   test_categorical_nansz%TestValueCounts.test_categorical_nans  so   ;tL123FFq	!"?O

 	vx$Gu- 0#sC1H IPW
 	vx$G \*D_U
 FFq	!"*
 
 	vx$Gu-"c3'OT 
 	vx$GrX   c           	          t        t        t        d      t        d      d            }|j                         }t        g dt        g dt        d      d      d      }t	        j
                  ||d	       y )
NbbbaacabcdTrQ  )r`   rK   rJ   r   )r[   rZ   r\   rw  r  r  r  )r   r   r5   r  r9   r  r  s       rG   test_categorical_zeroesz'TestValueCounts.test_categorical_zeroes1  sc    ;tH~$v,PTUV!$ft 
 	vx$GrX   c           
      z   t        j                  t        g d      j                  d      t        ddgddgd             t        j                  t        g d      j                  d      t        ddgddgd             t        j                  t        dgd	z  dgdz  z   d gd
z  z         j                  d      t        d	dgt	        ddgt
              d             t        j                  t        dgd
z  dgd	z  z   d gdz  z         j                  d      t        g dg dd             t        j                  t        g d      j                  d      t        ddgddgd             t        j                  t        g d      j                  d      t        ddgddgd             t        j                  t        g d      j                  d      t        ddgddgd             t        g d      j                  d      }t        g dg dd      }t        j                  ||       y )Nr,  Tr  rK   rJ   Fr  r  r`   r^   r&   )r^   r`   rK   )TFN)皙$@rb   rb   rb   r)  )r)  rb   rb   N)r)  r)  rb   rb   rb   Nr  )rb   r)  N)r9   r  r   r  r   r3   rc  s      rG   test_value_counts_dropnaz(TestValueCounts.test_value_counts_dropna>  s    	&'44D4AAq6$W=	
 	&'44E4BAq6$W=	

 	D6A:!+tfqj89FFdFSAq6e}F!C'R	
 	D6A:!+tfqj89FFeFT9$7gF	
 	#$111>Aq6#t7;	
 	#$111?Aq6#t7;	

 	)*77t7DAq6#t7;	

 9:GGuGU)+<7K
vx0rX   r'   r   c                    t        dgdz  dgdz  z   t        j                  gdz  z         }|j                  |      }|j	                  dd      }t        g dt        t        j                  d	d
g|      d      }t        j                  ||       |j	                  dd      }t        ddgt        d	d
g|      d      }t        j                  ||       y )NrJ   rK   r`   r^   TF)	normalizer  )g      ?g333333?g?rP   rO   r&   
proportionr  g333333?g?)r   r.   rR   r0   r  r9   r  )r<   r'   r7  s_typedr   r   s         rG   test_value_counts_normalizedz,TestValueCounts.test_value_counts_normalizedd  s     A37aS1W$x!|34((5/%%U%C"&&#s+59

 	vx0%%T%B#Jfc3Zu=L
 	vx0rX   c                 >   t        j                  dgt         j                        }t        dgdgd      }d}t	        j
                  t        |      5  t        j                  |      }d d d        t	        j                  |       t        j                  ddgt              }t        ddgddgd      }t	        j
                  t        |      5  t        j                  |      }d d d        t	        j                  ||       y # 1 sw Y   xY w# 1 sw Y   ,xY w)	Nr   r&   rJ   r  r  r  r   r_   )r.   rQ   r   r   r9   r   r   r   r  r  r3   )r<   ri   r   r   r   s        rG   test_value_counts_uint64z(TestValueCounts.test_value_counts_uint64w  s    hhwbii01#eW7;1''SA 	-'',F	- 	vx0hhE{&11a&U'B''SA 	-'',F	- 	vx0	- 	-	- 	-s   DDDDc                    t        j                  dddddt         j                  g      }t        |      j	                  d      }t        g dt        j                  g dd	      d
      }t        j                  ||       y )Nr`   rJ   rK   ra   r  )rK   rK   rJ   ))r  rP   )rP   rd   )rd   rc   zinterval[float64, right]r&   r  r  )	r.   rQ   rR   r   r  r   r,   r9   r  )r<   rS   r   r   s       rG   test_value_counts_seriesz(TestValueCounts.test_value_counts_series  sp    1aAq"&&12,,!,4++6>X 
 	vx0rX   N)r
  r  r  r  r  r  r  r  r[  r#  r'  r*  r   r  r  r.   r   r3   r/  r1  r3  r   rX   rG   r  r    sr    K1&M&C$)4H)HVH$1L [[Wrzz68&DE1 F1$1 1rX   r  c                      e Zd Zd Zej
                  j                  d ej                  g d       ej                  dddej                  ddddej                  dg
       ej                  g d	       ej                  g d
e
       ej                  g dej                        g      d        Zd Zej
                  j                  d eg d       ej                   dd      g      d        Zej
                  j                  dg dg dfg dddgfg dg dfg      d        Zej
                  j                  dg d ej                  g de
      fg      d        Zy )!TestDuplicatedc           	      R   t        j                  ddt         j                  ddt         j                  gt              }t	        j
                  |      }t        j                  g d      }t        j                  ||       t	        j
                  |d      }t        j                  g d      }t        j                  ||       t	        j
                  |d      }t        j                  g d	      }t        j                  ||       t	        j
                  |d
      }t        j                  g d      }t        j                  ||       t        j                  dt              }t        t        ddt         j                  t         j                  gdz  dt         j                  dt         j                  gdz              D ]
  \  }}|||<    t	        j
                  |      }d
gdz  }dgdz  }t        j                  ||z         }t        j                  ||       t	        j
                  |d      }t        j                  ||z         }t        j                  ||       t	        j
                  |d
      }t        j                  ||z         }t        j                  ||       y )Nr   rJ   rK   r&   )FFFTFTfirstkeeplast)TFTFFFF)TFTTFT   ra   T)r.   rQ   rR   r3   r   
duplicatedr9   r:   r  	enumeratezip)r<   keysr   r   r   tfalsestruess           rG   test_duplicated_with_nasz'TestDuplicated.test_duplicated_with_nas  s   xxArvvq!RVV4FC!!$'88DE
##FH5!!$W588DE
##FH5!!$V488DE
##FH5!!$U388BC
##FH5xx(Arvvrvv&*Q266,BQ,FG
 	DAq DG	
 !!$'1
88FUN+
##FH5!!$V488EFN+
##FH5!!$U388EEM*
##FH5rX   case)
rJ   rK   rJ   r^   r`   rK   ra   rJ   r^      g?g@gffffff
@g@gffffff@)
      ?      ?       @       @rF        @      @y      @      @rG  y      @      @rF  rH  y      @      @)
rZ   r[   rZ   er\   r[   rw  rZ   rI  fr&   )
rJ   r   rJ      r   r   '   rJ   rK     c                    t        j                  g d      }t        j                  g d      }||z  }t        j                  |d      }t	        j
                  ||       t        j                  |d      }t	        j
                  ||       t        j                  |d      }t	        j
                  ||       t        |      t        |d      fD ]z  }|j                  d      }t	        j
                  ||       |j                  d      }t	        j
                  ||       |j                  d      }t	        j
                  ||       | t        |      t        |d      fD ]  }	|	j                  d      }t	        j                  |t        |             |	j                  d      }t	        j                  |t        |             |	j                  d      }t	        j                  |t        |              y )	N
FFTFFTFTTF
TTTTFFFFFFr7  r8  r:  Fr  r&   )	r.   rQ   r   r<  r9   r:   r   r   r  )
r<   rD  	exp_firstexp_last	exp_false	res_firstres_last	res_falseidxr7  s
             rG   test_numeric_object_likesz(TestDuplicated.test_numeric_object_likes  s   4 HHN
	 88N
 (	$$T8	
##Iy9##Dv6
##Hh7$$T6	
##Iy9 $Kt:!>? 	>CG4I''	9=~~6~2H''(;E2I''	9=	> ,t: >? 	AA'2I""9fY.?@|||0H""8VH-=>%0I""9fY.?@	ArX   c                 d   g d}g d}t        j                  |D cg c]  }t        |       c}      t        j                  |D cg c]  }t        |d       c}      t        j                  |D cg c]  }t        |d       c}      t        j                  |D cg c]  }t        j                  |       c}      t        j                  |D cg c]  }t        |       c}      g}t        j                  g d      }t        j                  g d      }||z  }|D ]  }t        j                  |d	
      }	t        j                  |	|       t        j                  |d
      }
t        j                  |
|       t        j                  |d
      }t        j                  ||       t        |      t        |d      t        |t              fD ]z  }|j                  d	
      }	t        j                  |	|       |j                  d
      }
t        j                  |
|       |j                  d
      }t        j                  ||       | t        |      t        |d      t        |t              fD ]  }|j                  d	
      }	t        j                  |	t        |             |j                  d
      }
t        j                  |
t        |             |j                  d
      }t        j                  |t        |               y c c}w c c}w c c}w c c}w c c}w )N)

2011-01-01
2011-01-02rZ  r   
2011-01-03r[  z
2011-01-04rZ  r   z
2011-01-06)
1 days2 daysr]  r   z3 daysr^  z4 daysr]  r   z6 daysr  r  r  r{   rO  rP  r7  r8  r:  Fr  r&   )r.   rQ   r   r   r   r   r   r<  r9   r:   r   r3   r   r  )r<   r  r  rw  casesrQ  rR  rS  rD  rT  rU  rV  rW  r7  s                 rG   test_datetime_likesz"TestDuplicated.test_datetime_likes  s   

 HHB/qil/0HHR@il3@AHH26afQS)67HH31bmmA&34HHB/qil/0
 HHN
	 88N
 (	 &	ED((G<I''	9=''6:H''(;((E:I''	9= dd*-d&) B
  NNN8	++IyA>>v>6++Hh?NNN6	++IyAB  tt:.t6* E
 LLgL6	&&y&2CD<<V<4&&x1ABLLeL4	&&y&2CDE5&	E 0@63/s   LL
4L#!L(L-r   r   r`   c                     |j                   du sJ t        j                  |j                         t	        j
                  g d             y )NT)FFF)	is_uniquer9   r:   r<  r.   rQ   )r<   rD  s     rG   test_unique_indexz TestDuplicated.test_unique_indexP  s5    ~~%%%
##DOO$5rxx@U7VWrX   zarr, uniques)r   r   rJ   rJ   r   r   r   rd  re  r   )r   rd  re  r   )r[   r\   rZ   r[   rg  rf  rf  rg  )r   r[   rK   rZ   r`   r   )r   rh  ri  c                    t        j                  t        |      t              }||d d  d}t	        j
                  t        |      5  t        j                  |      }d d d        t	        j                  |       y # 1 sw Y    xY w)Nr&   rl  r   )
r.   r  r   r3   r9   r   r   r   r-   r:   )r<   ri   rV   r   r   r   s         rG   test_unique_tuplesz!TestDuplicated.test_unique_tuplesU  sh      88CL7=''SA 	$YYs^F	$
##FH5	$ 	$s   A<<Bzarray,expected)rF  r   rJ   r        ?       @rl  )rF  y                y      ?        r  rl  c                     d}t        j                  t        |      5  t        j                  |      }d d d        t        j
                  |       y # 1 sw Y    xY wrk  rm  )r<   rQ   r   r   r   s        rG   test_unique_complex_numbersz*TestDuplicated.test_unique_complex_numbersm  sL     >''SA 	&YYu%F	&
##FH5	& 	&rp  N)r
  r  r  rC  r   r  r  r.   rQ   rR   r3   r   rX  r`  r   r   r   rc  rk  rn  r   rX   rG   r5  r5    s   %6N [[BHH34BHHc3RVVS#sCMNBHH BHHGvVBHH>bii%	
2&A32&APPEd [[VeI&6a8K%LMX NX [[ Q0
 AZ( 67UV
	
66 [[ 3?vN	
	6	6rX   r5  c            	          e Zd Zej                  j                  dej                  dfej                  dfej                  dfej                  dfej                  dfg      d        Zej                  j                  dej                  dfej                  dfej                  dfej                  dfej                  dfg      d        Zy)	TestHashTablezhtable, tm_dtypeStringFloatIntUIntc                    t        t        d|z   dz         }t         |d            }|t        j                  k(  rt
        j                  |j                  d<   n7|t        j                  k(  r$t
        j                  d t        g|j                  dd |j                  dd      j                  d	      }|j                  j                  |
       |j                  d      j                  } |       j                  |j                        }t        j                   ||        |       j                  |j                  d      \  }}	t        j                   ||       ||	   }
t        j                   |
|j                         y )Nmaker   r!      r`   Tfracreplacedropr   r7  r8  )return_inverse)getattrr9   r   r   Float64HashTabler.   rR   locPyObjectHashTabler   samplereset_indexrS   r   drop_duplicatesr-   r:   )r<   htabletm_dtyper   makerr7  s_duplicatedexpected_uniqueresult_uniqueresult_inversereconstrs              rG   test_hashtable_uniquez#TestHashTable.test_hashtable_unique  sB    FX-785;R(((AEE#Jr+++ ffdC0AEE#cN xxQx5AAtAL$$8$4 '66G6DKK(;(;<
##M?C )/ )8 )
%~ 	##M?C 0
##Hl.A.ABrX   c                    t        t        d|z   dz         }t         |d            }|t        j                  k(  rt
        j                  |j                  d<   n7|t        j                  k(  r$t
        j                  d t        g|j                  dd |j                  dd      j                  d	      }|j                  j                  |
       |j                         j                  } |       j                  |j                        \  }}	|j!                         j#                         j                  }
t        j$                  ||
       ||	|       }|j!                         j                  }t        j$                  ||       y )Nrv  r   r!  rw  rx  r`   Try  r|  r   )r  r9   r   r   r  r.   rR   r  r  r   r  r  rS   r   r   r*   r  r  r:   )r<   r  r  r   r  r7  r  na_maskr  r  r  result_reconstructexpected_reconstructs                rG   test_hashtable_factorizez&TestHashTable.test_hashtable_factorize  sC    FX-785;R(((AEE#Jr+++ ffdC0AEE#cN xxQx5AAtAL$$8$4##%,,(.(:(:<;N;N(O%~
 '--/??AHH
##M?C +>7(+CD+224;;
##$68LMrX   N)r
  r  r  r   r  r  r   r  StringHashTabler  Int64HashTableUInt64HashTabler  r  r   rX   rG   rp  rp    s    [[!!8,*  '*&(	
	C	C< [[!!8,*  '*&(	
	N	NrX   rp  c                      e Zd Zej                  j                  dej                  ej                  dddej                  dddej                  g
dej                  dddej                  dddej                  g
g      d        Zej                  j                  dej                  d	         d
        Z
ej                  j                  dej                  ej                  g      d        Zd Zej                  j                  d        Zy)TestRankri   rb   rJ   rK   r`   rc   c                 h   t        j                  d      }t        j                  |      }t        j                  |       }|j                         }t        j                  |      }t        j                  ||<   |j                  |      }t        j                  ||<   t        j                  ||       y )Nzscipy.stats)r   importorskipr.   rQ   isfinitecopylibalgosrank_1drn   rankdatarR   r9   r(  )r<   ri   sp_statsr   r   rh   s         rG   test_scipy_compatzTestRank.test_scipy_compat  s     &&}5hhsmC  hhj!!#&FFD	$FFD	
vs+rX   r'   
AllIntegerc                    t        j                  ddgt         j                        }t        j                  ddg|      }|j                  |       t	        |      }t        j                  |      }t        j                  ||       y )NrJ   rK   r&   r  r   )	r.   rQ   r   r   r   r   rankr9   r:   )r<   r   r'   rh   r   rT   r   s          rG   rj   zTestRank.test_basic  sb    hh1vRZZ0xxC.H%TlC
##FC0rX   c                     t        j                  ddgt         j                        }t        ddg|      }t	        j
                  t        j                  |      |       y )NrJ   rK   r&   r   )r.   rQ   r   r   r9   r:   r   r  )r<   r'   rh   r7  s       rG   rJ  zTestRank.test_uint64_overflow  sB    hh1vRZZ0Au:U+
##EJJqM37rX   c                     t        j                  g dg dg dgg      }d}t        j                  t        |      5  t        j                  |       d d d        y # 1 sw Y   y xY w)Nr   )ra   r^   rE  )rM  r;  	   z%Array with ndim > 2 are not supportedr   )r.   rQ   r   r   r   r   r  )r<   ri   r   s      rG   test_too_many_ndimszTestRank.test_too_many_ndims  sM    hhIy9:;5]]9C0 	JJsO	 	 	s   AA%c                 (   t        j                  d      }t        j                  |d      j	                         }|dk(  sJ t        j                  d      j                  dd      }t        j                  |d      j	                         }|dk(  sJ y )Ni  T)pctrJ   i  rK   )r.   rf   r   r  maxreshape)r<   rS   r   s      rG   test_pct_max_many_rowszTestRank.test_pct_max_many_rows  sw     9%F-113{{9%--i;F-113{{rX   N)r
  r  r  r   r  r  r.   rR   r  	typecodesrj   r   r   rJ  r  
single_cpur  r   rX   rG   r  r    s    [[VVRVVS#sBFFAq!RVVD"&&#sCAsBFFC	
,, [[Wbll<&@A1 B1 [[Wrzz299&=>8 ?8 [[ rX   r  c                     t        j                  g d      } t        j                  t        ddd      gd      }t        j                  d   | |      }t        j                  dgt         j
                        }t        j                  ||       t        j                  d   ||       }t        j                  g t         j
                        }t        j                  ||       t        j                  d   | |      }t        j                  dgt         j
                        }t        j                  ||       t        j                  d   ||       }t        j                  g t         j
                        }t        j                  ||       y )Nr   r&   i        r3   r_   )	r.   rQ   r   r  padr8   r9   r:   backfill)oldnewr   r   s       rG   !test_pad_backfill_object_segfaultr  
  s   
((2S
!C
((HT2r*+3
7C\\(#C-FxxBGG,H1\\(#C-Fxx"''*H1x(c2FxxBGG,H1x(c2Fxx"''*H1rX   c                       e Zd Zd Zd Zy)TestTseriesUtilc                 V   t        g d      }t        t        t        d                  }t        j                  d   |j
                  |j
                        }t        j                  g dt        j                        }t        j                  ||       t        ddg      }t        t        t        dd	                  }t        j                  d   |j
                  |j
                        }t        j                  g d
t        j                        }t        j                  ||       y )NrJ   r^   r   r  int64_t)r   r   rJ   rJ   rJ   rJ   rK   rK   rK   rK   rK   r_   r&   rJ   ra   r^   r   r_   r_   r_   r_   r_   )r   r5   r   r  r  rS   r.   rQ   r8   r9   r:   r<   r  r  fillerexpect_fillers        rG   test_backfillzTestTseriesUtil.test_backfill   s    JDrO$""9-cjj#**E!FbggV
##FM: QFmDq"&'""9-cjj#**E!5RWWE
##FM:rX   c                 v   t        g d      }t        t        t        d                  }t        j                  d   |j
                  |j
                        }t        j                  g dt        j                        }t        j                  ||       t        ddg      }t        t        j                  dt        j                              }t        j                  d   |j
                  |j
                        }t        j                  g dt        j                        }t        j                  ||       y )	Nr  r  r  )r_   r   r   r   r   rJ   rJ   rJ   rJ   rJ   rK   rK   r&   r^   r   r  )r   r5   r   r  r  rS   r.   rQ   r8   r9   r:   rf   r   r  s        rG   test_padzTestTseriesUtil.test_pad1  s    JDrO$i(SZZ@!FbggV
##FM: QGnBIIarxx01i(SZZ@!5RWWE
##FM:rX   N)r
  r  r  r  r  r   rX   rG   r  r    s    ;";rX   r  c                      t        j                  dgdz  dgdz  z   dgdz  z   dgdz  z   d      t        j                  t        t        d            d d d	   d
z  d      g} t	        j
                  |       rJ y )Nr`       rK   rJ   r   r   r&   r  r_   ra   )r.   rQ   r5   r   r  is_lexsorted)failures    rG   test_is_lexsortedr  B  s    
S2X1#(#sRx0QC"H=	
 	rODbD!A%	
	G $$W----rX   c                     t         j                  j                  d      j                  ddd      j	                  t         j
                        } t         j                  j                  d      j                  ddd      j	                  t         j
                        }t        j                  | d      d   }t        j                  | d      }|j	                  t         j
                        }t        j                  ||       | dz  |z   }t        j                  |d      d   }t        j                  || f      }|j	                  t         j
                        }t        j                  ||       y )NrK   r   r!  r  	mergesort)r0  i@B )r.   r  r  r  r0   r8   r  groupsort_indexerargsortr9   r:   lexsort)rZ   r[   r   r   r   s        rG   test_groupsort_indexerr  Q  s   
		a ))!T37>>rwwGA
		a ))!T37>>rwwGA''403F
 zz!+.Hrww'H1
 d(Q,C''W5a8Fzz1a&!Hrww'H1rX   c                     t        j                         t        j                         t        d      dddt        d      g} t	        fd| D              sJ t	        fd| D              sJ k\  rk(  sJ k  skD  rJ t        j                         t        j                         k(  sJ t        j                         t        j                         k7  rJ t	        fd| D              sJ t	        fd	| D              sJ k  rk(  sJ k  skD  rJ t        j                         t        j                         k(  sJ t        j                         t        j                         k7  rJ t        |       D ]  }t        |      | k(  rJ  t        j                  t        j                         gd
z        j                          t        j                  t        j                         gd
z        j                          y )Nz-infg}Ô%Ir   g}Ô%ITrn   c              3   (   K   | ]	  }|k\    y wr  r   .0ro   Infs     rG   	<genexpr>z%test_infinity_sort.<locals>.<genexpr>u  s     *Asax*   c              3   4   K   | ]  }|kD  xs |u   y wr  r   r  s     rG   r  z%test_infinity_sort.<locals>.<genexpr>v  s!     5qsQw"!s("5   c              3   (   K   | ]	  }|k    y wr  r   r  ro   NegInfs     rG   r  z%test_infinity_sort.<locals>.<genexpr>|  s     -qv{-r  c              3   4   K   | ]  }|k  xs |u   y wr  r   r  s     rG   r  z%test_infinity_sort.<locals>.<genexpr>}  s!     ;Qvz(Q&[(;r  r  )
r  InfinityNegInfinityr  allr   sortedr.   rQ   r  )ref_numspermr  r  s     @@rG   test_infinity_sortr  j  s    


C!!#Ffvq%usKH*****5H5555#:#*$$Sys**("3"3"5555  "h&7&7&9999-H----;(;;;;V& 000v66!X%9%9%;;;;##%)=)=)????X& (d|x'''( HHh!"R'(002HHh""$%*+335rX   c                  L   t        j                         } t        j                         }| t        j                  kD  rJ | t        j                  k\  rJ | t        j                  k  rJ | t        j                  k  rJ | t        j                  k(  rJ | t        j                  k7  sJ |t        j                  kD  rJ |t        j                  k\  rJ |t        j                  k  rJ |t        j                  k  rJ |t        j                  k(  rJ |t        j                  k7  sJ y r  )r  r  r  r.   rR   )r  r  s     rG   test_infinity_against_nanr    s    



C!!#FRVV|bff}RVV|bff}bff}"&&==RVVrX   c                      t        j                  dt         j                        } t        j                  |       }|| u sJ y )Nr  r&   )r.   rf   r8   r  ensure_platform_int)ri   r   s     rG   test_ensure_platform_intr    s2    
))Crww
'C))#.FS==rX   c            
      b   d} t        j                  t         j                        j                  }t        j                  t         j                        j                  }t        j                  t        |       5  t        j                  t        j                  ||g      |       d d d        t        j                  t        |       5  t        j                  t        j                  ||g      t        j                  ||g             d d d        t        j                  t        |       5  t        j                  t        j                  ||g      |       d d d        t        j                  t        |       5  t        j                  t        j                  ||g      t        j                  ||g             d d d        t        j                  t        |       5  t        j                  t        j                  ||g      t        j                  ||g             d d d        t        j                  t        |       5  t        j                  t        j                  ||g      t        j                  ||g      t        j                  ddg             d d d        t        j                  t        |       5  t        j                  t        j                  ||g      t        j                  ||g      t        j                  ddg             d d d        t        j                  t        |       5  t        j                  t        j                  ||g      t        j                  ||g      t        j                  ddg      t        j                  ddg             d d d        t        j                  t        |       5  t        j                  t        j                  ||g      t        j                  t         j                  |g             d d d        t        j                  t        j                  ||g      t        j                  ||g      t        j                  ddg             t        j                  t        j                  ||g      t        j                  ||g      t        j                  ddg             t        j                  t        j                  ||g      t        j                  ||g      t        j                  ddg      t        j                  ddg             y # 1 sw Y   xY w# 1 sw Y   CxY w# 1 sw Y   xY w# 1 sw Y   xY w# 1 sw Y   SxY w# 1 sw Y   xY w# 1 sw Y   wxY w# 1 sw Y   xY w# 1 sw Y   xY w)NzOverflow in int64 additionr   FT)arr_mask)b_mask)r  r  )r.   iinfor   r  minr   r   OverflowErrorr   checked_add_with_arrrQ   rR   )r   r-  ns      rG   test_int64_add_overflowr    s   
&C
A
A	}C	0 8""288QF#3Q78	}C	0 G""288QF#3RXXq!f5EFG	}C	0 8""288QF#3Q78	}C	0 G""288QF#3RXXq!f5EFG	}C	0 G""288QF#3RXXq!f5EFG	}C	0 
""HHaVbhh1v.5$-9P	

 
}C	0 
""HHaVbhh1v.rxx7N	

 
}C	0 
""HHaVHHaVXXudm,88UDM*		

 
}C	0 L""288QF#3RXXrvvqk5JKL 

!Q"((Aq6*RXXtTl5K 

!Q"((Aq6*288T4L3I 

!Q
!Q4-(xx&	K8 8G G8 8G GG G
 

 

 
L Lss   8,T<AU	+,U:AU#AU0AU==AV
8A.V	AV$<U	UU #U-0U:=V
VV!$V.c                      e Zd Zd Zej
                  j                  dej                  d   ej                  d   z         d        Z	d Z
ej
                  j                  dej                  d   ej                  d   z         d        Zd Zej
                  j                  deeg      d	        Zd
 Zd Zd Zd Zd Zd Zd Zy)TestModec                     t        g t        j                  t        g t                    }t        j                  t        j                  t        j                  g             |j                         y )Nr&   )r'   r6   )r   r.   r   r   intr9   r:   r   moderQ   rS   r<   rh   s     rG   test_no_modezTestMode.test_no_mode  s@    Rrzzr1EF
##EJJrxx|$<cjjIrX   r  r  rr  c                 
   dg}dg}dg}ddg}t        ||      }t        ||      }t        j                  t        j                  |j
                        |j
                         t        j                  |j	                         |       t        ||      }t        ||      }t        j                  t        j                  |j
                        |j
                         t        j                  |j	                         |       y )NrJ   r&   r   r9   r:   r   r  rS   r  r<   r  
exp_singledata_single	exp_multi
data_multirT   rh   s           rG   test_mode_singlezTestMode.test_mode_single  s     S
cC	V
[+Zr*
##EJJszz$:CJJG
sxxz3/Zr*Yb)
##EJJszz$:CJJG
sxxz3/rX   c                 B   t        dgt              }t        j                  t	        j
                  |j                        |j                         t        g dt              }t        j                  t	        j
                  |j                        |j                         y )NrJ   r&   r]   )r   r  r9   r:   r   r  rS   r3   r  s     rG   test_mode_obj_intzTestMode.test_mode_obj_int  s^    aS$
##EJJszz$:CJJG_F3
##EJJszz$:CJJGrX   c                 @   dg}dgdz  dgdz  z   }ddg}dgdz  dgdz  z   dgdz  z   }t        ||      }t        ||      }t        j                  t        j                  |j
                        |j
                         t        j                  |j	                         |       t        ||      }t        ||      }t        j                  t        j                  |j
                        |j
                         t        j                  |j	                         |       y )NrJ   r^   rK   r`   r&   r  r  s           rG   test_number_modezTestMode.test_number_mode  s    S
cAga'F	S1WsQw&!q0
[+Zr*
##EJJszz$:CJJG
sxxz3/Zr*Yb)
##EJJszz$:CJJG
sxxz3/rX   c                    dg}dgdz  dgdz  z   }t        |d      }t        |d      }t        j                  t        j                  |j
                        |j
                         t        j                  |j	                         |       y )Nr[   rZ   rK   r`   r\   r&   r  )r<   rh   r   rT   s       rG   test_strobj_modezTestMode.test_strobj_mode	  sn    euqyC519$T%S$
##EJJszz$:CJJG
sxxz3/rX   c                    dg}dgdz  dgdz  z   }t        ||      }t        ||      }t        j                  t        j                  |j
                        |j
                         t        j                  |j	                         |       y )Nbarr   rK   r`   r&   r  )r<   r  rh   r   rT   s        rG   test_strobj_multi_charzTestMode.test_strobj_multi_char  sn    gw{eWq[(T$S#
##EJJszz$:CJJG
sxxz3/rX   c                     t        g dd      }t        g dd      }t        j                  t        j                  |j
                        |j                         t        j                  |j	                         |       t        ddgd      }t        g dd      }t        j                  t        j                  |j
                        |j                         t        j                  |j	                         |       y )N)
1900-05-03r\  
2013-01-02r   r&   )r\  r  r
  r\  r  )r\  r  r
  r\  r  r   r9   r   r   r  rS   r  r  r<   rh   rT   s      rG   test_datelike_modezTestMode.test_datelike_mode  s    ?xP?xP
''

3::(>L
sxxz3/lL1BR
 	''

3::(>L
sxxz3/rX   c                     t        g dd      }t        g dd      }t        j                  t        j                  |j
                        |j                         t        j                  |j	                         |       t        ddgd      }t        g dd      }t        j                  t        j                  |j
                        |j                         t        j                  |j	                         |       y )N)-1 days0 daysr]  r
  r&   )r]  r  r  2 minr   r   r   z-1 dayz-1 day 2 minr  r  r  r  s      rG   test_timedelta_modezTestMode.test_timedelta_mode*  s    4<MN4<MN
''

3::(>L
sxxz3/gw'/@AJ#
 	''

3::(>L
sxxz3/rX   c                     t        dg      }t        g d      }t        j                  t        j                  |j
                        |j
                         t        j                  |j	                         |       y )Nr   )rJ   r   r   r  r  s      rG   test_mixed_dtypezTestMode.test_mixed_dtype8  sO    eWo&'
##EJJszz$:CJJG
sxxz3/rX   c                 n   t        dgt        j                        }t        g dt        j                        }t        j                  t        j                  |j                        |j                         t        j                  |j                         |       t        ddgt        j                        }t        ddgt        j                        }t        j                  t        j                  |j                        |j                         t        j                  |j                         |       y )Nr   r&   )rJ   r   r   rJ   )	r   r.   r   r9   r:   r   r  rS   r  r  s      rG   rJ  zTestMode.test_uint64_overflow>  s    eWBII.&bii8
##EJJszz$:CJJG
sxxz3/aZryy1aZryy1
##EJJszz$:CJJG
sxxz3/rX   c                    t        ddg      }|}t        |      j                         j                  }t	        j
                  ||       t        g d      }t        dgddg      }t        |      j                         j                  }t	        j
                  ||       t        g d      }t        ddgg d      }t        |      j                         j                  }t	        j
                  ||       y )	NrJ   rK   rJ   rZ   rZ   rZ   rW  rJ   rJ   rK   r`   r`   r`   r   )r   r   r  r  r9   rX  )r<   r\   rh   r  s       rG   r[  zTestMode.test_categoricalI  s    AQinn&&
##C-&3%QH5Qinn&&
##C-(1a&Y7Qinn&&
##C-rX   c                    t        g d      }t        g dt        j                        }t	        j
                  t        j                  |      |j                         t        g d      }t        dgt              }t	        j
                  t        j                  |      |j                         t        g d      }t        ddgt        j                        }t	        j
                  t        j                  |      |j                         t        g dd	      }t        j                  t        d
      5  t        j                  |       d d d        y # 1 sw Y   y xY w)Nr   r&   r  rZ   r  rJ   r`   r  r
  TimedeltaIndexr   )r   r   r.   r   r9   r:   r   r  rS   r3   r   r   AttributeError)r<   rW  rh   s      rG   
test_indexzTestMode.test_indexY  s    IYbhh/
##EJJsOSZZ@M"cU&)
##EJJsOSZZ@O$aV288,
##EJJsOSZZ@J#
 ]]>1AB 	JJsO	 	 	s   7EEc                     t        g dd      }|j                         }t        dgd      }t        j                  ||       y )N)rJ   rJ   r`   r   rU  rJ   )r   r  r9   r  r  s       rG   test_ser_mode_with_namez TestMode.test_ser_mode_with_namen  s7    YU+1#E*
vx0rX   N)r
  r  r  r  r   r  r  r.   r  r  r  r  r  strr3   r  r  r  r  rJ  r[  r  r   r   rX   rG   r  r    s    J [[T2<<#=W@U#UV0 W0$H [[T2<<#=W@U#UV0 W0"0 [[TC=10 20000	0. *1rX   r  c                       e Zd Zej                  j                  dddg      d        Zd Zej                  j                  dddg      d        Zy	)
TestDiffr'   r   rF  c                    t        j                  d      j                  t         j                        j	                  |      j                  dd      }|j                  j                  dd      |d d df<   t        j                  |dd	      }t        j                  |j                  d
      dz  }t        j                  dd      |d d df<   t        j                  dd      |dd d f<   t        j                  ||       t        j                  |j                  dd	      }t        j                  ||j                         y )Nr  r`   ra   r   nsrK   rJ   r   axisr
  r&   )r.   rf   r0   r   r  r  r'   typer   diffr  r  r  r9   r:   Tr<   r'   ri   r   r   s        rG   test_diff_datetimelike_natz#TestDiff.test_diff_datetimelike_natw  s     iim""288,11%8@@AFIINN5$/AqD	C+77399,=>Bt4At4A
##FH5CEE11-
##FHJJ7rX   c                     t        ddd      j                  }d}t        j                  t        |      5  t        j                  |dd       d d d        y # 1 sw Y   y xY w)	Nra  r`   z
US/Pacific)r  r  z#cannot diff DatetimeArray on axis=1r   rJ   r&  )r   _datar   r   
ValueErrorr   r)  )r<   r  r   s      rG   test_diff_ea_axiszTestDiff.test_diff_ea_axis  sN    q\BHH3]]:S1 	'JJsAA&	' 	' 	's   AA!int8int16c                     t        j                  g d|      }t        j                  |d      }t        j                  t         j                  ddddgd      }t        j                  ||       y )N)r   rJ   rJ   r   r   r&   rJ   r   r_   r1   )r.   rQ   r   r)  rR   r9   r:   r+  s        rG   test_diff_low_precision_intz$TestDiff.test_diff_low_precision_int  sQ    hhe4C#88RVVQ2q1C
##FH5rX   N)	r
  r  r  r   r  r  r,  r0  r4  r   rX   rG   r#  r#  v  sY    [[Wx&:;8 <8' [[Wvw&786 96rX   r#  opc                 &    | g d      } | g d      } | g d      }t        |t        j                        r-t        j                  ||      }t        j                  ||       y t        j                  ||      }t        j                  ||       y )N)r`   rJ   r`   ra   )rK   r`   rJ   rJ   )r`   r`   rJ   rJ   ra   rK   )r+   r.   r   r   union_with_duplicatesr9   r:   r   )r5  lvalsrvalsr   r   s        rG   test_union_with_duplicatesr:    su     |E|E$%H(BJJ',,UE:
##FH5,,UE:
''9rX   )Kr   	itertoolsr   r{  numpyr.   r   pandas._libsr   r  r   r   pandas.core.dtypes.commonr   r   r	   r
   r   pandas.core.dtypes.dtypesr   r  pandasr   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   pandas._testing_testingr9   pandas.core.algorithmscore
algorithmspandas.core.arraysr   r    pandas.core.commoncommonr   r"   r  r  r  r  r5  rp  r  r  r  r  r  r  r  r  r  r  r#  r  r  rQ   r:  r   rX   rG   <module>rI     s6    "   
  >     (  & & !  X9 X9v\: \:~
^1 ^1B	{1 {1|g6 g6TON ONd6 6r2* ;  ;F.226B&0f[1 [1|6 6@ "((34
: 5
:rX   