VfimdZddlZddlZddlZddlZddlmZddlmZm Z ddl m Z gdZ ej Z ejZiZgZdZdZd Zd Zd Zd Zd ZdZdZdZdZdZdZdZdZdZ dZ!dZ"dZ#dZ$dZ%dZ&dZ'dZ(dZ)d Z*d!Z+d"Z,d#Z-d$Z.d%Z/d&Z0d'Z1d(Z2d)Z3d*Z4d+Z5d,Z6d-Z7d.Z8d/Z9d0Z:d1Z;d2Zd5Z?d6Z@d7ZAd8ZBd9ZCd:ZDd;ZEd<ZFd=ZGd>ZHd?ZId@ZJdAZKdBZLdCZMdDZNdEZOdFZPdGZQdHZRdIZSdJZTdKZUdLZVdMZWdNZXdOZYdPZZdQZ[dRZ\dSZ]dTZ^dUZ_eQdVeRdWeSdXeTdYeWdZeVd[eLd\e[d]e]d^e^d_e_d`i Z`daZadbZbdcZcddZddeZedfZfdgZgdhZhdiZidjZjdkZkdlZldmZmdnZndoZoGdpdqepZqGdrdsZrdtZsduZtdvZudwZvdxZwddyZxdzZyifd{Zzd|Z{d}Z|d~Z}dZ~dZdZdZdZdZddZdZifdZejdejjZejdejjZdZdZddZdS)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) __version__cfuncs)errmess)` applyrules debugcapi dictappendrgentitlegetargs2getcallprotoargumentgetcallstatementgetfortrannamegetpymethoddef getrestdoc getusercode getusercode1 getdimensionhasbodyhascallstatement hascommon hasexternals hasinitvaluehasnote hasresultnote isallocatableisarrayisarrayofstrings ischaracterischaracterarrayischaracter_or_characterarray iscomplexiscstyledirectiveiscomplexarrayiscomplexfunctioniscomplexfunction_warnisdoubleisdummyroutine isexternal isfunctionisfunction_wrapisint1 isint1array isinteger isintent_aux isintent_cisintent_callback isintent_copy isintent_dict isintent_hide isintent_inisintent_inoutisintent_inplaceisintent_nothide isintent_outisintent_overwrite islogicalislogicalfunctionislong_complex islong_doubleislong_doublefunction islong_longislong_longfunctionismoduleismoduleroutine isoptional isprivate isvariable isrequired isroutineisscalarissigned_long_longarrayisstring isstringarrayisstring_or_stringarrayisstringfunction issubroutineget_f2py_modulenameissubroutine_wrap isthreadsafe isunsignedisunsigned_charisunsigned_chararrayisunsigned_long_longisunsigned_long_longarrayisunsigned_shortisunsigned_shortarrayl_andl_notl_oroutmessreplaceshow stripcomma throw_error isattr_value getuseblocksprocess_f2cmap_dictcontainscommoncontainsderivedtypesc~tddr!tj|dSdS)Nverboser)optionsgetsysstdoutwrite)ts Bc:\PYTHON\DbComparer\venv\Lib\site-packages\numpy/f2py/auxfuncs.pyr]r];s>{{9a   cdtvS)Ncapi) debugoptionsvars ror r @s \ !!rpcBd|vo|ddkot| SNtypespec characterr)rts ro _ischaracterr{D0   ZK!? # rpcBd|vo|ddkot| Srwrzrts ro _isstringr~Ir|rpc(t|od|vSN charselectorr{rts ror!r!Ns    :s!::rpc@t|ot| SNr!rrts rorrRs ( - - Bgcll2BBrpc>t|ot|Srrrts ror r Vs ( - - >'#,,>rpc(t|od|vSrrrts rorMrMZs    63!66rpc@t|ot| SrrMrrts rorKrK^s "3 ' ' < ,<t|ot|Srrrts rorLrLbs "3 ' ' 8GCLL8rpcDt|o|dddkS)N dimensionz(*))rLrts rorrfs&    ?#k"22"6%"??rpc*d|vot| SNrrzrts rorrls #  5joo"55rpc^t|pt|pt| Sr)rrKr)rts rorIrIps' @ @C AArpcNt|o|ddvSNrx)complexzdouble complexrIrjrts ror"r"ts, C== @ 77:  "? ?@rpcRt|o|ddkS)Nrxlogicalrrts ror;r;y$ C== =SWWZ00I==rpcRt|o|ddkS)Nrxintegerrrts ror.r.}rrpcRt|o|ddkS)Nrxrealrrts roisrealrs$ C== :SWWZ00F::rpc |ddS#t$r$ |ddcYS#t$rYYdSwxYwwxYw)N kindselector*kindKeyErrorrts roget_kindrsq>"3''  ~&v. . . .    DDD s  > +> :>:>cz|ddko"t|dkot| SNrxr1)rjrrrts ror,r,s? 77:  ) + 6 SMMS  6)0%56rpc|t|sdS|ddvrdSt|dkS)Nrrxrr8rIrjrrts ror@r@sC C==q wwz"888q C==C rpct|sdS|ddkrdSt|dkS)Nrrxr-1rrts rorTrTB C==q wwzi''q C==D  rpct|sdS|ddkrdSt|dkS)Nrrxr-2rrts rorXrXrrpct|sdS|ddkrdSt|dkS)Nrrxr-4rrts rorSrSrrpct|sdS|ddkrdSt|dkS)Nrrxr-8rrts rorVrVrrpct|sdS|ddksdSt|dkS)Nrrxrrrrts ror'r'sB C==q 77:  & ( (q C==C rpct|sdS|ddksdSt|dkS)Nrrxr16rrts ror>r>sB C==q 77:  & ( (q C==D  rpcJt|sdSt|dkS)Nr32)r"rrts ror=r=s& S>>q C==D  rpcNt|o|ddvSr)rrjrts ror$r$s, 3<< @ 77:  "? ?@rpcxt|o+|ddkot|dkSrrrjrrts ror-r-s; 3<< !CGGJ//9< ! SMMS !rpctt|o)|ddvot|dkS)Nrxrrrrts rorUrU< 3<< "CGGJ//3II " SMMT !"rpctt|o)|ddvot|dkS)Nrxrrrrts rorYrYrrpctt|o)|ddvot|dkS)Nrxrrrrts roisunsignedarrayrrrpctt|o)|ddvot|dkS)Nrxrrrrts rorWrWrrpctt|o)|ddvot|dkS)Nrxrrrrts roissigned_chararrayr< 3<< !CGGJ//3II ! SMMS !rpctt|o)|ddvot|dkS)Nrxr2rrts roissigned_shortarrayrrrpctt|o)|ddvot|dkS)Nrxr4rrts roissigned_arrayrrrpctt|o)|ddvot|dkS)Nrxrrrrts rorJrJrrpcd|vo d|dvS)Nattrspec allocatablerts rorrs   A#j/!AArpc*d|vpt| Sr)rKrts ro ismutablers3&7(3-- 88rpc d|vS)N modulenamerrouts rorCrC s 4 rpc"d|vo d|dkS)Nblockmodulerrs rorBrBs d? 8x4=88rpc"d|vo d|dkS)Nrfunctionrrs ror*r*s d? :zT']::rpcpt|rdStot|ot| SNr)r0 wrapfuncsr*r)rs ror+r+s:$q  DD)) D:d3C3C/CDrpc"d|vo d|dkS)Nr subroutinerrs rorOrOs d? <|tG}<t|pt|Sr)rCrrs rorequiresf90wrapperr6s 4 9OD$9$99rpc>t|pt|Sr)r*rOrs rorHrH:s d   1|D111rpct|sdSd|vr |d}n|d}||dvrt|d|SdSNrresultnamer)r*r;rrs ror<r<>` d  q4 N LDLfa))) 1rpct|sdSd|vr |d}n|d}||dvrt|d|SdSr)r*r@rs rorArAJs` d  q4 N LDL4<?+++ 1rpct|sdSd|vr |d}n|d}||dvrt|d|SdSr)r*r>rs ror?r?Vs` d  q4 N LDLT&\!_--- 1rpct|sdSd|vr |d}n|d}||dvrt|d|SdSr)r*r"rs ror%r%brrpcFt|rtddSdS)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]rs ror&r&ns9 H I I Iq 1rpct|sdSd|vr |d}n|d}||dvrt|d|SdSr)r*rKrs rorNrN|s` d  q4 N LDLV Q((( 1rpcd|vo|dS)N externalsrrs rorrs $  44 #44rpcd|vo d|dvS)Nf2pyenhancements threadsaferrs rorRrRs"  % 4 4 23 34rpcd|vo|dS)Nrrrs ro hasvariablesrs T> *d6l*rpcPd|vo"d|dvod|dvot|S)Nroptionalrequired)r8rts rorDrDsB #  .*J"? . c*o - I3CC3H3HIrpcd|vo d|dvS)Nrexternalrrts ror)r)s   >s:!>>rpcdd|vr@td|dDr#tfd|dDSdSdS)Nz \((.*?)\)rc3K|]}d|vV dS)rNr).0ss ro zgetdimension..s'99A{a999999rpc3BK|]}tj|VdSr)refindall)rv dimpatterns ror zgetdimension..s/KKa :q11KKKKKKrp)keysanynext)rurs @rorrszJSXXZZ 99Z999 9 9 LKKKK3z?KKKKK K  L Lrpc@t| ot|Sr)rDr8rts rorGrGs#  8#3C#8#88rpcBhd}tfd|DS)N> pymethoddef callstatementcallprotoargumentc3DK|]}|vVdSrlower)r directive f2py_lines ror z$iscstyledirective..s2JJ)yIOO---JJJJJJrp)r)r directivess` ror#r#s1FFFJ JJJJzJJJ J JJrpcd|vrdSd|dvrdSd|dvrdSd|dvrdSd|dvrdSd|dvrdSd |dvrdSdS) Nintentrhiderinplaceinoutinoutoutinrrts ror5r5ssq XqCM!!q s8}q H q#h-q#h-q 1rpcnd|vo1d|dvs d|dvod|dvod|dvo d|dvS)Nrr#r$r!rr rrts ror6r6sg O KCM!9"% s8} $ K*.c(m*C K #h- ' K,5S],JLrpc2d|dgvS)Nr"rrrts ror9r9 CGGHb)) ))rpcd|voAd|dvp7d|dvo-d|dvo#ttt| S)Nrrr"r!)r\r6r7rts ror4r4sd O D3x=!8"C c(m #BCM(AB;T.*:;;C@@@Erpc"t| Sr)r4rts ror8r8sS!! !!rpc2d|dgvS)Ncrrrts ror0r0s #''(B'' ''rpc2d|dgvS)Ncacherrrts roisintent_cacher.s cggh++ ++rpc2d|dgvS)Ncopyrrrts ror2r2s SWWXr** **rpc2d|dgvS)N overwriterrrts ror:r: #''(B// //rpc2d|dgvS)Ncallbackrrrts ror1r1 2.. ..rpc2d|dgvS)Nr rrrts ror7r7s "-- --rpc2d|dgvS)Nauxrrrts ror/r/r'rpc2d|dgvS)Naligned4rrrts roisintent_aligned4r<r6rpc2d|dgvS)Naligned8rrrts roisintent_aligned8r?r6rpc2d|dgvS)N aligned16rrrts roisintent_aligned16rBr3rp INTENT_IN INTENT_INOUT INTENT_OUT INTENT_HIDE INTENT_CACHEINTENT_COPTIONALINTENT_INPLACEINTENT_ALIGNED4INTENT_ALIGNED8INTENT_ALIGNED16cd|vo d|dvS)Nrprivaterrts rorErEs   =c*o!==rpc^t|dkrd|vr|dddvrd}nd}|S)Nrrr)publicrOFTlen)ruis_vars rorFrF sA 3xx1}}s**  OA "7 7 7 Mrpc d|vS)N=rrts rorrs #:rpcDt|sdS|dddvS)NrrV)"')rrts rohasinitvalueasstringrZs*   q s8A;* $$rpc d|vS)Nnoterrts rorrs S=rpct|sdSd|vr |d}n|d}||dvrt|d|SdSr)r*rrs rorr"s` d  q4 N LDLtF|A''' 1rpc d|vS)Ncommonrrs rorr.s t rpct|rdSt|r|dD]}t|rdSdSNrbodyr)rrrerbs rorere2sWqt}}f  Aa   qq  1rpc"d|vo |ddkS)Nrtyperrs rohasderivedtypesrg<s tO 8g&!88rpct|rdSt|r|dD]}t|rdSdSra)rgrrcs rorfrf@sYtqt}}f  Aq!! qq  1rpct|rdSt|sdS|dD]}t|rdSdS)Nrrrb)rBrcontainsmodule)rrds rorjrjJs\q 5>>q 6] !   11  1rpc d|vS)Nrbrrs rorrUs T>rpc$t|duSr)rrs rorrYs D ! ! --rpcdS)Nrrrts roistruern] 1rpcdSrrrts roisfalserqarorpceZdZdS) F2PYErrorN)__name__ __module__ __qualname__rrprorsrsesDrprsceZdZdZdZdS)rac||_dSr)mess)selfrys ro__init__zthrow_error.__init__ks  rpc<d|d|jd}t|)Nz var = z Message:  )ryrs)rzrurys ro__call__zthrow_error.__call__ns(=c== ===oorpN)rtrurvr{r~rrprorarais2rpracdg}}tt|D]"}d|||fz}|d|z#t|dd|S)Nlambda v %s,f%d=f[%d]f%d(v)rz and rangerSappendevaljoinfl1l2is rorZrZssw B 3q66]]"" r1aj ( (a.!!!! 2** R((** + ++rpcdg}}tt|D]"}d|||fz}|d|z#t|dd|S)Nrrrrz or rrs ror\r\{su B 3q66]]"" r1aj ( (a.!!!! 2)) B)) * **rpc tdS)Nzlambda v,f=f:not f(v))r)rs ror[r[s ' ( ((rpcJ |dddkS#t$rYdSwxYw)Nr fortrannamerrrs ror(r(s?&' 6"<< qqs  ""c |dd}|dkrt|s td|ddtn#t$r |d}YnwxYw|S)NrrrzFailed to use fortranname from r}r)rr)rrs rorrs&' 6 2::N  Rd;M6NRRR S S SN  F| Ks=AAAcF |d|}n#t$rYdSwxYw|sdS|dkrt|trdSt|tr|t |krdS||}|dddkr|r'd|zdzt |zdz|ddz}n |dd}|dddkr.|r!|ddd zt |zd z}n-|dd}n"t|d t |d |S) Nrrz'''z /* start z multiline (z) */ z /* end multiline (z)*/z( multiline block should end with `'''`: r})rjr isinstancestrlistrSreprr)r blocknamecommentcounterrs rogetmultilineblockrsx # $ ( ( 3 3  {{z!S)){!T c!ff   F gJ!u~~   )!%g/19:<=abbEBAA!""A RSS6U?? crcF55W EMcrcF yUU$q''UUU V V V Hs  ,,c"t|dS)Nrrrs rorrs T? 3 33rpc 8t|dd}|r|St|rtddSddlm}gg}}t t tt|r| ddg|d D]}|d |}t|r ||vr ||d z}n||}t tttt|rn$t|rnt!|s|d z}t|st#|st%|r|d||d ||z} | sd} | S)Nrr)rzrpc<gdgc}fddD}|zdvrCdD]}|vr||D]}||vr||n |dz}|fS)NrcRg|]#}td|r|v!|$S)r)r/)rrrrs ro zgetargs2..s@"""Qd6l1o1N1N"D== ==rprr)rjrr)rrauxvarsrrs` @ror r s&"--NHd"""""$v,++--"""G T>DTj! # #ADyy""" # #A  """ #T&\) >rpcd|vrdSd}|ddkr|d|df}|d|dS)Nf2pymultilinesrz python modulerr)rks rorrsTt##t A G}'' M4< '  ! % %a . ..rpcVdt|z dz dz}d|dzd|d|dzdS)NPz/*r z*/rR)rlns ror r sD s4yy.1  "B .S . .4 . ."s( . . ..rpcdt|trttfd|gS|gS)Nc|||zSrr)xyrs rozflatlist..sq11Q44xrp)rrrflatlist)lsts rorrs7#tBX777bAAA 5Lrpc6|r|ddkr |ddS|S)Nrrr)rs ror`r`#s(QrUc\\"v Hrprc .ttrfdDSttrfdDSdtzD]}|dkr dvr|dvrd|}n}t|trAd|d|t |d|d|S)Nc2g|]}t|Srr^)r_m defaultseprs rorzreplace..+s%999R,,999rpc2g|]}t|Srr)rrrrs rorzreplace..-s%999rAz**999rpr separatorsfor#)rrrr^rr)rrrrseps``` ror^r^)s2!T:99999q9999#t:99999S9999 affhh  . .     a  A?);$;$;O$Q'CCC adD ! ! .++h!hhh!A$(@(@AACC++h!hhh!--CC Jrpc,t|tr|D]}t||}|S|D]Q}|ddkr||vr1t||tr ||g||<t||trRt||tr||||z||<||||t||t rt||t re|dkr@||D]#}|||vr||||||<$%t||||||<F||||<S|S)Nr_r)rrr rrrdict)rdarrrk1s ror r <s"d # #AB""BB WWYY Q43;;  77"Q%%% A1"Q%&& 9beT**(qEBqEMBqEEqELLA''''BqE4(( 9beT**9O++"$Q%**,,66B!A,.qE"I1b 6!+2a5"Q% 8 81qEBqEE Irpc i}t|tr.|D])}t|||}t||}d|vrn*|Sd|vr|d|s|Sd|vr7td|di||}d|vrt j|d|D]}|dkr ||||<t||trt|||||<nt||trJg||<||D]:}t||i||} || vr!|| | |;n|ddkrt||trZg||<||D]8} t| tj r| |rt||| try||| D]i}t|tr)td|i||}| dd }|| t||j||| }t|tr(td|i|}| dd }|| t||:n&td t||d t||tr9t!||d kr||d||<||gkr||=|S) N_break_checkneedneedsrrr supertextrzapplyrules: ignoring rule z. r)rrrr r append_needsrrr^rrtypes FunctionTyperjrrrS) rulesrruretrrrresrrrrs rorrYs C%  AAq#&&BS"%%C2~~ 5/%/#"6"6  '5=11c:: c>>  G - - - ZZ\\$$   1XCF  eAh $ $ FU1Xq))CFF a$ ' ' FCF1X ) )A3//77FMM"Q%((( )qTS[[  a$ ' ' FCFAhmmoo 5 5b%"455 5""S'' 5!%(2,55 5!&q"99A)!T22=&0+q1A1c&J&J$'GGK$<$<FMM'!Q--8888 9 "!HRL%a..9",k1-=q"A"AC # R 8 8AA gamm444 5 DeAhDDD E E E c!fd # # 3q6{{aQA1v||F Jrpz%\s*python\s*module\s*(?P[\w_]+)z4\s*python\s*module\s*(?P[\w_]*?__user__[\w_]*)cd}t|5}|D]:}t|}|r't|r#|d}n;dddn #1swxYwY|S)Nr)open_f2py_module_name_match_f2py_user_module_name_matchgroup)sourcerrlinems rorPrPs D f  D'--A /55wwv   Ks>AA #A cg}|dD]f}|dD][}|drD|d|dD\g|S)Nrbusecg|]}d|v| S)__r)rrs rorz getuseblocks..s X X Xq$VW-----rp)rjrr)pymodall_usesinnermodblocks rorcrcsHvZZf  Z ZH||E"" Z X XHLL,?,?,D,D,F,F X X XYYY Z OrpFcg}i}|D]:\}}d|D}|||<;|D]\}}||vri||<|D]\} } | |vrn| ||vr(td|d| d||| d| d | ||| <|rtd|d| d | d || w|r>t d |d| d| d | d t |d ||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. c>i|]\}}||Srr)rrv1s ro z'process_f2cmap_dict..s&<<'z'}} z Mapping "z(kind=z)" to "z" z Ignoring map {'z'}}: 'z ' must be in r})itemsrr]rrrr) f2cmap_allnew_mapc2py_maprh f2cmap_mapped new_map_lowerrd1d1_lowerrrs rordrdsLMM,,2<<<<<#+ aggii  $$&&2 J  JqMhhjj  FBX~~A&&G11bbb*Q-"3"3"3RRR9%' 1 b!HF!FF2FFbFFFGGG$$R(((( qq"""bbb"""d8==??&;&;&;&;= " } $$rp)rr)r)F)__doc__pprintr rkr functoolsrrrrr__all__version f2py_versionr_rirsrr]r r{r~r!rr rMrKrLrrrIr"r;r.rrr,r@rTrXrSrVr'r>r=r$r-rUrYrrWrrrrJrrrCrBr*r+rOrQrbrrrHr<rAr?r%r&rNrrRrrDr)rrGr#r5r6r9r4r8r0r.r2r:r1r7r/r<r?rBr3rErFrrZrrrrergrfrjrrrnrq ExceptionrsrarZr\r[r(rrrr rrrrr rr rr`r^r rcompileImatchrrrPrcrdrrprors   !!!!!!!!   :" }   """  ;;;CCC???777===999@@@ 666BBB@@@ >>>>>>;;;666    !!!!!!!!!!!!   !!!!!! @@@ !!! """ """ """ """ !!! !!! !!! !!! BBB999   999;;;EEE ===888 ...:::222                        555444 +++III ???LLL999KKK    $LLL ***EEE """(((,,,+++000///...***//////000k>>|]MZZ!#3"$5"$5#%7 >>>%%%        999      ...              ,,,+++)))       :444')####L///:::222    "//////     &: 5555p%"*%M%'T+++0)rz+=>@d D DDI   B%B%B%B%B%B%rp