
    xKg
                     x    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        Zed	        Zy
)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                     ddl m fd}t        |      }t        j                  |dt        j
                        } ||      }||fS )zA 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                     |j                   }|j                         sJ t        ||d         } | |||      }t        | |||j	                               S )Nr   )return_type
is_preciser   r   	_getvalue)contextbuilder	signatureargsarrtyshapesresr   s          [/home/alanp/www/video.onchill/myenv/lib/python3.12/site-packages/numba/np/unsafe/ndarray.pycodegenzempty_inferred.<locals>.codegen   sW    %%!!!gtAw/Wguf=%II    C)ndimlayoutdtype)numba.np.arrayobjr   lenr   Array	undefined)	typingctxshaper   ndarray_tysigr   s         @r   empty_inferredr(      sB     1J 
UB{{3eooFH
5/C<r   c                 H   t        |t        j                        st        d      |j                  dk7  r$t        dj                  |j                              t        |j                        t        j                  |j                         ||      }fd}||fS )zConvert *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                    d }|j                   d   t        j                  g}t        j                  g| }| j                  t        j                        }| j                        }|d    |      |g}	| j                  ||||	      }
|
S )Nc                 J    |}t        |      D ]  }t        ||| |         } |S )N)ranger
   )arraylengthempty_tupleoutis        r   implz-to_fixed_tuple.<locals>.codegen.<locals>.impl?   s,    C6]#CE!H5 #Jr   r   )r   r   intpr   r   get_value_typeget_constant_undefcompile_internal)r   r   r   r   r4   inner_argtypes	inner_sigll_idx_typer1   
inner_argsr   
tuple_size
tuple_types              r   r   zto_fixed_tuple.<locals>.codegen>   s    	 $..+UZZD$$ZA.A	,,UZZ800<1g{:6D
&&wiL
r   )
isinstancer   IntegerLiteralr   r   r	   formatintliteral_valueUniTupler   )r#   r/   r0   r'   r   r=   r>   s        @@r   to_fixed_tuplerE   )   s     fe223!"HIIzzQ:AA%**MNN V))*JekkDJ
UF
#C" <r   N)__doc__
numba.corer   r   numba.core.cgutilsr   numba.core.extendingr   numba.core.imputilsr   numba.core.errorsr   r	   numba.cpython.unsafe.tupler
   r(   rE    r   r   <module>rN      sF    % + * 0 > 4  4 % %r   