
    dҬ                     Z   d 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Z	 dZ	 e ej        eej        j                  z   dz
  Z e ej        edz
                      dz   Zdez  Z	 d	Z	 i d
ej        efdej        efdej        efdej        efdej        efdej        efdej        efdej        efdej        efdej         e!fdej"        e!fdej#        e$fdej%        e$fdej        efdej"        e!fdej        efddez  ej&        fZ'	 ej        ej(        ej)        ej*        ej+        ej,        ej-        ej.        ej/        ej0        ej1        dZ2	  e3ed          rej4        e!fe'd<   d e'5                                D             Z6	 d e'5                                D             Z7	  e8g d           Z9	  ej:        d!  e;e          D                       Z<	 dd#Z=dd$Z>dd%Z? e?d&d'          Z@	  e?d(d)e*          ZA	 i ZB	 d+ ZC G d, d-e
jD        jE                  ZF G d. d/e
jG        e
jH                  ZI G d0 d1          ZJ G d2 d3          ZKg d4ZL	  e8g d5          ZM	 ed6z  ZN	 ed7z  d6z  ZO	 d8ZP	 g d9ZQ	  G d: d;eI          ZRdd<ZSdd>ZTdaUe'D ]ZVeLD ]ZWeQD ]ZX eTeVeWeX           d?D ]ZVe2D ]ZYeLD ]ZW eTeVeWeY@           dAZZdBZ[ G dC dD          Z\ G dE dF          Z]dGdHgZ^ e8dHg          Z_dIgZ`dJ Za G dK dL          Zb G dM dN          Zc G dO dP          Zd G dQ dR          Ze G dS dT          Zf G dU dV          Zg G dW dX          Zhg dYZig dZZj e8d[dHg          Zkg d\Zl e8g d]          Zmd^ ZneaenfD ]CZo eo            D ]6\  ZpZqZr esd_ eqD                       Zt euepeter          Zv ewd`epz             7D G da dbeI          Zxday	  G dc ddeJex          Zz G de dfeKex          Z{ G dg dheJex          Z| G di dje|          Z} G dk dle|          Z~ G dm dne|          Z G do dpe|          Z G dq dre|          Z G ds dte|          Z G du dve|          Z G dw dxe|          Z G dy dze|          Z G d{ d|e|          Z G d} d~e|          Z G d de|          Z G d de|          Z G d de|          Z G d de|          Z G d de|          Z G d de|          Z G d de|          Z G d de|          Z G d de|          Z G d de|          Z G d de|          Z G d de|          Z G d de|          Z G d de|          Z G d de|          Z G d de|          Z G d de|          Z G d de|          Z G d de|          Z G d de|          Z G d de|          Zd Zedk    rA e
j        ej                    e
j                     e
jD                            d           dS dS )z$Test module for queries on datasets.    N)common2   )   r   dtype   z%%0%dd)i,  <         boolint8uint8int16uint16int32uint32int64uint64float32float64	complex64
complex128time32time64enumstringzS%s)log10logexpabssqrtsincostanarcsinarccosarctanfloat16c                 &    i | ]\  }}||d          S r    .0type_infos      9lib/python3.11/site-packages/tables/tests/test_queries.py
<dictcomp>r1   J   "    JJJ}tE47JJJ    c                 &    i | ]\  }}||d          S )r   r+   r,   s      r0   r1   r1   L   r2   r3   )r   r   r   r   r   c                     i | ]}d |z  |	S )zn%dr+   )r-   is     r0   r1   r1   R   s    888	1888r3   r+   c                    t           j        }t          t          t                              D ]\  }}|s
|t
          v r|dz   }d|z  }|dk    rVt          j                            t          |                   }t          j
        t          t          d          |||          }nDt          |         }	t          j        |	|f          }
t          j                            |
|          }|| |<   |}|S )zAppend a ``Col`` of each PyTables data type to the `classdict`.

    A column of a certain TYPE gets called ``c_TYPE``.  The number of
    added columns is returned.

    r   c_%sr   r   shapepos)r;   )r   heavy	enumeratesorted	type_infoheavy_typestbAtomfrom_sctypesctype_from_typeEnumColr   npr   Col
from_dtype)	classdictr:   r<   ityper.   colposcolnamebasecolsctyper   ncolss               r0   append_columnsrQ   X   s     LE#F9$5$566 ! ! 	+--5.F??7&&'7'>??D*T477D6JJJCC%e,FHfe_--E&##Ev#66C 	'ELr3   c                 j    i }t          ||           ||d<   t          | t          j        f|          S )zReturn a nested column description with all PyTables data types.

    A column of a certain TYPE gets called ``c_TYPE``.  The nested
    column will be placed in the position indicated by `pos`.

    r:   _v_pos)rQ   typerA   IsDescription)	classnamer;   r:   rI   s       r0   nested_descriptionrX   q   s>     I9E****Ih	B,.	:::r3   c                    i }t          ||          }t          |||          }||d<   |dz  }t          j        ||          }||d<   |dz  }t          j        ||          }||d<   |dz  }t	          | t          j        f|          S )a  Return a table description for testing queries.

    The description consists of all PyTables data types, both in the
    top level and in the ``c_nested`` nested column.  A column of a
    certain TYPE gets called ``c_TYPE``.  An extra integer column
    ``c_extra`` is also provided.  If a `shape` is given, it will be
    used for all columns.  Finally, an extra indexed column
    ``c_idxextra`` is added as well in order to provide some basic
    tests for multi-index queries.

    rS   c_nestedr   r9   c_extra
c_idxextra)rQ   rX   rA   IntColrU   rV   )rW   
nclassnamer:   rI   rK   ndescrextracolidxextracols           r0   table_descriptionrb   ~   s     IIu--F
F%@@@F"Ij
aKFyu&111H#Ii
aKF)%V444K)Il
aKF	B,.	:::r3   TableDescriptionNestedDescriptionMDTableDescriptionMDNestedDescriptionrS   c                    t                               ||f          }|+|                     |           |                                  dS t          j        }t          t          j        |t          j
        j                            }| j        d}}t          |          D ]+}t          j        |||z                                 |          }	t                                           D ]\  }
}|s
|
t$          v rd|
z  }d|z  }|
dk    r|	t&          dz  k    }nc|
dk    rGd	 t          |||z             D             }t          j        ||                              |          }nt          j        |	|          }|x||<   ||<   |	t&          dz  z
  |d
<   |	t&          dz  z
  |d<   |                                 |dz  }|t&          k    rd}-|                                  |                                 }|t           ||f<   dS )a[  Fill the given `table` with `nrows` rows of data.

    Values in the i-th row (where 0 <= i < `row_period`) for a
    multidimensional field with M elements span from i to i + M-1.  For
    subsequent rows, values repeat cyclically.

    The same goes for the ``c_extra`` column, but values range from
    -`row_period`/2 to +`row_period`/2.

    Nr   r   r8   c_nested/%sr   r   r   c                 "    g | ]}t           |z  S r+   )
str_format)r-   xs     r0   
<listcomp>zfill_table.<locals>.<listcomp>   s    LLLAaLLLr3   r[   r\   r   )
table_datagetappendflushr   r<   intrF   prodrA   utilsSizeTyperowrangearangereshaperD   itemsr@   
row_periodarrayasarrayread)tabler:   nrowstdatar<   sizeru   valuenrowdatar.   rO   rL   ncolnamecoldatasdatas                   r0   
fill_tabler      s    NNE5>**EULErwuBH$566677DACe  y--55e<</5577 	9 	9OUF Uk11unG$w.H*/2(""LLuedl1K1KLLL(5777??FF*T888+22CMCL!Z1_5C	N $
a 8C


JE	KKMMM JJLLE!&Ju~r3   c                       e Zd ZdS )SilentlySkipTestN)__name__
__module____qualname__r+   r3   r0   r   r      s        Dr3   r   c                   p     e Zd ZdZdZdZ ej        d          Z ej        d          Z	d Z
 fdZ xZS )BaseTableQueryTestCasea4  Base test case for querying tables.

    Sub-classes must define the following attributes:

    ``tableDescription``
        The description of the table to be created.
    ``shape``
        The shape of data fields in the table.
    ``nrows``
        The number of data rows to be generated for the table.

    Sub-classes may redefine the following attributes:

    ``indexed``
        Whether columns shall be indexed, if possible.  Default is not
        to index them.
    ``optlevel``
        The level of optimisation of column indexes.  Default is 0.

    Fr   z\bcan not be indexed\bz \bdoes not have a boolean type\bc                    | j         sd S 	 | j        }t          j        d| d| d           |||fD ]<}| j        j        |         }|                    | j        | j        t          d           =d S # t          $ r<}| j
                            t          |                    rt          d           d }~wt          $ r t          d          w xY w)Nz* Indexing ``z`` columns. Type: .T)kindoptlevel_blocksizes	_testmodez(Columns of this type can not be indexed.z3Indexing columns of this type is not supported yet.)indexedr   r   verbosePrintr~   colinstancescreate_indexr   small_blocksizes	TypeErrorcolNotIndexable_researchstrr   NotImplementedError)selfrL   r   extracolnamer   acolnameacolumntes           r0   create_indexesz%BaseTableQueryTestCase.create_indexes   s=   | 	F	G9DBBB4BBBD D D$h= B B*1(;$$T] 0D % B B B BB B  	 	 	&--c"gg66 @&>@ @ @" 	G 	G 	G"EG G G	Gs   A$A1 1
C;7B22Cc                     t                                                       | j                            dd| j        | j                  | _        t          | j        | j        | j                   d S )N/test)expectedrows)	supersetUph5filecreate_tabletableDescriptionr   r~   r   r:   )r   	__class__s    r0   r   zBaseTableQueryTestCase.setUp  s`    [--.TZ . I I
4:tz4:66666r3   )r   r   r   __doc__r   r   recompiler   condNotBoolean_rer   r   __classcell__r   s   @r0   r   r      s         * GH#$=>>"
#FGGG G G,7 7 7 7 7 7 7 7 7r3   r   c                       e Zd ZeZdZdS )ScalarTableMixinr+   N)r   r   r   rc   r   r:   r+   r3   r0   r   r     s        'EEEr3   r   c                       e Zd ZeZeZdS )MDTableMixinN)r   r   r   re   r   md_shaper:   r+   r3   r0   r   r   "  s        )EEEr3   r   )
N~<<=z==z!=>=>)r   r   r   r   )r   r   r   r   r         g?) z& ((c_extra + 1) < 0)z| (c_idxextra > 0)z*| ((c_idxextra > 0) | ((c_extra + 1) > 0))c                       e Zd ZdZdZdZdS )TableDataTestCasea  Base test case for querying table data.

    Automatically created test method names have the format
    ``test_XNNNN``, where ``NNNN`` is the zero-padded test number and
    ``X`` indicates whether the test belongs to the light (``l``) or
    heavy (``h``) set.

    z
test_l%04dz
test_h%04dN)r   r   r   r   _testfmt_light_testfmt_heavyr+   r3   r0   r   r   ?  s$          "N!NNNr3   r   c           	      b  	
 t           |          t          t          t          t          d

                                D ]/\  }}| dk    r
t
          |z  }t          |          |          }|
|<   0d| z  dz  |s	n|dk    rdz  	nz|dk    r-|+d                    |t          
d	                             	nGt          |t                    rd
|d         ddd|d         d		n|| d d| d	n d| d	|rd	 d| 	d }|	
fd            }d	z  |_        |S )N)boundlboundrbound
func_boundr   r8   rh   r   z~(%s)r   z{} {} {}r   z(lbound r    z) & (r   z rbound)(z) z func_boundz boundc                 F     t          j                    fd            }|S )Nc                 X   |                                   	  | g|R i |t          j        d           S # t          $ r8}|j        r|j        d         }nd}t          j        d|z             Y d }~nd }~ww xY w	 t          j        d           d S # t          j        d           w xY w)Nr   r   z	<skipped>z
Skipped test: %s)_verboseHeaderr   r   r   args)r   r   kwargssemsg	oldmethods        r0   	newmethodz=create_test_method.<locals>.ignore_skipped.<locals>.newmethodp  s    !!!	( y777777 #B'''' $ @ @ @7 &'!*CC%C#$83$>????????@
 @#B'''''#B''''s'   7 
A9.A4/B 4A99B B))	functoolswraps)r   r   s   ` r0   ignore_skippedz*create_test_method.<locals>.ignore_skippedo  s9    		#	#	( 	( 	( 	( 
$	#	( r3   c                 	   t          j        dz             }dD ]\  }}|                    ||          }t          |dd          }| j        |                     d           t          dj        dz
  d	          d
\  }}fD ]g g                                 }}} j	        d!i D ]}	|	         |<   |	d         |d<   |	d         |d<   	 t          j                    5  t          j        ddt                     t          |t          |          }
d d d            n# 1 swxY w Y   n# t           $ r t#          d          w xY w|
r5|                    |	j                   |                    |	                    t)          j        |          }t)          j        |          }|                                 t          j        dt/          |           d d           ||}|}nV|                     t)          j        ||k                         |                     t)          j        ||k                                                         }j                 |<   j        d         |d<   j        d         |d<   	                     |          }fdt9          d          D             }fdt9          d          D             }na# t           $ r<}| j                            t?          |                    rt#          d           d }~wt@          $ r t#          d          w xY w|D ]}|                                 t          j        dt/          |d                    d dd           t          j        d|rdnd d            |                     t)          j        |d         |k                         |                     t)          j        |d         |k                         |                     t)          j        |d         |d         k                         |                     t)          j        |d         |d         k                         d S )"Nz* Condition is ``%s``.))&and)|or)r   notz<string>evalr\   r   r   r   )startstopstep)NNr[   ignorez)invalid value encountered in arc(cos|sin)z/The Python type does not support the operation.r   z* z  rows selected by Python from ``z``.c                 2    g | ]} j         fd diS )sortT)get_where_list)r-   _condcondvarsr~   table_slices     r0   rl   z;create_test_method.<locals>.test_method.<locals>.<listcomp>  sU     / / / ! 1E0x @ @d @3>@ @ / / /r3   r   c                 2    g | ]} j         fd iS )field)
read_where)r-   r   r   r   r   r~   r   s     r0   rl   z;create_test_method.<locals>.test_method.<locals>.<listcomp>  sR         %E$T8 4 48 4'24 4  r3   zThe condition is not boolean.z1The PyTables type does not support the operation.r   z" rows selected by PyTables from ````T)nonlz(indexing: yesnoz).r+   )!r   r   replacer   r~   r   dictr   copyiterrowswarningscatch_warningsfilterwarningsRuntimeWarningr   	func_infor   r   ro   r   rF   r{   r   len
assertTrueallr   will_query_use_indexingrv   r   r   r   r   )r   pycondptoppyoprownosfvaluespyrownos	pyfvaluespyvarsru   
isvalidrowptvarsisidxqptrownos	ptfvaluesr   ptfvalsr   r~   r   rL   r   r   r   rO   s                    @@@r0   test_methodz'create_test_method.<locals>.test_method  s   4t;<<<E 	0 	0LT4^^D$//FFV44
GX|<<<qqAAA$ !(+ @	B @	BH*,b(--//iH%u~4444 4 4"%h-w$'	Ny!'*<'8|$	K!022 E E /$G*, , , &*&)V%D%D
E E E E E E E E E E E E E E E ! K K K*IK K KK  4OOCH---$$S]333x))H&999INN !8S]] !8 !8*2!8 !8 !8 9 9 9~!#x6'9 : :;;;yG'; < <=== ]]__F#0:F7O % 29 =F9#(#5l#CF< I66tVDD/ / / / / / /%*1XX/ / /        #1XX  		
    )00R99 L*+JKKK& I I I&GI I II %   !@S!%5%5 !@ !@3;!@ !@ !@FJL L L L Kv.Gee4 K K KLLLOOBF8A;&#899:::OOBF9Q<7#:;;<<<OOBF8A;(1+#=>>???OOBF9Q<9Q<#?@@AAAAA@	B @	BsI   D7-2D+D7+D//D72D/3D77EAK((
M27L))MzTesting ``%s``.)rD   right_bound
left_boundr   ry   rj   nxtype_from_typeformatrepr
isinstancetupler   )r.   op	extracondfuncbnamebvaluer   r  rL   r   r   r   rO   s           @@@@@r0   create_test_methodr  L  s   e$F %$%(* *H $>>++ ! !H&(F!%(00  unGw&H  '	s 	st|  "d8G3D.E.EFF	B		 ' 'a555'''777BqEEE3		3333B333&&B&&& '&4&&9&&    OB OB OB OB OB OB OB OB ^OBb ,d2Kr3   r   c                    | t           v p|t          v }|rt          j        }nt          j        }t          | |||          }|t          z  |_        |xj        |t          z  z  c_        t          t          |j        |           t          dz  ad S )Nr   )
r@   heavy_operatorsr   r   r   r  testnr   r   setattr)r.   r  r  r  r<   testfmttmethods          r0   add_test_methodr#    s     [ 9B/$9E 3#2#2 It<<G GOOw&OOw/999	QJEEEr3   )r   r   )r        c                   P    e Zd Zedz  Zeecxk     rek     sn J eez  dk    sJ dS )SmallNITableMixinr   r   N)r   r   r   rz   r   NX_BLOCK_SIZE2NX_BLOCK_SIZE1r+   r3   r0   r'  r'    sT        NEE2222N222222>!Q&&&&&&r3   r'  c                   Z    e Zd Zedz  Zeeez   k    sJ eez  dk    sJ eez  dk    sJ dS )BigNITableMixinr   r   N)r   r   r   rz   r   r)  r(  r+   r3   r0   r+  r+    s[        NE>N22222>!Q&&&&>!Q&&&&&&r3   r+  SmallBigScalarc               #      K   t           D ]Y} | t          v }t          D ]F}d                    | d         |d                   }d| z  d|z  df}t	          |          }|||fV  GZd S )Nz{}{}TDTestCaser   z%sNITableMixinz%sTableMixinr   )r<   )table_sizesheavy_table_sizestable_ndimsr  r   )r   r<   ndimrW   
cbasenamesrI   s         r0   niclassdatar5    s       5 5)) 	5 	5D(//QaAAI*T1>D3H-/J5)))Ij)44444	55 5r3   c                       e Zd ZdZdS )UltraLightITableMixin
ultralightNr   r   r   r   r+   r3   r0   r7  r7    s        DDDr3   r7  c                       e Zd ZdZdS )LightITableMixinlightNr9  r+   r3   r0   r;  r;  "  s        DDDr3   r;  c                       e Zd ZdZdS )MediumITableMixinmediumNr9  r+   r3   r0   r>  r>  &  s        DDDr3   r>  c                       e Zd ZdZdS )FullITableMixinfullNr9  r+   r3   r0   rA  rA  *  s        DDDr3   rA  c                       e Zd ZdZdS )SmallSTableMixinr   Nr   r   r   r   r+   r3   r0   rD  rD  0  s        EEEr3   rD  c                       e Zd ZdZdS )MediumSTableMixind   NrE  r+   r3   r0   rG  rG  4          EEEr3   rG  c                       e Zd ZdZdS )BigSTableMixini  NrE  r+   r3   r0   rK  rK  8  rI  r3   rK  )
UltraLightLightMediumFull)r,  rN  r-  rN  )r   r   r      	   )r   r   rP  rQ  c               #      K   t           D ]a} t          D ]W}t          D ]M}|t          v p|t          v }d|d         | d         |fz  }d|z  d| z  ddf}t          ||d          }|||fV  NXbd S )	Nz%sI%sO%dTDTestCaser   z%sSTableMixinz%sITableMixinr   r   T)r<   r   r   )ckindsitable_sizesitable_optvaluesheavy_itable_optvaluesheavy_itable_sizesr   )ckindr   r   r<   rW   r4  rI   s          r0   
iclassdatarY  M  s       9 9  	9 	9D, 
9 
9!%;; 7 $66 0GU1Xx41 1	-4-5013
 !uxNNN	 *i88888
9	99 9r3   c              #   4   K   | ]}t          |          V  d S N)r   )r-   cbases     r0   	<genexpr>r]  `  s(      ;;utE{{;;;;;;r3   z%s = class_c                       e Zd ZeZdS )BaseTableUsageTestCaseN)r   r   r   rz   r   r+   r3   r0   r_  r_  g  s        EEEr3   r_  c                   Z    e Zd ZdZd Zd Zd Zd Zd Zd Z	d Z
d	 Zd
 Zd Zd Zd ZdS )ScalarTableUsageTestCasezlTest case for query usage on scalar tables.

    This also tests for most usage errors and situations.

    c                 R    |                      t          | j        j        d           dS )zUsing an empty condition.r   NassertRaisesSyntaxErrorr~   wherer   s    r0   test_empty_conditionz-ScalarTableUsageTestCase.test_empty_conditionv  s'     	+tz'7<<<<<r3   c                 R    |                      t          | j        j        d           dS )z&Using a condition with a syntax error.zfoo barNrc  rg  s    r0   test_syntax_errorz*ScalarTableUsageTestCase.test_syntax_error{  s'     	+tz'7CCCCCr3   c                     |                      t          | j        j        d           |                      t          | j        j        ddi i           |                      t          | j        j        d           dS )z-Using a condition with an unsupported object.z[]objzc_bool < []Nrd  r   r~   rf  rg  s    r0   test_unsupported_objectz0ScalarTableUsageTestCase.test_unsupported_object  sg     	)TZ%5t<<<)TZ%5uubkJJJ)TZ%5}EEEEEr3   c                     |                      t          | j        j        d           |                      t          | j        j        d           |                      t          | j        j        d           dS )z*Using a condition with unsupported syntax.z	c_bool[0]zc_bool()zc_bool.__init__N)rd  r   r~   rf  	NameErrorrg  s    r0   test_unsupported_syntaxz0ScalarTableUsageTestCase.test_unsupported_syntax  sb     	)TZ%5{CCC)TZ%5zBBB)TZ%57HIIIIIr3   c                 R    |                      t          | j        j        d           dS )z0Using a condition with no participating columns.TrueN)rd  
ValueErrorr~   rf  rg  s    r0   test_no_columnz'ScalarTableUsageTestCase.test_no_column  s'     	*dj&6?????r3   c                     | j                             dd| j                  }|                     t          | j        j        d| j        j        j        |j        j        d           dS )z1Using a condition with a column from other table.r   otherzc_int32_a + c_int32_b > 0)	c_int32_a	c_int32_bN)	r   r   r   rd  rt  r~   rf  colsc_int32)r   table2s     r0   test_foreign_columnz,ScalarTableUsageTestCase.test_foreign_column  sj     ))#w8MNN*dj&65(,
(?(.(;= =	> 	> 	> 	> 	>r3   c                     t           }|                     || j        j        d           |                     || j        j        d           dS )z7Using a condition with unsupported operations on types.zc_complex128 > 0jzc_string + b"a" > b"abc"N)r   rd  r~   rf  )r   NIEs     r0   test_unsupported_opz,ScalarTableUsageTestCase.test_unsupported_op  sK     "#tz/1DEEE#tz/1KLLLLLr3   c                 R    |                      t          | j        j        d           dS )zUsing a non-boolean condition.r{  Nrm  rg  s    r0   test_not_booleanz)ScalarTableUsageTestCase.test_not_boolean  s'     	)TZ%5yAAAAAr3   c                 R    |                      t          | j        j        d           dS )z&Using a condition with nested columns.rZ   Nrm  rg  s    r0   test_nested_colz(ScalarTableUsageTestCase.test_nested_col  s'     	)TZ%5zBBBBBr3   c                                           t           j        j        d                                 t           j        j        dd j        j        j        i            fd}                      t          |           dS )z*Using implicit column names in conditions.r{  c_boolc                      j         j        j        }                     |            j                             d           d S )Nr{  )r~   rz  r  assertIsNotNonerf  )r{  r   s    r0   where_with_localszEScalarTableUsageTestCase.test_implicit_col.<locals>.where_with_locals  s?    jo,G  )))JY'''''r3   N)rd  r   r~   rf  rz  r{  )r   r  s   ` r0   test_implicit_colz*ScalarTableUsageTestCase.test_implicit_col  s     	)TZ%5yAAA)TZ%5"Xtz/F$G	I 	I 	I	( 	( 	( 	( 	( 	)%677777r3   c                                            t           j        j        dddi            fd}                      t          |            fd}                      t          |           dS )z(Using condition variables in conditions.c_string > boundr   r   c                  |    d}                      | t                     j                            dddi           d S )Nfoor  r   r   )assertIsInstancer   r~   rf  )r   r   s    r0   r  zGScalarTableUsageTestCase.test_condition_vars.<locals>.where_with_locals  sA    E!!%---J/'1>>>>>r3   c                      da                      t           t                     	  j                            dddi           b d S # b w xY w)Nr  zc_string > _gvar_gvarr   )r  r  r   r~   rf  rg  s   r0   where_with_globalszHScalarTableUsageTestCase.test_condition_vars.<locals>.where_with_globals  sR    E!!%---
  !3gq\BBBEEE				s   A ANrd  r   r~   rf  )r   r  r  s   `  r0   test_condition_varsz,ScalarTableUsageTestCase.test_condition_vars  s     	-tz/?,wl	< 	< 	<	? 	? 	? 	? 	?
 	-/@AAA	 	 	 	 	 	-/ABBBBBr3   c                 D                          t           j        j        d                                 t           j        j        dd j        j        j        i            fd}                      t          |            fd}                      t          |           dS )z*Looking up different scopes for variables.rN   c                      j         j        j        }                     |            j                             d           d S )NrN   )r~   rz  r{  r  rf  )rN   r   s    r0   where_whith_localsz@ScalarTableUsageTestCase.test_scopes.<locals>.where_whith_locals  s?    */)C  %%%JU#####r3   c                       j         j        j        a                     t                     	  j                             d           bd S # bw xY w)Nr  )r~   rz  r{  r  r  rf  rg  s   r0   r  z@ScalarTableUsageTestCase.test_scopes.<locals>.where_with_globals  sP    JO+E  '''
  )))EEE				s   A AN)rd  rp  r~   rf  r   rz  r{  )r   r  r  s   `  r0   test_scopesz$ScalarTableUsageTestCase.test_scopes  s     	)TZ%5u=== 	)TZ%5%)@!A	C 	C 	C	$ 	$ 	$ 	$ 	$ 	)%7888	 	 	 	 	 	)%788888r3   N)r   r   r   r   rh  rj  rn  rq  ru  r}  r  r  r  r  r  r  r+   r3   r0   ra  ra  o  s         = = =
D D D
F F FJ J J@ @ @
> > >M M MB B B
C C C
8 8 8 C C C29 9 9 9 9r3   ra  c                       e Zd ZdZd ZdS )MDTableUsageTestCasez5Test case for query usage on multidimensional tables.c                 R    |                      t          | j        j        d           dS )z.Using a condition on a multidimensional table.r  Nr  rg  s    r0   r   zMDTableUsageTestCase.test  s(     	-tz/?JJJJJr3   N)r   r   r   r   r   r+   r3   r0   r  r    s.        ??K K K K Kr3   r  c                   0     e Zd ZdZdZdZ fdZd Z xZS )IndexedTableUsagezTest case for query usage on indexed tables.

    Indexing could be used in more cases, but it is expected to kick in
    at least in the cases tested here.

    r   Tc                    t                                                       | j        j        j                            t                     | j        j        j                            t                     | j        j        | _        | j        j	        | _
        | j        j        | _        t                      }| j        D ]#}|d         }||vr|                    |           $t!          |          | _        d S )N)r   r   )r   r   r~   rz  r  r   r   r{  r   _compile_conditioncompileCondition_required_expr_varsrequiredExprVarssetidx_expradd	frozensetusable_idxs)r   r  expridxvarr   s       r0   r   zIndexedTableUsage.setUp	  s    
++8H+III
,,9I,JJJ'+z'I$ $
 = $
 >eeM 	( 	(D!WF[(('''$[11r3   c                    | j         D ]}|                     |i           }|                     || j        d| d| d| j         d           |                     |d           }|                     ||          }|j        }|                     || j        d| d| d| j         d           |j        }|                     || j	        d| d	| d| j	         d           t          j        d
| d|j         d           d S )Nz
Query with condition: ``z"``
Computed usable indexes are: ``z``
and should be: ``r   z(
Wrong index expression in condition:
``z#``
Compiled index expression is:
``z``
and should be:
``z(
Wrong index operations in condition:
``z$``
Computed index operations are:
``z* Query with condition ``z`` will use variables ``z`` for indexing.)
conditionsr   assertEqualr  r  r  index_expressionsr  string_expressionstr_exprr   r   index_variables)r   	conditionc_usable_idxsr   compiled
c_idx_expr
c_str_exprs          r0   r   zIndexedTableUsage.test  s    	A 	AI 88BGGM]D,<7) 7 7"/7 7 #'"27 7 78 8 8
 ,,Y==H,,YAAH!3JZ4"+4 4$.4 4 #'-4 4 45 5 5
 "3JZ4"+4 4$.4 4 #'-4 4 45 5 5
 @I @ @-@ @ @A A A A+	A 	Ar3   )	r   r   r   r   r   r   r   r   r   r   s   @r0   r  r    sd          EG2 2 2 2 2A A A A A A Ar3   r  c                        e Zd Zg dZdgZdZdS )IndexedTableUsage1)z(c_int32 > 0)z(c_int32 > 0) & (c_extra > 0)z+(c_int32 > 0) & ((~c_bool) | (c_extra > 0))z/(c_int32 > 0) & ((c_extra < 3) & (c_extra > 0))r{  )gtr*   e0Nr   r   r   r  r  r  r+   r3   r0   r  r  2  .          J ++HHHHr3   r  c                        e Zd Zg dZdgZdZdS )IndexedTableUsage2)z(c_int32 > 0) & (c_int32 < 5)z-(c_int32 > 0) & (c_int32 < 5) & (c_extra > 0)zB(c_int32 > 0) & (c_int32 < 5) & ((c_bool == True) | (c_extra > 0))zB(c_int32 > 0) & (c_int32 < 5) & ((c_extra > 0) | (c_bool == True))r{  )r  lt)r   r   r  Nr  r+   r3   r0   r  r  =  s.          J 22HHHHr3   r  c                        e Zd Zg dZdgZdZdS )IndexedTableUsage3)z(c_bool == True)z (c_bool == True) & (c_extra > 0)z (c_extra > 0) & (c_bool == True)z2((c_extra > 0) & (c_extra < 4)) & (c_bool == True)z2(c_bool == True) & ((c_extra > 0) & (c_extra < 4))r  eq)Tr  Nr  r+   r3   r0   r  r  H  s.          J --HHHHr3   r  c                   "    e Zd ZddgZddgZdZdS )IndexedTableUsage4z2((c_int32 > 0) & (c_bool == True)) & (c_extra > 0)zD((c_int32 > 0) & (c_bool == True)) & ((c_extra > 0) & (c_extra < 4))r  r  	(e0 & e1)Nr  r+   r3   r0   r  r  T  s3        <	J
 +,H HHHr3   r  c                   "    e Zd ZddgZddgZdZdS )IndexedTableUsage5z1(c_int32 >= 1) & (c_int32 < 2) & (c_bool == True)zA(c_int32 >= 1) & (c_int32 < 2) & (c_bool == True) & (c_extra > 0)r{  )ger  )r   r   r  r  Nr  r+   r3   r0   r  r  `  s3        ;	J
 2,H HHHr3   r  c                   "    e Zd ZddgZg dZdZdS )IndexedTableUsage6z>(c_int32 >= 1) & (c_int32 < 2) & (c_int32 > 0) & (c_int32 < 5)zN(c_int32 >= 1) & (c_int32 < 2) & (c_int32 > 0) & (c_int32 < 5) & (c_extra > 0))r  r  r{  )r  r   z((e0 & e1) & e2)Nr  r+   r3   r0   r  r  l  s5        H	J
  H "HHHr3   r  c                   "    e Zd Zg dZddgZdZdS )IndexedTableUsage7)z@(c_int32 >= 1) & (c_int32 < 2) & ((c_int32 > 0) & (c_int32 < 5))zB((c_int32 >= 1) & (c_int32 < 2)) & ((c_int32 > 0) & (c_int32 < 5))zR((c_int32 >= 1) & (c_int32 < 2)) & ((c_int32 > 0) & (c_int32 < 5)) & (c_extra > 0)r  r  r  Nr  r+   r3   r0   r  r  y  s5          J 21H HHHr3   r  c                       e Zd ZdgZdgZdZdS )IndexedTableUsage8z/(c_extra > 0) & ((c_int32 > 0) & (c_int32 < 5))r  r  Nr  r+   r3   r0   r  r    s)        9J 2 HHHHr3   r  c                   "    e Zd Zg dZddgZdZdS )IndexedTableUsage9)z-(c_extra > 0) & (c_int32 > 0) & (c_int32 < 5)z/((c_extra > 0) & (c_int32 > 0)) & (c_int32 < 5)z=(c_extra > 0) & (c_int32 > 0) & (c_int32 < 5) & (c_extra > 3)r  r  r  Nr  r+   r3   r0   r  r    s3          J
 +*,HHHHr3   r  c                   "    e Zd Zg dZddgZdZdS )IndexedTableUsage10)z0(c_int32 < 5) & (c_extra > 0) & (c_bool == True)z&(c_int32 < 5) & (c_extra > 2) & c_boolz@(c_int32 < 5) & (c_bool == True) & (c_extra > 0) & (c_extra < 4)z@(c_int32 < 5) & (c_extra > 0) & (c_bool == True) & (c_extra < 4)r  r  r  Nr  r+   r3   r0   r  r    s3          J +,.HHHHr3   r  c                   "    e Zd ZdZg dZg ZdZdS )IndexedTableUsage11z1Complex operations are not eligible for indexing.)zsin(c_int32) > 0z(c_int32 * 2.4) > 0z(c_int32 + c_int32) > 0zc_int32**2 > 0r   N)r   r   r   r   r  r  r  r+   r3   r0   r  r    s1        ;;  J HHHHr3   r  c                        e Zd Zg dZdgZdZdS )IndexedTableUsage12)~c_bool	~(c_bool)z~c_bool & (c_extra > 0)z~(c_bool) & (c_extra > 0)r  r  )Fr  Nr  r+   r3   r0   r  r    .          J ..HHHHr3   r  c                        e Zd Zg dZdgZdZdS )IndexedTableUsage13)z~(c_bool == True)z~((c_bool == True))!~(c_bool == True) & (c_extra > 0)z#~((c_bool == True)) & (c_extra > 0)r  r  Nr  r+   r3   r0   r  r    r  r3   r  c                        e Zd Zg dZdgZdZdS )IndexedTableUsage14)z~(c_int32 > 0)z ~((c_int32 > 0)) & (c_extra > 0)z,~(c_int32 > 0) & ((~c_bool) | (c_extra > 0))z0~(c_int32 > 0) & ((c_extra < 3) & (c_extra > 0))r{  )ler*   r  Nr  r+   r3   r0   r  r    r  r3   r  c                   "    e Zd Zg dZddgZdZdS )IndexedTableUsage15)z(~(c_int32 > 0) | ~c_bool)z,(~(c_int32 > 0) | ~(c_bool)) & (c_extra > 0)zF(~(c_int32 > 0) | ~(c_bool == True)) & ((c_extra > 0) & (c_extra < 4))r  r  z	(e0 | e1)Nr  r+   r3   r0   r  r    s5          J +-H HHHr3   r  c                   "    e Zd Zg dZddgZdZdS )IndexedTableUsage16z!(~(c_int32 > 0) & ~(c_int32 < 2))z1(~(c_int32 > 0) & ~(c_int32 < 2)) & (c_extra > 0)zC(~(c_int32 > 0) & ~(c_int32 < 2)) & ((c_extra > 0) & (c_extra < 4))r  r{  )r  )r   r  Nr  r+   r3   r0   r  r    5          J +*H HHHr3   r  c                   "    e Zd Zg dZddgZdZdS )IndexedTableUsage17r  r  r  r  Nr  r+   r3   r0   r  r    r  r3   r  c                       e Zd Zg dZg ZdZdS )IndexedTableUsage18)z~((c_int32 > 0) & (c_bool))z+~((c_int32 > 0) & (c_bool)) & (c_extra > 0)z=~((c_int32 > 0) & (c_bool)) & ((c_extra > 0) & (c_extra < 4))r   Nr  r+   r3   r0   r  r    s+          J HHHHr3   r  c                       e Zd ZdgZdgZdZdS )IndexedTableUsage19zA~((c_int32 > 0) & (c_bool)) & ((c_bool == False) & (c_extra < 4))r  r  Nr  r+   r3   r0   r  r    s+        	J . HHHHr3   r  c                   "    e Zd Zg dZddgZdZdS )IndexedTableUsage20)z((c_int32 > 0) & ~(c_bool))z+((c_int32 > 0) & ~(c_bool)) & (c_extra > 0)zE((c_int32 > 0) & ~(c_bool == True)) & ((c_extra > 0) & (c_extra < 4))r  r  r  Nr  r+   r3   r0   r  r    s5          J 	#%H HHHr3   r  c                   "    e Zd Zg dZddgZdZdS )IndexedTableUsage21)z(~(c_int32 > 0) & (c_bool))z+(~(c_int32 > 0) & (c_bool)) & (c_extra > 0)zE(~(c_int32 > 0) & (c_bool == True)) & ((c_extra > 0) & (c_extra < 4))r  r  r  Nr  r+   r3   r0   r  r    s5          J +,H HHHr3   r  c                        e Zd Zg dZdgZdZdS )IndexedTableUsage22)z5~((c_int32 >= 1) & (c_int32 < 2)) & ~(c_bool == True)r  zG~((c_int32 >= 1) & (c_int32 < 2)) & (~(c_bool == True) & (c_extra > 0))r  r  Nr  r+   r3   r0   r  r  ,  s0          J . HHHHr3   r  c                       e Zd Zg dZg ZdZdS )IndexedTableUsage23)zc_int32 != 1c_bool != Falsez~(c_int32 != 1)z~(c_bool != False)z(c_int32 != 1) & (c_extra != 2)r   Nr  r+   r3   r0   r  r  8  s+          J HHHHr3   r  c                        e Zd Zg dZdgZdZdS )IndexedTableUsage24)r  zc_bool == TruezTrue == c_boolz
~(~c_bool)z~~c_boolz
~~~~c_boolz~(~c_bool) & (c_extra != 2)r  r  Nr  r+   r3   r0   r   r   D  s0          J - HHHHr3   r   c                        e Zd Zg dZdgZdZdS )IndexedTableUsage25)r  zc_bool == FalsezFalse == c_boolr  z~((c_bool))z	~~~c_boolz~~(~c_bool) & (c_extra != 2)r  r  Nr  r+   r3   r0   r  r  S  s2          J 	&H HHHr3   r  c                       e Zd Zg dZg ZdZdS )IndexedTableUsage26)zc_bool != TruezTrue != c_boolr  zFalse != c_boolr   Nr  r+   r3   r0   r  r  c  s+        
 
 
J HHHHr3   r  c                   "    e Zd ZddgZg dZdZdS )IndexedTableUsage27z((c_int32 == 3) | c_bool | (c_int32 == 5)zF(((c_int32 == 3) | (c_bool == True)) | (c_int32 == 5)) & (c_extra > 0)r{  r  )r   r  r{  r  r  z((e0 | e1) | e2)Nr  r+   r3   r0   r  r  n  s5        2	
J
  H
 "HHHr3   r  c                   "    e Zd ZddgZg dZdZdS )IndexedTableUsage28z*((c_int32 == 3) | c_bool) & (c_int32 == 5)zF(((c_int32 == 3) | (c_bool == True)) & (c_int32 == 5)) & (c_extra > 0)r  ((e0 | e1) & e2)Nr  r+   r3   r0   r  r  |  s5        4	
J
  H
 "HHHr3   r  c                   "    e Zd ZddgZg dZdZdS )IndexedTableUsage29z2(c_int32 == 3) | ((c_int32 == 4) & (c_int32 == 5))zD((c_int32 == 3) | ((c_int32 == 4) & (c_int32 == 5))) & (c_extra > 0))r{  r  )r   r	  r  z((e0 & e1) | e2)Nr  r+   r3   r0   r  r    5        <	
J
  H
 "HHHr3   r  c                   "    e Zd ZddgZg dZdZdS )IndexedTableUsage30z2((c_int32 == 3) | (c_int32 == 4)) & (c_int32 == 5)zB((c_int32 == 3) | (c_int32 == 4)) & (c_int32 == 5) & (c_extra > 0))r  r  r	  r  Nr  r+   r3   r0   r  r    r  r3   r  c                        e Zd Zg dZdgZdZdS )IndexedTableUsage31)z2(c_extra > 0) & ((c_extra < 4) & (c_bool == True))z2(c_extra > 0) & ((c_bool == True) & (c_extra < 5))z2((c_int32 > 0) | (c_extra > 0)) & (c_bool == True)r  r  Nr  r+   r3   r0   r  r    s2        
 
 
J 	%H HHHr3   r  c                       e Zd ZdgZg ZdZdS )IndexedTableUsage32z@(c_int32 < 5) & (c_extra > 0) & (c_bool == True) | (c_extra < 4)r   Nr  r+   r3   r0   r  r    s$        J
J HHHHr3   r  c                  @   t           j                                        } t          g}|                    t
                     t           j        }|rd}nd}d}t          |          D ]}|D ]c} |            D ]V}t          |d                   }|s|j        s6t           j        	                    ||          }	| 
                    |	           Wd| 
                    t           j        	                    t                               | 
                    t           j        	                    t                               | 
                    t           j        	                    t                               | 
                    t           j        	                    t                               | 
                    t           j        	                    t                               | 
                    t           j        	                    t                                | 
                    t           j        	                    t"                               | 
                    t           j        	                    t$                               | 
                    t           j        	                    t&                               | 
                    t           j        	                    t(                               | 
                    t           j        	                    t*                               | 
                    t           j        	                    t,                               | 
                    t           j        	                    t.                               | 
                    t           j        	                    t0                               | 
                    t           j        	                    t2                               | 
                    t           j        	                    t4                               | 
                    t           j        	                    t6                               | 
                    t           j        	                    t8                               | 
                    t           j        	                    t:                               | 
                    t           j        	                    t<                               | 
                    t           j        	                    t>                               | 
                    t           j        	                    t@                               | 
                    t           j        	                    tB                               | 
                    t           j        	                    tD                               | 
                    t           j        	                    tF                               | 
                    t           j        	                    tH                               | 
                    t           j        	                    tJ                               | 
                    t           j        	                    tL                               | 
                    t           j        	                    tN                               | 
                    t           j        	                    tP                               | 
                    t           j        	                    tR                               | 
                    t           j        	                    tT                               | 
                    t           j        	                    tV                               | 
                    t           j        	                    tX                               | S )zCReturn a test suite consisting of all the test cases in the module.r   test_lr   r   )prefix)-r   unittest	TestSuiter5  ro   rY  r<   rv   r   	makeSuiteaddTestra  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  )
	testSuite
cdatafuncsr<   
autoprefixniterr6   	cdatafunccdataclass_suite_s
             r0   suiter&    s    ))++IJj!!!LE 


E5\\ +J +J# 	. 	.I" . .eAh . .#_66v>H 7 J JF%%f---. 	&/334LMMNNN&/334HIIJJJ&/334FGGHHH&/334FGGHHH&/334FGGHHH&/334FGGHHH&/334FGGHHH&/334FGGHHH&/334FGGHHH&/334FGGHHH&/334FGGHHH&/334GHHIII&/334GHHIII&/334GHHIII&/334GHHIII&/334GHHIII&/334GHHIII&/334GHHIII&/334GHHIII&/334GHHIII&/334GHHIII&/334GHHIII&/334GHHIII&/334GHHIII&/334GHHIII&/334GHHIII&/334GHHIII&/334GHHIII&/334GHHIII&/334GHHIII&/334GHHIII&/334GHHIII&/334GHHIII&/334GHHIIIIr3   __main__r&  )defaultTest)r+   r[  )r   N)r   r   sysr   r   numpyrF   tablesrA   tables.testsr   rz   r   rr   rs   rt   
_maxnvaluerq   r   _strlenrj   r   bool_r   r   r   r   r   r   r   r   r   r   floatr   r   complexr   string_r?   r   r   r    r!   r"   r#   r$   r%   r&   r'   r   hasattrr(   ry   rD   r  r  r@   Enumrv   r   rQ   rX   rb   rc   re   rm   r   r  SkipTestr   TempFileMixinPyTablesTestCaser   r   r   	operatorsr  r  r  r   extra_conditionsr   r  r#  r  r.   r  r  r  r)  r(  r'  r+  r0  r1  r2  r5  r7  r;  r>  rA  rD  rG  rK  rS  rT  rW  rU  rV  rY  r"  cnamer4  cdictr  cbasesrU   r$  execr_  r  ra  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   
parse_argvargvprint_versionsmainr+   r3   r0   <module>rB     s   * * 				 



                   
 
 > ''"'("(2CDDDDqH

#hbhz!|$$
%
%
)
 #  =

RXt
RWcN bh_ bh_	
 ry# bh_ ry# bh_ ry# 
E" 
E" ",( 2='* rxo rz5!  RXsO!" uw
+#	& I hrvbfFBGF26"&yBIL L	 I 72y /J.Ii KJ	8I8IJJJ  0JJ	8I8IJJJ  +iLLLMM 5rw88eeJ&7&788899 *
   2
; 
; 
; 
;; ; ; ;< %$+- -  ;&&/xA A A  =
 
 =/' /' /'d	 	 	 	 	v/ 	 	 	67 67 67 67 67V163J 67 67 67r       
         	 :)???@@ ;1_
 G1n! H
 D    ;
" 
" 
" 
" 
". 
" 
" 
"F F F FR   & 	
 2 2E 2 2) 	2 	2IOE2y1111	22 $ 2 2E 2 2 	2 	2BOE2D11111	22
 ' ' ' ' ' ' ' '' ' ' ' ' ' ' ' Iug&& j5 5 5                                                 
 
3	2	2)))Y%011 "?? "<<<00 9 9 9" z* $ $I&/ikk $ $"
E;;
;;;;;eVU++]U"####$    3    	 0C9 C9 C9 C9 C9/1G C9 C9 C9LK K K K K<)? K K K0A 0A 0A 0A 0A(*@ 0A 0A 0Af    *       *   	 	 	 	 	* 	 	 		 	 	 	 	* 	 	 		 	 	 	 	* 	 	 	
" 
" 
" 
" 
"* 
" 
" 
"
 
 
 
 
* 
 
 
    *       *   	 	 	 	 	+ 	 	 	
 
 
 
 
+ 
 
 
    +       +       +   
 
 
 
 
+ 
 
 

 
 
 
 
+ 
 
 

 
 
 
 
+ 
 
 
    +       +   
 
 
 
 
+ 
 
 

 
 
 
 
+ 
 
 
	 	 	 	 	+ 	 	 		 	 	 	 	+ 	 	 	    +       +        +   " " " " "+ " " "" " " " "+ " " "" " " " "+ " " "" " " " "+ " " "	 	 	 	 	+ 	 	 	    +   = = =@ zFchF
OW----- r3   