U
    ¿|e�
  ã                   @   sp   d 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
mZmZ ddlmZ edd	„ ƒZed
d„ ƒZdS )zd
This file provides internal compiler utilities that support certain special
operations with numpy.
é    )ÚtypesÚtyping)Úunpack_tuple)Ú	intrinsic)Úimpl_ret_new_ref)ÚRequireLiteralValueÚTypingError)Útuple_setitemc                    sB   ddl m‰  ‡ fdd„}t|ƒ}tj|dtjd�}||ƒ}||fS )z×A version of numpy.empty whose dtype is inferred by the type system.

    Expects `shape` to be a int-tuple.

    There is special logic in the type-inferencer to handle the "refine"-ing
    of undefined dtype.
    r   ©Ú_empty_nd_implc                    s@   |j }| ¡ st‚t||d ƒ}ˆ | |||ƒ}t| ||| ¡ ƒS )Nr   )Úreturn_typeÚ
is_preciseÚAssertionErrorr   r   Ú	_getvalue)ÚcontextÚbuilderÚ	signatureÚargsÚarrtyÚshapesÚresr
   © úT/var/www/website-v5/atlas_env/lib/python3.8/site-packages/numba/np/unsafe/ndarray.pyÚcodegen   s
    zempty_inferred.<locals>.codegenÚC)ÚndimÚlayoutÚdtype)Znumba.np.arrayobjr   Úlenr   ÚArrayÚ	undefined)Ú	typingctxÚshaper   ÚndÚarray_tyÚsigr   r
   r   Úempty_inferred   s    	
r&   c                    sh   t |tjƒstdƒ‚|jdkr.td |j¡ƒ‚t|jƒ‰ tj	|j
ˆ d�‰ˆ||ƒ}‡ ‡fdd„}||fS )zÑConvert *array* into a tuple of *length*

    Returns ``UniTuple(array.dtype, length)``

    ** Warning **
    - No boundchecking.
      If *length* is longer than *array.size*, the behavior is undefined.
    z$*length* argument must be a constanté   zNot supported on array.ndim={})r   Úcountc                    sf   dd„ }|j d tjˆg}tjˆf|žŽ }|  tj¡}|  ˆ¡}|d |ˆ ƒ|g}	|  ||||	¡}
|
S )Nc                 S   s&   |}t |ƒD ]}t||| | ƒ}q|S )N)Úranger	   )ÚarrayÚlengthÚempty_tupleÚoutÚir   r   r   Úimpl?   s    z-to_fixed_tuple.<locals>.codegen.<locals>.implr   )r   r   Úintpr   r   Úget_value_typeÚget_constant_undefÚcompile_internal)r   r   r   r   r/   Úinner_argtypesÚ	inner_sigÚll_idx_typer,   Ú
inner_argsr   ©Ú
tuple_sizeÚ
tuple_typer   r   r   >   s    
zto_fixed_tuple.<locals>.codegen)Ú
isinstancer   ÚIntegerLiteralr   r   r   ÚformatÚintÚliteral_valueÚUniTupler   )r!   r*   r+   r%   r   r   r8   r   Úto_fixed_tuple)   s    



rA   N)Ú__doc__Ú
numba.corer   r   Únumba.core.cgutilsr   Únumba.core.extendingr   Únumba.core.imputilsr   Únumba.core.errorsr   r   Únumba.cpython.unsafe.tupler	   r&   rA   r   r   r   r   Ú<module>   s   
