
    xKgf                        d dl mZmZ d dlmZmZ d dlmZ d dl	m
Z
 d dlmZ d dlZ G d d e             Z G d	 d
 e             Z G d d e             Z G d d e             Z G d d e             Z G d d e             Z G d d e             Z G d d e             Z G d d e             Z G d d e             Z G d d e             Z G d d e             Z G d d  e             Z G d! d" e             Z G d# d$ e             Z G d% d& e             Z G d' d( e             Z G d) d* e             Z G d+ d, e             Z  G d- d. e             Z! G d/ d0 e             Z" G d1 d2 e             Z# G d3 d4ejH                        Z% G d5 d6ejH                        Z& G d7 d8ejH                        Z' G d9 d:ejH                        Z(e)d;k(  r ejT                          yy)<    )irbinding)types	datamodel)test_factory)DataModelManager)OpaqueModelNc                   $    e Zd Zej                  Zy)TestBoolN)__name__
__module____qualname__r   booleanfe_type     ^/home/alanp/www/video.onchill/myenv/lib/python3.12/site-packages/numba/tests/test_datamodel.pyr   r   
       mmGr   r   c                   $    e Zd Zej                  Zy)TestPyObjectN)r   r   r   r   pyobjectr   r   r   r   r   r      s    nnGr   r   c                   $    e Zd Zej                  Zy)TestInt8N)r   r   r   r   int8r   r   r   r   r   r      s    jjGr   r   c                   $    e Zd Zej                  Zy)	TestInt16N)r   r   r   r   int16r   r   r   r   r   r          kkGr   r   c                   $    e Zd Zej                  Zy)	TestInt32N)r   r   r   r   int32r   r   r   r   r    r       r   r   r    c                   $    e Zd Zej                  Zy)	TestInt64N)r   r   r   r   int64r   r   r   r   r#   r#      r   r   r#   c                   $    e Zd Zej                  Zy)	TestUInt8N)r   r   r   r   uint8r   r   r   r   r&   r&   "   r   r   r&   c                   $    e Zd Zej                  Zy)
TestUInt16N)r   r   r   r   uint16r   r   r   r   r)   r)   &       llGr   r)   c                   $    e Zd Zej                  Zy)
TestUInt32N)r   r   r   r   uint32r   r   r   r   r-   r-   *   r+   r   r-   c                   $    e Zd Zej                  Zy)
TestUInt64N)r   r   r   r   uint64r   r   r   r   r0   r0   .   r+   r   r0   c                   $    e Zd Zej                  Zy)	TestFloatN)r   r   r   r   float32r   r   r   r   r3   r3   2   r   r   r3   c                   $    e Zd Zej                  Zy)
TestDoubleN)r   r   r   r   float64r   r   r   r   r6   r6   6   r   r   r6   c                   $    e Zd Zej                  Zy)TestComplexN)r   r   r   r   	complex64r   r   r   r   r9   r9   :   s    ooGr   r9   c                   $    e Zd Zej                  Zy)TestDoubleComplexN)r   r   r   r   
complex128r   r   r   r   r<   r<   >   s    Gr   r<   c                   D    e Zd Z ej                  ej
                        Zy)TestPointerOfInt32N)r   r   r   r   CPointerr!   r   r   r   r   r?   r?   B   s    ennU[[)Gr   r?   c                   F    e Zd Z ej                  ej
                  d      Zy)TestUniTupleOf2xInt32   Nr   r   r   r   UniTupler!   r   r   r   r   rB   rB   F       ennU[[!,Gr   rB   c                   F    e Zd Z ej                  ej
                  d      Zy)TestUniTupleEmptyr   NrD   r   r   r   rH   rH   J   rF   r   rH   c                   \    e Zd Z ej                  ej
                  ej                  g      Zy)TestTupleInt32Float32N)r   r   r   r   Tupler!   r4   r   r   r   r   rJ   rJ   N   s    ekk5;;67Gr   rJ   c                   0    e Zd Z ej                  g       Zy)TestTupleEmptyN)r   r   r   r   rK   r   r   r   r   rM   rM   R   s    ekk"oGr   rM   c                   H    e Zd Z ej                  ej
                  dd      Zy)Test1DArrayOfInt32   CNr   r   r   r   Arrayr!   r   r   r   r   rO   rO   V       ekk%++q#.Gr   rO   c                   H    e Zd Z ej                  ej
                  dd      Zy)Test2DArrayOfComplex128rC   rQ   N)r   r   r   r   rS   r=   r   r   r   r   rV   rV   Z   s    ekk%**As3Gr   rV   c                   H    e Zd Z ej                  ej
                  dd      Zy)Test0DArrayOfInt32r   rQ   NrR   r   r   r   rX   rX   ^   rT   r   rX   c                   6    e Zd Zd Zd Zd Zd Zd Zd Zd Z	y)	TestArgInfoc                 f   t         j                  }t        j                  ||      }t        j                         }t        j
                  t        j                         g       }t        j                  ||d      }t        j                         }|j                  |j                                |D cg c]5  }t        j                  |j                  |      j                         d      7 }	}|j                  ||	      }
|j                  ||
      }| j!                  t#        |      t#        |             t%        |
D cg c]  }|j&                   c}      }| j!                  ||j(                         |	D cg c]  }|j&                   }}|D cg c]  }|j&                   }}| j!                  ||       |j+                  |
t-        t#        |            D cg c]  }d c}       |j/                          t1        j2                  t5        |             yc c}w c c}w c c}w c c}w c c}w )z
        Test round-tripping types *fe_args* through the default data model's
        argument conversion and unpacking logic.
        test_arguments)nameNzarg%i)r   default_manager	ArgPackerr   ModuleFunctionTypeVoidTypeFunction	IRBuilderposition_at_endappend_basic_blockConstantlookupget_value_typeas_argumentsfrom_argumentsassertEquallentupletypeargument_typesassign_namesrangeret_voidllparse_assemblystr)selffe_argsdmmfimodulefntyfunctionbuildertargsvaluesasargsvvaltysaexpect_types	got_typesis                     r   _test_as_argumentszTestArgInfo._test_as_argumentsd   s   
 ''  g.r{{}b1;;vt2BC,,. ; ; => !" A CJJqM88:DA  	 " $/""7F3Vc'l3/1/0!2!23(,-1-%+,VQVVV	,y1 	%G2E F2EQ2E FG
#f+&+" 0 .,
 !Gs   2:H?H9H$H)	H.
c                     t         j                  t        j                  t         j                  dd      t         j                  g}| j	                  |       y )NrP   rQ   )r   r!   rS   r:   r   rw   rx   s     r   test_int32_array_complexz$TestArgInfo.test_int32_array_complex   s;    ;;;;u{{As3??$ 	(r   c                 x    t        j                  t         j                  dd      gdz  }| j                  |       y )NrP   rQ   rC   r   rS   r!   r   r   s     r   test_two_arrayszTestArgInfo.test_two_arrays   .    ;;u{{As34q8(r   c                 x    t        j                  t         j                  dd      gdz  }| j                  |       y )Nr   rQ   rC   r   r   s     r   test_two_0d_arrayszTestArgInfo.test_two_0d_arrays   r   r   c                    t        j                  t         j                  d      t        j                  t         j                  d      g}| j                  |       t        j                  t         j                  dd      }t        j                  |d      t        j                  |d      g}| j                  |       t        j                  t        j                  t         j                  d      d      g}| j                  |       y )NrC      rP   rQ   )r   rE   r!   r   rS   )rw   rx   arrtys      r   test_tupleszTestArgInfo.test_tuples   s    >>%++q1>>%++q13(EKKC0>>%+>>%+-(>>%..a"@!DE(r   c                     t        j                  t         j                  d      t        j                  d      t         j                  g}| j                  |       y )Nr   r   )r   rE   r   rK   r!   r   r   s     r   test_empty_tupleszTestArgInfo.test_empty_tuples   s=    >>%++q1;;r?;;  	(r   c                     t         j                  t        j                  t        j                  d      d      t         j                  g}| j                  |       y )Nr   rC   )r   r!   rE   rK   r$   r   r   s     r   test_nested_empty_tuplesz$TestArgInfo.test_nested_empty_tuples   s=    ;;>>%++b/15;;  	(r   N)
r   r   r   r   r   r   r   r   r   r   r   r   r   rZ   rZ   b   s&    #'J))))))r   rZ   c                   *    e Zd Zd Zd Zd Zd Zd Zy)TestMemInfoc                 .    t         j                  | _        y N)r   r^   ry   )rw   s    r   setUpzTestMemInfo.setUp   s    ,,r   c                     t         j                  }| j                  |   }| j                  |j	                                y r   )r   r!   ry   assertFalsecontains_nrt_meminforw   tydms      r   test_numberzTestMemInfo.test_number   s/    [[XXb\0023r   c                     t         j                  d d  }| j                  |   }| j                  |j	                                y r   )r   r!   ry   
assertTruer   r   s      r   
test_arrayzTestMemInfo.test_array   s1    [[^XXb\//12r   c                     t        j                  t         j                  d      }| j                  |   }| j	                  |j                                y NrC   )dtypecount)r   rE   r!   ry   r   r   r   s      r   test_tuple_of_numberz TestMemInfo.test_tuple_of_number   s:    ^^%++Q7XXb\0023r   c                     t        j                  t         j                  d d  d      }| j                  |   }| j	                  |j                                y r   )r   rE   r!   ry   r   r   r   s      r   test_tuple_of_arrayzTestMemInfo.test_tuple_of_array   s<    ^^%++a.:XXb\//12r   N)r   r   r   r   r   r   r   r   r   r   r   r   r      s    -4
3
4
3r   r   c                       e Zd Zd Zy)TestMiscc                    dd l }ddlm} |d        }|j                  d|j                        j                  |j                        }|j                  |      } |||       |j                  j                  ||j                  d             y )Nr   )njitc                 N    t        | j                  d         D ]
  }||   | |<    y )Nr   )rr   shape)r   br   s      r   copyz%TestMisc.test_issue2921.<locals>.copy   s&    1771:&t! 'r      )r   )FTTTT)numpynumbar   aranger'   viewbool_
zeros_liketestingassert_equalarray)rw   npr   r   r   r   s         r   test_issue2921zTestMisc.test_issue2921   sv    		 
	 IIarxxI(--bhh7MM!Q



288,B#CDr   N)r   r   r   r   r   r   r   r   r      s    Er   r   c                       e Zd Zd Zy)TestDMMChainingc                 .   t               } G d dt              } G d dt              }|j                  t        j                  |       |j                  t        j
                  |       t               } G d dt              }|j                  t        j                  |       |j                  |      }| j                  |j                  t        j                        |       | j                  |j                  t        j                        |       | j                  |j                  t        j                        |       | j                  |j                  t        j                        |       | j                  |j                  t        j                        |       | j                  |j                  t        j                        |       | j                  t              5  |j                  t        j                         d d d        y # 1 sw Y   y xY w)Nc                       e Zd Zy)/TestDMMChaining.test_basic.<locals>.int_handlerNr   r   r   r   r   r   int_handlerr          r   r   c                       e Zd Zy)1TestDMMChaining.test_basic.<locals>.float_handlerNr   r   r   r   float_handlerr      r   r   r   c                       e Zd Zy)3TestDMMChaining.test_basic.<locals>.new_int_handlerNr   r   r   r   new_int_handlerr      r   r   r   )r   r	   registerr   IntegerFloatchainassertIsInstancerh   intpassertNotIsInstancer4   assertRaisesKeyError)rw   ry   r   r   	inter_dmmr   chained_dmms          r   
test_basiczTestDMMChaining.test_basic   sd    	+ 		K 	 	U]]K0U[[-0$&		k 	 	5==/:ooc* 	k00<oN  !3!3EJJ!?Mcjj4kBk00?Ocjj7Gi..uzz:OLx(U]]+ )((s   " HHN)r   r   r   r   r   r   r   r   r      s     ,r   r   __main__)+llvmliter   r   rt   
numba.corer   r   numba.core.datamodel.testingr   numba.core.datamodel.managerr   numba.core.datamodel.modelsr	   unittestr   r   r   r   r    r#   r&   r)   r-   r0   r3   r6   r9   r<   r?   rB   rH   rJ   rM   rO   rV   rX   TestCaserZ   r   r   r   r   mainr   r   r   <module>r      s   & ' 5 9 3 |~ <> |~          ,.  * *-LN -- -8LN 8\^ / /4ln 4/ /M)(## M)`3(## 32Ex   E"!,h'' !,H zHMMO r   