o
    i                     @   s   d dl Zd dlmZmZ d dlmZ d dlZd dlm	Z	 dd Z
dd ZG d	d
 d
e	ZG dd de	Zedkr>e  dS dS )    N)njitjit)TypingErrorTestCasec                   C   s
   dddS )N      )r       r
   r
   r
   S/home/ubuntu/veenaModal/venv/lib/python3.10/site-packages/numba/tests/test_dicts.py	build_map   s   
r   c                  C   s   t } d| | diS )Nr   r   r   )xr
   r
   r   build_map_from_local_vars   s   r   c                   @   s$   e Zd Zdd Zdd Zdd ZdS )DictTestCasec                 C   s"   t dd|}| | |  d S )NT)forceobj)r   assertPreciseEqual)selfpyfunccfuncr
   r
   r   check   s   zDictTestCase.checkc                 C      |  t d S N)r   r   r   r
   r
   r   test_build_map      zDictTestCase.test_build_mapc                 C   r   r   )r   r   r   r
   r
   r   test_build_map_from_local_vars   r   z+DictTestCase.test_build_map_from_local_varsN)__name__
__module____qualname__r   r   r   r
   r
   r
   r   r      s    r   c                   @   s   e Zd ZdZdd Zdd Zdd Zdd	 Zd
d Zdd Z	dd Z
dd Zdd Zdd Zdd Zdd Zdd Zdd ZdS )TestCompiledDictzSTesting `dict()` and `{}` usage that are redirected to
    `numba.typed.Dict`.
    c                 C   &   t dd }| }| |ddi d S )Nc                  S   s   t  } d| d< | S Nr	   r   dictdr
   r
   r   foo$   s   z+TestCompiledDict.test_use_dict.<locals>.foor   r	   r   assertEqualr   r&   r%   r
   r
   r   test_use_dict"      
zTestCompiledDict.test_use_dictc                 C   s   t dd }t dd }g dg dftdtdfg ddfg d	dff}|D ]\}}|||}| |tt|| q*| | |  d S )
Nc                 S   s   t t| |}|S r   )r#   zip)abr%   r
   r
   r   dict_iterable_1/   s   zETestCompiledDict.test_use_dict_iterable_args.<locals>.dict_iterable_1c                   S   s   t g dS )N))sapei+  )guidoi  )jacki  r"   r
   r
   r
   r   dict_iterable_24   s   zETestCompiledDict.test_use_dict_iterable_args.<locals>.dict_iterable_2)r   r	   r   )         r4   abc)r   r	   r   r4   )r   nparanger(   r#   r,   py_func)r   r/   r3   inpsr-   r.   r%   r
   r
   r   test_use_dict_iterable_args-   s   




z,TestCompiledDict.test_use_dict_iterable_argsc                 C   s.   t dd }tddi}| }| || d S )Nc                   S      t dS )N)r   r	   r>   r"   r
   r
   r
   r   ctorF      z7TestCompiledDict.test_ctor_iterable_tuple.<locals>.ctorr   r	   )r   r#   r(   )r   r?   expectedgotr
   r
   r   test_ctor_iterable_tupleE   s
   
z)TestCompiledDict.test_ctor_iterable_tuplec              	   C   s   ddl m} tdd }tdd }tdd }td	d
 }d}d}d}|t|f|t|f|t|f|t|fg}	|	D ]&\}
}}| |}|
  W d    n1 sPw   Y  | |t|j q8d S )Nr   )_message_dict_supportc                  S   s   t  } d| d< t | S r!   r"   r$   r
   r
   r   ctor1R   s   z;TestCompiledDict.test_unsupported_dict_usage.<locals>.ctor1c                   S   r=   )N)r>   )r   r-   r"   r
   r
   r
   r   ctor2X   r@   z;TestCompiledDict.test_unsupported_dict_usage.<locals>.ctor2c                   S   r=   )N))r-   r.   c)r%   efr"   r
   r
   r
   r   ctor3\   r@   z;TestCompiledDict.test_unsupported_dict_usage.<locals>.ctor3c                   S   s   t i dfi dffS Nr   r	   r"   r
   r
   r
   r   ctor4`   s   z;TestCompiledDict.test_unsupported_dict_usage.<locals>.ctor4z(Non-iterable args used in dict(iterable)z0dictionary update sequence element has length 3;zUnhashable type)numba.core.typing.dictdeclrD   r   r   assertRaisesassertInstr	exception)r   rD   rE   rF   rJ   rL   _non_iter_args_dict_upd_item_len_unhashable_typeinputsfuncexcmsgraisesr
   r
   r   test_unsupported_dict_usageN   s.   



z,TestCompiledDict.test_unsupported_dict_usagec                 C   r    )Nc                  S   s   i } d| d< | S r!   r
   r$   r
   r
   r   r&   w   s   z2TestCompiledDict.test_use_curlybraces.<locals>.foor   r	   r'   r)   r
   r
   r   test_use_curlybracesu   r+   z%TestCompiledDict.test_use_curlybracesc                 C   r    )Nc                   S   s   ddiS rK   r
   r
   r
   r
   r   r&      r@   z=TestCompiledDict.test_use_curlybraces_with_init1.<locals>.foor   r	   r'   r)   r
   r
   r   test_use_curlybraces_with_init1   s   
z0TestCompiledDict.test_use_curlybraces_with_init1c                 C   s*   t dd }| }| |dddd d S )Nc                   S      ddddS )N皙@皙@ffffff@r   r   r5   r
   r
   r
   r
   r   r&         z@TestCompiledDict.test_use_curlybraces_with_initmany.<locals>.foor^   r_   r`   ra   r'   r)   r
   r
   r   "test_use_curlybraces_with_initmany   s   
z3TestCompiledDict.test_use_curlybraces_with_initmanyc                 C   "   t dd }| | |  d S )Nc                   S   r]   )Nr^   r4   r6   ra   r
   r
   r
   r
   r   r&      rb   zATestCompiledDict.test_curlybraces_init_with_coercion.<locals>.foor   r(   r:   r   r&   r
   r
   r   #test_curlybraces_init_with_coercion   s   
z4TestCompiledDict.test_curlybraces_init_with_coercionc                 C   s2   t dd }d\}}| |||||| d S )Nc                 S   s   | d|| | iS Nr   r
   )r   yr
   r
   r   r&      s   z?TestCompiledDict.test_use_curlybraces_with_manyvar.<locals>.foo)
      re   )r   r&   r   ri   r
   r
   r   !test_use_curlybraces_with_manyvar   s   
z2TestCompiledDict.test_use_curlybraces_with_manyvarc                 C   rd   )Nc                  S   s"   t  } ddi| d< ddi| d< | S )Nr   r   r4   r	   r"   kr
   r
   r   r&      s   z=TestCompiledDict.test_mixed_curlybraces_and_dict.<locals>.foore   rf   r
   r
   r   test_mixed_curlybraces_and_dict   s   
z0TestCompiledDict.test_mixed_curlybraces_and_dictc                 C   R   t dd }| t}|  W d    n1 sw   Y  | dt|j d S )Nc                  S   s   dd i} | S rh   r
   rm   r
   r
   r   r&         z;TestCompiledDict.test_dict_use_with_none_value.<locals>.fooz&Dict.value_type cannot be of type noner   rN   r   rO   rP   rQ   r   r&   rY   r
   r
   r   test_dict_use_with_none_value      
z.TestCompiledDict.test_dict_use_with_none_valuec                 C   T   t dd }| t}|d W d    n1 sw   Y  | dt|j d S )Nc                 S   s   | rdnd }d|i}|S Ng      @r   r
   )choiceoptionalrn   r
   r
   r   r&      s   z?TestCompiledDict.test_dict_use_with_optional_value.<locals>.fooTz7Dict.value_type cannot be of type OptionalType(float64)rr   rs   r
   r
   r   !test_dict_use_with_optional_value   s   

z2TestCompiledDict.test_dict_use_with_optional_valuec                 C   rv   )Nc                 S   s   | rdnd di}|S rw   r
   )rx   rn   r
   r
   r   r&      s   z=TestCompiledDict.test_dict_use_with_optional_key.<locals>.fooTz5Dict.key_type cannot be of type OptionalType(float64)rr   rs   r
   r
   r   test_dict_use_with_optional_key   s   

z0TestCompiledDict.test_dict_use_with_optional_keyc                 C   rp   )Nc                  S   s   d di} | S rh   r
   rm   r
   r
   r   r&      rq   z9TestCompiledDict.test_dict_use_with_none_key.<locals>.fooz$Dict.key_type cannot be of type nonerr   rs   r
   r
   r   test_dict_use_with_none_key   ru   z,TestCompiledDict.test_dict_use_with_none_keyN)r   r   r   __doc__r*   r<   rC   rZ   r[   r\   rc   rg   rl   ro   rt   rz   r{   r|   r
   r
   r
   r   r      s     	'			r   __main__)numpyr8   numbar   r   numba.core.errorsr   unittestnumba.tests.supportr   r   r   r   r   r   mainr
   r
   r
   r   <module>   s     K