CoolFace
Apppublic

Aluode/PerceptionLabPortable

sourceHugging Faceupdated 9mo agoView on Hugging Face
0likes
slicing.cpython-310.pyc91 linesDownload Raw Back to __pycache__
1o

2�Yi	&�@s8dZddlmZddlmZddlmZmZmZm	Z	ddl3mZmZm
Z
mZmZmZmZmZdd�Zdd	�Zd4d�Zdd
�Zdd�Zdd�Zdd�Zeee�ej��dd��Zeejd�dd��Zeejd�dd��Z eejd�dd��Z!edejej"�d d!��Z#d"d#�Z$eej�d$d%��Z%eej&j'ej�d&d'��Z(d(S))z25Implement slices and various slice computations.6�)�zip_longest)�ir)�cgutils�types�typing�utils)�impl_ret_borrowed�impl_ret_new_ref�impl_ret_untracked�
iternext_impl�
lower_builtin�7lower_cast�lower_constant�
lower_getattrcCs2|�d|t�|jd��}|�||�}|�|||�S)z^8    Fix negative index by adding *size* to it.  Positive9    indices are left untouched.10    �<r)�icmp_signedr�Constant�type�add�select)�builder�idx�sizeZis_negativeZ
wrapped_index�r�E:\DocsHouse\542 percep lab latest\PerceptionLab\PerceptionLab_Portable\python_embed\Lib\site-packages\numba/cpython/slicing.py�	fix_indexsrc		st��jd��t��jd�}����fdd�}��t���j���W\}}|�|d���|d���Wd�n1s=wY|�|}���|�}|d||�|d||�Wd�n1scwYWd�dSWd�dS1s{wYdS)z�11    Fix *slice* start and stop to be valid (inclusive and exclusive, resp)12    indexing bounds for a sequence of the given *size*.13    r�����cs�t�|�}t�|��}t�||���d|��}�j|dd��t�||�Wd�n1s0wY��d|��}�j|dd��t�||�Wd�dS1sUwYdS)NrF�Zlikely�>=)�getattrr�setattrr�if_then)Z14bound_nameZ15lower_replZ16upper_repl�boundZ	underflow�overflow�rr�slice�zerorr�	fix_bound"s17�"�zfix_slice.<locals>.fix_bound�start�stopN)rrrZif_elser�18is_neg_int�stepr)	rr%rZ	minus_oner'Zif_neg_stepZif_pos_step�lower�upperrr$r�	fix_slices"���"�r.c	Cs�|j}|j}|j}t�|jd�}t�|jd�}t�||�}|�||�}|�||�}	|�	||�}19|�20||21|	�}|�	||�||��}|�22||�d||�|�d||��}
|�23|
||�S)a24    Given a slice, compute the number of indices it spans, i.e. the25    number of iterations that for_range_slice() will execute.26 27    Pseudo-code:28        assert step != 029        if step > 0:30            if stop <= start:31                return 032            else:33                return (stop - start - 1) // step + 134        else:35            if stop >= start:36                return 037            else:38                return (stop - start + 1) // step + 139 40    (see PySlice_GetIndicesEx() in CPython)41    �rrz<=)
r(r)r+rrrrr*�subrrZsdivr)r�slicestructr(r)r+�oner&�is_step_negative�deltaZpos_dividendZneg_dividendZdividendZnominal_lengthZis_zero_lengthrrr�get_slice_length=s �r5c	Csd|j}|j}|�d�}|�d�}|�d|j|�}|�||�||�|�}|�||�||�|�}||fS)z?42    Return the [lower, upper) indexing bounds of a slice.43    rr/r)r(r)rrr+rr)	rr1r(r)r&r2r3r,r-rrr�get_slice_boundsis4445��r6cCs|�|j|�S)z446    Fix the given stride for the slice's step.47    )�mulr+)rr%Zstriderrr�48fix_stride{sr8cCs$|jrt�|||jtdf�dSdS)zP49    Guard against *slicestruct* having a zero step (and raise ValueError).50    �slice step cannot be zeroN)�has_steprZ51guard_nullr+�52ValueError)�contextr�typr1rrr�guard_invalid_slice�s53��r>cCs&d|jd>d}d|||ddfS)z�54    Get the default values for a slice's members:55    (start for positive step, start for negative step,56     stop for positive step, stop for negative step, step)57    r/r)Zaddress_size)r<Zmaxintrrr�get_defaults�sr?cs �fdd�t��D�\}}}}}dgd�t|�dkr*|jdtjur*|d�d<ntt|j|��D]\}	\}58}|59tjurA|�|	<q2�fdd�}|d|�}
|�d	|
��tj	d��}|�60|||�}|�61|||�}|d|�}|d|�}|j}62��||j�}||_
||_|
|_|��}t�||j|�S)63Nc�g|]	}��tj|��qSr��get_constantr�intp��.0�x�r<rr�64<listcomp>��z*slice_constructor_impl.<locals>.<listcomp>�r/rcs�|}|dur65|S|S�Nr)�i�default�val)�66slice_argsrr�
get_arg_value�sz-slice_constructor_impl.<locals>.get_arg_value�r)r?�len�argsr�none�	enumerate�ziprrBrCr�return_type�make_helperr(r)r+�	_getvaluer67)r<r�sigrS�default_start_pos�default_start_neg�default_stop_pos�default_stop_neg�default_steprL�tyrNrPr+r3Zdefault_stopZ
default_startr)r(�sli�resr)r<rOr�slice_constructor_impl�sD�6869�70���7172rcr(cC�|�|||�}|jSrK)rXr(�r<rr=�valuerarrr�slice_start_impl��rgr)cCrdrK)rXr)rerrr�slice_stop_impl�rhrir+cCs(|jr
|�|||�}|jS|�tjd�S)Nr/)r:rXr+rBrrCrerrr�slice_step_impl�srjz
slice.indicescCs�|d}|�||jd|d�}|jt�||�dd��|j�|td�Wd�n1s.wY|jt�||j	�dd��|j�|td�Wd�n1sRwYt73|||�|�||j|j
|j|j	f�S)Nr/rFr)zlength should not be negative)r9)rXrSr!rr*Z	call_convZreturn_user_excr;Zis_scalar_zeror+r.Z74make_tuplerWr(r))r<rrZrS�lengthrarrr�
slice_indices�s(�����rlcs���||�}��tj�}�fdd�t��D�\}}}}	}75|j}|dur(d}|76}n|dk}||�}|j}
|
dur?|r<|}
n|}
n||
�}
|j}|durR|rO|	}n|}n||�}|
|_||_||_|��S)Ncr@rrArDrGrrrH�rIz,make_slice_from_constant.<locals>.<listcomp>Fr)	rXZget_value_typerrCr?r+r(r)rY)r<rr`�pyvalraZltyr[r\r]r^r_r+Zstep_is_negr(r)rrGr�make_slice_from_constant�s>�rncCs&t|tj�r77|j}n|}t||||�SrK)�78isinstancer�LiteralZliteral_typern)r<rr`rmr=rrr�constant_slice srqcCst||||j�SrK)rnZ
literal_value)r<rZfromtyZtotyrNrrr�cast_from_literal*s79�rrN))�__doc__�	itertoolsrZllvmliterZ80numba.corerrrrZnumba.core.imputilsrr	r81rrr
rrrr.r5r6r8r>r?r%ZVarArg�AnyrcZ	SliceTypergrirj�Integerrlrnrq�miscZSliceLiteralrrrrrr�<module>s6(82$,	
8384/858687888990-91	
Aluode/PerceptionLabPortable · CoolFace