
    ei\                    x    d dl mZ d dlZd dlZd dlmZmZ d dlZd dlZd dl	Z	d dl
Z
d dlZd dlZd dlZd dlZ	 d dlZ	 d dlZd dlZd dlmZ d dlmZ 	 d dlmZ  eej>                  jA                               D  cg c]  \  } } e!|d      r| c}} Z" eej>                  jA                               D  cg c]1  \  } } e#|e$      r#|ejJ                  ur e&|ejJ                        r|3 c}} Z' ejP                          ejR                          ejT                          ejV                          ejX                          ejZ                          ej\                          ej^                         gZ0dg dfd e1d	      fd
 e1d	      fd e1d	      fd e1d	      fd e1d	      fd e1d	      fd e1d	d      fd e1d	d      fdg dfdg dfdg dfdg df ejd                  d      g df ejf                   ejP                               ddgddgd	dgddd ggf ejh                   ejR                               dgg d!d	dgddd ggf ejj                  d" ejP                         fd# ejP                         fg      ddd$dddd$dd	dd$gfgZ6d% Z7d& Z8d' Z9ejt                  jw                  d(      d)        Z<d* Z=	 dd+Z>d, Z?d- Z@d. ZAd/ ZBejt                  j                  d0        ZCd1 ZDd2 ZEd3 ZFd4 ZGejt                  j                  d5e0      d6        ZIejt                  j                  d5 ej                  dd       ej                  dd      g      d7        ZLejt                  j                  d5e0      d8        ZMejt                  j                  d5 ej                  dd       ej                  dd      g      d9        ZNd: ZOd; ZPd< ZQd= ZRd> ZSd? ZTejt                  j                  d@g dA ej                  dB       ej                  dC      dDfg dE ej                  dF      ddDfddGgdddDff      dH        ZVdI ZWdJ ZXdK ZYdL ZZdM Z[dN Z\dO Z]dP Z^dQ Z_dR Z`dS ZadT ZbdU ZcdV ZddW ZedX ZfdY ZgdZ Zhd[ Zi e       d\        Zjd]d^hZkh d_Zlh d`Zmh daZnh dbZmemenz  ekz  ekenemeldcZoejt                  j                  ddg de      ejt                  j                  dfdgdhg      di               Zpdj Zqdk Zrejt                  j$                  dl        Zsdm Ztdn Zudo Zvdp Zwdq Zxdr Zyejt                  j                  dse6      dt        Zzdu Z{dv Z|ejt                  j                  dwdxdyg      dz        Z}d{ Z~ejt                  j                  dse6      d|        Zd} Zd~ Zd Zd Zejt                  j                  dse6      d        Zejt                  j                  ejt                  j                  dse6      d               Zd Zd Zd Zd Zd Zejt                  j                  dddg      d        Zejt                  j                  dddg      d        Zejt                  j                  dddg      d        Zd Zd Zd Zd Zejt                  j                  dddg      d        Zejt                  j                  d        Zejt                  j                  d        Zd Zd Zd Zd Zejt                  j                  d5e0      d        Zejt                  j                  d5e0      d        Zd Zd Zd Zd Zejt                  j                  d ej>                          ej@                         g      d        Zejt                  j                  de0      d        Z edd      Z edd      Z edejJ                  d       edejL                  d       edej                  d       edej                  d      gZd Zd Zd Zd Zd Zd Zejt                  j                  ejt                  j                  d ej^                         ge      ejt                  j                  ded       ejt                  j                  deeegg d      d                             Zejt                  j                  ejt                  j                  d ej\                          ej^                         ge      ejt                  j                  ded       d                      Zd Zejt                  j$                  ejt                  jd                  d               ZddZejt                  j$                  dÄ        ZdĄ Zejt                  j                  dg dƢ      dǄ        Zejt                  j$                  ejt                  jd                  dȄ               ZdɄ Zejt                  jd                  ejt                  j                  ddʫ      ejt                  j$                  d˄                      Zd̄ Zd̈́ Zd΄ Zdτ ZdЄ Zdф Zd҄ Zdӄ ZdԄ ZdՄ Zdք Zdׄ Zd؄ Zdل Zdڄ Zdۄ Zejt                  j                  ejt                  j                  ddݫ      ejt                  j                  dd߫      d                      Zejt                  j                  ejt                  j                  ddݫ      ejt                  j                  dd߫      d                      Zejt                  j                  ejt                  j                  dd      ejt                  j                  dd߫      d                      Zejt                  j                  ejt                  j                  dd      ejt                  j                  dd߫      d                      Zd Zd Zd Zd Zd Zd Zd Zd Zd Zejt                  j                  ddg dfdg dfdg dfdg dfg      d        Zd Zd Zd Zd Zejt                  j                  d        Zejt                  j                  ejt                  j8                  d               Zd Zd Zd  Zd Zejt                  j                  dd dg dg dg ddgfd ddgdgdgdgfd dddgdd	gddgdgfdddgd	gdgdgfddddgddgddgdgff      ejt                  j                  dd      ejt                  j                  dej                  ejR                  ej^                  f      ejt                  j                  dejf                  ejh                  d	f      d
                             Zejt                  j                  dd      ejt                  j                  dd      ejt                  j                  dej                  ejR                  ej^                  f      ejt                  j                  dejf                  ejh                  d	f      d                             Zejt                  j                  dd      ejt                  j                  dd d d f      d               Zd ZddZejt                  j                  d ejP                          ejR                          ej                          ejT                          ej                          ej\                          ej^                          ejJ                  dd        ejL                  dd        ej                  dd        ej                  dd       f      ejt                  j                  dd ej                   ejR                                ej                  d       ej                   ejT                               f      d               Zd Zd Zd Zy# e$ r dZY w xY w# e$ r dZY w xY w# e$ r dZY w xY wc c}} w c c}} w (      )
namedtupleN)	lru_cachepartial)ArrowNotImplementedError__arrow_compute_function__bool)TFFTTuint8   int8uint16int16uint32int32uint64
   int64float)r   皙?皙?333333?皙?doublestring)abNdddeebinary)   a   b   cs   ddds   ee   )s   abcs   bcds   cdes   defs   efg            	      )r$   r"   r%   r   r   r   r   c                  ,   t         } t        |       dk\  sJ | D ]m  }|j                  }|d   r|d   }|dk(  r |t        u rt	               gdz  }nt	               g|z  }t        j                  t        d      5   ||  d d d        o y # 1 sw Y   zxY w)Nr   options_requiredarityr   r"   zBGot unexpected argument type <class 'object'> for compute functionmatch)exported_functionslenr   Ellipsisobjectpytestraises	TypeError)	functionsfuncdescr,   argss        \/var/www/html/glpi_dashboard/venv/lib/python3.12/site-packages/pyarrow/tests/test_compute.pytest_exported_functionsr;   ^   s    
 #Iy>R .."# WA:HH:>DH:%D]]9"IJ 	 $K	 		 	s   9B

B	c                      t         D ]5  } t        j                  | j                  d         }|j                  dk7  r5J  y )Nnamehash_aggregate)r/   pcget_functionr   kind)r7   arrow_fs     r:    test_hash_aggregate_not_exportedrC   x   s?     # 0//$"A"A&"IJ||////0    c                      t         } t        |       dk\  sJ | D ]\  }t        j                  |      }|j                  j                         D ](  }|j                  |j                  |j                  fvr(J  ^ y )Nr   )	exported_option_classesr0   inspect	signature
parametersvaluesrA   VAR_POSITIONALVAR_KEYWORD)classesclssigparams       r:   test_exported_option_classesrQ      s    %Gw<2 9 $^^**, 	9E::e&:&:&+&7&7&9 9 9 9	9	9rD   z<ignore:pyarrow.CumulativeSumOptions is deprecated as of 14.0c           
      |   g t        j                         t        j                  d      t         j                  j	                  t        j                               t        j                  d d      t        j                         t        j                  dd      t        j                         t        j                         t        j                  d      t        j                  d      t        j                  d      t        j                         t        j                   t        j"                  d	            t        j$                         t        j&                  dd
d	d      t        j(                  d      t        j*                  ddgddgt        j,                  ddi      t        j,                  ddi      g      t        j.                  t        j"                  d	      d      t        j0                  d      t        j2                         t        j4                         t        j6                  d      t        j8                  d	      t        j:                  d	d      t        j<                  dgd      t        j>                         t        j@                         t        jB                  ddd      t        jD                  dd      t        jF                  dd	d      t        jH                  dd      t        jJ                  dd       t        jL                  d       t        jN                  d	d!d"      t        jP                  d#d       t        jR                         t        jT                  dd$g%      t        jV                  t        jX                  d	g            t        jZ                  d&      t        j\                  dd	d	      t        j^                  d'gd      t        j`                         t        jb                  d      t        jd                         t        jf                  d(d)d      t        jh                  g *      t        jj                         t        jl                         t        jn                  d+      t        jp                  d,      t        jr                         t        jt                  d-d.      t        jv                  ddd/      t        jx                  d0d1      }| jz                  j|                  j~                  d2   r$|j                  t        j                  d3             |D ch c]  }t        |       }}t        D ]V  }||vs| jz                  j|                  j~                  d2   s,|t         j                  k7  s@	 |j                   |              X |D ]  }||k(  sJ t        |      j                  |j                  j                        sJ |j                         }t         j                  j                  |      }||k(  sJ t        |      j                  d5      rt        |      j                  d6      rJ t        |      t        |      k(  rJ  t        ||d	d        D ]  \  }}||k7  rJ  t        t        j                   t        j"                  d	                  d7k(  sJ t        t        j                               d8k(  sJ y c c}w # t        $ r t        j                  d4|        Y w xY w)9NUTCFstart
skip_nullsr   count_from_zero
week_startTrV   patternr#   )	recursivefieldnamesr   1r   2)field_nullabilityfield_metadatafirstr
   periodat_startnull_placementheightraise)unexpected_key_behavior	ascendingmax	sort_keysri   
tiebreakerrp   ri   r$   towards_infinitysecond)week_starts_mondayd   r   rm   rp   	min_countdummy
descending%Ysindices NFKC皙??ru   rX   first_week_is_fully_in_yearr%   0timezone_dataEurope/LjubljanazOptions class is not tested: CumulativeSumOptionsCumulativeOptionszIndexOptions(value=int64:1)z7ArraySortOptions(order=Ascending, null_placement=AtEnd))Nr?   ArraySortOptionsAssumeTimezoneOptionsCastOptionssafepar   r   CountOptionsDayOfWeekOptionsDictionaryEncodeOptionsRunEndEncodeOptionsElementWiseAggregateOptionsExtractRegexOptionsExtractRegexSpanOptionsFilterOptionsIndexOptionsscalarJoinOptionsListSliceOptionsListFlattenOptionsMakeStructOptionsKeyValueMetadataMapLookupOptionsMatchSubstringOptionsModeOptionsNullOptions
PadOptionsPairwiseOptionsPartitionNthOptionsPivotWiderOptionsQuantileOptionsRandomOptionsRankOptionsRankQuantileOptionsReplaceSliceOptionsReplaceSubstringOptionsRoundOptionsRoundBinaryOptionsRoundTemporalOptionsRoundToMultipleOptionsScalarAggregateOptionsSelectKOptionsSetLookupOptionsarraySkewOptionsSliceOptionsSortOptionsSplitOptionsSplitPatternOptionsStrftimeOptionsStrptimeOptionsStructFieldOptionsTakeOptionsTDigestOptionsTrimOptionsUtf8NormalizeOptionsVarianceOptionsWinsorizeOptionsWeekOptionsZeroFillOptionsconfigpyarrow
is_enabledappendtyperF   r5   r3   failrepr
startswith	__class____name__	serializeFunctionOptionsdeserializezip)	requestoptionsoptionrM   rN   bufdeserializedoption1option2s	            r:   test_option_class_equalityr      s   =
=
  '= 	BGGI&= 	4E:	=
 	= 	Ea@= 	""$= 	 = 	&&$7= 	y)= 	""9-= 	= 			!%= 	= 	Ar1d+=  	.!=" 	gw/04d|-/-@-@#s-L-/-@-@#s-L-N	O#=* 	BIIaL'2+=, 	  +-=. 	/=0 	1=2 	a3=4 	!$5=6 	q<7=8 	hZI9=: 	;=< 	==> 	&0U	D?=B 	.8	:C=F 	q!S)G=H 	""3,I=J 	-.K=L 	01M=N 	8EO=P 	!!#'9:Q=R 	!!#S=T 	!(:';<U=V 	BHHaSM*W=X 	#Y=Z 	1a [=\ 	/0L]=^ 	_=` 	y)a=b 	c=d 	4d+e=f 	b)g=h 	i=j 	k=l 	sm=n 	'o=p 	q=r 	D#&s=t 	$38	:u=x 	1c"y=G~ ~~((9r//0BCD*12tF|2G2& 
C w''22?Cr///Csu%
C  6F|&&v'7'7'@'@AAA ))55c:%%% <""#9:%001DEEE<4#55556  5 "'!!!" 		!-.2OOOO##%&AB B B= 3  C;C5ABCs   #\>\!\;:\;c                  x    t        t        j                               dkD  sJ dt        j                         v sJ y )Nr   add)r0   r?   list_functions rD   r:   test_list_functionsr      s5    r  "#b(((B%%''''rD   c                     t        j                  |       }t        ||      sJ |j                  }||k\  sJ |t	        |j
                        k(  sJ t        fd|j
                  D              sJ y )Nc              3   6   K   | ]  }t        |        y wN)
isinstance).0kerexpected_ker_clss     r:   	<genexpr>z&_check_get_function.<locals>.<genexpr>   s     ISz#/0Is   )r?   r@   r   num_kernelsr0   kernelsall)r=   expected_func_clsr   min_num_kernelsr7   ns     `   r:   _check_get_functionr      sj    ??4 Dd-...ADLL!!!!IDLLIIIIrD   c                  X    t        dt        j                  t        j                  d       y )Nr      )r   r?   ScalarFunctionScalarKernelr   rD   r:   test_get_function_scalarr     s    r00"//1ErD   c                  X    t        dt        j                  t        j                  d       y )Nuniquer   )r   r?   VectorFunctionVectorKernelr   rD   r:   test_get_function_vectorr     s    ""3"3R__aHrD   c                  X    t        dt        j                  t        j                  d       y )Nmeanr   )r   r?   ScalarAggregateFunctionScalarAggregateKernelr   rD   r:   "test_get_function_scalar_aggregater     s     : :00!5rD   c                  X    t        dt        j                  t        j                  d       y )Nhash_sumr#   )r   r?   HashAggregateFunctionHashAggregateKernelr   rD   r:    test_get_function_hash_aggregater    s    
B$<$<..3rD   c                     t        j                  g d      } t        j                  g d      }| j                  |      }t	        j
                  d| |gt        j                               }t        j                  g d      }|j                  |      sJ |j                  |      sJ t	        j                  | |t        j                               }|j                  |      sJ y )N)foobarbaz)r$   r$   r#   take)memory_pool)r  r  r  )r   r   npr	  r?   call_functiondefault_memory_poolequals)arrr   result1result2expectedresult3s         r:   #test_call_function_with_memory_poolr    s    
(((
)Chhy!GhhwGvW~+-+A+A+CEGxx-.H>>(###>>(###ggc70F0F0HIG>>(###rD   c                 r   t        j                         D ]  }t        j                  |      }| j                  | j	                  |            }t        |      t        |      u sJ |j                  |j                  k(  sJ |j                  |j                  k(  sJ |j                  |j                  k(  rJ  y r   )	r?   r   r@   loadsdumpsr   r=   r,   r   pickle_moduler=   r7   reconstructeds       r:   test_pickle_functionsr  $  s    !!# =t$%++M,?,?,EFM"d4j000!!TYY...""djj000((D,<,<<<<=rD   c                     t        j                         D ]9  }	 t        t         |      }| j	                  | j                  |            }||u r9J  y # t        $ r Y Hw xY wr   )r?   r   getattrAttributeErrorr  r  r  s       r:   test_pickle_global_functionsr  /  sj    !!# %	2t$D &++M,?,?,EF$$$%  		s   A	AAc                  h   t        j                         D ]  } t        j                  |       }t        |t         j                        sJ |j
                  | k(  sJ |j                  }|j                  t        |      k(  sJ t        d |D              sJ t        |       |D ]  }t        |         y )Nc              3   P   K   | ]  }t        |t        j                           y wr   )r   r?   Kernel)r   r   s     r:   r   z+test_function_attributes.<locals>.<genexpr>C  s     A#:c299-As   $&)r?   r   r@   r   Functionr=   r   r   r0   r   r   )r=   r7   r   r   s       r:   test_function_attributesr$  ;  s    !!# 	t$$,,,yyD   ,,3w<///AAAAAT
 	CI		rD   c                     t        j                  ddgdd g      } | j                         dd gk(  sJ t        j                  ddgd      } | j                         ddgk(  sJ t        j                  g dd      j                         g dk(  sJ y )	Nr#   r$   r%   r
   r&   )r  r  Nr  TFN)r?   r   	to_pylistequalr  s    r:   test_input_type_conversionr*  I  s    
&&!Q!T
#C==?q$i'''
&&!Q
C==?q!f$$$88($9;*=> > >rD   
arrow_typec                    t        j                  g d|       }|j                         j                         dk(  sJ t	        j                  |      j                         dk(  sJ t        j                  g d|       }|j                         j                         dk(  sJ t	        j                  |      j                         dk(  sJ t        j                  d g|       }|j                         j                         J t	        j                  |      j                         J |j                  d      j                         dk(  sJ t	        j                  |d      j                         dk(  sJ t        j                  g |       }|j                         j                         J |j                  d      j                         dk(  sJ t	        j                  |d      j                         dk(  sJ y )Nr#   r$   r"   r%   r   r   r#   r$   r"   r%   Nr   ry   )r   r   sumas_pyr?   r+  r  s     r:   test_sum_arrayr3  U  s   
((<j
1C779??"""66#;"$$$
((%J
7C779??"""66#;"$$$
((D6

+C779??$$$66#;&&&77Q7%%'1,,,66##))+q000
((2J
'C779??$$$77Q7%%'1,,,66##))+q000rD   c                    ddl m} t        j                  j	                  |       r t        j
                  d| j                        nt        j                  d| j                        } |d      } |d      } |d      }t        j                   |d       |d	      g| 
      }|j                         j                         |k(  sJ |j                         j                  |k(  sJ t        j                   |d       |d	      d g| 
      }|j                         j                         |k(  sJ |j                         j                  |k(  sJ t        j                   |d       |d      g| 
      }|j                         j                         |k(  sJ |j                         j                  |k(  sJ t        j                   |d       |d      d g| 
      }|j                         j                         |k(  sJ |j                         j                  |k(  sJ t        j                  d g| 
      }|j                         j                         J |j                         j                  |k(  sJ |j                  d      j                         |k(  sJ |j                  d      j                  |k(  sJ t        j                  g | 
      }|j                         j                         J |j                         j                  |k(  sJ |j                  d      j                         |k(  sJ |j                  d      j                  |k(  sJ y )Nr   Decimal&   L   5.79z10.000.001.234.56r.  z8.77ry   )decimalr6  r   typesis_decimal128
decimal128scale
decimal256r   r0  r1  r   )r+  r6  max_precision_typeexpected_sumexpected_sum_overflowzeror  s          r:   test_sum_decimal_arrayrG  k  s    88!!*- 	b***+]]2z//0 
 6?L#G,6?D ((GFOWV_5J
GC779??,,,779>>////
((GFOWV_d;*
MC779??,,,779>>//// ((GFOWV_5J
GC779?? 5555779>>////
((GFOWV_d;*
MC779?? 5555779>>////
((D6

+C779??$$$779>>////77Q7%%'4///77Q7$$(::::
((2J
'C779??$$$779>>////77Q7%%'4///77Q7$$(::::rD   c                 |   t        j                  t        j                  g d|       g      }t        j                  |      j                         dk(  sJ t        j                  t        j                  ddg|       t        j                  ddg|       g      }t        j                  |      j                         dk(  sJ t        j                  t        j                  ddg|       t        j                  g |       t        j                  ddg|       g      }t        j                  |      j                         dk(  sJ t        j                  d|       }|j                  d	k(  sJ t        j                  |      j                         J t        j                  |d	
      j                         d	k(  sJ y )Nr-  r.  r   r#   r$   r"   r%   r   r   ry   )r   chunked_arrayr   r?   r0  r1  
num_chunksr2  s     r:   test_sum_chunked_arrayrK    sc   


BHH\
CD
EC66#;"$$$



!Qj)288QF+L C 66#;"$$$



!Qj)
*%
!Qj) C
 66#;"$$$


2J
/C>>Q66#;&&&66##))+q000rD   c           	         ddl m} t        j                  j	                  |       r t        j
                  d| j                        nt        j                  d| j                        } |d      } |d      }t        j                  t        j                   |d       |d      g| 	      g      }t        j                  |      j                         |k(  sJ t        j                  |      j                  |k(  sJ t        j                  t        j                   |d      g| 	      t        j                   |d      g| 	      g      }t        j                  |      j                         |k(  sJ t        j                  |      j                  |k(  sJ t        j                  t        j                   |d      g| 	      t        j                  g | 	      t        j                   |d      g| 	      g      }t        j                  |      j                         |k(  sJ t        j                  |      j                  |k(  sJ t        j                  d
| 	      }|j                  dk(  sJ t        j                  |      j                         J t        j                  |      j                  |k(  sJ t        j                  |d      j                         |k(  sJ t        j                  |d      j                  |k(  sJ y )Nr   r5  r7  r8  r9  r:  r;  r<  r.  r   ry   )r=  r6  r   r>  r?  r@  rA  rB  rI  r   r?   r0  r1  r   rJ  )r+  r6  rC  rD  rF  r  s         r:   #test_sum_chunked_array_decimal_typerM    sr    88!!*- 	b***+]]2z//0 
 6?L6?D


HHgfowv7jI	
C
 66#;,...66#;1111



'&/"4
'&/"4 C 66#;,...66#;1111



'&/"4
*%
'&/"4 C
 66#;,...66#;1111


2J
/C>>Q66#;&&&66#;111166##))+t33366##((,>>>>rD   c                     t        j                  g dd      } t        j                  |       }t	        |      dk(  sJ |d   j                         dddk(  sJ t        j                  | d      }t	        |      dk(  sJ |d   j                         dddk(  sJ |d   j                         d	ddk(  sJ t        j                  g d      } t	        t        j                  |             dk(  sJ t        j                  g d
d      } t        j                  | d      }t	        |      dk(  sJ t        j                  | d      }t	        |      dk(  sJ t        j                  | dd      }t	        |      dk(  sJ t        j                  ddg      } t        j                  | d      }t	        |      dk(  sJ |d   j                         dddk(  sJ |d   j                         dddk(  sJ y )Nr#   r#   r"   r%   r"   r
   r   r.  r#   r   r$   modecountr   r"   )r#   r#   r"   r%   r"   NFrZ   r&   ry   r
   rV   rz   T)r   r   r?   rQ  r0   r1  r  rQ  s     r:   test_mode_arrayrV    s   
((%G
4C773<Dt9>>7==?q15555773!Dt9>>7==?q155557==?q15555
((2G
$Crwws|!!!
(((w
7C7735)Dt9>>773!$Dt9>>7735A6Dt9>>
((D%=
!C773!Dt9>>7==?uq99997==?ta8888rD   c                  .   t        j                  t        j                  g dd      g      } t        j                  |       }t        |      dk(  sJ |d   j                         dddk(  sJ t        j                  | d      }t        |      dk(  sJ |d   j                         dddk(  sJ |d   j                         d	ddk(  sJ t        j                  d
d      } | j                  dk(  sJ t        t        j                  |             dk(  sJ y )NrO  r   r.  r#   r   r$   rP  rS  r"   r   )r   rI  r   r?   rQ  r0   r1  rJ  rU  s     r:   test_mode_chunked_arrayrX    s    


BHH%7gFG
HC773<Dt9>>7==?q15555773!Dt9>>7==?q155557==?q15555


2G
,C>>Qrwws|!!!rD   c                      d} t        j                  t        j                  |       5  t        j                  g        d d d        t        j                  g t        j
                                y # 1 sw Y   3xY w)Nz@cannot construct ChunkedArray from empty vector and omitted typer-   r.  )r3   r4   r   ArrowInvalidrI  r   )msgs    r:   test_empty_chunked_arrayr\    sT    
LC	rc	2 
 Rbggi( s   A00A9c                     g d} t        j                  |       j                         dk(  sJ t        j                  | d      j                         dk(  sJ t        j                  | d      j                         dk(  sJ y )N)r#   r$   r"   r%   r
   r&      r   g      @r   )ddofr#   g      @)r?   variancer1  datas    r:   test_variancerc    sk    #D;;t""$,,,;;t!$**,444;;t!$**,333rD   c                  "   g d} t        j                  |       j                         t        j                  dd      k(  sJ t        j                  | d      j                         J t        j                  | d      j                         J y )	Nr#   r#   Nr$   g;f?绽|=relFrZ   r%   ry   )r?   skewr1  r3   approxra  s    r:   	test_skewrk    sr    D774= FMM2C$OOOO774E*002:::7741%++-555rD   c                  "   g d} t        j                  |       j                         t        j                  dd      k(  sJ t        j                  | d      j                         J t        j                  | d      j                         J y )	Nre  g      rf  rg  FrZ   r%   ry   )r?   kurtosisr1  r3   rj  ra  s    r:   test_kurtosisrn    sr    D;;t""$d(FFFF;;t.446>>>;;tq)//1999rD   zinput, expected)      ?g       @g      @g      D@NgIcݺ?gpՕ@)ri  rm  )r#   r$   (   gdV?rp  c                     t        j                  | dd      }t        j                  | dd      }|j                         |d   k(  sJ |j                         |d   k(  sJ y )NTF)rV   biasedri  rm  )r?   ri  rm  r1  )inputr  
arrow_skewarrow_kurtosiss       r:   test_unbiased_skew_and_kurtosisrv  #  s`     4>J[[4FN&!1111!Xj%9999rD   c                     t        j                         t        j                         ft        j                         t        j                         ffD ]  \  } }t        j
                  g d|       }t        j                  |d      }t        j
                  g d|      }||k(  sJ t        j                  |dd      }t        j
                  g d|      }||k(  rJ  y )N)abcababcabbaABNr.  rx  )r#   r#   r$   r   r   NTignore_case)r#   r#   r$   r   r#   N)r   r   r   large_stringr   r   r?   count_substringtyoffsetr  resultr  s        r:   test_count_substringr  3  s    ))+rxxz2//+RXXZ8: 
"Vhh?bI##C.881?6!!!##C4@881?6!!!
"rD   c                     t        j                         t        j                         ft        j                         t        j                         ffD ]  \  } }t        j
                  g d|       }t        j                  |d      }t        j
                  g d|      }|j                  |      sJ t        j                  |dd      }t        j
                  g d|      }|j                  |      rJ  y )N)rx  ry  baAacaar{  r|  Nr.  za+)r#   r#   r"   r#   r   NTr}  )r#   r#   r$   r#   r#   N)	r   r   r   r  r   r   r?   count_substring_regexr  r  s        r:   test_count_substring_regexr  A  s    ))+rxxz2//+RXXZ8: 
'VhhAK))#t4881?v&&&))#tF881?v&&&
'rD   c                  ~   t        j                         t        j                         t        j                         t        j                         fD ]  } t        j
                  g d|       }t        j                  |d      }|j                         g dk(  sJ t        j                  |d      }|j                         g dk(  sJ t        j
                  g d|       }t        j                  |dd	
      }|j                         g dk(  sJ t        j                  |dd	
      }|j                         g dk(  rJ  y )N)rx  ry  r{  Nr.  rx  )r   r#   r\   Nza?b)r   r#   r   N)zab*zcAB*r{  zaB?zaB*Tr}  )r   r#   r\   r\   )r   r#   r   r   )
r   r   r   r  large_binaryr   r?   find_substringr'  find_substring_regex)r  r  r  s      r:   test_find_substringr  O  s    yy{BIIK):BOO<MN 2hh0r:""3-!%5555((e4!_444hh3"=""34@!^333((eF!\1112rD   c                     t        j                  g d      } t        j                  | d      }t        j                  g d      }|j	                  |      sJ t        j                  g d      } t        j                  | dd      }t        j                  g d      }|j	                  |      sJ t        j                  | dd      }t        j                  g d      }|j	                  |      sJ y )	N)rx  zba%r{  ca%dNz_a\%%)FTFTN)aBzbA%r{  r  NTr}  F)FFFTN)r   r   r?   
match_liker  r  r  r  s      r:   test_match_liker  `  s    
((4
5C]]3)Fxx89H??6"""
((4
5C]]3d;Fxx89H??6"""]]3e<Fxx9:H??6"""rD   c                     t        j                  g d      } t        j                  | d      }t        j                  g d      }|j	                  |      sJ t        j                  g d      } t        j                  | dd      }t        j                  g d      }|j	                  |      sJ t        j                  | dd      }t        j                  g d	      }|j	                  |      sJ y )
N)rx  abcr{  Nrx  TTFN)u   áBu   Ábcr{  Nu   ábTr}  F)FFFN)r   r   r?   match_substringr  r  s      r:   test_match_substringr  o  s    
((,
-CT*Fxx12H??6"""
((.
/CU=Fxx12H??6"""U>Fxx34H??6"""rD   c                     t        j                  g d      } t        j                  | d      }t        j                  g d      }|j	                  |      sJ t        j                  g d      } t        j                  | dd      }t        j                  g d      }|j	                  |      sJ t        j                  | dd      }t        j                  g d      }|j	                  |      sJ y )	N)rx  r  r{  cNz^a?b)TTTFN)r  AbcBAr  NTr}  F)FFFFN)r   r   r?   match_substring_regexr  r  s      r:   test_match_substring_regexr  ~  s    
((1
2C%%c62Fxx78H??6"""
((1
2C%%c6tDFxx78H??6"""%%c6uEFxx:;H??6"""rD   c                     t        j                  g d      } t        j                  |       }t        j                  g d      }|j	                  |      sJ t        j                  g d      } t        j
                  |       }t        j                  g d      }|j	                  |      sJ t        j                  g d      } t        j                  | d      }t        j                  g d      }|j	                  |      sJ t        j                  | d      }t        j                  g d      }|j	                  |      sJ y )N) fooNu    　foo bar 	)r  Nfoo bar)r  Nu
   　foo baru    f　)
characters)ooNzoo bar 	)r   r   r?   utf8_trim_whitespacer  ascii_trim_whitespace	utf8_trimr  s      r:   	test_trimr    s    
((6
7C$$S)Fxx01H??6"""
((6
7C%%c*Fxx67H??6"""
((6
7C\\#*5Fxx12H??6"""\\#z*Fxx12H??6"""rD   c                     t        j                  g d      } t        dd      D ]  }t        j                  t        dd      d g      D ]  }dD ]  }t        j                  | D cg c]  }|j                         |||    c}      }t        j                  | |||      }|j                  |      sJ t        j                  | |||      |k(  rJ    y c c}w )N) u   𝑓u   𝑓öu   𝑓öõu   𝑓öõḍu   𝑓öõḍšr&   )r\   r#   r$   r"   rU   stopstep)	r   r   range	itertoolschainr1  r?   utf8_slice_codeunitsr  )r  rU   r  r  kr  r  s          r:   test_slice_compatibilityr    s    
((U
VCr1 
LOOE"aL4&9 		LD- L88.1%3)* &'WWYuT$%? %3 400u4d<v.....s/4dDBEKL L LL		L
L%3s   #Cc            
         g d} t        j                  |       }t        j                  t	        dd      t	        dd      t	        dd            D ])  \  }}}|dk(  rt        j                  |D cg c]  }|j                         |||    c}      }t        j                  ||||      }|j                  |      sJ t        j                  ||||      |k(  sJ | D ]  }t        j                  |t        j                  t        |                  }	||||   }t        j                  |	|||      }
|
j                  t        j                  t        |            k(  sJ |
j                         |k(  rJ  , y c c}w )	N)rD   r   s   as   ab s   abcs   abder  r&   r  r%   r   r  r.  )r   r   r  productr  r1  r?   binary_slicer  r   r   r0   r   )rb  r  rU   r  r  r  r  r  item
fsb_scalaractuals              r:   test_binary_slice_compatibilityr    s^   DD
((4.C&..uR|/4R|/4R|= .tT 1988&)+!" WWYuT$7 + ,u4d4v&&&sE46&@@@ 	.D4biiD	.BCJE$tO,H__ZdCF;;"))CM"::::<<>X---	..
+s   0E=
c                     t        j                  ddg      } t        j                  | d      }t        j                  ddgg dg      }|j	                  |      sJ t        j                  | dd	      }t        j                  ddgd
dgg      }|j	                  |      sJ t        j                  | ddd      }t        j                  ddgddgg      }|j	                  |      sJ y )N-foo---bar--
---foo---b---r[   z-foozbar--r  r  r   r#   
max_splitsr  foo---bTr  reversez---foor   )r   r   r?   split_patternr  r  s      r:   test_split_patternr    s    
((NL1
2Cc51Fxx&'*,<=>H??6"""c5Q7Fxx&'*RO<=H??6"""c5QEFxx&'*XsO<=H??6"""rD   c                     t        j                  ddg      } t        j                  |       }t        j                  ddgg dg      }|j	                  |      sJ t        j                  | d      }t        j                  ddgdd	gg      }|j	                  |      sJ t        j                  | dd
      }t        j                  ddgddgg      }|j	                  |      sJ y )Nr      foo  　	br  r  r  r#   r  r  
   foo  　	bTr  r  r   )r   r   r?   utf8_split_whitespacer  r  s      r:   test_split_whitespace_utf8r    s    
((I01
2C%%c*Fxx%)9:;H??6"""%%ca8Fxx%".>)?@AH??6"""%%caFFxx%&#78H??6"""rD   c                     t        j                  ddg      } t        j                  |       }t        j                  ddgg dg      }|j	                  |      sJ t        j                  | d      }t        j                  ddgdd	gg      }|j	                  |      sJ t        j                  | dd
      }t        j                  ddgddgg      }|j	                  |      sJ y )Nr  r  r  r  )r  r  u   　r   r#   r  r  r  Tr  u	    foo  　r   )r   r   r?   ascii_split_whitespacer  r  s      r:   test_split_whitespace_asciir    s    
((I01
2C&&s+Fxx%)CDEH??6"""&&sq9Fxx%".>)?@AH??6"""&&sq$GFxx%.#)>?@H??6"""rD   c                     t        j                  ddg      } t        j                  | d      }t        j                  g dg dg      }|j	                  |      sJ t        j                  | dd      }t        j                  d	d
gd	dgg      }|j	                  |      sJ t        j                  t        d      5  t        j                  | ddd      }d d d        y # 1 sw Y   y xY w)Nr  r  z-+r  )r  r  r  r  r  r#   r  r  zfoo---bar--r  z"Cannot split in reverse with regexr-   r  T)r[   r  r  )r   r   r?   split_pattern_regexr  r3   r4   NotImplementedErrorr  s      r:   test_split_pattern_regexr    s    
((NL1
2C##C6Fxx/1ABCH??6"""##C!<Fxx"m,r9o>?H??6"""	*A
C <''1d<< < <s   >C!!C*c                     g d} t        j                  |       }|j                         dddk(  sJ t        j                  | t        j                               }|j                         dddk(  sJ t        j                  | t        j                  d            }|j                         dddk(  sJ t        j                  | t        j                  d            }|j                         d d dk(  sJ t        j                  | d	di      }|j                         d d dk(  sJ t        j                  | d      }|j                         d d dk(  sJ t	        j
                  t              5  t        j                  | t        j                         d
      }d d d        t        j                         }t	        j
                  t              5  t        j                  | |      }d d d        t	        j
                  t        d      5  t        j                         }d d d        y # 1 sw Y   xY w# 1 sw Y   NxY w# 1 sw Y   y xY w)N)r%   r
   r&   Nr#   r#   r&   )minrn   r   TrZ   FrV   )r   rV   zmin_max takes 1 positionalr-   )r?   min_maxr1  r   r3   r4   r5   r   )rb  r   r   s      r:   test_min_maxr    s   D


4A779!,,,,


4!:!:!<=A779!,,,,


4!:!:d!KLA779!,,,,


4!:!:e!LMA779T2222 	

4,!67A779T2222


4E*A779T2222 
y	! IJJ"335%II
 nnG	y	! .JJtW-. 
y(D	E JJL I I. . s$   2+H+H7I+H47I Ic                     t        j                  dd      } t        j                  g d      }t        j                  |      j                         J t        j                  |d      j                         du sJ t        j                  ||       j                         du sJ t        j                  g d      }t        j                  |      j                         d	u sJ t        j                  ||       j                         d	u sJ t        j                  g d
      }t        j                  |      j                         du sJ t        j                  ||       j                         J y )NFr   rT  r   r.  ry   r  )FNTT)FNF)r?   r   r   r   anyr1  r   r   s     r:   test_anyr  )  s    ''5AFG
&!A66!9??$$$66!q!'')U22266!W%++-666
$%A66!9??$$$66!W%++-555
%&A66!9??%%%66!W%++-555rD   c                     t        j                  dd      } t        j                  g d      }t        j                  |      j                         J t        j                  |d      j                         du sJ t        j                  ||       j                         du sJ t        j                  ddg      }t        j                  |      j                         du sJ t        j                  ||       j                         du sJ t        j                  dd g      }t        j                  |      j                         du sJ t        j                  ||       j                         J t        j                  dgdd gg      }t        j                  |      j                         du sJ t        j                  ||       j                         J t        j                  dgdgg      }t        j                  |      j                         du sJ t        j                  ||       j                         du sJ y )	NFr   rT  r   r.  ry   Tr  )r?   r   r   r   r   r1  rI  r  s     r:   test_allr  <  s    ''5AFG
&!A66!9??$$$66!q!'')T11166!W%++-555
%A66!9??%%%66!W%++-666
$A66!9??$$$66!W%++-555
4&4,/0A66!9??$$$66!W%++-555
4&5'*+A66!9??%%%66!W%++-666rD   c                      g d} t        j                  |       j                         g dk(  sJ t        j                  t
              5  t        j                  | d        d d d        y # 1 sw Y   y xY w)Nr%   r
   N)TTFr  )r?   is_validr'  r3   r4   r5   ra  s    r:   test_is_validr  W  sW    D;;t&&(,????	y	! (
D$'( ( (s   A))A2c                     t         j                  j                  t        j                  d      k(  sJ t         j
                  j                  t        j                  d      k(  sJ t         j                  j                  t        j                  d      k(  sJ t         j                  j                  t        j                  d      k(  sJ y )Nas          Compute the minimum and maximum values of a numeric array.

        Null values are ignored by default.
        This can be changed through ScalarAggregateOptions.

        Parameters
        ----------
        array : Array-like
            Argument to compute function.
        skip_nulls : bool, default True
            Whether to skip (ignore) nulls in the input.
            If False, any null in the input forces the output to null.
        min_count : int, default 1
            Minimum number of non-null values in the input.  If the number
            of non-null values is below `min_count`, the output is null.
        options : pyarrow.compute.ScalarAggregateOptions, optional
            Alternative way of passing options.
        memory_pool : pyarrow.MemoryPool, optional
            If not passed, will allocate memory from the default memory pool.
        a          Add the arguments element-wise.

        Results will wrap around on integer overflow.
        Use function "add_checked" if you want overflow
        to return an error.

        Parameters
        ----------
        x : Array-like or scalar-like
            Argument to compute function.
        y : Array-like or scalar-like
            Argument to compute function.
        memory_pool : pyarrow.MemoryPool, optional
            If not passed, will allocate memory from the default memory pool.
        a          Find the element-wise minimum value.

        Nulls are ignored (by default) or propagated.
        NaN is preferred over null, but not over any valid value.

        Parameters
        ----------
        *args : Array-like or scalar-like
            Argument to compute function.
        skip_nulls : bool, default True
            Whether to skip (ignore) nulls in the input.
            If False, any null in the input forces the output to null.
        options : pyarrow.compute.ElementWiseAggregateOptions, optional
            Alternative way of passing options.
        memory_pool : pyarrow.MemoryPool, optional
            If not passed, will allocate memory from the default memory pool.
        aO          Filter with a boolean selection filter.

        The output is populated with values from the input at positions
        where the selection filter is non-zero.  Nulls in the selection filter
        are handled based on FilterOptions.

        Parameters
        ----------
        input : Array-like or scalar-like
            Argument to compute function.
        selection_filter : Array-like or scalar-like
            Argument to compute function.
        null_selection_behavior : str, default "drop"
            How to handle nulls in the selection filter.
            Accepted values are "drop", "emit_null".
        options : pyarrow.compute.FilterOptions, optional
            Alternative way of passing options.
        memory_pool : pyarrow.MemoryPool, optional
            If not passed, will allocate memory from the default memory pool.

        Examples
        --------
        >>> import pyarrow as pa
        >>> arr = pa.array(["a", "b", "c", None, "e"])
        >>> mask = pa.array([True, False, None, False, True])
        >>> arr.filter(mask)
        <pyarrow.lib.StringArray object at ...>
        [
          "a",
          "e"
        ]
        >>> arr.filter(mask, null_selection_behavior='emit_null')
        <pyarrow.lib.StringArray object at ...>
        [
          "a",
          null,
          "e"
        ]
        )r?   r  __doc__textwrapdedentr   min_element_wisefilterr   rD   r:   test_generated_docstringsr  `  s    :: 2 "   , 66>>X__ .    " &&(// ; +   $ 99 '1 '! ' ' 'rD   c                  h   t        j                  t        j                        } t	        |       dk(  sJ t        j                  t        j
                        } t	        |       dk(  sJ t        j                  t        j                        } t	        |       dk(  sJ t        j                  t        j                        } t	        |       dk(  sJ t        j                  t        j                        } t	        |       dk(  sJ t        j                  t        j                        } t	        |       dk(  sJ y )Nz(x, y, /, *, memory_pool=None)zK(array, /, *, skip_nulls=True, min_count=1, options=None, memory_pool=None)zj(array, /, q=0.5, *, interpolation='linear', skip_nulls=True, min_count=0, options=None, memory_pool=None)zZ(*strings, null_handling='emit_null', null_replacement='', options=None, memory_pool=None)z'(indices, /, *values, memory_pool=None)z<(n, *, initializer='system', options=None, memory_pool=None))
rG   rH   r?   r   strr  quantilebinary_join_element_wisechooserandom)rO   s    r:   test_generated_signaturesr    s   
 

BFF
#Cs87777


BJJ
'Cs8 : ; ; ; 

BKK
(Cs8 : ; ; ; 

B77
8Cs8 , - - - 

BII
&Cs8@@@@


BII
&Cs8 : ; ; ;rD   c                  v   t               } t        dd      D cg c]  }d|cxk  rdk  sn t        |       }}t        j                  t        j                  |            j                         }t        |      D ]6  \  }}||   |j                         k7  s| j                  t        |             8 | S c c}w )N           )setr  chrr?   utf8_is_printabler   r   r'  	enumerateisprintabler   ord)newr  r  is_printableis        r:   find_new_unicode_codepointsr    s    
%C"'g"6 1Q A.. a& 1J 1''(<=GGIL*% 1?ammo-GGCFO J1s   B6i  i  >   ,  -  .  /  0  1  2  3  4  5  6  7  8  9  :  ;  <  =  >  ?  @  A  B  C  D  E  F  G  H  I  J  K  L  M  N  O  P  Q  R  S  T  U  V  W  X  Y  Z  [  \  \  ]  ]  ^  ^  _  _  `  a  b  c  d  e  f  g  h  i  j  p  q   x  z  |,  },                                                霦    靦                                                                                                                >H           N  N  Q  4  o  N  	N  _  O  _  _  _  !  *8  ,  0  AS  CS  DS  ES  FQ  F  LS  Lc  L  M;  ]N  iQ  kQ  k  mQ  pO  s  x  x  z^  ~v  4  醀  N  N  N  s  鮌    鳌  N  N  S  S  S  S    g    V  N  N  X    X    ^  b  ^  >l   @
 A
 B
 C
 ` `$  a a$  b b$  c c$  d d$  e e$  f f$  g g$  h h$  i  j  k  l  m  n  o  p  p   q  t   t$  u   u$  v   v$  v'  w   w$  w'  x   x$  x'  y   y$  y'  z$  z'  {$  {'  |$  |'  }'  ~'     '     '     '     '     '     '     '     '     $  '     $  $  '  $  '  $  '  $  '  $  '  $  '  $  '  '  '    $  $  $  $  $  $  $  $  $  $  $           >A   r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  )is_alnumis_alphais_digit
is_numericis_lowerfunction_name)
rI  rJ  is_ascii
is_decimalrK  rM  rL  r   is_spaceis_uppervariantasciiutf8c                    |dz   | z   }| j                  dd      }t        j                  | t                     t	               z  }t        t        rdnd      D ]  }|t        dd      v r||v rt        |      }t        t        |      s3| dk7  s9t        j                  |g      }t        t        |      } ||      d   j                          t        ||             k(  rJ  y )	N_r  r  r  r  r  rQ  r   )replacecodepoints_ignoregetr  r  r  rT  r  hasattrr?   r   r   r  r1  )	rN  rS  
arrow_namepy_nameignorer  r  ar
arrow_funcs	            r:   test_string_py_compat_booleanra  H  s     3.J##C,G""=#%8#%&F%3W- Fff%%; F2z"}
'B1#B Z0Jb>!$**,0C70C0EEEEFrD   c                  t   t        j                  g d      } t        j                  | d      j	                         g dk(  sJ t        j
                  | d      j	                         g dk(  sJ t        j                  | d      j	                         g dk(  sJ t        j                  | d      j	                         g dk(  sJ t        j
                  | d      j	                         g dk(  sJ t        j                  | d      j	                         g dk(  sJ t        j                  g d      } t        j                  | d      j	                         g dk(  sJ t        j                  | d      j	                         g d	k(  sJ t        j                  | d      j	                         g d
k(  sJ t        j                  | d      j	                         g dk(  sJ t        j                  | d      j	                         g d	k(  sJ t        j                  | d      j	                         g d
k(  sJ y )N)Nr   abcdr"   width)Nz a rc  )Nz  arc  )Nza  rc  )N   árc  )Nu    á rc  )Nu     árc  )Nu   á  rc  )
r   r   r?   ascii_centertolist
ascii_lpad
ascii_rpadutf8_center	utf8_lpad	utf8_rpadr)  s    r:   test_padrn  b  s   
((&
'C??3a(//15JJJJ==A&--/3HHHH==A&--/3HHHH??3"))+/DDDD==a '')-BBBB==a '')-BBBB
(('
(C>>#Q'..04JJJJ<<1%,,.2HHHH<<1%,,.2HHHH>>#q!((*.DDDD<<Q&&(,BBBB<<Q&&(,BBBBrD   c                     t         j                  t         j                  u sJ g d} t        dd      D ]s  }t	        j
                  |       }t        j                  ||      j                         }| D cg c]  }||j                  |      nd  }}||k(  reJ d| d| d|         t	        j
                  g d      }t        j                  |t        j                  d	d
            j                         }|g dk(  sJ t	        j
                  g d      }t        j                  |t        j                  dd            j                         }|g dk(  sJ t	        j
                  dg      }t        j                  t        j                  d      5  t        j                  |t        j                  dd             d d d        t        j                  t        j                  d      5  t        j                  |t        j                  dd             d d d        y c c}w # 1 sw Y   ixY w# 1 sw Y   y xY w)N)Ar|  ABCr  -1z+1r`   Nr   r&   rd  zMismatch at width=z: z vs )r`   z-2z+3r
   u   💠)re  paddingr  )u   💠💠💠💠1u   -💠💠💠2u   +💠💠💠3r%   x)xxx1z-xx2z+xx3r  zPadding must be one codepointr-   spamr  )r?   
utf8_zfillutf8_zero_fillr  r   r   r'  zfillr   r3   r4   rZ  )examplesre  r  r  rt  r  s         r:   test_utf8_zfillr{  t  s   ==B----- =Hq! Xhhx ""3e4>>@GOP!amAGGEN=PP!W%7wbXJ#WW!	X (($
%CsB,>,>-! ""+)+ NNNN (($
%CsB,>,>- (y{ ---- ((E7
C	r.M	N T
#r'9'96'RST	r.M	N P
#r'9'92'NOP P' Q"T TP Ps   4H(-H-2-H9-H69Ic                  V   t        dd      } t        j                  g d      }|j                         j	                  t
              j                  t        j                  d i      }| D ]  }| D ]x  }|j                  j                  ||d      }t        j                  |||d      }|j                         |j                         k(  sJ t        j                  |||d      |k(  rxJ   t        j                  g d      }|j                         j	                  t
              j                  t        j                  d i      }| D ]b  }| D ][  }|j                  j                  ||d      }t        j                  |||d      }|j                         |j                         k(  r[J  d y )Nr  r%   )Nr  r   rx  r  rc  abcdeXX)rU   r  replacement)Nr  u   πu   πbu   πbθu   πbθdu   πbθde)r  r   r   	to_pandasastyper2   rX  r  nanr  slice_replacer?   binary_replace_slicerh  utf8_replace_slice)offsetsr  seriesrU   r  r  r  s          r:   test_replace_slicer    sv   BlG
((@
AC]]_##F+33RVVTNCF M 	MDzz//tTBH,,5t?F==?hoo&7777**3tTBfLLL	MM ((H
IC]]_##F+33RVVTNCF 8 	8Dzz//tTBH**5t?F==?hoo&7777		88rD   c                     t        j                  g d      } t        j                  | dd      }|j	                         g dk(  sJ t        j                  | dd      }|j	                         g dk(  sJ t        j                  | ddd      }|j	                         g dk(  sJ t        j                  | ddd	      }|j	                         g dk(  sJ y )
N)foozfoofoodNr  r  r[   r  )barzbarbardNr#   )r[   r  max_replacements)barzfoor  N)r  )r   r   r?   replace_substringrh  )rb  r_  s     r:   test_replace_plainr    s    88-.D			dEu	EB99;3333			dE5	1B99;3333			dEu/0
2B99;3333			dE51	EB99;3333rD   c                  F   t        j                  g d      } g d}t        j                  | dd      }|j	                         |k(  sJ t        j                  | dd      }|j	                         |k(  sJ t        j                  | dd      }|j	                         |k(  sJ y )N)r  moodN)f00m00dNz(.)ooz\100r  )r  )r   r   r?   replace_substring_regexrh  )rb  r  r_  s      r:   test_replace_regexr    s    88)*D$H		#	#D'w	OB99;("""		#	#D'w	GB99;("""		#	#D'7	;B99;("""rD   c                      t        j                  ddg      } ddddddg}t        j                  | d	      }|j	                         |k(  sJ t        j                  | d      }|j	                         |k(  sJ y )
Na1zb2zr   r`   letterdigitr   ra   z(?P<letter>[ab])(?P<digit>\d)r  )r   r   r?   extract_regexrh  r_  r  structs      r:   test_extract_regexr    sv    	4.	!B-#/LMHb*JKF==?h&&&b"BCF==?h&&&rD   c                     t        j                  ddg      } ddgddgdddgddgdg}t        j                  | d	      }|j	                         |k(  sJ t        j                  | d      }|j	                         |k(  sJ y )
Nr  zb234zr   r#   r  r$   r"   z(?P<letter>[ab])(?P<digit>\d+)r  )r   r   r?   extract_regex_spanrh  r  s      r:   test_extract_regex_spanr    s    	4"	#Bq6QF3q6QF35H""2/PQF==?h&&&""2'HIF==?h&&&rD   c                  2   t        j                  ddgd g g      } t        j                  g d      }t        j                  | d      j	                  |      sJ t        j                  ddgt        j
                               }t        j                  dd	gt        j
                               }t        j                  d
dgddggt        j                  t        j
                                     } t        j                  | |      j	                  |      sJ y )Nr  r  )zfoo-barNr  -r`   ra   r.  a1bc2dr   r   r  d)r   r   r?   binary_joinr  r   list_)ar_listr  separator_arrays      r:   test_binary_joinr    s    hhb12Gxx-.H>>'3'..x888hhSz		<OxxRYY[9Hhhc
S#J/bhhryy{6KLG>>'?3::8DDDrD   c                     t        j                  d t        j                               } g dg dg dg}t        j                  | j                         g dk(  sJ t        j                  ddd      j                         d	k(  sJ t        j                  d| d      j                         J t        j                  dd|       j                         J t        j                  d
      }t        j                  |d|ij                         g dk(  sJ t        j                  ddd|      j                         d	k(  sJ t        j                  d| d|      j                         dk(  sJ t        j                  dd| |      j                         J t        j                  dd      }t        j                  |d|ij                         g dk(  sJ t        j                  ddd|      j                         d	k(  sJ t        j                  d| d|      j                         dk(  sJ t        j                  dd| |      j                         J y )Nr.  )Nr   r   )r  Nr  )Nr  z--)NNb--dr   r   r  za-bskip)null_handlingr   )Nr   r  r  rX  rv  )r  null_replacement)Na-spamr  r  )r   r   r   r?   r  r'  r1  r   )nullarrsr  rX  s       r:   test_binary_join_element_wiser    sO   99T		,D.0ABD&&-779  &&sC5;;=FFF&&sD#6<<>FFF&&sC6<<>FFF>>/D&&;d;EEG  &&S#t%%*UW6 6 6&&T3&&+eg5 5 5&&S$&&+eg6 6 6 nn9vNG&&>g>HHJ ! ! !&&S#w((-59 9 9&&T3)).H= = =&&S$)).9 9 9rD   )r  rJ   c                    t        j                  ||       }t        j                         t        j                         fD ]  }t        j                  g d|      }|j	                  |      }|j                          t        j                  |d   |d   |d   d g|       }|j                  |      sJ t        j                  g |      }|j	                  |      }|j                          t        j                  g |       }|j                  |      rJ  t        j                  ddg      }t        j                  t              5  |j	                  |       d d d        t        j                  ddg      }t        j                  t              5  |j	                  |       d d d        y # 1 sw Y   TxY w# 1 sw Y   y xY w)Nr.  r   r%   r$   Nr   r%   r$   r
   r\   )
r   r   r   r   r	  validater  r3   r4   
IndexError)r  rJ   r  indices_typer   r  r  s          r:   	test_taker    sd   
((6
#CBHHJ/ '((?>'"88VAYq	6!9dC"M}}X&&& ((2L1'"88BR(}}X&&&' hh1vG	z	"  hh2wG	z	"  	  s   F-F9-F69Gc                      t        j                  t        d            } dD ]f  }t        j                  g d|      }| j                  |      }|j	                          t        j                  g d      }|j                  |      rfJ  t        j                         t        j                         fD ]N  }t        j                  g d|      }t        j                  t              5  | j                  |       d d d        P y # 1 sw Y   [xY w)Nr
   )r	   r   r   r   r   r   r   r   r  r.  )r   r%   r$   )r   r   r  r	  r  r  float32float64r3   r4   r  )r  r  r   r  r  s        r:   test_take_indices_typesr    s    
((58
C? '((?>'"88O,}}X&&&' rzz|4 ((9<8]]./ 	HHW	 		 	s   'DD	c                     t        j                  g dg dg      } t        j                  g d      }| j                  |      }t        j                  g dg      }|j	                  |      sJ t        j                  dgddgg      }| j                  |      }t        j                  dgd	d
gg      }|j	                  |      sJ y )N)r   r   r  r  e)fghr  j)r   r
   r#   r&   r'   r$   )r   r  r   r  r  r  r#   r'   r$   r   r  r  )r   rI  r   r	  r  )r  r   r  r  s       r:   test_take_on_chunked_arrayr  ,  s    


	
	
 C" hh)*GXXgF!? @AH=="""aV}-GXXgF	
 	
	! H =="""rD   orderedFTc                 `   t         j                  j                  g dg d|       }|j                  t        j                  g d            }|j                          |j                         g dk(  sJ |j                  j                         g dk(  sJ |j                  j                  | u sJ y )N)r   r#   r$   r   r#   r$   r   r   r  )r  )r   r#   r"   )r   r   r   )
r   DictionaryArrayfrom_arraysr	  r   r  r'  
dictionaryr   r  )r  r  r  s      r:   test_take_dictionaryr  R  s    



(
();_18 ) :CXXbhhy)*F
OO000&&(O;;;;;')))rD   c                  2   t        j                  d gdz        } t        j                  d gdz  gdz        }t        j                  | gdg      }t        j                  d| i      }t        j                  g d      }t        | j                  |            dk(  sJ t        |j                  |            dk(  sJ t        |j                  |      j                  d            dk(  sJ t        |j                  |      j                  d            dk(  sJ y )	Nr   r
   r$   r   r_   )r#   r"   r^  Nr%   r   )r   r   rI  record_batchtabler0   r	  column)r  chunked_arrbatchr  r   s        r:   test_take_null_typer  ]  s    
((D6B;
C""TFQJ<!#34KOOSE#/EHHc3Z Ehh'Gsxx !Q&&&{()Q...uzz'"))!,-222uzz'"))!,-222rD   c                 P   t        j                  ||       }|j                         }|j                  d       t	        t        |            D cg c]  }||   j                  s| }}|j                  t        j                  |            }|j                  |      sJ y c c}w )Nr.  Tfull)	r   r   	drop_nullr  r  r0   r  r	  r  )r  rJ   r  r  r  r   r  s          r:   test_drop_nullr  k  s~    
((6
#C]]_F
OOOC/=QSV__q=G=xx)*H==""" >s   B#%B#c                      t        j                  dd gg dd gg g      } t        j                  dgddgg g g      }| j                         }|j                  |      sJ y )Nr   r  r  Nr  r  )r   rI  r  r  )r  expected_dropr  s      r:   test_drop_null_chunked_arrayr  u  s^    


S$K)9D62F
GC$$sec3ZR%@AM]]_F=='''rD   c                  X   t        j                  t        j                  g d      gdg      } | j                         }t        j                  t        j                  g d      gdg      }|j	                  |      sJ t        j                  t        j                  g d      t        j                  g d      gddg      } | j                         }t        j                  t        j                  dg      t        j                  dg      gddg      }|j	                  |      sJ y )Nr   Nr  r  Na'r  r   r  r  )NNr  Nr  zb'r  )r   r  r   r  r  )r  r  r  s      r:   test_drop_null_record_batchr  }  s    OO	-	./v?E__F 9:4&IH=="""OO	-	.	.	/	19=tFE __F	3%"((C5/*4,@H=="""rD   c                     t        j                  t        j                  g d      gdg      } t        j                  t        j                  g d      gdg      }| j                         }|j	                  |      sJ t        j                  t        j
                  dd gg dg      t        j
                  dd gg dg      t        j
                  dgdgd gdd gg      gg d	      } t        j                  t        j                  ddg      t        j                  ddg      t        j                  ddg      gg d	      }| j                         }|j	                  |      sJ t        j                  t        j
                  ddgg d
g      t        j
                  dgdgd gdd gg      t        j
                  dd gg dg      gg d	      } t        j                  t        j                  ddg      t        j                  ddg      t        j                  ddg      gg d	      }| j                         }|j	                  |      sJ y )Nr  r   r  r  r  )Nr  Nr   r  r  r  r  r  rp  BDza`)zc`d`Nr  )r   r  r   r  r  rI  )r  r  r  s      r:   test_drop_null_tabler    s    HHbhh:;<SEJExx/23C5AH__F=="""HHb&&d5E'FG&&d5F'GH&&utfsDk'JKM +,E xx3*-3*-3*-/ ./H __F=="""HHb&&c
O'DE&&utfsDk'JK&&t6H'IJL +,E xx3*-3*-4,/1 ./H __F=="""rD   c                     t        j                  d gdz        } t        j                  d gdz  gdz        }t        j                  | gdg      }t        j                  d| i      }t        | j                               dk(  sJ t        |j                               dk(  sJ t        |j                         j                  d            dk(  sJ t        |j                         j                  d            dk(  sJ y )Nr   r
   r$   r   r  r   )r   r   rI  r  r  r0   r  r  )r  r  r  r  s       r:   test_drop_null_null_typer    s    
((D6B;
C""TFQJ<!#34KOOSE#/EHHc3Z Es}}1$$${$$&'1,,,u ''*+q000u ''*+q000rD   c                 
   t        j                  ||       }t        j                  g d      }|j                  |d      }|j                          |j	                  t        j                  |d   |d   g|             sJ |j                  |d      }|j                          |j	                  t        j                  |d   |d   d g|             sJ t        j                  g d      }t        j                  t              5  |j                  |       d d d        t        j                  g d	      }t        j                  t        d
      5  |j                  |       d d d        y # 1 sw Y   VxY w# 1 sw Y   y xY w)Nr.  TFFTNdropnull_selection_behaviorr   r"   	emit_nullr   r#   r   r#   r   TFTmust all be the same lengthr-   )	r   r   r  r  r  r3   r4   r  
ValueErrorr  rJ   r  maskr  s        r:   test_filterr    s3   
((6
#C8845DZZfZ=F
OO==6!9fQi"8rBCCCZZkZBF
OO==6!9fQi">RHIII 88O$D	*	+ 

4 88'(D	z)F	G 

4  
 s   E-E9-E69Fc                    t        j                  ||       }t        j                  g d      }|j                  |d      }|j	                          |j                  t        j                  |d   |d   g|             sJ y )Nr.  r  r  r  r   r"   )r   r   r  r  r  r  r  s        r:   test_filter_numpy_array_maskr    si     ((6
#C8845DZZfZ=F
OO==6!9fQi"8rBCCCrD   c                     t        j                  dd gg dg      } t        j                  dgdgg      }t        j                  dgd dgg      }t        j                  g d      t        j                  g dddgg      g dfD ]L  }| j                  |      }|j	                  |      sJ | j                  |d	      }|j	                  |      rLJ  y )
Nr   r  r  TFNFTr&  FTr  r  )r   rI  r   r  r  )r  r  expected_nullr  r  s        r:   test_filter_chunked_arrayr    s    


S$K9
:C$$secU^4M$$sedC[%9:M 	12
-t}=>( , D!}}]+++D+F}}]+++,rD   c                  \   t        j                  t        j                  g d      gdg      } t        j                  g d      }| j                  |      }t        j                  t        j                  ddg      gdg      }|j	                  |      sJ t        j
                  ddgd gddgg      }| j                  |      }|j	                  |      sJ | j                  |d	
      }t        j                  t        j                  g d      gdg      }|j	                  |      sJ y )Nr   Nr  r  r  r  r  r   r   r  TFr  r  r   Nr  )r   r  r   r  r  rI  )r  r  r  r  chunked_masks        r:   test_filter_record_batchr    s    OO	,	-.tf>E 8845D\\$F#s 45dVDH==""" ##dE]TFUDM$JKL\\,'F=="""\\$\DF)9 :;D6JH=="""rD   c                      t        j                  t        j                  g d      gdg      } t        j                  t        j                  ddg      gdg      }t        j                  t        j                  g d      gdg      }t        j                  g d      t        j                  ddgg d	g      g dfD ]L  }| j	                  |      }|j                  |      sJ | j	                  |d
      }|j                  |      rLJ  y )Nr  r   r  r  r  r   TF)NFTr  r  )r   r  r   rI  r  r  )r  r  r  r  r  s        r:   test_filter_tabler	     s    HHbhh9:;C5IEHHbhhSz23C5AMHHbhh'789#GM 	12
4-)<=>( , d#}}]+++dKH}}]+++,rD   c                  4   t        j                  dd gg dg      } t        j                  t        j                  g d      gdg      }t        j                  t        j                  g d      gdg      }| ||fD ]  }t        j                  g d      }t        j                  t              5  |j                  |       d d d        t        j                  g d      }t        j                  t         j                  d	      5  |j                  |       d d d         t        j                  d
      }|||fD ]5  }t        j                  t              5  |j                  |       d d d        7 y # 1 sw Y   xY w# 1 sw Y   xY w# 1 sw Y   [xY w)Nr   r  r  r  r  r  r  r  r-   T)r   rI  r  r   r  r3   r4   r  r  rZ  r   r5   )r  r  r  objr  r   filts          r:   test_filter_errorsr    sR   


S$K9
:COO	,	-.tf>EHHbhh9:;C5IEUE" 
xx(]]./ 	JJt	 xx+,]]2??!>@ 	JJt	 	
 YYt_Fv& ]]9% 	LL	 		 	
	 		 	s$   0E5FF5E>	F	F	c                  8   t        j                  d gdz        } t        j                  d gdz  gdz        }t        j                  | gdg      }t        j                  d| i      }t        j                  ddgdz        }t        | j                  |            dk(  sJ t        |j                  |            dk(  sJ t        |j                  |      j                  d            dk(  sJ t        |j                  |      j                  d            dk(  sJ y )	Nr   r
   r$   r   r  TFr   )r   r   rI  r  r  r0   r  r  )r  r  r  r  r  s        r:   test_filter_null_typer  +  s    
((D6B;
C""TFQJ<!#34KOOSE#/EHHc3Z E88T5MA%&Dszz$ A%%%{!!$'(A---u||D!((+,111u||D!((+,111rD   typr   rI  c                    | dk(  rd }nd } |g d      } |g d      }t        j                  ||      }|j                   |g d            sJ t        j                  ||      }|j                   |g d            sJ t        j                  ||      }|j                   |g d            sJ t        j
                  ||      }|j                   |g d	            sJ t        j                  ||      }|j                   |g d
            sJ t        j                  ||      }|j                   |g d            sJ y )Nr   c                 ,    t        j                  |       S r   r   r   rJ   s    r:   conztest_compare_array.<locals>.con<      88F##rD   c                 .    t        j                  | g      S r   r   rI  r  s    r:   r  ztest_compare_array.<locals>.con?      ##VH--rD   r/  )r#   r#   r%   Nr%   )TFFNN)FTTNN)FFTNN)TFTNN)FTFNN)TTFNN)r?   r(  r  	not_equalless
less_equalgreatergreater_equal)r  r  arr1arr2r  s        r:   test_compare_arrayr!  9  s   
g~	$	. !"D!"DXXdD!F===>???\\$%F==<=>>>WWT4 F===>???]]4&F==<=>>>ZZd#F===>???dD)F==<=>>>rD   c                 j   | dk(  rd }nd } |g d      }t        j                  d      }t        j                  ||      }|j	                   |g d            sJ | dk(  r]t        j                  d d      }t        j                  ||      }t        j
                  |      }|j	                   |g d	            sJ t        j                  ||      }|j	                   |g d
            sJ t        j                  ||      }|j	                   |g d            sJ t        j                  ||      }|j	                   |g d            sJ t        j                  ||      }|j	                   |g d            sJ t        j                  ||      }|j	                   |g d            sJ y )Nr   c                 ,    t        j                  |       S r   r  r  s    r:   r  z'test_compare_string_scalar.<locals>.con[  r  rD   c                 .    t        j                  | g      S r   r  r  s    r:   r  z'test_compare_string_scalar.<locals>.con^  r  rD   )r   r   r  Nr   FTFNr   r.  )TTTTTFTNTFFNr  FFTNFTTN)r   r   r?   r(  r  is_nullr  r  r  r  r  )r  r  r  r   r  nascalarisnulls          r:   test_compare_string_scalarr-  X  sl   
g~	$	. #
$CYYs^FXXc6"F==78999
g~99T1#x(F#}}S!9:;;;\\#v&F==67888WWS&!F==78999]]3'F==67888ZZV$F==78999c6*F==67888rD   c                 8   | dk(  rd }nd } |g d      }t        j                  d      }t        j                  ||      }|j	                   |g d            sJ | dk(  rDt        j                  d d      }t        j                  ||      }|j                         g d	k(  sJ t        j                  ||      }|j	                   |g d
            sJ t        j                  ||      }|j	                   |g d            sJ t        j                  ||      }|j	                   |g d            sJ t        j                  ||      }|j	                   |g d            sJ t        j                  ||      }|j	                   |g d            sJ y )Nr   c                 ,    t        j                  |       S r   r  r  s    r:   r  z test_compare_scalar.<locals>.con  r  rD   c                 .    t        j                  | g      S r   r  r  s    r:   r  z test_compare_scalar.<locals>.con  r  rD   r#   r$   r"   Nr$   r%  r   r.  NNNNr&  r'  r  r(  r)  )r   r   r?   r(  r  r'  r  r  r  r  r  )r  r  r  r   r  r+  s         r:   test_compare_scalarr3  }  s]   
g~	$	. o
CYYq\FXXc6"F==78999
g~99T0#x(!%====\\#v&F==67888WWS&!F==78999]]3'F==67888ZZV$F==78999c6*F==67888rD   c                  F   t        j                  g d      } t        j                  g ddd gg      }t        j                  ddgg dg      }t        j                  g dg      }| |f|| f||ffD ].  \  }}t        j                  ||      }|j                  |      r.J  y )Nr/  r#   r$   r"   r%   r#   r$   )r"   r%   N)TTTTN)r   r   rI  r?   r(  r  )r  arr_chunkedarr_chunked2r  leftrightr  s          r:    test_compare_chunked_array_mixedr:    s    
((%
&C""I4y#9:K##aV\$:;L!? @AH 
k	c	l# 'e
 $&}}X&&&'rD   c                      t        j                  g d      } t        j                  g d      }t        j                  | |      }t        j                  g d      }|j	                  |      sJ y )Nr#   r$   r"   r%   r
   r   r\   r#   r$   r"   )r#   r#   r%   r&   r   )r   r   r?   r   r  r8  r9  r  r  s       r:   test_arithmetic_addr?    sO    88O$DHH%&EVVD% Fxx(H=="""rD   c                      t        j                  g d      } t        j                  g d      }t        j                  | |      }t        j                  g d      }|j	                  |      sJ y )Nr<  r=  )r#   r"   r$   r$   r$   )r   r   r?   subtractr  r>  s       r:   test_arithmetic_subtractrB    sO    88O$DHH%&E[[u%Fxx(H=="""rD   c                      t        j                  g d      } t        j                  g d      }t        j                  | |      }t        j                  g d      }|j	                  |      sJ y )Nr<  r=  )r   r  r"   r      )r   r   r?   multiplyr  r>  s       r:   test_arithmetic_multiplyrF    sP    88O$DHH%&E[[u%Fxx)*H=="""rD   r  roundround_to_multiplec                    | dk(  r,t         j                  }t        t         j                  d      }n0| dk(  r+t         j                  }t        t         j
                  d      }g d}g dg d	g d
g dg dg dg dg dg dg dd
}|j                         D ]T  \  }} |      } ||      }t        j                  |t        j                               }	|	j                  |      rTJ  y )NrG  r   ndigitsrH  r#   multiple)g	@      @皙@      @皙	g      gN)r"   r"   r"   r%   rR  rR  N)r%   r%   r%   r
   r  r  r  N)r"   r"   r"   r%   r  r  r  N)r%   r%   r%   r
   rR  rR  rR  N)r"   r"   r%   r%   r  rR  rR  N)r"   r%   r%   r
   r  r  rR  N)r"   r"   r%   r%   r  r  rR  N)r"   r%   r%   r
   r  rR  rR  N)r"   r%   r%   r%   r  rR  rR  N)r"   r"   r%   r
   r  r  rR  N)
downuptowards_zerors   	half_downhalf_uphalf_towards_zerohalf_towards_infinityhalf_to_evenhalf_to_odd
round_moder  r.  )r?   rG  r   r   rH  r   itemsr   r   r  r  )
r  rG  r   rJ   rmode_and_expectedr]  r  r   r  expected_arrays
             r:   test_round_to_integerra    s    	W}r:	"	"$$r881E9F.,6:31;!?65 !3 8 8 : -
H*5vw/(>$$V,,,	-rD   c                     g d} g dg dg dg dg dd}|j                         D ]  \  }}t        j                  |d      }t        j                  | |	      }t        j
                  j                  |t        j                  |      d
       t        j                  | |d      |k(  sJ t        j                  | |d      |k(  rJ  y )N@  rN  g@rP  gV-	g):ˏAg\(\Ni,  r   r   r   r   r   r   Nrd  r   r   r   r   ir   N)rd  r%   r"   r
   r  ir  Nrd  rN  @rP  rQ  ̌Ar  N)rd  rN  gp=
ף@rP  gGz	g(\AffffffN)r  r\   r   r#   r$   rY  r  T	equal_nanr\  )	r^  r?   r   rG  r  testingassert_allcloser   r   )rJ   ndigits_and_expectedrK  r  r   r  s         r:   
test_roundrp    s    CF,-,6< 2779 L//'+BC&'2


""6288H+="Nxx#:<?EF 	F Fxx)@AVKKKLrD   c                  `   g d} dg dt        j                  d      g ddg ddg d	t        j                  d
t        j                  dd            g di}|j                         D ]  \  }}t	        j
                  |d      }t	        j                  | |      }t        j                  j                  |t        j                  |      d       t	        j                  | |d      |k(  rJ  ddt        j                  d      fD ]G  }t        j                  t         j                  d      5  t	        j                  | |       d d d        I t        dfD ]=  }t        j                  t        d      5  t	        j                  | |       d d d        ? y # 1 sw Y   xY w# 1 sw Y   VxY w)Nrc  r   )rd  rN  rh  rP  rQ  ri  rj  Nr   rg  r$   )rd  r%   r%   r%   rR  irR  Nr   rf  rv   r%   r.  re  rY  r  Trk  r   r  g$z"Rounding multiple must be positiver-   rL  l   l+?R zis not a valid multiple type)r   r   rB  r^  r?   r   rH  r  rm  rn  r   r3   r4   rZ  r2   r5   )rJ   multiple_and_expectedrM  r  r   r  s         r:   test_round_to_multiplers    s   CF<
		#C	,
-
		#BMM"a01, 499; G(++H6MN%%fg>


""6288H+="N##FH$;=@FG 	G G	G BIIe,- <]]2??!EG 	<  (;	< 	<<
 45 <]]9,JK 	<  (;	< 	<<		< 	<
	< 	<s   -F5F$F!	$F-	c                  N   g d} t        j                  g dt        j                               }t        j                  g dt        j                               }t	        j
                  | |      |k(  sJ t        j                  dt        j                               }t        j                  dt        j                               }t        j                  dt        j                               }t	        j
                  d|d	      |k(  sJ t	        j
                  d|d
	      |k(  sJ y )N)w/^@/$Rm@+ٚu@gv|@ru  rv  rw  )r  r  r\   r   r#   r$   r"   )r      i^  i  g     ^@g
ףp=Rm@rw  r   r   r\   g      @rX  r\  rY  )r   r   r   r  r?   round_binaryr   )rJ   scalesr  expect_zero
expect_infrA  s         r:   test_round_binaryr}    s    LFXX.
;Fxx2BJJLBH??66*h666))Arzz|,K2rzz|,JIIb"((*%E??U247BC C C??U68;EF F FrD   c            	         t        j                  g d      } | j                         }t        j                  g d      }|j                  |      sJ |j                  t	        j                  |             sJ | j                         }t        j                  g d      }|j                  |      sJ |j                  t	        j
                  |             sJ t        j                  ddgdd gg      } | j                         }t        j                  ddgddgg      }|j                  |      sJ | j                         }t        j                  ddgddgg      }|j                  |      sJ t        j                  dddd t        d	      g      } | j                         }t        j                  g d
      }|j                  |      sJ | j                  d      }t        j                  g d      }|j                  |      sJ y )Nr1  )FFFT)TTTFr#   r$   r"   FTr  )FFFTF)nan_is_null)FFFTT)r   r   r*  r  r?   r  rI  r   r  s      r:   test_is_nullr  &  s   
((?
#C[[]Fxx34H=="""==C)))\\^Fxx12H=="""==S)***


QFQI.
/C[[]F%% ?@H=="""\\^F$e} =>H=="""
((Aq!T5<0
1C[[]Fxx:;H=="""[[T[*Fxx9:H=="""rD   c            	      j   t        j                  dddd t        d      g      } | j                         }t        j                  g d      }|j	                  |      sJ t        j                  g dt        j
                               } t        j                  t        d	      5  | j                         }d d d        t        j                  t        d	      5  t        j                  g d
t        j                               } | j                         }d d d        y # 1 sw Y   ixY w# 1 sw Y   y xY w)Nr#   r$   r"   r  )FFFNT)r`   ra   Nr.  z"has no kernel matching input typesr-   r      bbN)
r   r   r   is_nanr  r   r3   r4   r   r  )r  r  r  rW  s       r:   test_is_nanr  C  s    
((Aq!T5<0
1CZZ\Fxx9:H=="""
((#"))+
6C	$,P
R JJL 
$,P
R hh*1BCJJL 	  s   $D<D)D&)D2c                     t        j                  g dt        j                               } t        j                  dgt        j                               }t        j                  t         j
                  d      5  | j                  |       d d d        t        j                  g dt        j                               } t        j                  d t        j                               }| j                  |      }t        j                  g d      }|j                  |      sJ t        j                  g d      } | j                  d      }t        j                  g d	      }|j                  |      sJ t        j                  g d
t        j                               } | j                  d      }t        j                  g dt        j                               }|j                  |      sJ t        j                  g d      } | j                  d       }t        j                  g d      }|j                  |      sJ y # 1 sw Y   xY w)Nr#   r$   Nr%   r.  r
   +Array arguments must all be the same lengthr-   r2  )r   bbNccc)r   r  r  r  )r   r  s   ccc)r   r   r   r3   r4   rZ  	fill_nullr  r   r  r  )r  
fill_valuer  r  s       r:   test_fill_nullr  T  s   
((?
3C1#BGGI.J	rJ
L "j!" ((+"'')
<C4bggi0J]]:&Fxx01H=="""
(($
%C]]5!Fxx*+H=="""
((&R__->
?C]]5!Fxx-BOO4EFH=="""
(($
%C]]4 Fxx)*H=="""/" "s   ;IIc                 t   t        j                  g d|       }t        j                  d|       }|j                  |      }t        j                  g d|       }|j	                  |      sJ |j                  d      }|j	                  |      sJ t         j
                  j                  |j                        s9t        j                  t        t        f      5  |j                  d       d d d        |j                  t        j                  dd            }|j	                  |      sJ y # 1 sw Y   CxY w)Nr  r.  r
   )r#   r$   r
   r%   5r   )r   r   r   r  r  r>  is_unsigned_integerr   r3   r4   r  r5   )r+  r  r  r  r  s        r:   test_fill_null_arrayr  q  s    
((?
4C1:.J]]:&Fxx:6H==""" ]]1F==""" 88''1]]J	23 	MM#	 ]]299QV45F=="""		 	s   D..D7c                    t        j                  d|       }t        j                  t        j                  g d|       g      }|j	                  |      }t        j                  t        j                  g d|       g      }|j                  |      sJ t        j                  t        j                  ddg|       t        j                  g |       t        j                  d dg|       g      }t        j                  t        j                  ddg|       t        j                  g |       t        j                  ddg|       g      }|j	                  |      }|j                  |      sJ |j	                  d      }|j                  |      sJ |j	                  t        j                  dd            }|j                  |      sJ y )	Nr
   r.  )Nr$   r"   r%   )r
   r$   r"   r%   r#   r$   r%   r   )r   r   rI  r   r  r  )r+  r  r  r  r  s        r:   test_fill_null_chunked_arrayr    sm   1:.J


BHH_:FG
HC]]:&F,Z!H IJH=="""



!Qj)
*%
$, C
 
!Qj)
*%
!Qj)! H
 ]]:&F==""" ]]1F=="""]]299QV45F=="""rD   c                     t        j                  g d      } t        j                  dt        j                               }t         j                  j                  d| |g      }|j                  d       t        j                  g d      }|j                  |      sJ t        j                         t        j                         t        j                         t        j                         fD ]  }t        j                  g d|      } t        j                  d|      }t         j                  j                  d| |g      }|j                  d       t        j                  g d	|      }|j                  |      rJ  y )
N)TFFFFNTr.  coalescer  )TFFFFT)r#   r$   r"   r%   r
   N*   )r#   r$   r"   r%   r
   r  )r   r   r   bool_computer  r  r  r   r   r   r   )r  r   r  r  r  s        r:   !test_fill_null_windows_regressionr    s    ((;
<C
		$RXXZ(AZZ%%j3(;F
OOOxx@AH=="""wwy"((*bhhj"((*= 'hh,26IIbr"))*sAh?T"88/b9}}X&&&'rD   c                     t        j                  g d      } t        j                  g d      }t        j                  | |      t        j                  g d      k(  sJ t        j                  | |      t        j                  g d      k(  sJ t        j
                  | |      t        j                  g d      k(  sJ t        j                  | |      t        j                  g d      k(  sJ t        j                  | |      t        j                  g d      k(  sJ t        j                  |       t        j                  g d      k(  sJ y )Nr'  )TTFTr  r%  r)  )	r   r   r?   and_
and_kleeneor_	or_kleenexorinvertr)   s     r:   test_logicalr    s    
+,A
*+A771a=BHH%?@@@@==A"((+E"FFFF66!Q<288$=>>>><<1*C!DDDD66!Q<288$>????99Q<288$=>>>>rD   c                      t        j                  g d      } | j                         }t        j                  |      }| |k7  sJ | |k(  sJ | t        j                  |       k(  sJ t        j                  |      |k(  sJ y )N)r   r   r   r  r   )r   r   dictionary_encoder?   dictionary_decode)r   dictionary_arraydictionary_array_decodes      r:   test_dictionary_decoder    s    HH./E..0 223CD$$$$++++B((//// 015EEEErD   c                     t        j                  g dd      } t        j                  t        j                               }t        j                  t              5  t        j                  | d        d d d        t        j                  t              5  t        j                  | d|       d d d        t        j                  t              5  t        j                  | d|       d d d        t        j                  | |      t        j                  g dd	      k(  sJ t        j                  d
gd      } t        j                  t        j                         d      }t        j                  t         j                        5  t        j                  | d       d d d        t        j                  | dd      t        j                  dgd      k(  sJ t        j                  | |      t        j                  dgd      k(  sJ t        j                  t        j                  ddd      t        j                  ddd      g      } t        j                  ddgd      }t        j                  | d      |k(  sJ t        j                  ddgg dgt        j                  t        j                                     } t        j                  ddgg dgt        j                  t        j                                     }t        j                  | |j                         |k(  sJ y # 1 sw Y   xY w# 1 sw Y   xY w# 1 sw Y   ^xY w# 1 sw Y   xY w)Nr-  r   r.  )target_typer   r  T)r   r   r   l    )allow_int_overflowFr   r\   i  r#   i  l    x\Nl    0E*ztimestamp[ms]r$   )r"   r%   r
   r`   ra   )34r  )r   r   r?   r   r   r3   r4   r5   castr  r   rZ  datetime
large_listr  rU  r   )r  r   allow_overflow_optionsr  s       r:   	test_castr    s}   
((<g
.CnnRWWY'G	y	! '
&' 
z	" /
Wg./ 
z	" 1
$01 773(BHH6-# # # # ((K=w
/C^^

t- 
r	' 
W 773e,"G0LLLL773 67288	7<    ((			4A	&(9(9$1(EFHCxx6_MH773(H444
((QFI&R]]2779-E
FCxx#s_5XXbggi02H773&(222A' '/ /1 1 s0   L(L5MM(L25L?MM
value_typec                     t        j                  ddd      }t        j                  |g|       }t	        j
                  ||       |k(  sJ y )Ni  r"   r#   r.  )r  dater   r   r?   r  )r  dtr  s      r:   test_identity_cast_datesr    s?    	tQ	"B
((B4j
)C773
#s***rD   c                 b   t        j                  t        j                  d|       d      }t        j                         }t        j                  t        j                  d|      d      }t         j                  j                  t        j                  g d|      |      }||j                  |      j                  k(  sJ t         j                  j                  t        j                  g d|      |      }||j                  |      j                  k(  sJ t        j                         }t        j                  t        j                  d|      d      }t         j                  j                  t        j                  g d|      |      }||j                  |      j                  k(  sJ t        j                  t        j                  d|       d      }d	}t        j                  t         j                  j                  |
      5  |j                  |       d d d        y # 1 sw Y   y xY w)Nelementr$   rJ   )r#   r$   r"   r%   r
   r&   r.  )r#   NNr%   r
   r&   )NNNNNNr"   z&Size of FixedSizeList is not the same.r-   )r   r  r^   r   FixedSizeListArrayr  r   r  r   r  r3   r4   libArrowTypeError)r  	cast_typedtyper   fslerr_msgs         r:   test_fsl_to_fsl_castr    s    )Z8!<IHHJE88BHHXu-q1D



+
+
#%0t , =C+00000 


+
+
)6T , CC+00000 GGIE88BHHXu-q1D



+
+
5EB , OC+00000 )Z8!<I6G	rvv,,G	<   s   
H%%H.DecimalTypeTraits)r=   factorymax_precisionFloatToDecimalCase)	precisionrA  	float_val	decimal32	decimal64   r@  r7  rB  r8  c                     | dk\  sJ |dk\  sJ t        |       d|z  z  }|d|z  z  | kD  r7t        j                  |d      }|d|z  z  | kD  rt        j                  |d      }|d|z  z  | k  sJ |S )zA
    Find the largest float f such as `f * 10**scale <= val`
    r   r           )r   r  	nextafter)valrA  r  s      r:   largest_scaled_float_not_abover  .  s     !8O8A::c
RY&I2u9s"LLC0	r5y 3&Y4Ir5y C'''rD   c                     t        | t              sJ t        j                  |       }|j	                  |       }t        |      }|S )zS
    Return a float representation (possibly approximate) of `int_val**-scale`
    )r   intr=  r6  scalebr   )int_valrA  unscaledscaledr  s        r:   scaled_floatr  >  sA     gs###w'H__eV$FfIrD   c              #      K   d}t        d|d      D ]e  }t        d|d      D ]S  }t        ||d       t        ||d       dt        ||z
  |      z  }t        d|z  |z
  |      }t        |||       U g y	w)
zC
    Return FloatToDecimalCase instances with integral values.
    r(   r#   r"   r   r$   r  ro  r   N)r  r  rn   r  )float_tyr  mantissa_digitsr  rA  epsilon
abs_maxvals          r:   $integral_float_to_decimal_cast_casesr  I  s      O1mQ/ C	1i+ 	CE$Ys;;$Ys;;#i/95AAG7I'0J$YzBB	CC   A9A;c              #      K   d}t        d|d      D ]e  }t        d|d      D ]S  }ddt        ||z
  d      z  z  }t        ||      }t        d|z  |z
  |      }t        |||       t        |||       U g yw)z?
    Return FloatToDecimalCase instances with real values.
    r(   r#   r"   r   r$   r   N)r  rn   r  r  )r  r  r  r  rA  r  
abs_minvalr  s           r:    real_float_to_decimal_cast_casesr  X  s      O1mQ/ C	1i+ 	CE"c)o"=qAAAG7GJ7I'0J$YzBB$YzBB	CCr  c              #     K   t        j                  d      }t        d|d      D ]d  }t        d|d      D ]R  }t        d      D ]B  }|j                  dd|z        }t	        ||      }|d|z  z  d|z  k  sJ t        |||       D T f yw)	z?
    Return random-generated FloatToDecimalCase instances.
    r  r#   r&   r   r%      r   N)r  Randomr  	randranger  r  )r  r  rr  rA  r  r  r  s           r:   "random_float_to_decimal_cast_casesr  g  s      	bA1mQ/ F	1i+ 	FE2Y F;;q"i-8(59	 2u9,r9}<<<(E9EE	F	FFs   BBc                 "   |j                   |_        t        j                  |_        |j                  |      }|j                  t        j                  d      j                  |j                               }t        j                  ||       }t        j                  ||      j                         }||k7  rZt        ||z
        d|j                  z  z  }|j                   |dz
  k  rdnd}	||	k  s J d|d|j                    d|d	|d
|
       y y )Nr#   r.  r   r$   r%   zfloat_val = z, precision=z, expected = z, actual = z, diff_digits = )r  precr=  ROUND_HALF_EVENroundingcreate_decimal_from_floatquantizer6  r  rA  r   r   r?   r  r1  abs)
r  r  
decimal_tydecimal_ctxr  r  r   r  diff_digitslimits
             r:   check_cast_float_to_decimalr  u  s    "++K"22K44Y?H  !3!:!:J<L<L;L!MNH
		)(+AWWQ
#))+F &8+,r:3C3C/CC))MA,==1e# 	.9-|J4H4H3I J"[
 ;(O-	.# rD   r  )idsr  c                     | j                   S r   r=   vs    r:   <lambda>r    
    qvv rD   case_generator)	integralsrealsr  c           
         t        j                         5 } || |j                        D ]I  }t        | |j                  |j                  |j                  |j                        ||j                         K 	 d d d        y # 1 sw Y   y xY wr   )r=  localcontextr  r  r  r  r  rA  )r  r  r  ctxcases        r:   test_cast_float_to_decimalr    sw     
			 /3"8Z-E-EF 	/D'$..""4>>4::>Z--/	// / /s   A A??Bdecimal_traitsc                     | j                   S r   r  r  s    r:   r  r    r  rD   c                    t        j                  d      }t        j                         t        j                  t        j
                         t        j
                  i|    }t        j                         dt        j
                         di|    }t        j                         dt        j
                         di|    \  }}t        j                  t        j                  d|z              }|j                  }||k  rVt        j                  t        j                  d|z              }t        j                  t        j                  d|z              }t        j                         5 }	|}
|
|	_        t        | |
t        j                  t        j                  d|z              z         }t!        |t        j                  t        j                  d|z                    }t#        ||      D ]c  }|j%                  |
|      }| t        j                  t        j                  d|
|z
  z              z   }||cxk  r|k  sJ  J t#        d      D ]  }|j'                  d	d|z        }t	        j(                   ||      |      }t+        ||      sJ |d	k\  rt        j,                  |      d|z  z  }nt        j,                  |      d| z  z  }t/        |j1                  |            }t3        j4                  t        j6                  || 
      |      j9                         }t/        |j1                  |            }t;        ||z
        dk  rJ  f 	 ddd       y# 1 sw Y   yxY w)zL
    Test float-to-decimal conversion against exactly generated values.
    +      5   )i   )ii  r$   r   r
   r   r.  r#   N)r  r  r   r  r  r  mathfloorlog10r  log2r=  r  r  rn   ceilr  r  r  r  ldexpr   r6  rG  r  r?   r  r   r1  r  )r  r  r  np_float_tymantissa_bitsfloat_exp_minfloat_exp_maxr  r  r  r  	min_scale	max_scalerA  r  	float_expr  mantissar  r  expected_as_intr  actual_as_ints                          r:   !test_cast_float_to_decimal_randomr    s    	bA


bjj


bjj K
 	

b


b M
 	

k


m$ $ M= jjA},<!=>O"00M &

499R->#?@**TZZ=0@%AB				 "A3#	 !DIIdjjM9I.J$KKM	

4::a.>#?@B	9i0 	AE'//	5AJ
 (DIIb9u3D.E$FGHI I>>>>>>1X A;;q!]*:;HH[%:IF	!)[999 >&x81i<GH&x81yj=HH"'(>"?IIih7EEJUW  %fmmE&: ;=?:;q@@@A	A"A "A "As   "G$MMM c            	         t        j                  g d      } t        j                  | dd      }t        j                  t	        j                  ddd      d t	        j                  dd	d
      gt        j
                  d            }||k(  sJ t        j                  | dd      |k(  sJ t        j                  t	        j                  ddd      d d gt        j
                  d            }t        j                  | ddd      }||k(  sJ t        j                  t         j                  d      5  t        j                  | ddd       d d d        t        j                  t         j                  d      5  t        j                  | dd       d d d        t        j                  | ddd      }|t        j                  g dt        j
                  d            k(  sJ y # 1 sw Y   xY w# 1 sw Y   `xY w)N)z5/1/2020Nz
12/13/1900z%m/%d/%Yr   formatuniti  r
   r#   il        r.  r  z%d/%m/%YT)r  r  error_is_nullz"Failed to parse string: '5/1/2020'r-   z%Y-%m-%dF)NNN)	r   r   r?   strptimer  	timestampr3   r4   rZ  )r  gotr  s      r:   test_strptimer%    s   
((3
4C
++c*3
7Cxx			4A	&h.?.?b".MN\\# H (??;;sJS1S888xx**4A6dC\\#.0H
++c*3d
KC(??	rA
C K
C
EJK 
rA
C 6
C
56 ++c*3d
KC"((-BLL4EFFFFK K6 6s   2G%9G1%G.1G:c            	         g d} g d}g d}t         j                  dk7  r|j                  g d       |D ]$  }t        j                  |       j                  |      }dD ]  }t        j                  |t        j                  ||            }|D ]~  }t        j                  |      }t        j                  ||      }	t        j                  |j                  |            j                  |	j                        }
|	j                  |
      r~J   d	}t        j                  |t        j                  d
|            }t        j                  |t        j                               }	t        j                  |j                  |            j                  |	j                        }
|	j                  |
      sJ t        j                  |t        j                  d
|            }t        j                  |t        j                  |dz               }	t        j                  |j                  |dz               j                  |	j                        }
|	j                  |
      sJ t        j                  |t        j                  d
|            }t        j                  d      }t        j                  ||      }	t        j                  |j                  d            j                  |	j                        }
|	j                  |
      sJ t        j                  |t        j                  d|            }t        j                  d      }t        j                  ||      }	t        j                  |j                  d            j                  |	j                        }
|	j                  |
      sJ t        j                  |t        j                  d
|            }t        j                  |d      }t        j                  ||      }	t        j                  |j                  |            j                  |	j                        }
|	j                  |
      r%J  d	}t        j                  |       }t        j                  |t        j                  d
            }t        j                  |t        j                  |            }	t        j                  |j                  |            j                  |	j                        }
t        j                  ||      |	k(  sJ |	j                  |
      sJ t        j                   t        j"                  d      5  t        j                  |t        j                  |dz                d d d        t        j                   t        j"                  d      5  t        j                  |t        j                  |dz                d d d        y # 1 sw Y   exY w# 1 sw Y   y xY w)N)z2018-03-10 09:00z2038-01-31 12:23N)CETrS   r   )z%az%Az%wz%dz%bz%Bz%mz%yr~   z%Hz%Iz%pz%M%z%Zz%jz%Uz%Wz%%z%Gz%Vz%uwin32)z%cz%xz%Xr   msusnsr.  r  %Y-%m-%dT%H:%M:%Sr   r)  z%Sr-  z%S.%fC)localez.Timezone not present, cannot convert to stringr-   r(  )sysplatformextendpdto_datetimetz_localizer   r   r#  r?   r   strftimer  r   r  r3   r4   rZ  )times	timezonesformatstimezonetsr  tsafmtr   r  r  s              r:   test_strftimer@    st    ;E2IQG
||w)* ,'^^E"..x8+ 	/D((2BLLx$@AC /,,S1S':88BKK$45::6;;G}}X.../	/ " hhrS( ;<S"*<*<*>?88BKK,-226;;?}}X&&& hhrS( ;<S"*<*<S4Z*HI88BKKd
3499&++F}}X&&& hhrS( ;<$$T*S'288BKK-.33FKK@}}X&&& hhrT8 <=$$T*S'288BKK0166v{{C}}X&&& hhrS( ;<$$S5S'288BKK,-226;;?}}X&&&Y,'^ C		B
((2BLL-
.C[[b&8&8&=>FxxC()..v{{;H ;;sC F***=="""	rM
O A
C!3!3C$J!?@A 
rM
O A
C!3!3C$J!?@A AA AA As   .W*3.W6*W36W?c                    ddl m} t        j                  |       j	                  d      j                  |      j                         }t        j                  |t        j                  d|            }|j                  j                  dz  |j                  j                  z   dz  j                  d      }t        j                  d	t        j                               t        j                  d
t        j                               t        j                  dt        j                               g} |t        j                          |d      k  rd|j#                  d       j%                  d      }|j#                  d       j%                  d      }|j#                  d       j%                  d      }	n|j                  j'                         d   j%                  d      }|j                  j'                         d   j%                  d      }|j                  j'                         d   j%                  d      }	t        j(                  j+                  |||	g|      }
|j                  j,                  j%                  d      }|j                  j.                  j%                  d      }|j                  j0                  j%                  d      }|j                  j2                  j%                  d      }|j                  j4                  j%                  d      }|j                  j6                  j%                  d      }|j                  j8                  j%                  d      }|j                  j:                  j%                  d      }|j                  j<                  j>                  j%                  d      }|j                  j                  j%                  d      }|j                  j                  j%                  d      }tA        j,                  |      jC                  t        j                  |            sJ tA        jD                  |      jC                  t        j                  |j                  jD                              sJ tA        j.                  |      jC                  t        j                  |            sJ tA        j0                  |      jC                  t        j                  |            sJ tA        jF                  |      jC                  t        j                  |            sJ tA        jH                  |      jC                  t        j                  |            sJ tA        jJ                  |      jC                  t        j                  |            sJ tA        jL                  |      jC                  t        j                  |            sJ tA        jN                  |      jC                  |
      sJ tA        j6                  |      jC                  t        j                  |            sJ tA        j8                  |      jC                  t        j                  |            sJ tA        j:                  |      jC                  t        j                  |            sJ tA        j<                  |      jC                  t        j                  |            sJ tA        jP                  |      jC                  t        j                  |dz              sJ tA        j                  |      jC                  t        j                  |dz              sJ tA        j                  |      jC                  t        j                  |            sJ tA        jR                  |      jC                  t        j                  |            sJ tA        jT                  |      jC                  t        j                  |j                  j	                  d                   sJ |j                  jV                  r|j                  jV                  tX        jZ                  j\                  u rdgt_        |      z  }n|ja                  d       }tA        jb                  |      jC                  t        j                  |            sJ tA        jd                  dd      }tA        jF                  ||      jC                  t        j                  |dz               sJ tA        jf                  ddd      }tA        jh                  ||      jC                  t        j                  |            sJ y )Nr   )VersionrS   r.  tzi  g&.>r'   iso_yeariso_weekiso_day_of_weekz1.1.0c                 (    | j                         d   S Nr   isocalendarrt  s    r:   r  z,_check_datetime_components.<locals>.<lambda>[	      AMMOA$6 rD   r   c                 (    | j                         d   S )Nr#   rJ  rL  s    r:   r  z,_check_datetime_components.<locals>.<lambda>\	  rM  rD   c                 (    | j                         d   S )Nr$   rJ  rL  s    r:   r  z,_check_datetime_components.<locals>.<lambda>]	  s    1==?1#5 rD   yearweekday)fieldsFc                 <    | j                         j                  dkD  S rI  )dstsecondsrL  s    r:   r  z,_check_datetime_components.<locals>.<lambda>	  s    !(; rD   r#   rW   r  Tr   )5pyarrow.vendored.versionrB  r5  r6  r7  
tz_convert	to_seriesr   r   r#  r  microsecond
nanosecondrG  r^   r   __version__mapr  rK  StructArrayr  rP  monthrR  	dayofweek	dayofyearquarterhourminutert   rJ   r?   r  is_leap_yearday_of_weekday_of_yearrE  rF  iso_calendarmillisecond	subsecondlocal_timestamprD  r  r<  utcr0   applyis_dstr   r   rQ  )
timestampsr<  rB  r=  r>  
subsecondsiso_calendar_fieldsrE  rF  iso_dayrh  rP  r_  rR  r`  ra  rb  rc  rd  rt   rZ  r[  rn  day_of_week_optionsweek_optionss                            r:   _check_datetime_componentsru  J	  s   0	
	#	/	/
z(#IIK 
((2r||DX6
7C55$$w.55##$'/016q  	RXXZ(
RXXZ(
"BHHJ/ r~~!116667>>wG6667>>wG&&56==gF 55$$&v.55g>55$$&v.55g>%%##%e,33G<>>--	8W%" . $L 55::W%DEEKKw'E
%%))

7
#C&&w/I&&w/Ieemm""7+G55::W%DUU\\  )FUU\\  ''0F%%##**73K!!((1J773<rxx~...??3&&rxx0B0B'CDDD88C=00066#;bhhsm,,,>>#%%bhhy&9:::>>#%%bhhy&9:::;;s""288H#5666;;s""288H#5666??3&&|444::c?!!"((7"3444773<rxx~...99S>  &!122299S>  &!1222>>#%%bhh{g/E&FGGG>>#%%bhh{W/D&EFFF==$$RXXj%9:::<<##BHHZ$8999c"))"((2553D3DT3J*KLLL	uuxx5588x((,,,Ws2w&FXX;<Fyy~$$RXXf%5666--!->>#':;BB
Q! ! ! >>$)+L 773-44RXXh5GHHHrD   c                     g d}g d}t        |       | j                  j                  j                  d   st	        j
                  d       y |D ]  }t        ||        y )Nz1970-01-01T00:00:59.123456789z2000-02-29T23:23:23.999999999z2033-05-18T03:33:20.000000000z2020-01-01T01:05:05.001z2019-12-31T02:10:10.002z2019-12-30T03:15:15.003z2009-12-31T04:20:20.004132z2010-01-01T05:25:25.005321z2010-01-03T06:30:30.006163z2010-01-04T07:35:35.0z2006-01-01T08:40:40.0z2005-12-31T09:45:45.0z2008-12-28T00:00:00.0z2008-12-29T00:00:00.0z2012-01-01T01:02:03.0)rS   America/ChicagoAsia/Kolkata	Etc/GMT-4	Etc/GMT+4zAustralia/Broken_Hillr   z-Timezone database is not installed on Windows)ru  r   r   r   r3   r  )r   ro  r:  r<  s       r:    test_extract_datetime_componentsr|  	  s[    +JDI z* >>!!,,_=CD! 	=H&z8<	=rD   c                  .   t        j                  dgdd      } | j                  t        j                  dd            }t        j
                  |      d   j                         dk(  sJ t        j                  |      d   j                         d	k(  sJ y )
Nz2012-12-12T12:12:12r/  r   r  z+05:30rC  r      r  )r?   r"  r  r   r#  rc  r1  rd  )r  	zoned_arrs     r:   test_offset_timezoner  	  s}    
++,-6IPS
TCch78I779a &&(B...99Y"((*b000rD   r  r+  c                 >   t        j                  t        j                  dddd      gdz  t        j                  |             }t	        j
                  |      }t         j                  j                  dgdz  dgdz  dgdz  gg d	
      }|j                  |      sJ y )Ni  r#   r$   r'   2   i  4   r^  )rE  rF  rG  r  )	r   r   r  r#  r?   rh  r^  r  r  )r  r  r  r  s       r:   test_iso_calendar_longer_arrayr  	  s     ((H%%dAq!45b8",,t:L
MC__S!F~~))
RDGaSV$9 * H =="""rD   c                  	   t        j                  d      } t        j                  g d      }t        j                  ddg      }t        j                  g d      }t        j                  ||       }t        j                  ||       }dD ])  }t        j                  |      }t        j                  ||       }|j                  |      }	t        j                  ||      }
|
j                  t        j                  |	            sJ t        j                  ||      }
|
j                  t        j                  |	            sJ t        j                  |t        j                  d|            }t        j                  t         j                  d	
      5  t        j                  ||       d d d        , t        j                  d      }t        j                  t        d
      5  t        j                  |       d d d        d}t        j                  |      }t        j                  |dd      }t        j                  |dd      }t        j                  t        d| d
      5  t        j                  ||       d d d        t        j                  |j                  |d            }	t        j                  ||      }
|	j                  |
       t        j                  |j                  |d            }	t        j                  ||      }
|	j                  |
       t        j                  |      }t        j                  |dd      }t        j                  |dd      }t        j                  t        d| d
      5  t        j                  ||       d d d        |j                  |g d      }	t        j                  ||      }
|
j                  t        j                  |	             |j                  |g d      }	t        j                  ||      }
|
j                  t        j                  |	             y # 1 sw Y   xY w# 1 sw Y   ^xY w# 1 sw Y   xY w# 1 sw Y   xY w)Nr.  rw  z2015-03-29 02:30:00z2015-03-29 03:30:00)z2018-10-28 01:20:00z2018-10-28 02:36:00z2018-10-28 03:46:00r.  )rS   rx  ry  r  zalready have a timezone:r-   zEurope/Brusselsssznot found in timezone databaseEurope/Brusselsrk   earliest)	ambiguousnonexistentlatestz%Timestamp doesn't exist in timezone ''shift_forward)r  shift_backwardz$Timestamp is ambiguous in timezone ')TTT)r  )FFF)r   r#  r5  r6  r   r?   r   r7  assume_timezoner  r3   r4   rZ  r  )ts_typero  r  r  ambiguous_arraynonexistent_arrayr<  r   tar  r  ta_zonedinvalid_optionsoptions_nonexistent_raiseoptions_nonexistent_earliestoptions_nonexistent_latestoptions_ambiguous_raiseoptions_ambiguous_latestoptions_ambiguous_earliests                      r:   test_assume_timezoner  	  s    ll4 G !: ;J .."7"7"9 :K  7 8I hhyw7O7;> :**84XXjw/))(3##B8}}RXXh/000##B1}}RXXh/00088JR\\$-IJ]]2??2LM 	:x9	: 	:: ../BCO	z)I	J 8
278 !H " 8 8 B#%#;#;G$= !#!9!9G"; 
z$$,:Q0
1 > 	,#<	>> xx//o 0 / 0H#=?FOOFxx//. 0 0 1H#?AFOOF 66x@!77H' ;!#!9!9JG"= 
z**216
7 M 	?4KLM
 $$X9K$LH!;=F
MM"((8$%$$X9N$OH!9;F
MM"((8$%i	: 	:8 8> >0M Ms0   Q(Q.Q)Q6Q	Q&)Q36Q?c           	         dddddddd}ddddddd	}t        j                  |       }|D ]  }t        |      ||   z   }t        j                  ||      }t        j
                  ||
      j                         }	| j                  j                  |      }
t        j                  j                  |	|
       t        j                  ||
      j                         }	| j                  j                  |      }
t        j                  j                  |	|
       t        j                  ||
      j                         }	| j                  j                  |      }
t        j                  j                  |	|
       |dk7  r~t        j                  ||d      }| j                  j                  ||         }|j                   j"                  ft        j
                  ||
      j                         }	| |z
  j                  j                  |      |z   }
t        j                  j                  |	|
       t        j                  ||
      j                         }	| |z
  j                  j                  |      |z   }
t        j                  j                  |	|
       t        j                  ||
      j                         }	| |z
  j                  j                  |      |z   }
t        j                  j                  |	|
       |dk(  st        j
                  ||      j                         }	| j                  j                  |      }
t        j                  j                  |	|
       t        j                  ||      j                         }	| j                  j                  |      }
t        j                  j                  |	|
       t        j                  ||      j                         }	| j                  j                  |      }
t        j                  j                  |	|
        |j                   j"                  t        j                  |d      }t        j
                  ||
      }	| j                  j                        }
t        j$                  |
| k(  |
t'        j(                  |||         z   |
      }
t        j                  j                  |	|
       |dk(  rd}t        j
                  |      j                         }	| j                  j                  |      }
t        j                  j                  |	|
       t        j                  |      j                         }	| j                  j                  |      }
t        j                  j                  |	|
       t        j                  |      j                         }	| j                  j                  |      }
t        j                  j                  |	|
       y y )Nr.  r-  r,  r   r  r  r  r[  rZ  ri  rt   rd  rc  rR  )r[  rZ  ri  rt   rd  rc  r  rR  T)calendar_based_originrL  )ceil_is_strictly_greater1D)r   r   r  r?   r   ceil_temporalr  r  r  r  rm  assert_array_equalfloor_temporalr
  round_temporalrG  r   rD  wherer5  	Timedelta)r=  rJ   r  unit_shorthandgreater_unitr  value	frequencyr   r  r  origins               r:   _check_temporal_roundingr  ,
  s   N L 
"B 1<J!55	))%6!!"g6@@B55::i(


%%fh7""2w7AAC55;;y)


%%fh7""2w7AAC55;;y)


%%fh7
 5=--t49GUU[[d!34Fwwzz!))"g>HHJK++00;fD

--fh?&&r7;EEGFV''--i86AHJJ))&(;&&r7;EEGFV''--i86AHJJ))&(; 5=%%b59CCEFuuzz),HJJ))&(;&&rE:DDFFuu{{9-HJJ))&(;&&rE:DDFFuu{{9-HJJ))&(;c1<n 
wwzz))4$8!!"g655::i(88Nr||E>$+?@@ 	

%%fh7 u}	!!"%//155::i(


%%fh7""2&00255;;y)


%%fh7""2&00255;;y)


%%fh7 rD   r  c           	      <   d}g d}t        j                  |D cg c]  }t        j                  |d       c}      }t        |||        g d}|D ]C  }|j                  j                  d      j                  j                  |      }t        |||        E y c c}w )N)r#   r$   r"   r%   r
   r&   r^  r   rD  r  <      i  i  )z1923-07-07 08:52:35.203790336z1931-03-17 10:45:00.641559040z1932-06-16 01:16:42.911994368z1941-05-27 11:46:43.822831872z1943-12-14 07:32:05.424766464z1954-04-12 04:31:50.699881472z1966-02-12 17:41:28.693282560z1967-02-26 05:56:46.922376960z1975-11-01 10:55:37.016146432z1982-01-21 18:43:44.517366784z1992-01-01 00:00:00.100000000z1999-12-04 05:55:34.794991104z2026-10-26 08:39:00.316686848r.  r   )ry  zAmerica/New_Yorkrz  r{  r  zPacific/Marquesasrx  rS   rS   )r5  Series	Timestampr  r  r7  rX  )r  rJ   ro  rt  r=  r:  r<  ts_zoneds           r:   test_round_temporalr  
  s    
 BF)J 

C1BLL.C	DBR.SI  955$$U+..99(C 6489 Ds   Bc                  \   t        j                  g d      } t        j                  |       j	                         dk(  sJ t        j                  | d      j	                         dk(  sJ t        j                  | d      j	                         dk(  sJ t        j                  | d      j	                         dk(  sJ t        j                  | d      j	                         dk(  sJ t        j                  t        d	
      5  t        j                  | d       d d d        y # 1 sw Y   y xY w)Nr#   r$   r"   NNr"   
only_validrQ  	only_nullr$   r   r
   z*"something else" is not a valid count moder-   zsomething else)r   r   r?   rR  r1  r3   r4   r  r)  s    r:   
test_countr  
  s    
(((
)C88C= A%%%88Cl+113q88888Ck*002a77788Ce$**,11188C%%'1,,,	zI
K (
&'( ( (s   D""D+c                     t        j                  g dt        j                               } t        j                  | t        j
                  d            j                         dk(  sJ t        j                  | t        j
                  dt        j                                     j                         dk(  sJ t        j                  | d      j                         dk(  sJ | j	                  dd      j                         dk(  sJ | j	                  d       j                         dk(  sJ t        j                  d	dgd	dggt        j                               } | j	                  d	      j                         dk(  sJ | j	                  d	d      j                         dk(  sJ | j	                  d	d	d
      j                         dk(  sJ y )N)r   r#   Nr"   r%   r.  r   r$   r\   r%   r"   rU   r#   )rU   end)	r   r   r   r?   indexr   r1  r   rI  r)  s    r:   
test_indexr  
  si   
((%BHHJ
7C88C1&,,.!33388C1277956<<>"DDD88C!!#q(((99Qa9 &&(A---99T?  "b(((


QFQF+"((*
=C99Q<1$$$99Qa9 &&(A---99QaQ9'--/2555rD   c                 |   |j                         }t        |      t        |       k(  sJ t        |      t        t	        t        |                   k(  sJ t	        |      D cg c]
  }| ||       }}t	        |t        |             D cg c]
  }| ||       }}| ||      /|dk(  rt        d |D              sJ t        d |D              sJ y y |dk(  r-t        fd|D              sJ t        fd|D              sJ y t        fd|D              sJ t        fd|D              sJ y c c}w c c}w )Nrg   c              3   $   K   | ]  }|d u  
 y wr   r   r   r  s     r:   r   z&check_partition_nth.<locals>.<genexpr>
       6QqDy6   c              3   $   K   | ]  }|d u  
 y wr   r   r  s     r:   r   z&check_partition_nth.<locals>.<genexpr>
  r  r  c              3   4   K   | ]  }|d u xs |k    y wr   r   r   r  ps     r:   r   z&check_partition_nth.<locals>.<genexpr>
  !     @qqDy*AF*@   c              3   (   K   | ]	  }|k\    y wr   r   r  s     r:   r   z&check_partition_nth.<locals>.<genexpr>
       3!qAv3   c              3   (   K   | ]	  }|k    y wr   r   r  s     r:   r   z&check_partition_nth.<locals>.<genexpr>
  r  r  c              3   4   K   | ]  }|d u xs |k\    y wr   r   r  s     r:   r   z&check_partition_nth.<locals>.<genexpr>
  r  r  )r'  r0   sortedlistr  r   )rb  r   pivotri   r  until_pivotafter_pivotr  s          @r:   check_partition_nthr  
  s8   !Gw<3t9$$$'?d5T#34444-25\:4
#:K:-25#d)-DE4
#EKEWU^AyZ'6+66666+6666 7 Z'@K@@@@3{33333{3333@K@@@@ ;Es   #D4D9c                  f   t        t        dd            } t        j                  |        d}t	        j
                  | |      }t        | ||d       t	        j
                  | |      |k(  sJ t        j                  t        d      5  t	        j
                  |        d d d        y # 1 sw Y   y xY w)Nrv      r   )r  at_endz8'partition_nth_indices' cannot be called without optionsr-   )
r  r  r  shuffler?   partition_nth_indicesr  r3   r4   r  )rb  r  r   s      r:   test_partition_nthr  
  s    c3 D
NN4E&&t59Gguh7##D%0G;;;	L
N ' 	  &' ' 's   B''B0c                      t        t        d            d gdz  z   } t        j                  |        dD ]/  }dD ](  }t	        j
                  | ||      }t        | |||       * 1 y )Nr   )r   r^  r     )rg   r  )r  ri   )r  r  r  r  r?   r  r  )rb  r  ri   r   s       r:   !test_partition_nth_null_placementr  
  sn    b	?dVb[(D
NN4 F4 	FN..t5>LNGgunE	FFrD   c                  v   dd} t        j                  g d      }dD ]p  }dD ]'  }t        j                  ||d|fg      } | |||       ) t        j                  ||      } | ||d       t        j
                  ||      } | ||d	       r t        j                  |t        j                  d
dg            } | ||d       t        j                  |t        j                  d
dg            } | ||d	       t        j                  |d
dg      |k(  sJ t        j                  |d
dg      |k(  sJ y )Nc                     t        j                  |d|fg      }|j                  dt        |             }|r| |k(  sJ y t        j                  ||      }t        j                  ||       }||k(  sJ y )Nr|   rx   r   r?   sort_indicesslicer0   r	  )select_k_indicesr  orderstable_sortsorted_indiceshead_k_indicesr  r  s           r:   validate_select_kz.test_select_k_array.<locals>.validate_select_k
  sr    '59I8JK'--a5E1FG#~555wwsN3HWWS"23FX%%%rD   r#   r$   Nr   r   r$   r%   )r}   rm   r|   r  rp   )r  r}   rm   r$   r{   r  r|   rm   rx   F)r   r   r?   select_k_unstabletop_k_unstablebottom_k_unstabler   )r  r  r  r  r  s        r:   test_select_k_arrayr  
  s\   & ((?
#C 
40 	2E))qgu%5$68Ffc51	2
 ""3!,&#|4%%cQ/&#{3
4 !!R&&346F fc<0!!R&&7M6NOF fc;/ Q+A*BDGMN N NQ)?(@AVKKKrD   c                  |   dd} t        j                  g dg dd      }dD ]  }t        j                  ||dg      } | ||dg       t        j                  ||t        j                  d	      d
fdg      } | ||ddg       t        j
                  ||d	g      } | ||dg       t        j                  ||d	dg      } | ||ddg        t        j                  t        d      5  t        j                  |       d d d        t        j                  t        d      5  t        j                  |ddg       d d d        t        j                  t        d      5  t        j                  |dg        d d d        t        j                  t        d      5  t        j                  |dg       d d d        t        j                  t        d      5  t        j                  |dg       d d d        y # 1 sw Y   xY w# 1 sw Y   xY w# 1 sw Y   xY w# 1 sw Y   kxY w# 1 sw Y   y xY w)Nc                     t        j                  ||      }|j                  dt        |             }|r| |k(  sJ y t        j                  ||      }t        j                  ||       }||k(  sJ y )Nrx   r   r  )r  tblrp   r  r  r  r  r  s           r:   r  z.test_select_k_table.<locals>.validate_select_k'  sj    	B'--a5E1FG#~555wwsN3HWWS"23FX%%%rD   )r#   r$   r   )r#   r   r#   r)   r  r   rm   r  rx   r   rm   rw   r   r}   r   z4'select_k_unstable' cannot be called without optionsr-   z,select_k_unstable requires a nonnegative `k`r\   z2select_k_unstable requires a non-empty `sort_keys`r$   not a valid sort orderr   nonscending.Invalid sort key column: No match for.*unknownunknownrm   r  )
r   r  r?   r  r^   r  r  r3   r4   r  )r  r  r  r  s       r:   test_select_k_tabler  &  s5   & HH9956E O%%Q#5"68&%4F3GH%%QBHHSM;#?AS"TVE&8:L%M	O ""5A#?&%4G3HI%%eqS#JGE&8:L%M	OO" 
H
J $ 	U#$
 
zK
M J
Ub5G4HIJ 
z5
6 7 	Ua267
 
z)A	B K
Ua4H3IJK 
zM
O O
Ua4L3MNO O#$ $
J J7 7
K KO Os<   0H)H&H"H&H2HHH#&H/2H;c                     t        j                  g d      } t        j                  |       }|j	                         g dk(  sJ t        j                  | d      }|j	                         g dk(  sJ t        j                  | d      }|j	                         g dk(  sJ t        j                  | dd      }|j	                         g d	k(  sJ t        j                  | dd
      }|j	                         g d	k(  sJ t        j                  t        d      5  t        j                  | d       d d d        y # 1 sw Y   y xY w)Nr  r"   r   r#   r$   rm   )r  r}   r#   r   r"   r$   rg   )r  ri   r$   r#   r   r"   rh   r  r-   r  )r   r   r?   array_sort_indicesr'  r3   r4   r  r  r  s     r:   test_array_sort_indicesr  Y  s   
((?
#C""3'F---""3k:F---""3l;F---""3l2<>F---""32<>F---	z)A	B 8
c78 8 8s   D::Ec                     t        j                  g d      } t        j                  |       }|j	                         g dk(  sJ t        j                  | dg      }|j	                         g dk(  sJ t        j                  | dg      }|j	                         g dk(  sJ t        j                  | dgd      }|j	                         g d	k(  sJ t        j                  | dgd
      }|j	                         g d	k(  sJ t        j                  | t        j
                  dg            }|j	                         g dk(  sJ t        j                  | t        j
                  dgd            }|j	                         g d	k(  sJ y )Nr  r  r  rx   r{   r   rg   rr   r  rh   r  )r   r   r?   r  r'  r   r  s     r:   test_sort_indices_arrayr  l  sb   
((?
#C__S!F---__S-C,DEF---__S-D,EFF---__S-D,E,68F---__S#:";,68F---__R^^/F.GHF ---__R^^/F.G3=?F ---rD   c                     t        j                  g dg dd      } t        j                  | dg      }|j	                         g dk(  sJ t        j                  | t        j
                  d      dfgd	
      }|j	                         g dk(  sJ t        j                  | ddg      }|j	                         g dk(  sJ t        j                  | ddgd	
      }|j	                         g dk(  sJ t        j                  | ddgd	      }|j	                         g dk(  sJ t        j                  t        d      5  t        j                  |        d d d        t        j                  t        d      5  t        j                  | dg       d d d        t        j                  t        d      5  t        j                  | dg       d d d        y # 1 sw Y   xY w# 1 sw Y   RxY w# 1 sw Y   y xY w)N)r#   r#   Nr   )r#   r   r   r#   r)   r  rx   r  r   rm   rg   rr   )r$   r"   r   r#   r  rw   r   r  rh   z"Must specify one or more sort keysr-   r  r  r  r  )	r   r  r?   r  r'  r^   r3   r4   r  )r  r  s     r:   test_sort_indices_tabler    s   HH?>?E__U/A.BCF---__U{/K.L,68F---__-/ABF ---__-/AB!F ---__#%78!F ---	z)M	N 
 
zM
O E
*B)CDE 
z)A	B A
*>)?@A A E EA As$   >G7G!3G-G!G*-G6c                  N   t        j                  g d      } t        j                  | t        j                  g d            }|j	                         g dk(  sJ t        j                  | t        j                  g d      d      }|j	                         g dk(  sJ t        j                  | t        j                  dd	g            }|j	                         g dk(  sJ t        j                  | t        j                  dd	g      d      }|j	                         g dk(  sJ y )
Nr#   r$   Nr#   r$   r"   r#   r"   N	value_set)TFTTFTTr  rV   )TFFTFTr#   r"   )r   r   r?   is_inr'  r  s     r:   
test_is_inr    s    
(((
)CXXcRXXl%;<F!GGGGXXcRXXl%;MF!HHHHXXcRXXq!f%56F!HHHHXXcRXXq!f%5$GF!HHHHrD   c                     t        j                  g d      } t        j                  | t        j                  g d            }|j	                         g dk(  sJ t        j                  | t        j                  g d      d      }|j	                         g dk(  sJ t        j                  | t        j                  dd	g            }|j	                         g dk(  sJ t        j                  | t        j                  dd	g      d      }|j	                         g dk(  sJ t        j                  | t        j                  dd	g      d
      }|j	                         g dk(  sJ y )Nr
  r  r  )r   Nr$   r   Nr#   Tr  )r   NNr   Nr#   r#   r"   rZ   )r   r   r?   index_inr'  r  s     r:   test_index_inr    s   
(((
)C[[(>?F!9999[[(>$(*F!<<<<[[!Q(89F!<<<<[[!Q(8TJF!<<<< [[bhh1v.4@F!<<<<rD   c                  @   t        j                  g d      } t        j                  |       }|j	                         dgk(  sJ t        j                  | d      }|j	                         dgk(  sJ t        j                  | d      }|j	                         dgk(  sJ t        j                  | d      }|j	                         dgk(  sJ t        j                  | d	      }|j	                         dgk(  sJ t        j                  | d
      }|j	                         dgk(  sJ t        j                  ddg      } t        j                  | g d      }|j	                         g dk(  sJ t        j                  | g dd      }|j	                         g dk(  sJ t        j                  | g dd      }|j	                         g dk(  sJ t        j                  | g dd	      }|j	                         g dk(  sJ t        j                  | g dd      }|j	                         g dk(  sJ t        j                  | g dd
      }|j	                         g dk(  sJ t        j                  | g dd
      }|j	                         g dk(  sJ t        j                  t        d      5  t        j                  | d       d d d        t        j                  t        d      5  t        j                  | d       d d d        y # 1 sw Y   ExY w# 1 sw Y   y xY w)Nr-        @lower)interpolationr$   higherr"   nearestmidpointlinearr#   )g      ?      ?g      ?q)      ?      ?g      ?)r  r  )r#   r#   r#   )r$   r$   r$   )r   r   r   r#   r#   r$   z Quantile must be between 0 and 1r-   皙?z"not a valid quantile interpolationzzz)r   r   r?   r  r'  r3   r4   r  r  s     r:   test_quantiler$    s   
((<
 C[[F#&&&[[G4F!$$$[[H5F!$$$[[I6F!$$$[[J7F#&&&[[H5F#&&&
((Aq6
C[[ 12F!2222[[ 1IF***[[ 1JF***[[ 1LF000[[ 1KF***[[ 1JF!2222 [[/xHF!2222	z)K	L  
C3 	z)M	N .
Cu-. .   . .s   ,L'LLLc                     t        j                  g d      } t        j                  |       }|j	                         dgk(  sJ t        j
                  t        j                  ddg      t        j                  ddg      g      } t        j                  |       }|j	                         dgk(  sJ t        j                  g d      } t        j                  | g d      }|j	                         g d	k(  sJ t        j
                  t        j                  ddg      t        j                  ddg      g      } t        j                  | g d      }|j	                         g d	k(  sJ y )
Nr-  r  r#   r$   r"   r%   )r   r  r#   r  )r#   r  r%   )r   r   r?   tdigestr'  rI  r  s     r:   test_tdigestr'    s   
((<
 CZZ_F#&&&


BHHaV,bhh1v.>?
@CZZ_F#&&&
((<
 CZZ{+F,,,


BHHaV,bhh1v.>?
@CZZ[)F,,,rD   c                     t        j                  d gt        j                               j                  d      } | j	                  t        j
                               }|t        j                  dgt        j
                               k(  sJ y )NFr   )r   r   r  r  r  r   r  s     r:   test_fill_null_segfaultr)    sZ    
((D6288:
&
0
0
7CXXbggi FRXXqc2779----rD   c                     t        j                  g d      } t        j                  g d      }t        j                  g d      }t        j                  | |      }|t        j                  g d      k(  sJ t        j                  | |      }|t        j                  g d      k(  sJ t        j                  | ||      }|t        j                  g d      k(  sJ t        j                  | ||      }|t        j                  g d      k(  sJ t        j                  | |d      }|t        j                  g d	      k(  sJ t        j                  | |d      }|t        j                  g d      k(  sJ t        j                  | |t        j
                         
      }|t        j                  g d	      k(  sJ t        j                  | |t        j
                         
      }|t        j                  g d      k(  sJ t        j                  | |d      }|t        j                  g d      k(  sJ t        j                  | |d      }|t        j                  g d      k(  sJ y )Nr5  )r"   r#   r$   r$   r"   N)r"   r$   r"   r!  )r"   r"   r"   TrZ   )r$   r"   r"   r  F)r#   r$   N)r   r   r?   max_element_wiser  r   )r  r   arr3r  s       r:   test_min_max_element_wiser.    s   88ID88ID88L!D  t,FRXXi((((  t,FRXXi((((  tT2FRXXi((((  tT2FRXXi((((   t=FRXXi((((  t=FRXXi((((  dB::<>FRXXi((((  dB::<>FRXXi((((   t>FRXXl++++  t>FRXXl++++rD   rU   )r  g      %@g      %rV   )TFc                 N   t        |       }d |t        j                  |t        j                               t        j                  |t        j                               g}|D ]  }t        j
                  g d      t        j
                  g d      t        j                  dd gddgg      g}t        j
                  g d      |rt        j
                  g d      nt        j
                  g d	      |rt        j                  g dg      nt        j                  g d	g      g}t        |      D ]M  \  }}t        j                  |||
      }	t        j                  ||   ||nd      }
|	j                  |
      rMJ  ! d | t        j                  | t        j                               t        j                  | t        j                               g}|D ]  }t        j
                  g d      t        j
                  dt        j                  ddddg      t        j
                  dt        j                  d dd dg      g}t        j
                  g d      t        j
                  dt        j                  t        j                  t        j                  t        j                  t        j                  g      |rEt        j
                  dt        j                  d t        j                  d t        j                  g      n(t        j
                  dt        j                  d d d d g      g}t        |      D ]z  \  }}t        j                  |||
      }	t        j                  ||   ||nd      }
t        j                   j#                  |	j%                  d      |
j%                  d             |  dt        j                  d      dfD ]G  }t'        j(                  t        j*                        5  t        j                  g d|       d d d        I y # 1 sw Y   TxY w)Nr.  r5  )r   Nr     r   r  r0  )r#   r"   r&   )r   Nr  r  )r   NNNrT   )      ?g      @g     @@r#   r$   r  r%   r
   r"   )r1  g      @g     @Fzero_copy_onlyr   arrowr"  r  )r  r   r   r   r   r   rI  r  r?   cumulative_sumr   r  r  r  r  r  rm  assert_array_almost_equalto_numpyr3   r4   rZ  rU   rV   	start_intstartsstrtarraysexpected_arraysr  r  r  r  s              r:   test_cumulative_sumr>  6  sF   
 E
IIryyCii	
35F +HHYHH&'q$i"b23
 HHY HH&'!xx(=> /01!//1F0GH
  ' 	+FAs&&s$:NFvvoa0$:J$#$&H==***	++( E299U>iiBJJL13F PHH+,HHaB1-.HHaq$23
 HH,-HHa@A HHarvvtRVV<=!xxBFFD$d(KL	
  ' 	PFAs&&s$:NFvvoa0$:J$#$&HJJ00$ 2A 2&'/'8'8'8'NP	PP( bii(#. 5]]2??+ 	5it4	5 	55	5 	5   6PP$	c                 N   t        |       }d |t        j                  |t        j                               t        j                  |t        j                               g}|D ]  }t        j
                  g d      t        j
                  g d      t        j                  dd gddgg      g}t        j
                  g d      |rt        j
                  g d      nt        j
                  g d	      |rt        j                  g dg      nt        j                  g d	g      g}t        |      D ]M  \  }}t        j                  |||
      }	t        j                  ||   ||nd      }
|	j                  |
      rMJ  ! d | t        j                  | t        j                               t        j                  | t        j                               g}|D ]  }t        j
                  g d      t        j
                  dt        j                  ddddg      t        j
                  dt        j                  d dd dg      g}t        j
                  g d      t        j
                  dt        j                  t        j                  t        j                  t        j                  t        j                  g      |rEt        j
                  dt        j                  d t        j                  d t        j                  g      n(t        j
                  dt        j                  d d d d g      g}t        |      D ]z  \  }}t        j                  |||
      }	t        j                  ||   ||nd      }
t        j                   j#                  |	j%                  d      |
j%                  d             |  dt        j                  d      dfD ]G  }t'        j(                  t        j*                        5  t        j                  g d|       d d d        I y # 1 sw Y   TxY w)Nr.  r5  )r#   Nr  r
   r#   r  r
   )r#   r$   r&   )r#   Nr  rv   )r#   NNNrT   )r   r  rN  r$   r  r%   r"   )r   g      @g     @*@Fr2  r   r4  r"  r  )r  r   r   r   r   r   rI  r  r?   cumulative_prodrE  r  r  r  r  r  rm  r6  r7  r3   r4   rZ  r8  s              r:   test_cumulative_prodrB  m  sE   
 E
IIryyCii	
35F +HHYHH%&q$i"a12
 HHY HH'(!xx(=> 012!//1F0GH
  ' 	+FAs''4JOF{{?1#5t?Ot()+H==***	++( E299U>iiBJJL13F PHH_%HHaB1-.HHaq$23
 HH()HHa@A HHarvvtRVV<=!xxBFFD$d(KL	
  ' 	PFAs''4JOF{{?1#5t?Ot()+HJJ00$ 2A 2&'/'8'8'8'NP	PP( bii(#. 6]]2??+ 	6y5	6 	66	6 	6r?  )r  rN  g      @c                 T   t        |       }d |t        j                  |t        j                               t        j                  |t        j                               g}|D ])  }t        j
                  g d      t        j
                  g d      t        j                  g dg dg      g}t        j
                  g d      |rt        j
                  g d      nt        j
                  g d      |rt        j                  g dg      nt        j                  g dg      g}t        |      D ]X  \  }}t        j                  |||	      }	t        j                  ||   ||n
t        d
      d      }
|	j                  |
      rXJ  , d | t        j                  | t        j                               t        j                  | t        j                               g}|D ]R  }t        j
                  g d      t        j
                  dddt        j                  ddg      t        j
                  ddd t        j                  dd g      g}t        j
                  g d      t        j
                  g d      |rt        j
                  g d      nt        j
                  g d      g}t        |      D ]|  \  }}t        j                  |||	      }	t        j                  ||   ||nd
d      }
t        j                   j#                  |	j%                  d      |
j%                  d             ~ U dt        j                  d      dfD ]G  }t'        j(                  t        j*                        5  t        j                  g d|       d d d        I y # 1 sw Y   TxY w)Nr.  )r$   r#   r"   r
   r%   r&   )r$   r#   Nr
   r%   N)r$   r#   N)r
   r%   N)r$   r$   r"   r
   r
   r&   )r$   r$   Nr
   r
   N)r$   r$   NNNNrT   g    eFrZ   )r  ?rO  ffffff@皙@@r  rD  rO  rF  rG  )r  r  rO  rE  rE  rG  )r  r  rO  rO  rF  rG  )r  r  Nr  rF  N)r  r  NNNNr2  r   r4  r"  r5  r  )r  r   r   r   r   r   rI  r  r?   cumulative_maxr,  r  r  r  r  r  rm  r6  r7  r3   r4   rZ  r8  s              r:   test_cumulative_maxrI    s
   
 E
IIryyCii	
35F +HH'(HH-.lL9:
 HH'( HH-.!xx(FG 678<=>
  ' 	+FAs&&s$:NF**"D,<D#d) "H ==***	++, E299U>iiBJJL13F PHH34HHc3RVVS#67HHc3bffc489
 HH34HH34 HH56!xx(JK	
  ' 	PFAs&&s$:NF**"D,<D$ "H JJ00$ 2A 2&'/'8'8'8'NP	PP* bii(#. 5]]2??+ 	5it4	5 	55	5 	5   9NN'	c                 T   t        |       }d |t        j                  |t        j                               t        j                  |t        j                               g}|D ])  }t        j
                  g d      t        j
                  g d      t        j                  g dg dg      g}t        j
                  g d      |rt        j
                  g d      nt        j
                  g d      |rt        j                  g dg      nt        j                  g dg      g}t        |      D ]X  \  }}t        j                  |||	      }	t        j                  ||   ||n
t        d
      d      }
|	j                  |
      rXJ  , d | t        j                  | t        j                               t        j                  | t        j                               g}|D ]R  }t        j
                  g d      t        j
                  dddt        j                  ddg      t        j
                  ddd t        j                  dd g      g}t        j
                  g d      t        j
                  g d      |rt        j
                  g d      nt        j
                  g d      g}t        |      D ]|  \  }}t        j                  |||	      }	t        j                  ||   ||nd
d      }
t        j                   j#                  |	j%                  d      |
j%                  d             ~ U dt        j                  d      dfD ]G  }t'        j(                  t        j*                        5  t        j,                  g d|       d d d        I y # 1 sw Y   TxY w)Nr.  )r
   r&   r%   r$   r"   r#   )r
   r&   Nr$   r"   N)r
   r&   Nr+  )r
   r
   r%   r$   r$   r#   )r
   r
   Nr$   r$   N)r
   r
   NNNNrT   g    eAFrZ   )      @333333@@ @333333@333333?rL  rM  rN  rP  rQ  )rL  rL  rN  rO  rO  rQ  )rL  rL  rN  rN  rP  rQ  )rL  rL  NrL  rP  N)rL  rL  NNNNr2  r   r4  r"  r5  r  )r  r   r   r   r   r   rI  r  r?   cumulative_minr  r  r  r  r  r  rm  r6  r7  r3   r4   rZ  rH  r8  s              r:   test_cumulative_minrS    s
   
 E
IIryyCii	
35F +HH'(HH-.lL9:
 HH'( HH-.!xx(FG 678<=>
  ' 	+FAs&&s$:NF**"D,<D#c( "H ==***	++, E299U>iiBJJL13F PHH34HHc3RVVS#67HHc3bffc489
 HH34HH34 HH56!xx(JK	
  ' 	PFAs&&s$:NF**"D,<D# "H JJ00$ 2A 2&'/'8'8'8'NP	PP* bii(#. 5]]2??+ 	5it4	5 	55	5 	5rJ  c                     t        j                  dd      j                         dddk(  sJ t        j                  ddddg      j                         dddk(  sJ t        j                  g dd	j                               t        j
                  j                  g dd	j                         gd
j                               k(  sJ t        j                  t        d      5  t        j                  g dd	j                                d d d        t        j                  t        d      5  t        j                  ddg       d d d        y # 1 sw Y   FxY w# 1 sw Y   y xY w)Nr#   r   )r   r`   r  r   )field_names)r  r   r5  za b cz0 1r  r  r-   r-  z0 arguments but 2 field namesonetwo)
r?   make_structr1  splitr   r^  r  r3   r4   r  r   rD   r:   test_make_structrZ    s7   >>!S!'')13-????>>!SsCj9??ASF    >>)!--/+.0nn.H.H'%mmoJ/6;kkm /I /EE E E
 
zJ
L 6
|W]]_56 
z)H	I 3
E5>23 3	6 63 3s   "'E,EEE#c                     t        j                  t        j                         t        j                               } t        j                  ddgdgg ddgd g|       }t        j                  g dt        j                               }t        j                  g dt        j                               }t        j                  d	gd d d
dgd gt        j
                  t        j                                     }t        j                  |dd      |k(  sJ t        j                  |t        j                  dt        j                               d      |k(  sJ t        j                  |t        j                  dt        j                               d      |k(  sJ t        j                  |t        j                  dt        j                               d      |k(  sJ y )N)rV  r#   )rW  r$   )noner"   )rV  r
   )rV  r^  r.  )r#   NNr
   N)r#   NNr^  Nr#   r
   r^  rV  rd   lastr   )	r   map_rU  r   r   r  r?   
map_lookupr   )r  r  result_firstresult_last
result_alls        r:   test_map_lookuprc  +  su   	BHHJ	'B
((Z,{mZ0$8>@BC884288:FL((3"((*EKA3dQFD9!xx
35J ==eW-=====biiBGGI '),89 9 9==biiBGGI &(+67 7 7==biiBGGI %'*45 5 5rD   c                  J   t        j                  g dt        j                               } t        j                  g d      }t         j                  j	                  | |gddg      }t         j                  j	                  | |gddg      }t        j                  |d      |k(  sJ t        j                  |d      |k(  sJ t        j                  |ddg      |k(  sJ t        j                  |d	dg      |k(  sJ t        j                  |d
      |k(  sJ t        j                  |t        j                  d            |k(  sJ t        j                  |d      | k(  sJ t        j                  |dg      | k(  sJ t        j                  |d      | k(  sJ t        j                  |t        j                  d            | k(  sJ t        j                  |d	d	g      |k(  sJ t        j                  |d      |k(  sJ t        j                  |dg      | k(  sJ t        j                  |g       |k(  sJ t        j                  t         j                  d      5  t        j                  |d       d d d        t        j                  t         j                  d      5  t        j                  |d       d d d        t        j                  t         j                  d      5  t        j                  |d       d d d        y # 1 sw Y   xY w# 1 sw Y   ZxY w# 1 sw Y   y xY w)Nr%   r
   r&   r.  )r  Nr  r   r   r  z.c.bs   .c.br#   )r!   r   )r  r   z.a)r   r   )r#   r#   r   zNo match for FieldRefr-   r  z.c.fooz.a.foo)r   r   r   r^  r  r?   struct_fieldr^   r3   r4   rZ  )r   r   r  r  s       r:   test_struct_fields_optionsrg  =  s   
,A
"#A
""Aq6C:6A
..
$
$aVc3Z
8C??3'1,,,??3(A---??3c
+q000??3C)Q...??3,111??3 45:::??3%***??3&!+++??3$)))??3 01Q666??3A/1444??3'1,,,??3$)))??3#s***	r.E	F $
U#$ 
r.E	F '
X&' 
r.E	F '
X&' '$ $' '' 's$   LL!LL
LL"c                      t        j                  t        j                  g dg d      g dg d      t        j                  g d      k(  sJ y )Nr&  )FTNr5  )   r  r  )r#   r  N)r?   	case_whenrX  r   r   r   rD   r:   test_case_whenrk  b  sE    <<':':<!$& *,-)@A A ArD   c                  b   t        j                  dt        j                         fdt        j                         fg      } t        j                  |       }dddd dddd dd	dg}d d
dddddd dddg}t        j
                  ||g|      }d}t         j                  j                  ||      }t        j
                  d d
ddg|       }|j                  |      sJ d}t         j                  j                  ||      }t        j
                  dd	ddddg|       }|j                  |      sJ y )Nr   r   r   r$   r)   r   r%   gffffff@r&   gp=
ף?r"   ffffff?g333333?r   r#   )	r   r  r  r   r  r   r  list_elementr  )element_type	list_typel1l2listsr  r  r  s           r:   test_list_elementrt  i  s   99sBJJL1C3CDEL&I
T!#4d#A<N	OB
c""1$5t2A=N	OBHHb"Xy)EEZZ$$UE2FxxT23\BH=="""EZZ$$UE2Fxxs+2A->?NH=="""rD   c                  R   t        dd      D  cg c]  } t        j                  | dd       }} t        j                  |t        j                  d            }t        j                  |      t        j                  t        |      t        j                               k(  sJ y c c} w )Ni  i,  r#   )rP  r_  rR  r.  r.  )
r  r  r   r   r#  r?   count_distinctr   r0   r   )ysamplesr  s      r:   test_count_distinctry  {  sx    BGdBSTQx  aqa8TGT
((7BLL.
/CS!RYYs7|"((*%MMMM Us   B$c                     t        j                  g d      } t        j                  |       j	                         dk(  sJ t        j                  | d      j	                         dk(  sJ t        j                  | d      j	                         dk(  sJ t        j                  | d      j	                         dk(  sJ t        j                  | d      j	                         dk(  sJ y )	Nr  r"   r  r  r  r#   r   r%   )r   r   r?   rv  r1  r)  s    r:   test_count_distinct_optionsr{    s    
(((
)CS!'')Q...S|4::<AAAS{399;q@@@Su-335:::S%(..0A555rD   c                     t        j                  dg      } t        j                  | d      | k(  sJ t        j                  | d      t        j                  dg      k(  sJ t        j                  | d      | k(  sJ t        j                  | d      t        j                  dg      k(  sJ t	        j
                  t        d	      5  t        j                  | d
       d d d        y # 1 sw Y   y xY w)Nu   01²3NFC)formr   0123NFDNFKDz/"NFZ" is not a valid Unicode normalization formr-   NFZ)r   r   r?   utf8_normalizer3   r4   r  r)  s    r:   test_utf8_normalizer    s    
((G9
CSu-444Sv."((F82DDDDS%(C///S&)RXXvh-????	C
E + 	#E*+ + +s   C))C2c            
         dD ]E  } t        j                  d|       t        j                  g t        j                               k(  rEJ  t        d      D cg c].  }t        t        j                  d      j                               0 }}t        t        |            t        |      k(  sJ t        dd      D cg c]3  }t        t        j                  d|dz        j                               5 }}t        t        |            dk(  sJ t               dd	g}|j                  d
 t        d      D               |D cg c]0  }t        t        j                  d|      j                               2 }}t        t        |            t        |      k(  sJ t        j                  t        d      5  t        j                  dg        d d d        y c c}w c c}w c c}w # 1 sw Y   y xY w)N)systemr  is   abcdefr   )initializerr.  r   rv   r^  re  r  c              3   F   K   | ]  }t        j                  d         yw)r   N)osurandom)r   r  s     r:   r   ztest_random.<locals>.<genexpr>  s     :1

2:s   !zJinitializer should be 'system', an integer, or a hashable object; got \[\]r-   )r?   r  r   r   r  r  tupler'  r0   r  r2   r4  r3   r4   r5   )r  r  r<  initializerss       r:   test_randomr    s   5 ,yy4HHRbjjl+, 	, ,,
 :?rCAeBIIcN,,./CFCs6{s6{*** Q}& BIIcq1u5??AB &F &s6{q    Hi/L:b	::#% BIIcq1;;=> %F %s6{s6{***	y?
@ ' 			#2&' ' D&%' 's   3G=8G5G!6G&&G/ztiebreaker,expected_valuesr  )r"   r#   r%   r&   r%   r&   r#   rn   )r"   r$   r
   r^  r
   r^  r$   rd   r"   r#   r%   r&   r
   r^  r$   dense)r$   r#   r"   r%   r"   r%   r#   c                    t        j                  g d      }t        j                  dd|       }t        j                  ||      }t        j                  |t        j
                               }|j                  |      sJ y )NrQ  r  333333@Nr  Nr  rm   r  ro   r  r.  )r   r   r?   r   rankr   r  )rq   expected_valuesr  rank_optionsr  r  s         r:   test_rank_options_tiebreakerr    sc     ((8
9C>>K19-79L WWS,/Fxxbiik:H=="""rD   c                     t        j                  g d      } t        j                  g dt        j                               }t        j                  |       }|j                  |      sJ t        j                  | t        j                               }|j                  |      sJ t        j                  | t        j                  dg            }|j                  |      sJ t        j                  | d      }t        j                  g d	t        j                               }|j                  |      sJ t        j                  | d
      }t        j                  g dt        j                               }|j                  |      sJ t        j                  t        d      5  t        j                  d
dd       d d d        y # 1 sw Y   y xY w)Nr  r  r.  r  rw   rx   rg   rh   )r
   r"   r&   r#   r^  r$   r%   r}   )r"   r%   r#   r&   r$   r^  r
   z'"NonExisting" is not a valid tiebreakerr-   r  NonExistingro   )
r   r   r   r?   r  r  r   r3   r4   r  r  r  r  expected_at_startexpected_descendings        r:   test_rank_optionsr    s\   
((8
9Cxx-BIIK@H WWS\F==""" WWS".."23F==""" WWS"..%&#( F =="""WWS4F!6RYY[I==*+++WWSL1F((#8ryy{K==,---	zG
I 1
&."/	11 1 1s   +GGc                     t        j                  g d      } t        j                  g dt        j                               }t        j                  |       }|j                  |      sJ t        j                  | t        j                               }|j                  |      sJ t        j                  | t        j                  dg            }|j                  |      sJ t        j                  | d      }t        j                  g d	t        j                               }|j                  |      sJ t        j                  | d
      }t        j                  g dt        j                               }|j                  |      sJ t        j                  t        d      5  t        j                  | d       d d d        y # 1 sw Y   y xY w)NNr#   Nr$   N)rm  r   rm  r   rm  r.  r  rw   rx   rg   rh   )r   rm  r   r   r   r}   )rm  r   rm  r   rm  r  r-   XXX)
r   r   r  r?   rank_quantiler  r   r3   r4   r  r  s        r:   test_rank_quantile_optionsr    sd   
((+
,Cxx1

EH c"F==""" c2+A+A+CDF==""" c2+A+A%&,( F =="""c*=F!:N==*+++c\:F((#<2::<P==,---	z)A	B /
./ / /s   +GGc                     t        j                  g d      } t        j                  g d      }t	        j
                  |       }|j                         |k(  sJ t	        j
                  | dd      }|j                         |k(  sJ t	        j
                  | t	        j                               }|j                         |k(  sJ t        j                  g d      }t	        j
                  | dd	      }|j                         |k(  sJ t	        j
                  | t	        j                  dd	            }|j                         |k(  sJ y )
Nr  )ł?g2m6<r  łr  r  rm   )ri   rp   r  )r  g2m6<?r  r  r  rg   r}   )r   r   r3   rj  r?   rank_normalr'  r   r  r  r  s      r:   test_rank_normal_optionsr    s    
((+
,C}}	23H ^^C F)))^^CKPF)))^^C)?)?)ABF)))}}	23H ^^C
lSF)))^^C$&$:$:*EQ%STF )))rD   c                     t        j                  t        j                  dt        j                               t        j                  dt        j                  t        j                  dt        j
                               g            g      } t        j                  d      }t        j                  d      }t        j                  d      }t        j                  d      }t        j                  d       }t        j                  ddi      }t        j                  t        j                  d            }t        j                  t        j                  d	            }t        j                  d
      }	t        j                  d      }
||||||||	|
g	}g ||k(  ||k7  ||kD  ||	z  ||	z  | |j                         ||z   ||z
  ||z  ||z  t        j                  |      t        j                  ||      t        j                  ||      t        j                  ||      t        j                  ||      t        j                  ||      t        j                   |      t        j"                  |      t        j$                  |      t        j&                  |      t        j(                  |      t        j*                  |      t        j,                  |      t        j.                  |      t        j0                  ||      t        j2                  |      t        j4                  |      t        j6                  |      t        j8                  |      t        j:                  |      t        j<                  |
      t        j>                  |      t        j@                  |      t        jB                  |      t        jD                  ||      t        jF                  ||      t        jH                  ||      t        jJ                  |      t        jL                  |      t        jN                  ||      |jQ                  t        jR                         d
      }t        j                  d      dkD  t        j                  d      dk(  t        j                  d      dk(  t        j                  d      dk(  t        j                  dd      dk(  g}t        j                  d      dkD  t        j                  d      dk(  t        j                  d      dk(  t        j                  d      dk(  t        j                  dd      dk(  g}||jU                  g d      t        j                  d      jW                         g}|jY                         }||z  }||z  }||z  }||||||| dS )Ni64r  r  r#   r"  Tr   r   r$   Fr   r  r
   r^  )r  r  r  )r#   r   r5  )r   literalscallsrefsnumeric_refsspecialschema)-r   r  r^   r   r  r   r?   r   r  r  negater   rA  dividerE  powersqrtexpcossintanacosatanasinatan2sinhcoshtanhasinhacoshatanhr  signbit_wise_notbit_wise_andbit_wise_orbit_wise_xorr  	is_finiter  r  r   isinr*  copy)r  r   r   r  r  r  r  r  r  r  r  literal_exprsexprs_with_callexprs_with_refexprs_with_numeric_refsspecial_cases	all_exprss                    r:   create_sample_expressionsr    s   YY
3RXXryy"((5"))+6786: ; <F 			!A
		#A
		$A
		(A
		$A
		3(A
		"))A,A
		"((1+A
		%A
		!A 1aAq!Q/M7qAv 7qAv 7q1u 7a!e 7QU 7QB 7

 71u7!e7%&U7,-E73599Q<7vva|7%'[[A%678:		!Q7 {{1a(7 +-((1a.7 ;=''!*7 vvay	7 #%&&)	7 .0VVAY	7 9;q		7
 wwqz7
 $&771:7
 02wwqz7
 <>88Aq>7 wwqz7 $&771:7 02wwqz7 xx{7 %'HHQK7 24!7 vvay7 #%''!*7 /1ooa.@7 q!,7 /1nnQ.B7 q!,7 /1iil7 =?LLO7 {{1a(7 vvbhhjuv57O  hhuo)288E?a+?hhuo*hh~.'9hhue,79N  "xx{Qq0@!xx{a/!xx/7:!xx1~8: 	
	y
!M ""$I III ! /  rD   c                     t               d   D ]Q  }t        |t        j                        sJ | j	                  | j                  |            }|j                  |      rQJ  y )Nr   )r  r   r?   
Expressionr  r  r  )r  exprrestoreds      r:   #test_expression_serialization_arrowr  f  sZ    )+E2 %$... &&}':':4'@A{{8$$$%rD   c                  x   t               } | d   }| d   D ]E  }|j                  |      }t        j                  j	                  |      }|j                  |      rEJ  | d   D ]  }|j                  |      }t        j                  j	                  |      }t        |      t        |      k(  sJ |j                  |      }t        j                  j	                  |      }|j                  |      rJ  t        | d   | d         D ]  \  }}|j                  |      }t        j                  j	                  |      }t        |      t        |      k(  sJ |j                  |      }t        j                  j	                  |      }|j                  |      rJ  | d   D ]u  }|j                  |      }t        j                  j	                  |      }|j                  |      }t        j                  j	                  |      }|j                  |      ruJ  | d   d   }|j                  |      }t        j                  j	                  |      }|j                  t        j                  dd	i            sJ t        j                  d	      }	|	j                  g d
      }|	d	k(  |	dk(  z  |	dk(  z  }
|j                  |      }t        j                  j	                  |      }t        |
      t        |      k(  sJ |j                  |      }t        j                  j	                  |      }|j                  |      sJ y )Nr  r  r  r  r  r  r   r  r#   r5  r$   r"   )
r  to_substraitr?   r  from_substraitr  r  r   r   r  )exprsr  r  
serializedr   serialized_againdeserialized_again	expr_normr  r   targets              r:   'test_expression_serialization_substraitr  n  s    &'E8_F j! )&&v.
}}33J?{{<((() g 7&&v.
}}33J? < CI---'44V<]]99:JK""#56667 uV}eN.CD 7i&&v.
}}33J?< C	N222'44V<]]99:JK""#56667 i  7&&v.
}}33J?'44V<]]99:JK""#56667 	iA'J==//
;Lryy"a1222 			!A66)D1fa AF+F""6*J==//
;Lv;#l++++#008556FG1222rD   c                     t        j                  d      } t        j                  d      }t        j                  d      }t        j                  d      }t        j                  d      }t        j                  d      }t        j                  ddd      }t        j                  d	      }t        j                  d
d      }| |z  |k(   | |k(   dt        j                         fD ]  }	|j                  |	      |k(    |j                  ddg       |j                  ddg       |j                  ddg       |j                  ddg       t        j                  t              5  |j                  d       d d d        t        j                  t        j                        5  |t               k7   d d d        y # 1 sw Y   CxY w# 1 sw Y   y xY w)Nr   r#   TFr   r^   r   r   )nestedr^   r  r   r$   r  r  )r?   r   r^   r   r  r  r  r3   r4   r5   rZ  r2   )
rF  rV  truefalser   r^   nested_mixed_typesnested_fieldnested_field2r  s
             r:   test_expression_constructionr    sn   99Q<D
))A,C99T?DIIeEYYx FHHWE$3/88/0LHHXw/M3J&	EUN
#  

34  
JJ1vUEN+uen%u~&	y	! 

1 
r	'    s   #F7 G7G Gc                     t        j                  d      } t        j                  d      }t        j                  t        d      5  | xr | d d d        t        j                  t        d      5  | xs | d d d        t        j                  t        d      5  t        |        d d d        t        j                  t        d      5  |   d d d        y # 1 sw Y   xY w# 1 sw Y   lxY w# 1 sw Y   IxY w# 1 sw Y   y xY w)NTFz"cannot be evaluated to python Truer-   )r?   r   r3   r4   r  r   )r  r  s     r:   !test_expression_boolean_operatorsr    s    99T?DIIeE	z)M	N  
z)M	N  
z)M	N T
 
z)M	N      s0   C0C"C.	C:C"C+.C7:Dc                  R   t        j                  d      } t        t        j                  |             dk(  sJ t        t        j                  |             dk(  sJ t        t        j                  | d            dk(  sJ t        t        j
                  | d            dk(  sJ t        t        j
                  | t        j                  d                  dk(  sJ d}t        j                  t        |	      5  t        j
                  | t               d d d        y # 1 sw Y   y xY w)
Nr^   zhour(field)zround(field)r#   rJ  z2round(field, {ndigits=1, round_mode=HALF_TO_EVEN})zadd(field, 1)z+only other expressions allowed as argumentsr-   )r?   r^   r  rc  rG  r   r   r   r3   r4   r5   r2   )r^   r[  s     r:   test_expression_call_functionr    s    HHWE rwwu~-/// rxx>111rxxq)*<= = = rvveQ O333rvveRYYq\*+>>> 8C	y	, 
uf  s   9DD&c                  
   t        j                  dddgi      } t        j                  t         j                  j
                        5  t        j                  | t        j                                d d d        y # 1 sw Y   y xY w)Nr   r#   r$   )	r   r  r3   r4   r  r  r?   r  r   )r  s    r:   test_cast_table_raisesr    sW    HHcAq6]#E	rvv,,	- #
rxxz"# # #s   )A99Bzstart,stop,expectedr5  r  r&   NNr  r#   r$   rp  fixedc                    |dk(  rot        j                  g dg dg dd gt        j                  t        j                         d            j	                  t        j                   |       d            }n^t        j                  g dddgdgd gt        j                  t        j                                     j	                   | |                   }|| ||d	f}|H|dk7  rCd
}t        j                  t         j                  |      5  t        j                  |  d d d        y t        j                  | }	|	j	                  t        j                  t        j                         |	j                  j                              j                         }
|
|D cg c]  }|r|d d |   n| c}k(  sJ y # 1 sw Y   y xY wc c}w )Nr  r5  r  r  r"   r%   r
   r&   TzZUnable to produce FixedSizeListArray from non-FixedSizeListArray without `stop` being set.r-   )r   r   r  r   r  r3   r4   rZ  r?   
list_slicer   	list_sizer'  )rU   r  r  r  r  rp  r  r9   r[  r  pylistr  s               r:   test_list_slice_output_fixedr    sm    Ghh	<$Gxx	1-//3tBHHZ\14M/N 	 hh	Aq6A35xx	*,,0D:<1H,I 	 tT4'D|	W,B]]2??#6 	!MM4 	! 	! %RXXbggi#[[224 55>Y[ 	BAq!FdF)a/BBBB	! 	! Cs   F/F;/F8z
start,stop))r   N)r   r#   )r   r$   r  )r$   r%   c                    |dk(  rqg dg dg dd g}t        j                  |t        j                  t        j                         d            j	                  t        j                   |       d            }n`g dddgdgd g}t        j                  |t        j                  t        j                                     j	                   | |                   }|dk(  rt         j                  }t        j                  || ||d	
      }|j                   | |             k(  sJ |j	                  t        j                  t        j                                     j                         }|D 	cg c]  }	|	|	| ||   nd  }
}	||
k(  sJ y c c}	w )Nr  r5  r  r  r"   r%   r
   r&   Freturn_fixed_size_list)	r   r   r  r   r  r?   r  r   r'  )rU   r  r  r  rp  rb  r  r  r  r  r  s              r:   test_list_slice_output_variabler    sO    G<$?hhHHRWWY"$$(D*,)B$C 	 Aq6A3-hhtxx	*,,0D:<1H,I 	 GHH	]]3tT279F;;)JL1111[["''),-779F HLL!am%T/"=LHLX Ms   *Freturn_fixed_sizer&  r   c                  x    t        j                  t        j                  dt        j                                     S Ncolr   r  r^   r   r   rD   r:   r  r  >  s     BHHRXXeRWWY/0 rD   c                  z    t        j                  t        j                  dt        j                               d      S )Nr  r#   r  r   rD   r:   r  r  ?  s"    BHHRXXeRWWY/3 rD   c                  x    t        j                  t        j                  dt        j                                     S r  )r   r  r^   r   r   rD   r:   r  r  @  s     BMM"((5"'')45 rD   c                 F   t        j                  dgg |             }t        j                  |dd|       }|j                  j                  d      j                  |j                  j                  d      j                  k(  sJ | |j                  |j                  k(  sJ y y )Nr#   r   r  )r   r   r?   r  r   r^   r=   )r  r   r  outs       r:   $test_list_slice_field_names_retainedr  <  s     ((QC5$&
!C
--Q:K
LC88>>!!!SXX^^A%6%;%;;;;  xx388### !rD   c                     t        j                  dggt        j                  t        j                         d            } d}t	        j
                  t         j                  |      5  t        j                  | dd       d d d        t	        j
                  t         j                  |      5  t        j                  | dd       d d d        t	        j
                  t         j                  |      5  t        j                  | dd       d d d        d}t	        j
                  t         j                  |dz         5  t        j                  | ddd	       d d d        t	        j
                  t         j                  |d
z         5  t        j                  | ddd	       d d d        y # 1 sw Y   +xY w# 1 sw Y   xY w# 1 sw Y   xY w# 1 sw Y   yxY w# 1 sw Y   y xY w)Nr#   z@`start`(.*) should be greater than 0 and smaller than `stop`(.*)r-   r\   r$   r   z`step` must be >= 1, got: r   )r  rr  )	r   r   r  r   r3   r4   rZ  r?   r  )r  r[  s     r:   test_list_slice_bad_parametersr  K  sY   
((QC5"((2779a0
1C
MC	rc	2 "
c2q!"	rc	2 !
c1a ! 
rc	2 !
c1a ! 'C	rcCi	8 )
c1aa()	rcDj	9 *
c1ab)* *" "! !! !
) )* *s<   &F'+F40G :GG'F14F= G	GG!c                     g d}t        j                  ||       }t        j                  ||      }t        j                  |      }|j
                  |j
                  k(  sJ |j                  |      sJ y )N)r#   r#   r#   r$   r$   r#   r#   r#   r#   r#   r"   r"   r"   r"   r"   r"   r"   r"   r"   r.  r  )r   r   r?   run_end_encoderun_end_decoder   r  )r  run_end_encode_optsrJ   r  encodeddecodeds         r:   check_run_end_encode_decoder  _  sb    FF
((6

+C-@AG(G<<388###>>#rD   r   c                     t        | |       y r   )r  )r  r   s     r:   test_run_end_encoder  h  s    4  
F3rD   c                     t        j                  g d      } t        j                  g d      }t         j                  j                  | d      }|j	                  |      sJ t        j                  g d      } t        j                  g d      }t         j                  j                  | d      }|j	                  |      sJ t        j                  g dt        j
                               } t        j                  g dt        j
                               }t         j                  j                  | d	      }|j	                  |      sJ t        j                  g dt        j                               } t        j                  g d
t        j                               }t         j                  j                  | d	      }|j	                  |      sJ t        j                  g dt        j                               } t        j                  t         j                  d      5  t         j                  j                  | d	       d d d        y # 1 sw Y   y xY w)N)r#   r$   r"   Nr%   r
   )Nr#   r#   NNr#   r#   re   )NNr$   Nr#   Nr$   r.  )r\   r\   NNr\   Nr\   )   r  NNr  Noverflowr-   )r   r   r  pairwise_diffr  r   r	   r3   r4   rZ  pairwise_diff_checkedr  s      r:   test_pairwise_diffr    s   
(((
)Cxx34HZZ%%c!%4F=="""
(((
)Cxx67HZZ%%c!%4F==""" (((rwwy
9Cxx6RWWYGHZZ%%c"%5F==""" (((rxxz
:Cxx9
KHZZ%%c"%5F==""" (((rxxz
:C	r'
) 9


((R(89 9 9s   )"IIc                     ddg} t        j                  g dg d      }|j                         i k(  sJ t        j                  g dg d|       }|j                         d ddk(  sJ t        |j                               ddgk(  sJ t        j                  g dg d|       }|j                         d ddk(  sJ t	        j
                  t        d	      5  t        j                  g dg d| d
      }d d d        t	        j
                  t        d	      5  t        j                  g dg d|       }d d d        y # 1 sw Y   JxY w# 1 sw Y   y xY w)Nre  rj   )rj   re  depth)r   Nri  r   )re  rj   )	key_nameszUnexpected pivot key: depthr-   rk   )r  rl   z(Encountered more than one non-null value)rj   re  rj   )r?   pivot_widerr1  r  r3   r4   KeyErrorr  )r  r  s     r:   test_pivot_widerr    s0   (#I^^8.IF<<>R^^8.%'F<<>tr::::GX#6666^^8.&/1F<<>tr::::	x'D	E A <n*38?AA
 
z)S	T 5 =~*355 5A A
5 5s   D=E	=E	Ec                     t        j                  g d      } t        j                  | dd      }|j	                         g dk(  sJ t        j                  | t        j
                  dd            }|j	                         g dk(  sJ y )N)
r   r%   r'   r   r
   r"   r^  r$   r#   r&   r   g?)
r   r%   r   r   r
   r"   r^  r$   r$   r&   )lower_limitupper_limitr  )r   r   r?   	winsorizer'  r   r  s     r:   test_winsorizer    st    
((2
3C\\#sC(F!????\\R((ScJLF!????rD   )r#   r   )collectionsr   r  r=  	functoolsr   r   rG   r  r	  r  r3   r  r2  r  numpyr  ImportErrorpandasr5  r   r   pyarrow.computer  r?   pyarrow.libr   pyarrow.substrait	substraitpasr  __dict__r^  r[  r/   r   r   r   
issubclassrF   r   r   r   r	   r   r   r  r  numerical_arrow_typesr  r   r  r  r  all_array_typesr;   rC   rQ   markfilterwarningsr   r   r   r   r   r   r  r  r  r  r$  r*  parametrizer3  r@  rB  rG  rK  rM  rV  rX  r\  rc  rk  rn  rj  rv  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  unknown_issue_is_alphautf8proc_issue_is_lowernumeric_info_missingdigit_info_missingrY  ra  rn  r{  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r	  r  r  r!  r-  r3  r:  r?  rB  rF  ra  rp  rs  r}  r  r  r  r  r  r  r  r  r  date32date64r  r  r  r  r  r  decimal_type_traitsr  r  r  r  r  r  r  r  r  r%  r   r@  ru  r|  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r$  r'  r)  r.  r>  rB  rI  rS  rZ  rc  rg  rk  rt  ry  r{  r  r  r  r  r  r  r  r  r  r  r  r  r  r   r  r  r  r  r  r   float16r   r  r  r  r  )r=   r7   rN   s   000r:   <module>r9     s  $ #   (    	   
    0#
 $BKK$5$5$784dDt12 	4 
 ""++"3"3"56.T332%%%3**+ .  BGGIBHHJBHHJBHHJBIIKBIIKBJJLBJJL	  -.eAhU1XuQxeAhuQxeAhuQ|eArl%&&',-01RYYq\;<RXXgbggiAq6Aq6Aq64!RABR]]8288:!i!Q2w GHRYYgbggi 3	"234a$aa 0$aa8H7J K#,40	9 BbBbBJ( )*JFI5
3
 $ $=	%	> '<=1 >1* a(;]R]]1a=P'QR'; S';T '<=1 >1, a(;]R]]1a=P'QR&? S&?R9<"")46: *#01"V]]#56	8
 -&--(:;NOWt./- ::"'2"####,L.0###< D6&76(bJ;D   !&) . 4 3 ".  %'99&"&'   +E F
 Wf$56F 7FF(C$P> 8 804#''E9< )?; <2"##L UDM2* 3*3 )?;# <#(#"#:	1 )?; <, )?;D < D,&#(,&02 / :;? <?< / :;!9 <!9H / :; 9 < 9F' ### )<=>- ?-8 L L$ < <6F"#:"#: '<=# >#( '<=# >#8',?	F$3N 			YRYY['AB+ C+ '<= >< 2CE    4 CE  )bllAF(bllBG(r}}bI(r}}bIK  CCF.0 jbjjl^=':-  /)>:<> >	  ?
/?/ > / jbjjlJBJJL%AsK)+>-  /;A/ L ;A|G8 HA  HAVPIf = =<1 !89	# :	# W&  W&te8P  "E F9 F 96
(6A*'F&LR0Of8&.6!AHI =*(.V-$.,D "56}515 6 7 15h "56}516 6 7 16h /2}545 6 3 45n /2}545 6 3 45n3&5$'JA#$N6	+'6  "#"#$%$%'##1B/<*0HZ % % :3  :3z8$,# .y,>?QC!qc4 !QFQFQIt,-QC!tfd#$QId|dD\4891  (		288RZZ'HIrxx&HIC J J )C,  (  (		288RZZ'HIrxx&HI J J )4 ,.AB035"7 8$	8 C
$*( 	








QQaa  xrxxz*w'xrxxz*	4!249<54@y|  	B
  	B  
C4.sQ   A@ A@ A@" ;A@076A@6@A@@A@@A@@A@@"A@-@,A@-