HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux spn-python 5.15.0-89-generic #99-Ubuntu SMP Mon Oct 30 20:42:41 UTC 2023 x86_64
User: arjun (1000)
PHP: 8.1.2-1ubuntu2.20
Disabled: NONE
Upload Files
File: //home/arjun/.local/lib/python3.10/site-packages/numpy/f2py/__pycache__/auxfuncs.cpython-310.pyc
o

���g�g�@s|dZddlZddlZddlZddlZddlmZddlmZddl	m
Z
ddl	mZgd�Ze
j
ZejjZejZiZgZdZd	d
�Zdd�Zd
d�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Z dd �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~�ZPdd��ZQd�d��ZRd�d��ZSd�d��ZTd�d��ZUd�d��ZVd�d��ZWd�d��ZXd�d��ZYd�d��ZZd�d��Z[d�d��Z\d�d��Z]d�d��Z^d�d��Z_d�d��Z`d�d��Zad�d��ZbeTd�eUd�eVd�eWd�eZd�eYd�ePd�e^d�e`d�ead�ebd�iZcd�d��Zdd�d��Zed�d��Zfd�d��Zgd�d��Zhd�d��Zid�d��Zjd�d��Zkd�d��Zld�d��Zmd�dÄZnd�dńZoGd�dDŽd�ep�ZqGd�dɄdɃZrd�d˄Zsd�d̈́Ztd�dτZud�dфZvd�dӄZwd�d�dՄZxd�dׄZyifd�dلZzd�dۄZ{d�d݄Z|d�d߄Z}d�d�Z~d�d�Zd�d�Z�d�d�Z�d�d�Z�d�d�Z�d�d�d�Z�d�d�Z�ifd�d�Z�e��d�ej��j�Z�e��d�ej��j�Z�d�d��Z�d�d��Z�d�d�d��Z�dS)�a9
Auxiliary functions for f2py2e.

Copyright 1999 -- 2011 Pearu Peterson all rights reserved.
Copyright 2011 -- present NumPy Developers.
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.
�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�getuseblocks�process_f2cmap_dictcCs t�dd�rtj�|�dSdS)N�verboser)�options�get�sys�stdout�write)�t�rj�F/home/arjun/.local/lib/python3.10/site-packages/numpy/f2py/auxfuncs.pyr[>s�r[cCsdtvS)N�capi)�debugoptions��varrjrjrkrC�rcC�d|vo|ddkot|�S�N�typespec�	character�r(rnrjrjrk�_ischaracterG��rvcCrqrrrurnrjrjrk�	_isstringLrwrxcCst|�od|vS�N�charselector�rvrnrjrjrkr!Q�r!cC�t|�ot|�S�N�r!rrnrjrjrkrU�rcC�t|�ot|�Sr~rrnrjrjrkr Yr|r cCst|�od|vSryr{rnrjrjrkrK]r|rKcCr}r~�rKrrnrjrjrkrIar�rIcCr�r~r�rnrjrjrkrJer|rJcCst|�o|dddkS)N�	dimension���z(*))rJrnrjrjrkrisrcCsd|vot|�S�Nr�rurnrjrjrkror�rcCst|�pt|�pt|�Sr~)rrIr(rnrjrjrkrGssrGcC�t|�o
|�d�dvS�Nrs)�complexzdouble complex�rGrernrjrjrkr"w��r"cC�t|�o
|�d�dkS)Nrs�logicalr�rnrjrjrkr:|�r:cCr�)Nrs�integerr�rnrjrjrkr-�r�r-cCr�)Nrs�realr�rnrjrjrk�isreal�r�r�cCsHz|ddWSty#z	|ddWYSty"YYdSww)N�kindselector�*�kind��KeyErrorrnrjrjrk�get_kind�s��r�cCs$|�d�dkot|�dkot|�S�Nrsr��1)rer�rrnrjrjrkr+�s

��r+cCs*t|�sdS|�d�dvrdSt|�dkS)Nrrs�r�r��8�rGrer�rnrjrjrkr?��
r?cC�*t|�sdS|�d�dkrdSt|�dkS)Nrrsr��-1r�rnrjrjrkrR�r�rRcCr�)Nrrsr��-2r�rnrjrjrkrV�r�rVcCr�)Nrrsr��-4r�rnrjrjrkrQ�r�rQcCr�)Nrrsr��-8r�rnrjrjrkrT�r�rTcC�*t|�sdS|�d�dksdSt|�dkS)Nrrsr�r�r�rnrjrjrkr&�r�r&cCr�)Nrrsr��16r�rnrjrjrkr=�r�r=cCst|�sdSt|�dkS)Nr�32)r"r�rnrjrjrkr<�sr<cCr�r�)rrernrjrjrkr#�r�r#cCs"t|�o|�d�dkot|�dkSr��rrer�rnrjrjrkr,��
�r,cC�"t|�o|�d�dvot|�dkS)Nrsr�r�r�rnrjrjrkrS�r�rScCr�)Nrsr�r�r�rnrjrjrkrW�r�rWcCr�)Nrsr�r�r�rnrjrjrk�isunsignedarray�r�r�cCr�)Nrsr�r�r�rnrjrjrkrU�r�rUcCr�)Nrsr�r�r�rnrjrjrk�issigned_chararray�r�r�cCr�)Nrsr��2r�rnrjrjrk�issigned_shortarray�r�r�cCr�)Nrsr��4r�rnrjrjrk�issigned_array�r�r�cCr�)Nrsr�r�r�rnrjrjrkrHr�rHcC�d|vo	d|dvS)N�attrspec�allocatablerjrnrjrjrkr�rcCsd|vpt|�Sr�)rIrnrjrjrk�	ismutabler�r�cC�d|vS)N�
modulenamerj��routrjrjrkrBrprBcC�d|vo	d|dkS)N�block�modulerjr�rjrjrkrAr�rAcCr�)Nr��functionrjr�rjrjrkr)r�r)cCs"t|�rdStot|�ot|�S�Nr)r/�	wrapfuncsr)r(r�rjrjrkr*sr*cCr�)Nr��
subroutinerjr�rjrjrkrM!r�rMcCst|�rdSt|�o
t|�Sr�)r/rM�hasassumedshaper�rjrjrkrO%�rOcC�d|�dg�vS)N�valuer��rernrjrjrkr`*r|r`cCsV|�d�rdS|dD]}|d�|i��dg�D]}|dkr'd|d<dSqqdS)Nr�T�args�varsr��:Fr�)r��a�drjrjrkr�.s
��r�cC�t|�pt|�Sr~)rBr�r�rjrjrk�requiresf90wrapper9r|r�cCr�r~)r)rMr�rjrjrkrF=r|rFcC�Ft|�sdSd|vr|d}n|d}||dvr!t|d|�SdS�Nr�result�namer�)r)r:�r�r�rjrjrkr;A�
r;cCr�r�)r)r?r�rjrjrkr@Mr�r@cCr�r�)r)r=r�rjrjrkr>Yr�r>cCr�r�)r)r"r�rjrjrkr$er�r$cCst|�r
td�dSdS)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
    **************************************************************
rr)r$r[r�rjrjrkr%qsr%cCr�r�)r)rIr�rjrjrkrLr�rLcC�d|vo|dS)N�	externalsrjr�rjrjrkr�r|rcCr�)N�f2pyenhancements�
threadsaferjr�rjrjrkrP�s
�rPcCr�)Nr�rjr�rjrjrk�hasvariables�r|r�cCs(d|vod|dvod|dvot|�S)Nr��optional�required)r7rnrjrjrkrC�s

��rCcCr�)Nr��externalrjrnrjrjrkr(�r�r(csHd�d|��vr tdd�|dD��r"�fdd�|dD�dSdSdS)Nz	\((.*?)\)r�css�|]}d|vVqdS)r�Nrj)�.0�srjrjrk�	<genexpr>�s�zgetdimension.<locals>.<genexpr>csg|]}t��|��qSrj)�re�findall)r��v��
dimpatternrjrk�
<listcomp>��z getdimension.<locals>.<listcomp>r)�keys�anyrnrjr�rkr�s�rcCst|�ot|�Sr~)rCr7rnrjrjrkrE�r�rEcCspd|vrdSd|dvrdSd|dvrdSd|dvrdSd|dvr&dSd|dvr.dSd	|dvr6dSdS)
N�intentr�hider�inplace�in�out�inout�outinrjrnrjrjrkr4�sr4cCsDd|vo!d|dvsd|dvo!d|dvo!d|dvo!d|dvS)Nr�r�r�r�r�r�rjrnrjrjrkr5�s
�
�
�
�r5cCr�)Nr�r�r�rnrjrjrkr8�r|r8cCs<d|vod|dvpd|dvod|dvottt�|�S)Nr�r�r�r�)rZr5r6rnrjrjrkr3�s�r3cCs
t|�Sr~)r3rnrjrjrkr7��
r7cCr�)N�cr�r�rnrjrjrkr/�r|r/cCr�)N�cacher�r�rnrjrjrk�isintent_cache�r|r�cCr�)N�copyr�r�rnrjrjrkr1�r|r1cCr�)N�	overwriter�r�rnrjrjrkr9�r|r9cCr�)N�callbackr�r�rnrjrjrkr0�r|r0cCr�)Nr�r�r�rnrjrjrkr6�r|r6cCr�)N�auxr�r�rnrjrjrkr.�r|r.cCr�)N�aligned4r�r�rnrjrjrk�isintent_aligned4�r|r�cCr�)N�aligned8r�r�rnrjrjrk�isintent_aligned8�r|r�cCr�)N�	aligned16r�r�rnrjrjrk�isintent_aligned16�r|r��	INTENT_IN�INTENT_INOUT�
INTENT_OUT�INTENT_HIDE�INTENT_CACHE�INTENT_C�OPTIONAL�INTENT_INPLACE�INTENT_ALIGNED4�INTENT_ALIGNED8�INTENT_ALIGNED16cCr�)Nr��privaterjrnrjrjrkrDr�rDcCr�)N�=rjrnrjrjrkr	rprcCst|�sdS|dddvS)Nrr)�"�')rrnrjrjrk�hasinitvalueasstring
r�rcCr�)N�noterjrnrjrjrkrrprcCr�r�)r)rr�rjrjrkrr�rcCr�)N�commonrjr�rjrjrkr#rprcCs4t|�rdSt|�r|dD]	}t|�rdSqdS)Nr�bodyr)rr�containscommon)r��brjrjrkr's�rcCs8t|�rdSt|�sdS|dD]	}t|�rdSqdS)Nrrr)rAr�containsmodule)r�r
rjrjrkr1s�rcCr�)Nrrjr�rjrjrkr<rprcCst|�duSr~)rr�rjrjrkr@srcC�dS)Nrrjrnrjrjrk�istrueD�rcCrr�rjrnrjrjrk�isfalseHrrc@seZdZdS)�	F2PYErrorN)�__name__�
__module__�__qualname__rjrjrjrkrLsrc@seZdZdd�Zdd�ZdS)r_cCs
||_dSr~)�mess)�selfrrjrjrk�__init__Rr�zthrow_error.__init__cCsd||jf}t|��)Nz

  var = %s
  Message: %s
)rr)rrorrjrjrk�__call__Uszthrow_error.__call__N)rrrrrrjrjrjrkr_Psr_cG�Ndg}}tt|��D]}d|||f}|�d|�qtd|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�irjrjrkrXZ�

rXcGr)Nrrrrz or r r&rjrjrkrZbr+rZcCstd�S)Nzlambda v,f=f:not f(v))r$)r'rjrjrkrYjrprYcCs(z	|dddkWStyYdSw)Nr��fortranname�rr�r�rjrjrkr'ns
�r'cCsTz|dd}|dkr
t�|std|d�t�W|Sty)|d}Y|Sw)Nr�r,r-z"Failed to use fortranname from %s
r�)r�r
)r�r�rjrjrkrus���
�rcCs
z	|d�|�}Wn
tyYdSw|sdS|dkr#t|t�r#dSt|t�r4|t|�kr0dS||}|dd�dkr�|rQd|dt|�d|dd�}n|dd�}|dd�dkry|rq|dd�d	t|�d
}|S|dd�}|Std|t|�f�|S)Nr�r�z'''z
	/* start z multiline (z) */
���z
	/* end multiline (z)*/z-%s multiline block should end with `'''`: %s
)rer��
isinstance�str�listr"�reprr
)r��	blockname�comment�counter�rrjrjrk�getmultilineblock�sF�
���
���
�r8cC�
t|d�S)N�
callstatement�r8r�rjrjrkr�r�rc
Cst|ddd�}|r|St|�rtd�dSddlm}gg}}tttt��|�r0|�	ddg�|d	D]J}|d
|}t
|�rAq4||vrL||d}n-||�}tttt
t��|�r[n
t|�r`nt|�sh|d}t|�stt|�stt|�ry|�d�|�|�q4d
�||�}	|	s�d}	|	S)N�callprotoargumentr)r5z<warning: callstatement is defined without callprotoargument
r)�getctypezchar*�size_tr�r��_typedefr��,�void)r8rr[�	capi_mapsr=rXrLrYr*�extendr0r/rZrGr"rIr`rrJr#r%)
r��cb_mapr7r=�	arg_types�
arg_types2�nro�ctype�
proto_argsrjrjrkr
�sH�
��
r
cCr9)N�usercoder;r�rjrjrkr�r�rcCst|ddd�S)NrJr)r6r;r�rjrjrkr�srcCr9)N�pymethoddefr;r�rjrjrkr�r�rcCsvgg}}d|vr7|d}d|vr3|dD]}||vr |�|�q|D]}||vr.|�|�q#||fS|d}||fS)Nr��sortvars)r#)r��sortargsr�r�rjrjrk�getargs�s

�
��rNcs�g��dg�}���fdd��d��D�}|��d�vrA�dD]}|�vr.|�|�q#�D]}||vr<|�|�q1�|fS|�d}�|fS)Nr�cs(g|]}t�d|�r|�vr|�qS)r�)r.)r�r��r�r�rjrkr��s�zgetargs2.<locals>.<listcomp>r�rL)rer�r#)r�rM�auxvarsr�rjrOrkr�s
�
��rcCs<d|vrdSd}|ddkr|d|df}|d�|d�S)N�f2pymultilinesr�z
python moduler�r�)r��krjrjrkr�srcCs*dt|�dd}d|d||dfS)N�P��z/*%s %s %s*/r�)r")r��lnrjrjrkrsrcCs$t|t�rttfdd�|g�S|gS)NcSs|||�Sr~rj)�x�yr'rjrjrk�<lambda>	szflatlist.<locals>.<lambda>)r0r2r�flatlist)�lstrjrjrkrZs
rZcCs |r|ddkr|dd�S|S)Nr�r@rj)r�rjrjrkr^
sr^r-c	s�t�t�r��fdd��D�St�t�r��fdd��D�Sdt����D];}|dkr-q&d�vr>|�dvr>�d|}n�}t�|t�rW��d||�t�|����q&��d|�|��q&�S)Ncsg|]}t�|���qSrj�r\�r��_m)�
defaultsepr1rjrkr�r�zreplace.<locals>.<listcomp>csg|]}t|����qSrjr\r])r�r_rjrkr�r�rU�
separatorsforz#%s#)r0r2r�r\r%rZ)r1r�r_rR�seprj)r�r_r1rkr\s

 r\cCs(t|t�r|D]}t||�}q|S|��D]|}|ddkrq||vr�t||t�r0||g||<t||t�rSt||t�rI||||||<q||�||�qt||t�r�t||t�r�|dkr||��D]}|||vr}||||||<qkqt||||�||<q||||<q|S)Nr�_r`)r0r2r	r�r1r#�dict)�rd�arr�rR�k1rjrjrkr	&s4
���r	cCs�i}t|t�r |D]}t|||�}t||�}d|vr|Sq	|Sd|vr,|d|�s,|Sd|vrEtd|di||�}d|vrEt�|d�|��D]�}|dkrV||||<qIt||t�rgt|||�||<n�t||t�r�g||<||D]}t||i||�}	||	vr�||�	|	|�qvn�|ddkr�qIt||t
��rg||<||��D]l}
t|
tj��r|
|��rt|||
t�r�|||
D]$}t|t
�r�td|i||�}d|vr�|d}nd	}||�	t||��q�q�|||
}t|t
��r
td|i|�}d|v�r|d}nd	}||�	t||��q�n
t
d
t||��t||t��rCt||�dk�r9||d||<||gk�rC||=qI|S)N�_break�_check�need�needsr`rrb�	supertextr-zapplyrules: ignoring rule %s.
r)r0r2rr	r�append_needsr�r1r\r#rc�types�FunctionTyper
r3r")�rulesr�ro�retr7�rr�resrRr*rerfrjrjrkrCs|

���

�	

���rz%\s*python\s*module\s*(?P<name>[\w_]+)z4\s*python\s*module\s*(?P<name>[\w_]*?__user__[\w_]*)cCspd}t|��(}|D]}t|�}|rt|�rq	|�d�}n	q	Wd�|SWd�|S1s1wY|S)Nr�)�open�_f2py_module_name_match�_f2py_user_module_name_match�group)�sourcer�r'�line�mrjrjrkrN�s$

��
��
��rNcCsLg}|dD]}|dD]}|�d�r"|�dd�|�d���D��qq|S)Nr�usecSsg|]}d|vr|�qS)�__rj)r�rWrjrjrkr��r�z getuseblocks.<locals>.<listcomp>)rerCr�)�pymod�all_uses�inner�modblockrjrjrkra�s
��raFcCs�g}i}|��D]\}}dd�|��D�}|||��<q|��D]U\}}||vr,i||<|��D]D\}	}
|
|vrc|	||vrLtd||	|||	|
f�|
|||	<|r]td||	|
f�|�|
�q0|rttd||	|
|
t|���f�q0q ||fS)a�
    Update the Fortran-to-C type mapping dictionary with new mappings and
    return a list of successfully mapped C types.

    This function integrates a new mapping dictionary into an existing
    Fortran-to-C type mapping dictionary. It ensures that all keys are in
    lowercase and validates new entries against a given C-to-Python mapping
    dictionary. Redefinitions and invalid entries are reported with a warning.

    Parameters
    ----------
    f2cmap_all : dict
        The existing Fortran-to-C type mapping dictionary that will be updated.
        It should be a dictionary of dictionaries where the main keys represent
        Fortran types and the nested dictionaries map Fortran type specifiers
        to corresponding C types.

    new_map : dict
        A dictionary containing new type mappings to be added to `f2cmap_all`.
        The structure should be similar to `f2cmap_all`, with keys representing
        Fortran types and values being dictionaries of type specifiers and their
        C type equivalents.

    c2py_map : dict
        A dictionary used for validating the C types in `new_map`. It maps C
        types to corresponding Python types and is used to ensure that the C
        types specified in `new_map` are valid.

    verbose : boolean
        A flag used to provide information about the types mapped

    Returns
    -------
    tuple of (dict, list)
        The updated Fortran-to-C type mapping dictionary and a list of
        successfully mapped C types.
    cSsi|]	\}}|��|�qSrj)�lower)r�rf�v1rjrjrk�
<dictcomp>�sz'process_f2cmap_dict.<locals>.<dictcomp>z3	Warning: redefinition of {'%s':{'%s':'%s'->'%s'}}
z	Mapping "%s(kind=%s)" to "%s"
z5	Ignoring map {'%s':{'%s':'%s'}}: '%s' must be in %s
)�itemsr�r[r#r
r2r�)�
f2cmap_all�new_map�c2py_maprc�
f2cmap_mapped�
new_map_lowerrR�d1�d1_lowerrfr�rjrjrkrb�s:&������rb)rr)r-)F)��__doc__�pprintrfr�rm�	functoolsrr�rr-rr�__all__�version�f2py_version�stderrrhr
r]rdrmr�r[rrvrxr!rr rKrIrJrrrGr"r:r-r�r�r+r?rRrVrQrTr&r=r<r#r,rSrWr�rUr�r�r�rHrr�rBrAr)r*rMrOr`r�r�rFr;r@r>r$r%rLrrPr�rCr(rrEr4r5r8r3r7r/r�r1r9r0r6r.r�r�r�r2rDrrrrrrrrrrr�	Exceptionrr_rXrZrYr'rr8rr
rrrrNrrrrZr^r\r	r�compile�I�matchrtrurNrarbrjrjrjrk�<module>s*

�


'	
=����