o
    p>e6_                     @   sr  d 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
 ddl	mZ g dZe
jZejjZejZi Zg 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%d& Z$d'd( Z%d)d* Z&d+d, Z'd-d. Z(d/d0 Z)d1d2 Z*d3d4 Z+d5d6 Z,d7d8 Z-d9d: Z.d;d< Z/d=d> Z0d?d@ Z1dAdB Z2dCdD Z3dEdF Z4dGdH Z5dIdJ Z6dKdL Z7dMdN Z8dOdP Z9dQdR Z:dSdT Z;dUdV Z<dWdX Z=dYdZ Z>d[d\ Z?d]d^ Z@d_d` ZAdadb ZBdcdd ZCdedf ZDdgdh ZEdidj ZFdkdl ZGdmdn ZHdodp ZIdqdr ZJdsdt ZKdudv ZLdwdx ZMdydz ZNd{d| ZOd}d~ ZPdd ZQdd ZRdd ZSdd ZTdd ZUdd ZVdd ZWdd ZXdd ZYdd ZZdd Z[dd Z\dd Z]dd Z^dd Z_dd Z`dd Zadd ZbeTdeUdeVdeWdeZdeYdePde^de`deadebdiZcdd Zddd Zedd Zfdd Zgdd Zhdd Zidd Zjdd Zkdd Zldd ZmddÄ Znddń ZoG ddǄ depZqG ddɄ dɃZrdd˄ Zsdd̈́ Ztddτ Zuddф Zvddӄ ZwdddՄZxddׄ Zyi fddلZzddۄ Z{dd݄ Z|dd߄ Z}dd Z~dd Zdd Zdd Zdd Zdd ZdddZdd Zi fddZdd ZedejjZedejjZdd ZdS )aW  

Auxiliary functions for f2py2e.

Copyright 1999,2000 Pearu Peterson all rights reserved,
Pearu Peterson <pearu@ioc.ee>
Permission to use, modify, and distribute this software is given under the
terms of the NumPy (BSD style) LICENSE.


NO WARRANTY IS EXPRESSED OR IMPLIED.  USE AT YOUR OWN RISK.
$Date: 2005/07/24 19:01:55 $
Pearu Peterson

    N)reduce)deepcopy   )__version__)cfuncs)[
applyrules	debugcapi
dictappenderrmessgentitlegetargs2getcallprotoargumentgetcallstatementgetfortrannamegetpymethoddef
getrestdocgetusercodegetusercode1getdimensionhasbodyhascallstatement	hascommonhasexternalshasinitvaluehasnotehasresultnoteisallocatableisarrayisarrayofstringsischaracterischaracterarrayischaracter_or_characterarray	iscomplexiscomplexarrayiscomplexfunctioniscomplexfunction_warnisdoubleisdummyroutine
isexternal
isfunctionisfunction_wrapisint1isint1array	isintegerisintent_aux
isintent_cisintent_callbackisintent_copyisintent_dictisintent_hideisintent_inisintent_inoutisintent_inplaceisintent_nothideisintent_outisintent_overwrite	islogicalislogicalfunctionislong_complexislong_doubleislong_doublefunctionislong_longislong_longfunctionismoduleismoduleroutine
isoptional	isprivate
isrequired	isroutineisscalarissigned_long_longarrayisstringisstringarrayisstring_or_stringarrayisstringfunctionissubroutineget_f2py_modulenameissubroutine_wrapisthreadsafe
isunsignedisunsigned_charisunsigned_chararrayisunsigned_long_longisunsigned_long_longarrayisunsigned_shortisunsigned_shortarrayl_andl_notl_oroutmessreplaceshow
stripcommathrow_errorisattr_value
deep_mergec                 C   s    t ddrtj|  d S d S )Nverboser   )optionsgetsysstdoutwrite)t ri   T/home/www/facesmatcher.com/pyenv/lib/python3.10/site-packages/numpy/f2py/auxfuncs.pyr[   D   s   r[   c                 C   s   dt v S )NZcapi)debugoptionsvarri   ri   rj   r   I      r   c                 C      d| v o| d dkot |  S Ntypespec	characterr(   rl   ri   ri   rj   _ischaracterM      rt   c                 C   ro   rp   rs   rl   ri   ri   rj   	_isstringR   ru   rv   c                 C   s   t | od| vS NZcharselectorrt   rl   ri   ri   rj   r!   W      r!   c                 C      t | ot|  S Nr!   r   rl   ri   ri   rj   r   [      r   c                 C      t | ot| S r{   r|   rl   ri   ri   rj   r    _   ry   r    c                 C   s   t | od| v S rw   rx   rl   ri   ri   rj   rK   c   ry   rK   c                 C   rz   r{   rK   r   rl   ri   ri   rj   rI   g   r}   rI   c                 C   r~   r{   r   rl   ri   ri   rj   rJ   k   ry   rJ   c                 C   s   t | o| d d dkS )N	dimensionz(*))rJ   rl   ri   ri   rj   r   o   s   r   c                 C   s   d| v ot |  S Nr   rs   rl   ri   ri   rj   r   u   r}   r   c                 C   s   t | pt| pt|  S r{   )r   rI   r(   rl   ri   ri   rj   rG   y   s   rG   c                 C      t | o
| ddv S Nrq   )complexzdouble complexrG   rd   rl   ri   ri   rj   r"   }      r"   c                 C      t | o
| ddkS )Nrq   logicalr   rl   ri   ri   rj   r:         r:   c                 C   r   )Nrq   integerr   rl   ri   ri   rj   r-      r   r-   c                 C   r   )Nrq   realr   rl   ri   ri   rj   isreal   r   r   c                 C   sH   z| d d W S  t y#   z	| d d W  Y S  t y"   Y Y d S w w )NZkindselector*kindKeyErrorrl   ri   ri   rj   get_kind   s   r   c                 C   s$   |  ddkot| dkot|  S Nrq   r   1)rd   r   r   rl   ri   ri   rj   r+      s
   
r+   c                 C   s*   t | sdS | ddvrdS t| dkS )Nr   rq   r   r   8rG   rd   r   rl   ri   ri   rj   r?      
   r?   c                 C   *   t | sdS | ddkrdS t| dkS )Nr   rq   r   -1r   rl   ri   ri   rj   rR      r   rR   c                 C   r   )Nr   rq   r   -2r   rl   ri   ri   rj   rV      r   rV   c                 C   r   )Nr   rq   r   -4r   rl   ri   ri   rj   rQ      r   rQ   c                 C   r   )Nr   rq   r   -8r   rl   ri   ri   rj   rT      r   rT   c                 C   *   t | sdS | ddksdS t| dkS )Nr   rq   r   r   r   rl   ri   ri   rj   r&      r   r&   c                 C   r   )Nr   rq   r   Z16r   rl   ri   ri   rj   r=      r   r=   c                 C   s   t | sdS t| dkS )Nr   Z32)r"   r   rl   ri   ri   rj   r<      s   r<   c                 C   r   r   )r   rd   rl   ri   ri   rj   r#      r   r#   c                 C   s"   t | o| ddkot| dkS r   r   rd   r   rl   ri   ri   rj   r,         
r,   c                 C   "   t | o| ddv ot| dkS )Nrq   r   r   r   rl   ri   ri   rj   rS      r   rS   c                 C   r   )Nrq   r   r   r   rl   ri   ri   rj   rW      r   rW   c                 C   r   )Nrq   r   r   r   rl   ri   ri   rj   isunsignedarray   r   r   c                 C   r   )Nrq   r   r   r   rl   ri   ri   rj   rU      r   rU   c                 C   r   )Nrq   r   r   r   rl   ri   ri   rj   issigned_chararray   r   r   c                 C   r   )Nrq   r   2r   rl   ri   ri   rj   issigned_shortarray   r   r   c                 C   r   )Nrq   r   4r   rl   ri   ri   rj   issigned_array  r   r   c                 C   r   )Nrq   r   r   r   rl   ri   ri   rj   rH     r   rH   c                 C      d| v o	d| d v S )NattrspecZallocatableri   rl   ri   ri   rj   r        r   c                 C   s   d| vpt |  S r   )rI   rl   ri   ri   rj   	ismutable  r}   r   c                 C      d| v S )N
modulenameri   routri   ri   rj   rB     rn   rB   c                 C      d| v o	d| d kS )Nblockmoduleri   r   ri   ri   rj   rA     r   rA   c                 C   r   )Nr   functionri   r   ri   ri   rj   r)     r   r)   c                 C   s"   t | rdS tot| ot|  S Nr   )r/   	wrapfuncsr)   r(   r   ri   ri   rj   r*   !  s   r*   c                 C   r   )Nr   Z
subroutineri   r   ri   ri   rj   rM   '  r   rM   c                 C   s   t | rdS t| ot| S r   )r/   rM   hasassumedshaper   ri   ri   rj   rO   +     rO   c                 C      d|  dg v S )Nvaluer   rd   rl   ri   ri   rj   r`   0  ry   r`   c                 C   sV   |  drdS | d D ]}| d  |i  dg D ]}|dkr'd| d<   dS qqdS )Nr   Targsvarsr   :Fr   )r   adri   ri   rj   r   4  s   
r   c                 C      t | pt| S r{   )rB   r   r   ri   ri   rj   requiresf90wrapper?  ry   r   c                 C   r   r{   )r)   rM   r   ri   ri   rj   rF   C  ry   rF   c                 C   F   t | sdS d| v r| d }n| d }|| d v r!t| d | S dS Nr   resultnamer   )r)   r:   r   r   ri   ri   rj   r;   G     
r;   c                 C   r   r   )r)   r?   r   ri   ri   rj   r@   S  r   r@   c                 C   r   r   )r)   r=   r   ri   ri   rj   r>   _  r   r>   c                 C   r   r   )r)   r"   r   ri   ri   rj   r$   k  r   r$   c                 C   s   t | r
td dS dS )Na      **************************************************************
        Warning: code with a function returning complex value
        may not work correctly with your Fortran compiler.
        When using GNU gcc/g77 compilers, codes should work
        correctly for callbacks with:
        f2py -c -DF2PY_CB_RETURNCOMPLEX
    **************************************************************
r   r   )r$   r[   r   ri   ri   rj   r%   w  s   r%   c                 C   r   r   )r)   rI   r   ri   ri   rj   rL     r   rL   c                 C      d| v o| d S )NZ	externalsri   r   ri   ri   rj   r     ry   r   c                 C   r   )Nf2pyenhancementsZ
threadsaferi   r   ri   ri   rj   rP     s   
rP   c                 C   r   )Nr   ri   r   ri   ri   rj   hasvariables  ry   r   c                 C   s(   d| v od| d v od| d vot | S )Nr   optionalrequired)r7   rl   ri   ri   rj   rC     s
   
rC   c                 C   r   )Nr   Zexternalri   rl   ri   ri   rj   r(     r   r(   c                    sH   d d|   v r tdd | d D r" fdd| d D d S d S d S )Nz	\((.*?)\)r   c                 s   s    | ]}d |v V  qdS )r   Nri   ).0sri   ri   rj   	<genexpr>  s    zgetdimension.<locals>.<genexpr>c                    s   g | ]}t  |qS ri   )refindall)r   vZ
dimpatternri   rj   
<listcomp>      z getdimension.<locals>.<listcomp>r   )keysanyrl   ri   r   rj   r     s   r   c                 C   s   t |  ot| S r{   )rC   r7   rl   ri   ri   rj   rE     r}   rE   c                 C   sp   d| vrdS d| d v rdS d| d v rdS d| d v rdS d| d v r&dS d| d v r.dS d	| d v r6dS dS )
Nintentr   hider   inplaceinoutinoutoutinri   rl   ri   ri   rj   r4     s   r4   c                 C   sD   d| v o!d| d v sd| d v o!d| d vo!d| d vo!d| d vS )Nr   r   r   r   r   r   ri   rl   ri   ri   rj   r5     s   



r5   c                 C   r   )Nr   r   r   rl   ri   ri   rj   r8     ry   r8   c                 C   s<   d| v od| d v pd| d v od| d vot tt|  S )Nr   r   r   r   )rZ   r5   r6   rl   ri   ri   rj   r3     s   r3   c                 C   s
   t |  S r{   )r3   rl   ri   ri   rj   r7        
r7   c                 C   r   )Ncr   r   rl   ri   ri   rj   r/     ry   r/   c                 C   r   )Ncacher   r   rl   ri   ri   rj   isintent_cache  ry   r   c                 C   r   )Ncopyr   r   rl   ri   ri   rj   r1     ry   r1   c                 C   r   )N	overwriter   r   rl   ri   ri   rj   r9     ry   r9   c                 C   r   )Ncallbackr   r   rl   ri   ri   rj   r0     ry   r0   c                 C   r   )Nr   r   r   rl   ri   ri   rj   r6     ry   r6   c                 C   r   )NZauxr   r   rl   ri   ri   rj   r.     ry   r.   c                 C   r   )NZaligned4r   r   rl   ri   ri   rj   isintent_aligned4  ry   r   c                 C   r   )NZaligned8r   r   rl   ri   ri   rj   isintent_aligned8  ry   r   c                 C   r   )NZ	aligned16r   r   rl   ri   ri   rj   isintent_aligned16  ry   r   Z	INTENT_INZINTENT_INOUTZ
INTENT_OUTZINTENT_HIDEZINTENT_CACHEZINTENT_COPTIONALZINTENT_INPLACEZINTENT_ALIGNED4ZINTENT_ALIGNED8ZINTENT_ALIGNED16c                 C   r   )Nr   privateri   rl   ri   ri   rj   rD     r   rD   c                 C   r   )N=ri   rl   ri   ri   rj   r     rn   r   c                 C   s   t | sdS | d d dv S )Nr   r   )"')r   rl   ri   ri   rj   hasinitvalueasstring  r   r   c                 C   r   )NZnoteri   rl   ri   ri   rj   r     rn   r   c                 C   r   r   )r)   r   r   ri   ri   rj   r     r   r   c                 C   r   )Ncommonri   r   ri   ri   rj   r   )  rn   r   c                 C   s4   t | rdS t| r| d D ]	}t|r dS qdS )Nr   bodyr   )r   r   containscommon)r   bri   ri   rj   r   -  s   r   c                 C   s8   t | rdS t| sdS | d D ]	}t|r dS qdS )Nr   r   r   )rA   r   containsmodule)r   r   ri   ri   rj   r   7  s   r   c                 C   r   )Nr   ri   r   ri   ri   rj   r   B  rn   r   c                 C   s   t | d uS r{   )r   r   ri   ri   rj   r   F  s   r   c                 C      dS )Nr   ri   rl   ri   ri   rj   istrueJ     r   c                 C   r   r   ri   rl   ri   ri   rj   isfalseN  r   r   c                   @   s   e Zd ZdS )	F2PYErrorN)__name__
__module____qualname__ri   ri   ri   rj   r   R  s    r   c                   @   s   e Zd Zdd Zdd ZdS )r_   c                 C   s
   || _ d S r{   )mess)selfr   ri   ri   rj   __init__X  r   zthrow_error.__init__c                 C   s   d|| j f }t|)Nz

  var = %s
  Message: %s
)r   r   )r   rm   r   ri   ri   rj   __call__[  s   zthrow_error.__call__N)r   r   r   r   r   ri   ri   ri   rj   r_   V  s    r_   c                  G   N   dg }}t t| D ]}d|||f }|d|  qtd|d|f S )Nlambda v%s,f%d=f[%d]f%d(v)%s:%sz and rangelenappendevaljoinfl1l2iri   ri   rj   rX   `  
   
rX   c                  G   r   )Nr  r  r  r  z or r  r  ri   ri   rj   rZ   h  r  rZ   c                 C   s   t dS )Nzlambda v,f=f:not f(v))r	  )r  ri   ri   rj   rY   p  rn   rY   c                 C   s(   z	| d d dkW S  t y   Y dS w )Nr   fortranname r   r   r   ri   ri   rj   r'   t  s
   r'   c                 C   sT   z| d d }|dkrt |std| d   t W |S  t y)   | d }Y |S w )Nr   r  r  z"Failed to use fortranname from %s
r   )r   r
   )r   r   ri   ri   rj   r   {  s   
r   c                 C   s
  z	| d  |}W n
 ty   Y d S w |sd S |dkr#t|tr#d S t|tr4|t|kr0d S || }|d d dkr|rQd| d t| d |dd   }n|dd  }|dd  dkry|rq|d d d	 t| d
 }|S |d d }|S td|t|f  |S )Nr   r      z'''z
	/* start z multiline (z) */
z
	/* end multiline (z)*/z-%s multiline block should end with `'''`: %s
)rd   r   
isinstancestrlistr  reprr
   )r   Z	blocknamecommentcounterrri   ri   rj   getmultilineblock  sF   


r  c                 C   
   t | dS )NZcallstatementr  r   ri   ri   rj   r     r   r   c           
      C   s  t | ddd}|r|S t| rtd d S ddlm} g g }}tttt| r0|	ddg | d	 D ]J}| d
 | }t
|rAq4||v rL|| d }n-||}ttttt|r[nt|r`nt|sh|d }t|stt|stt|ry|d || q4d|| }	|	sd}	|	S )NZcallprotoargumentr   )r  z<warning: callstatement is defined without callprotoargument
r   )getctypezchar*Zsize_tr   r   Z_typedefr   ,void)r  r   r[   Z	capi_mapsr  rX   rL   rY   r*   extendr0   r/   rZ   rG   r"   rI   r`   r   rJ   r  r
  )
r   Zcb_mapr  r  Z	arg_typesZ
arg_types2nrm   ctypeZ
proto_argsri   ri   rj   r     sH   

r   c                 C   r  )Nusercoder  r   ri   ri   rj   r     r   r   c                 C   s   t | dddS )Nr%  r   )r  r  r   ri   ri   rj   r     s   r   c                 C   r  )NZpymethoddefr  r   ri   ri   rj   r     r   r   c                 C   sv   g g }}d| v r7| d }d| v r3| d D ]}||v r | | q|D ]}||vr.| | q#||fS | d }||fS )Nr   sortvars)r  )r   sortargsr   r   ri   ri   rj   getargs  s   


r(  c                    s   g  dg }  fddd  D }|   dv rAd D ]}| v r.|| q# D ]}||vr<|| q1 |fS |d  } |fS )Nr   c                    s(   g | ]}t d  | r| vr|qS )r   )r.   )r   r   r   r   ri   rj   r     s    
zgetargs2.<locals>.<listcomp>r   r&  )rd   r   r  )r   r'  Zauxvarsr   ri   r)  rj   r     s   

r   c                 C   s<   d| vrd S d }| d dkr| d | d f}| d  |d S )NZf2pymultilinesr   zpython moduler   r   )r   kri   ri   rj   r     s   r   c                 C   s*   dt |  d d }d|d | |d f S )NP         z/*%s %s %s*/r   )r  )r   lnri   ri   rj   r     s   r   c                 C   s$   t | trttfdd| g S | gS )Nc                 S   s   | || S r{   ri   )xyr  ri   ri   rj   <lambda>  s    zflatlist.<locals>.<lambda>)r  r  r   flatlist)lstri   ri   rj   r2    s   
r2  c                 C   s    | r| d dkr| d d S | S )Nr   r   ri   )r   ri   ri   rj   r^     s   r^   r  c              	      s   t  trfdd D S t tr fddD S dt   D ];}|dkr-q&d v r>| d v r> d | }n}t  | trWd| |t | q&d|  | q&S )Nc                    s   g | ]}t | qS ri   r\   r   _m)
defaultsepr  ri   rj   r     r   zreplace.<locals>.<listcomp>c                    s   g | ]}t | qS ri   r4  r5  )r   r7  ri   rj   r     r   r-  separatorsforz#%s#)r  r  r   r\   r
  r2  )r  r   r7  r*  sepri   )r   r7  r  rj   r\     s   

 r\   c                 C   s(  t |tr|D ]}t| |} q| S | D ]|}|d dkrq|| v rt | | tr0| | g| |< t | | trSt || trI| | ||  | |< q| | ||  qt | | trt || tr|dkr||  D ]}|| | vr}|| | | | |< qkqt| | || | |< q|| | |< q| S )Nr   _r8  )r  r  r	   r   r  r  dict)rdarr   r*  k1ri   ri   rj   r	   ,  s4   
r	   c                 C   s  i }t | tr | D ]}t|||}t||}d|v r |S q	|S d| v r,| d |s,|S d| v rEtd| d i||}d|v rEt|d  |  D ]}|dkrV| | ||< qIt | | trgt| | |||< nt | | trg ||< | | D ]}t||i||}	||	v r|| 	|	|  qvn|d dkrqIt | | t
rg ||< | |  D ]l}
t |
tjr|
|rt | | |
 tr| | |
 D ]$}t |t
rtd|i||}d|v r|d }nd	}|| 	t|| qq| | |
 }t |t
r
td|i|}d|v r|d }nd	}|| 	t|| qn
td
t| |   t || trCt|| dkr9|| d ||< || g krC||= qI|S )N_break_checkZneedZneedsr8  r   r:  Z	supertextr  zapplyrules: ignoring rule %s.
r   )r  r  r   r	   r   Zappend_needsr   r  r\   r  r;  typesFunctionTyper
   r  r  )rulesr   rm   retr  rrresr*  r  r=  r>  ri   ri   rj   r   I  s|   



	

r   c                 C   sd   t | }| D ]'\}}||v r+t|| tr&t|tr&t|| |||< q|||< q|||< q|S )a%  Recursively merge two dictionaries into a new dictionary.

    Parameters:
    - dict1: The base dictionary.
    - dict2: The dictionary to merge into a copy of dict1.
             If a key exists in both, the dict2 value will take precedence.

    Returns:
    - A new merged dictionary.
    )r   itemsr  r;  ra   )Zdict1Zdict2Zmerged_dictkeyr   ri   ri   rj   ra     s   

ra   z%\s*python\s*module\s*(?P<name>[\w_]+)z4\s*python\s*module\s*(?P<name>[\w_]*?__user__[\w_]*)c                 C   sp   d }t | (}|D ]}t|}|rt|rq	|d} q&q	W d    |S W d    |S 1 s1w   Y  |S )Nr   )open_f2py_module_name_match_f2py_user_module_name_matchgroup)sourcer   r  linemri   ri   rj   rN     s$   



rN   )r   r   )r  )__doc__pprintre   r   rA  	functoolsr   r   r   r  r   r   __all__versionZf2py_versionstderrrg   r
   r]   rc   rk   r   r[   r   rt   rv   r!   r   r    rK   rI   rJ   r   r   rG   r"   r:   r-   r   r   r+   r?   rR   rV   rQ   rT   r&   r=   r<   r#   r,   rS   rW   r   rU   r   r   r   rH   r   r   rB   rA   r)   r*   rM   rO   r`   r   r   rF   r;   r@   r>   r$   r%   rL   r   rP   r   rC   r(   r   rE   r4   r5   r8   r3   r7   r/   r   r1   r9   r0   r6   r.   r   r   r   r2   rD   r   r   r   r   r   r   r   r   r   r   r   	Exceptionr   r_   rX   rZ   rY   r'   r   r  r   r   r   r   r   r(  r   r   r   r2  r^   r\   r	   r   ra   compileImatchrJ  rK  rN   ri   ri   ri   rj   <module>   s(  



'	
=