U
    ð¾|e¤L  ã                L   @   sÀ  d dl Z d dlZd dlZd dlZd dlZd dlZd dlZd dlZd dlZd dl	Z	d dl
Z
d dlZd dlZd dlZd dlmZ d dlmZ d dlmZmZ d dlZd dlmZ d dlmZ d dlmZ d dlmZmZm Z  d d	l!m"Z" d d
l!mZ dd„ Z#ej$fdd„Z%ej&ej'ej(ej)ej*ej+ej,ej-ej.ej/ej0ej1ej2ej3ej4ej5ej6ej7ej8ej9ej:ej;dœZ<ej=ej>ej?ej@ejAejBejCejDejEejFejGejHejIdœZJe<eJ–ZKejLejMejNejOejPdœZQej&dej=dej'dej>dej(dej?dej)dej@dej*dejAdej+dejBdej,dejCdej-d ejDd!ej.d"ejEd#ej/d$ejFd%ej0d&ejGd'ej1d(ejHd)ej2d*ej3d+ej4d,ej5d-ej6d.ej7d/ej8d0ej9d1ej:d2ejLdejMdejNd3ejOd4ejPd5i&ZRd6aSd7d8„ ZTeUfd9d:„ZVe
 Wd;d<„ d;d<„ ¡ e  XeT¡ d=d>„ ZYd?d@„ ZZG dAdB„ dBƒZ[G dCdD„ dDe\ƒZ]dgdFdG„Z^G dHdI„ dIeƒZ_G dJdK„ dKe`ƒZadLdM„ ZbdNdO„ ZcdPdQ„ ZdG dRdS„ dSe\ƒZedTdU„ ZfdhdWdX„ZgdYZheehƒZieei_jdZd[„ Zkd\d]„ Zld^d_„ Zmdidadb„ZnG dcdd„ ddeƒZodedf„ ZpdS )jé    N)Ú
ModuleType)Úimport_module)ÚMappingÚSequence)Ú	signature)Ú	Signature)Ú	Parameter)Ú	PYVERSIONÚMACHINE_BITSÚDEVELOPER_MODE)Úconfig)Útypesc                 C   s    | j dk	rt | j ¡ |  d¡S )zS
    Erase the traceback and hanging locals from the given exception instance.
    N)Ú__traceback__Ú	tracebackÚclear_framesÚwith_traceback)Ú	exc_value© r   úM/var/www/website-v5/atlas_env/lib/python3.8/site-packages/numba/core/utils.pyÚerase_traceback   s    
r   c                 C   s@   dd„ }|| ƒ}||ƒ}||kr,t j | ¡S t jj| |d�S dS )zÃ
    Produces a "safe" relative path, on windows relpath doesn't work across
    drives as technically they don't share the same root.
    See: https://bugs.python.org/issue7195 for details.
    c                 S   s   t j t j | ¡¡d S )Nr   )ÚosÚpathÚ
splitdriveÚabspath©Úxr   r   r   Ú<lambda>0   ó    zsafe_relpath.<locals>.<lambda>)ÚstartN)r   r   r   Úrelpath)r   r   Zdrive_letterZ
drive_pathZdrive_startr   r   r   Úsafe_relpath(   s    r    )ú+ú-Ú*ú//ú/ú%ú**ú&ú|ú^ú<<ú>>ú==ú!=ú<ú<=ú>ú>=Úisúis notÚinú@)ú+=ú-=ú*=ú//=ú/=ú%=ú**=ú&=ú|=ú^=ú<<=ú>>=z@=)r!   r"   ú~ÚnotÚis_truer!   r7   r"   r8   r#   r9   r$   r:   r%   r;   r&   r<   r'   r=   r(   r>   r)   r?   r*   r@   r+   rA   r,   rB   r-   r.   r/   r0   r1   r2   r3   r4   r5   rC   rD   rE   Fc                   C   s   da d S ©NT)Ú_shutting_downr   r   r   r   Ú_at_shutdown¢   s    rH   c                 C   s   | ƒ   d¡}|dkp|dkS )a  
    Whether the interpreter is currently shutting down.
    For use in finalizers, __del__ methods, and similar; it is advised
    to early bind this function rather than look it up when calling it,
    since at shutdown module globals may be cleared.
    rG   TN)Úget)ÚglobalsÚvr   r   r   Úshutting_down§   s    rL   c                   C   s   d S ©Nr   r   r   r   r   r   ¹   r   r   c                   C   s
   t jdkS )z@Returns True if new style errors are to be used, false otherwiseÚ	new_style©r   ÚCAPTURED_ERRORSr   r   r   r   Úuse_new_style_errors½   s    rQ   c                   C   s
   t jdkS )z@Returns True if old style errors are to be used, false otherwiseÚ	old_stylerO   r   r   r   r   Úuse_old_style_errorsÄ   s    rS   c                       sl   e Zd ZU dZe ¡ Zeed< i Z	‡ fdd„Z
dd„ Zdd„ Zd	d
„ Zdd„ Zdd„ Zejdd„ ƒZ‡  ZS )ÚThreadLocalStackz`A TLS stack container.

    Uses the BORG pattern and stores states in threadlocal storage.
    Ú
stack_namec                   s<   t ƒ jf |Ž || jks(td|› d�ƒ‚|| _| | j|< d S )Nzstack_name: 'z' already in use)ÚsuperÚ__init_subclass__Ú_registeredÚAssertionErrorrU   )ÚclsrU   Úkwargs©Ú	__class__r   r   rW   Ô   s    
ÿz"ThreadLocalStack.__init_subclass__c                 C   sb   t | ƒtk	st‚| j}d| j› �}zt||ƒ}W n& tk
rV   tƒ }t|||ƒ Y nX || _	d S )NZstack_)
ÚtyperT   rY   Ú_tlsrU   ÚgetattrÚAttributeErrorÚlistÚsetattrÚ_stack)ÚselfZtlsÚattrZ	tls_stackr   r   r   Ú__init__Ü   s    zThreadLocalStack.__init__c                 C   s   | j  |¡ dS )zPush to the stack
        N)rd   Úappend©re   Ústater   r   r   Úpushé   s    zThreadLocalStack.pushc                 C   s
   | j  ¡ S )zPop from the stack
        )rd   Úpop©re   r   r   r   rl   î   s    zThreadLocalStack.popc                 C   s
   | j d S )z–Get the top item on the stack.

        Raises IndexError if the stack is empty. Users should check the size
        of the stack beforehand.
        éÿÿÿÿ)rd   rm   r   r   r   Útopó   s    zThreadLocalStack.topc                 C   s
   t | jƒS rM   )Úlenrd   rm   r   r   r   Ú__len__û   s    zThreadLocalStack.__len__c                 c   s$   |   |¡ z
dV  W 5 |  ¡  X dS )zXA contextmanager that pushes ``state`` for the duration of the
        context.
        N)rk   rl   ri   r   r   r   Úenterþ   s    

zThreadLocalStack.enter)Ú__name__Ú
__module__Ú__qualname__Ú__doc__Ú	threadingÚlocalr_   ÚstrÚ__annotations__rX   rW   rg   rk   rl   ro   rq   Ú
contextlibÚcontextmanagerrr   Ú__classcell__r   r   r\   r   rT   Ë   s   
rT   c                       sr   e Zd Zi Zdd„ Zddd„Zdd„ Zdd	„ Zd
d„ Z‡ fdd„Z	dd„ Z
dd„ Zdd„ Zdd„ Zdd„ Z‡  ZS )ÚConfigOptionsc                 C   s   | j  ¡ | _d S rM   )ÚOPTIONSÚcopyÚ_valuesrm   r   r   r   rg     s    zConfigOptions.__init__Tc                 C   s$   || j krtd| ƒ‚|| j|< d S ©NzInvalid flag: %s)r   Ú	NameErrorr�   ©re   ÚnameÚvaluer   r   r   Úset  s    
zConfigOptions.setc                 C   s   |   |d¡ d S )NF)r‡   ©re   r…   r   r   r   Úunset  s    zConfigOptions.unsetc                 C   s   || j krtd| ƒ‚d S r‚   )r   ra   rˆ   r   r   r   Ú_check_attr  s    
zConfigOptions._check_attrc                 C   s   |   |¡ | j| S rM   )rŠ   r�   rˆ   r   r   r   Ú__getattr__  s    
zConfigOptions.__getattr__c                    s6   |  d¡rtt| ƒ ||¡ n|  |¡ || j|< d S )NÚ_)Ú
startswithrV   r~   Ú__setattr__rŠ   r�   r„   r\   r   r   rŽ      s    

zConfigOptions.__setattr__c                 C   s   dd  dd„ | j ¡ D ƒ¡ S )Nz	Flags(%s)z, c                 s   s&   | ]\}}|d k	rd||f V  qdS )Fz%s=%sNr   ©Ú.0ÚkrK   r   r   r   Ú	<genexpr>(  s   þz)ConfigOptions.__repr__.<locals>.<genexpr>)Újoinr�   Úitemsrm   r   r   r   Ú__repr__'  s    ÿzConfigOptions.__repr__c                 C   s   t | ƒƒ }| j ¡ |_|S rM   )r^   r�   r€   )re   r€   r   r   r   r€   ,  s    
zConfigOptions.copyc                 C   s   t |tƒo|j| jkS rM   )Ú
isinstancer~   r�   ©re   Úotherr   r   r   Ú__eq__1  s    

ÿzConfigOptions.__eq__c                 C   s
   | |k S rM   r   r—   r   r   r   Ú__ne__5  s    zConfigOptions.__ne__c                 C   s   t tt| j ¡ ƒƒƒS rM   )ÚhashÚtupleÚsortedr�   r”   rm   r   r   r   Ú__hash__8  s    zConfigOptions.__hash__)T)rs   rt   ru   r   rg   r‡   r‰   rŠ   r‹   rŽ   r•   r€   r™   rš   rž   r}   r   r   r\   r   r~   
  s   
r~   Ú c                    sÄ   |g krg S ddl m} d}g }t|ƒD ]J\}}t|di ƒ}| d|¡}	|	dk	r(||	 }
ˆ  |
¡r(| ||
|f¡ q(‡ fdd„}d	d
„ t||d�D ƒ}|sÀd|› dˆ › d�}ddlm	} ||ƒ‚|S )zöThis orders the given templates from most to least specific against the
    current "target". "fnkey" is an indicative typing key for use in the
    exception message in the case that there's no usable templates for the
    current "target".
    r   )Útarget_registryÚgenericÚmetadataÚtargetNc                    s   ˆ j  | d ¡S ©Né   )Ú__mro__Úindexr   ©r£   r   r   ÚkeyV  s    z(order_by_target_specificity.<locals>.keyc                 S   s   g | ]}|d  ‘qS )r   r   )r�   r   r   r   r   Ú
<listcomp>X  s     z/order_by_target_specificity.<locals>.<listcomp>)r©   z:Function resolution cannot find any matches for function 'z' for the current target: 'z'.)ÚUnsupportedError)
Únumba.core.target_extensionr    Ú	enumerater`   rI   Zinherits_fromrh   r�   Únumba.core.errorsr«   )r£   Ú	templatesZfnkeyr    ZDEFAULT_TARGETZusableÚixZtemp_clsÚmdZhwZhw_clazzr©   ÚorderÚmsgr«   r   r¨   r   Úorder_by_target_specificity<  s&    
r´   c                   @   s0   e Zd ZdZdd„ Zdd„ Zdd„ Zdd	„ Zd
S )Ú	SortedMapzImmutable
    c                 C   sD   g | _ i | _tt|ƒƒD ]&\}\}}|| j|< | j  ||f¡ qd S rM   )r�   Ú_indexr­   r�   rh   )re   ÚseqÚir‘   rK   r   r   r   rg   g  s
    
zSortedMap.__init__c                 C   s   | j | }| j| d S r¤   )r¶   r�   )re   r‘   r¸   r   r   r   Ú__getitem__n  s    
zSortedMap.__getitem__c                 C   s
   t | jƒS rM   )rp   r�   rm   r   r   r   rq   r  s    zSortedMap.__len__c                 C   s   t dd„ | jD ƒƒS )Nc                 s   s   | ]\}}|V  qd S rM   r   r�   r   r   r   r’   v  s     z%SortedMap.__iter__.<locals>.<genexpr>)Úiterr�   rm   r   r   r   Ú__iter__u  s    zSortedMap.__iter__N)rs   rt   ru   rv   rg   r¹   rq   r»   r   r   r   r   rµ   c  s
   rµ   c                       s   e Zd Z‡ fdd„Z‡  ZS )Ú
UniqueDictc                    s,   || krt d|f ƒ‚tt| ƒ ||¡ d S )Nzkey already in dictionary: %r)rY   rV   r¼   Ú__setitem__)re   r©   r†   r\   r   r   r½   z  s    zUniqueDict.__setitem__)rs   rt   ru   r½   r}   r   r   r\   r   r¼   y  s   r¼   c                    s"   t  ˆ ¡‡ ‡fdd„ƒ‰dˆ_ˆS )Nc                     s   ˆj sˆ ƒ } | ˆ_dˆ_ ˆjS rF   )Ú_ranÚ_result)Úres©ÚfnÚinnerr   r   rÃ   �  s
    zrunonce.<locals>.innerF)Ú	functoolsÚwrapsr¾   )rÂ   r   rÁ   r   Úrunonce€  s    rÆ   c                 C   s@   t | tƒst‚| dkr&tt| ƒƒd S tt|  d ƒƒd S dS )zL
    Return the number of bits necessary to represent integer `intval`.
    r   é   r¥   N)r–   ÚintrY   rp   Úbin)Zintvalr   r   r   Ú
bit_length�  s    rÊ   c                 #   s.   ‡ fdd„}d}t ˆ ƒ}|||ƒV  |}qdS )a  
    Given a list, return an infinite iterator of iterators.
    Each iterator iterates over the list from the last seen point up to
    the current end-of-list.

    In effect, each iterator will give the newly appended elements from the
    previous iterator instantiation time.
    c                    s   t ˆ | |… ƒS rM   )rº   )r   Ústop©Úlstr   r   Úsublist_iterator¡  s    z%stream_list.<locals>.sublist_iteratorr   N)rp   )rÍ   rÎ   r   rË   r   rÌ   r   Ústream_list˜  s
    	rÏ   c                   @   s   e Zd Zdd„ Zdd„ ZdS )ÚBenchmarkResultc                 C   s.   || _ || _t |¡| | _t | j¡| _d S rM   )ÚfuncÚloopÚnpÚarrayÚrecordsÚminÚbest)re   rÑ   rÕ   rÒ   r   r   r   rg   ¬  s    zBenchmarkResult.__init__c                 C   s0   t | jd| jƒ}|| j| jjt| jƒf}d| S )Nrs   z)%20s: %10d loops, best of %d: %s per loop)r`   rÑ   rÒ   rÕ   ÚsizeÚformat_timer×   )re   r…   Úargsr   r   r   r•   ²  s    zBenchmarkResult.__repr__N)rs   rt   ru   rg   r•   r   r   r   r   rÐ   «  s   rÐ   c                 C   sJ   d  ¡ }d}|d d… D ]}| |kr( q:|d }q|d }d| | |f S )Nzs ms us ns psr¥   rn   iè  z%.1f%s)Úsplit)ÚtmÚunitsÚbaseÚunitr   r   r   rÙ   ¸  s    
rÙ   r¥   c                 C   s®   t  | ¡}d}| d|¡}t|ƒ| dkr@|d9 }| d|¡}qt|ƒ| }||kr`t| ||ƒS |d | }t|| d dƒ}tdt t 	|¡¡ ƒ}| d|¡}t| ||ƒS )Nr¥   r   é
   é   )
ÚtimeitÚTimerÚrepeatrÖ   rÐ   ÚmaxrÈ   ÚmathÚceilÚlog10)rÑ   ZmaxsecÚtimerÚnumberÚresultr×   Zmax_per_run_timerÕ   r   r   r   Ú	benchmarkÄ  s    
rì   z	<dynamic>c                 C   s   t r
|| _| S )z{Set the __cause__ attribute on *new_exc* for explicit exception
    chaining.  Returns the inplace modified *new_exc*.
    )r   Ú	__cause__)Únew_excÚold_excr   r   r   Úchain_exceptionÞ  s    rð   c                 C   sD   t | ƒ}d}d}|j ¡ D ] }|d7 }|jtjkr|d7 }q||fS )zWReturn the minimal and maximal number of Python function
    positional arguments.
    r   r¥   )ÚpysignatureÚ
parametersÚvaluesÚdefaultÚinspectÚ_empty)ÚpyfuncÚsigZ	min_nargsZ	max_nargsÚpr   r   r   Úget_nargs_rangeç  s    
rú   c                 C   s"   t | ƒ}|dkr| S |ft| ƒ S )a›  Return a normalized tuple of Numba function types so that

        Tuple(numba_types)

    becomes

        UniTuple(dtype=<unified function type>, count=len(numba_types))

    If the above transformation would be incorrect, return the
    original input as given. For instance, if the input tuple contains
    types that are not function or dispatcher type, the transformation
    is considered incorrect.
    N)Úunified_function_typerp   )Únumba_typesÚdtyper   r   r   Úunify_function_typesõ  s    rþ   Tc                 C   sä  ddl m} t| tƒr8t| ƒdkr8t| d tjtjfƒs<dS tj	d|d� d\}}t
ƒ }d}d}| D �]}t|tjƒrÐt|jjƒ\}	}
|dkrš|	|
 }}n||f|	|
fks° dS | |j¡ |j ¡ }|dkrÐqdt|tjƒ�rf|dkrò|j }}n"||  k�r|jk�sn  dS t|tjƒ�rF|dk�r2|}n dS | |j¡ n|dk�rV|}n||k�slt‚qd dS qd|�rŒ|dk�sˆ|dk	�rŒdS |dk	�r¸|dk	�rà|j|jk�s²t‚|}n(|dk	�rÔ|j |¡ |}nt ||¡}|S )a¸  Returns a unified Numba function type if possible.

    Parameters
    ----------
    numba_types : Sequence of numba Type instances.
    require_precise : bool
      If True, the returned Numba function type must be precise.

    Returns
    -------
    typ : {numba.core.types.Type, None}
      A unified Numba function type. Or ``None`` when the Numba types
      cannot be unified, e.g. when the ``numba_types`` contains at
      least two different Numba function type instances.

    If ``numba_types`` contains a Numba dispatcher type, the unified
    Numba function type will be an imprecise ``UndefinedFunctionType``
    instance, or None when ``require_precise=True`` is specified.

    Specifying ``require_precise=False`` enables unifying imprecise
    Numba dispatcher instances when used in tuples or if-then branches
    when the precise Numba function cannot be determined on the first
    occurrence that is not a call expression.
    r   )ÚNumbaExperimentalFeatureWarningNz1First-class function type feature is experimental)Úcategory)NN)r®   rÿ   r–   r   rp   r   Z
DispatcherÚFunctionTypeÚwarningsÚwarnr‡   rú   Ú
dispatcherZpy_funcÚaddZget_function_typeÚnargsZUndefinedFunctionTypeÚupdateÚdispatchersrY   )rü   Zrequire_preciserÿ   ZmnargsZmxargsr  ÚfunctionZundefined_functionÚtZmnargs1Zmxargs1r   r   r   rû   	  sh    

ÿ
ÿþÿ






rû   c                       s(   e Zd ZdZ‡ fdd„Zdd„ Z‡  ZS )Ú_RedirectSubpackagea!  Redirect a subpackage to a subpackage.

    This allows all references like:

    >>> from numba.old_subpackage import module
    >>> module.item

    >>> import numba.old_subpackage.module
    >>> numba.old_subpackage.module.item

    >>> from numba.old_subpackage.module import item
    c           	         s¶   |d }t ƒ  |¡ i | _|| _t|ƒ}|j ¡ D ]:\}}t| ||ƒ t|t	ƒr2t
j|j t
j|› d|› �< q2| ¡ D ]:\}}| d¡rv| d¡rv|dkrvt| ||ƒ || j|< qvd S )Nrs   Ú.Ú__Ú__builtins__)rV   rg   Ú&_RedirectSubpackage__old_module_statesÚ_RedirectSubpackage__new_moduler   Ú__dict__r”   rc   r–   r   ÚsysÚmodulesrs   r�   Úendswith)	re   Zold_module_localsZ
new_moduleZ
old_moduleZnew_mod_objr‘   rK   rf   r†   r\   r   r   rg   l  s    
z_RedirectSubpackage.__init__c                 C   s   | j | jf}t|fS rM   )r  r  r  )re   rÚ   r   r   r   Ú
__reduce__†  s    z_RedirectSubpackage.__reduce__)rs   rt   ru   rv   rg   r  r}   r   r   r\   r   r  _  s   r  c                 C   s2   zt | ƒ W n tk
r(   t| ƒ Y S X | S dS )zÈ
        Given a value, returns a key that can be used
        as a hash. If the value is hashable, we return
        the value, otherwise we return id(value).

        See discussion in gh #6957
    N)r›   Ú	TypeErrorÚid)r†   r   r   r   Úget_hashable_key‹  s
    r  )rŸ   )r¥   )T)qÚatexitÚbuiltinsrÄ   rõ   r   Úoperatorrâ   ræ   r  r   Úweakrefr  rw   r{   r   r   Ú	importlibr   Úcollections.abcr   r   ÚnumpyrÓ   r   rñ   r   ZpySignaturer   ZpyParameterZnumba.core.configr	   r
   r   Ú
numba.corer   r   Úcurdirr    r  ÚsubÚmulÚfloordivÚtruedivÚmodÚpowÚand_Úor_ÚxorÚlshiftÚrshiftÚeqÚneÚltÚleÚgtÚgeÚis_Úis_notÚcontainsÚmatmulZBINOPS_TO_OPERATORSÚiaddÚisubÚimulÚ	ifloordivÚitruedivÚimodÚipowÚiandÚiorÚixorÚilshiftÚirshiftÚimatmulZINPLACE_BINOPS_TO_OPERATORSZALL_BINOPS_TO_OPERATORSÚposÚnegÚinvertÚnot_ÚtruthZUNARY_BUITINS_TO_OPERATORSZOPERATORS_TO_BUILTINSrG   rH   rJ   rL   ÚfinalizeÚregisterrQ   rS   rT   Úobjectr~   r´   rµ   Údictr¼   rÆ   rÊ   rÏ   rÐ   rÙ   rì   Z_dynamic_modnameZ_dynamic_moduler  rð   rú   rþ   rû   r  r  r   r   r   r   Ú<module>   s^  	éóÿû	                                      Ø,
?2
'
	
V,