K i(i\dZddlZddlZddlZddlZddlmZddlmZm Z ddl m Z gdZ ejZ 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~dZdZdZdZdZddZdZifdZejdejjZejdejjZdZdZddZy)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_dictcontainscommoncontainsderivedtypescptjddr tjj |yy)Nverboser)optionsgetsysstdoutwrite)ts Y/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/numpy/f2py/auxfuncs.pyr]r];s'{{9a  !cdtvS)Ncapi) debugoptionsvars ror r @s \ !!rpc:d|vxr|ddk(xr t| SNtypespec characterr)rts ro _ischaracterr{D.   ZK!? # rpc:d|vxr|ddk(xr t| Srwrzrts ro _isstringr~Ir|rpc$t|xrd|vSN charselectorr{rts ror!r!Ns   :s!::rpc4t|xr t| SNr!rrts rorrRs ( - Bgcl2BBrpc2t|xr t|Srrrts ror r Vs ( - >'#,>rpc$t|xrd|vSrrrts rorMrMZs   63!66rpc4t|xr t| SrrMrrts rorKrK^s "3 ' < ,<"3''  ~&v. .   s  // +/+/cf|jddk(xrt|dk(xr t| SNrxr1)rjrrrts ror,r,s8 77: ) + 6 SMS  6)0%56rpc^t|sy|jddvryt|dk(S)Nrrxrr8rIrjrrts ror@r@s0 C= wwz"88 C=C rpc`t|sy|jddk7ryt|dk(S)Nrrxr-1rrts rorTrT/ C= wwzi' C=D  rpc`t|sy|jddk7ryt|dk(S)Nrrxr-2rrts rorXrXrrpc`t|sy|jddk7ryt|dk(S)Nrrxr-4rrts rorSrSrrpc`t|sy|jddk7ryt|dk(S)Nrrxr-8rrts rorVrVrrpc`t|sy|jddk(syt|dk(S)Nrrxrrrrts ror'r's/ C= 77: & ( C=C rpc`t|sy|jddk(syt|dk(S)Nrrxr16rrts ror>r>s/ C= 77: & ( C=D  rpc6t|syt|dk(S)Nr32)r"rrts ror=r=s S> C=D  rpcBt|xr|jddvSr)rrjrts ror$r$s' 3< @ 77: "? ?@rpcdt|xr$|jddk(xrt|dk(Srrrjrrts ror-r-s4 3< !CGGJ/9< ! SMS !rpcbt|xr#|jddvxrt|dk(S)Nrxrrrrts rorUrU5 3< "CGGJ/3II " SMT !"rpcbt|xr#|jddvxrt|dk(S)Nrxrrrrts rorYrYrrpcbt|xr#|jddvxrt|dk(S)Nrxrrrrts roisunsignedarrayrrrpcbt|xr#|jddvxrt|dk(S)Nrxrrrrts rorWrWrrpcbt|xr#|jddvxrt|dk(S)Nrxrrrrts roissigned_chararrayr5 3< !CGGJ/3II ! SMS !rpcbt|xr#|jddvxrt|dk(S)Nrxr2rrts roissigned_shortarrayrrrpcbt|xr#|jddvxrt|dk(S)Nrxr4rrts roissigned_arrayrrrpcbt|xr#|jddvxrt|dk(S)Nrxrrrrts rorJrJrrpcd|vxrd|dvS)Nattrspec allocatablerts rorrs   A#j/!AArpc&d|vxs t| Sr)rKrts ro ismutablers3&7(3- 88rpc d|vS)N modulenamerrouts rorCrC s 4 rpcd|vxrd|dk(S)Nblockmodulerrs rorBrBs d? 8x4=88rpcd|vxrd|dk(S)Nrfunctionrrs ror*r*s d? :zT']::rpc\t|rytxrt|xr t| SNr)r0 wrapfuncsr*r)rs ror+r+s*$  DD) D:d3C/CDrpcd|vxrd|dk(S)Nr subroutinerrs rorOrOs d? <|tG}<I d 4 N LDLfa)) rpcjt|syd|vr|d}n|d}||dvrt|d|Syr)r*r@rs rorArAJsI d 4 N LDL4<?++ rpcjt|syd|vr|d}n|d}||dvrt|d|Syr)r*r>rs ror?r?VsI d 4 N LDLT&\!_-- rpcjt|syd|vr|d}n|d}||dvrt|d|Syr)r*r"rs ror%r%brrpc2t|r tdyy)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&ns!H I rpcjt|syd|vr|d}n|d}||dvrt|d|Syr)r*rKrs rorNrN|sI d 4 N LDLV Q(( rpcd|vxr|dS)N externalsrrs rorrs $  44 #44rpcd|vxrd|dvS)Nf2pyenhancements threadsaferrs rorRrRs"  % 4 4 23 34rpcd|vxr|dS)Nrrrs ro hasvariablesrs T> *d6l*rpcHd|vxrd|dvxrd|dvxr t|S)Nroptionalrequired)r8rts rorDrDs? #  .*J"? . c*o - I3CC3HIrpcd|vxrd|dvS)Nrexternalrrts ror)r)s   >s:!>>rpcdd|jvr-td|dDrtfd|dDSyy)Nz \((.*?)\)rc3$K|]}d|v yw)rNr).0ss ro zgetdimension..s9A{a9sc3JK|]}tj|ywr)refindall)rv dimpatterns ror zgetdimension..sKa :q1Ks #)keysanynext)rurs @rorrsGJSXXZ 9Z9 9K3z?KK K : rpc4t| xr t|Sr)rDr8rts rorGrGs#  8#3C#88rpc4hd}tfd|DS)N> pymethoddef callstatementcallprotoargumentc3BK|]}|jvywr)lower)r directive f2py_lines ror z$iscstyledirective..sJ)yIOO--Js)r)r directivess` ror#r#sFJ JzJ JJrpcnd|vryd|dvryd|dvryd|dvryd|dvryd|dvryd |dvryy) Nintentrhiderinplaceinoutinoutoutinrrts ror5r5sjs XCM! s8} H #h-#h- rpcdd|vxr+d|dvxsd|dvxrd|dvxrd|dvxrd|dvS)Nrr"r#r rrrrts ror6r6sg O KCM!9"% s8} $ K*.c(m*C K #h- ' K,5S],JLrpc*d|jdgvS)Nr!rrrts ror9r9 CGGHb) ))rpczd|vxr6d|dvxs-d|dvxr$d|dvxrttt| S)Nrrr!r )r\r6r7rts ror4r4s^ O D3x=!8"C c(m #BCM(AB;T.*:;C@@Erpct| Sr)r4rts ror8r8sS! !!rpc*d|jdgvS)Ncrrrts ror0r0s #''(B' ''rpc*d|jdgvS)Ncacherrrts roisintent_cacher-s cggh+ ++rpc*d|jdgvS)Ncopyrrrts ror2r2s SWWXr* **rpc*d|jdgvS)N overwriterrrts ror:r: #''(B/ //rpc*d|jdgvS)Ncallbackrrrts ror1r1 2. ..rpc*d|jdgvS)Nrrrrts ror7r7s "- --rpc*d|jdgvS)Nauxrrrts ror/r/r&rpc*d|jdgvS)Naligned4rrrts roisintent_aligned4r;r5rpc*d|jdgvS)Naligned8rrrts roisintent_aligned8r>r5rpc*d|jdgvS)N aligned16rrrts roisintent_aligned16rAr2rp INTENT_IN INTENT_INOUT INTENT_OUT INTENT_HIDE INTENT_CACHEINTENT_COPTIONALINTENT_INPLACEINTENT_ALIGNED4INTENT_ALIGNED8INTENT_ALIGNED16cd|vxrd|dvS)Nrprivaterrts rorErEs   =c*o!==rpcJt|dk(rd|vr|dddvrd}|Sd}|S)Nrrr)publicrNFTlen)ruis_vars rorFrF s> 3x1}s*  OA "7 7 M Mrpc d|vS)N=rrts rorrs #:rpc.t|sy|dddvS)NrrU)"')rrts rohasinitvalueasstringrYs   s8A;* $$rpc d|vS)Nnoterrts rorrs S=rpcjt|syd|vr|d}n|d}||dvrt|d|Syr)r*rrs rorr"sI d 4 N LDLtF|A'' rpc d|vS)Ncommonrrs rorr.s t rpc`t|ryt|r|dD]}t|syyNrbodyr)rrrerbs rorere2s6t}f Aa   rpcd|vxr|ddk(S)Nrtyperrs rohasderivedtypesrf<s tO 8g&!88rpc`t|ryt|r|dD]}t|syyr`)rfrrbs rorfrf@s7tt}f Aq!  rpcbt|ryt|sy|dD]}t|syy)Nrrra)rBrcontainsmodule)rrcs roririJs9 5> 6] !  rpc d|vS)Nrarrs rorrUs T>rpct|duSr)rrs rorrYs D ! --rpcy)Nrrrts roistruerm] rpcyrrrts roisfalserparnrpc eZdZy) F2PYErrorN)__name__ __module__ __qualname__rrprorrrresrprrceZdZdZdZy)rac||_yr)mess)selfrxs ro__init__zthrow_error.__init__ks  rpc>d|d|jd}t|)Nz var = z Message:  )rxrr)ryrurxs ro__call__zthrow_error.__call__ns$cU- {"=orpN)rsrtrurzr}rrprorarais rpracdg}}tt|D]}d|||fz}|jd|z t|ddj |S)Nlambda v %s,f%d=f[%d]f%d(v)rz and rangerRappendevaljoinfl1l2is rorZrZssd B 3q6]" r1aj ( (a.!" 2$a R()* ++rpcdg}}tt|D]}d|||fz}|jd|z t|ddj |S)Nrrrrz or rrs ror\r\{sc B 3q6]" r1aj ( (a.!" 2$a B() **rpctdS)Nzlambda v,f=f:not f(v))r)rs ror[r[s ' ((rpc8 |dddk(S#t$rYywxYw)Nr fortrannamerrrs ror(r(s/&' 6"<< s c |dd}|dk(rt|std|ddt |S#t$r |d}Y|SwxYw)NrrrzFailed to use fortranname from r|r)rr)rrs rorrso&' 6 2:N 5d;M6N5OrR SN K F| Ks-2AAc |dj|}|sy|dkDrt|tryt|tr|t |k\ry||}|dddk(ri|rd|zdzt |zdz|ddz}n|dd}|dddk(r"|r|ddd zt |zd z}|S|dd}|St|d t |d |S#t$rYywxYw) Nrrz'''z /* start z multiline (z) */ z /* end multiline (z)*/z( multiline block should end with `'''`: r|)rjr isinstancestrlistrRreprr)r blocknamecommentcounterrs rogetmultilineblockrs, # $ ( ( 3 {z!S)!T c!f   gJ!u~  )!%g/19:<=abEBA!"A RS6U?crF55W EM HcrF H yk!I$q'RTU V H/ sC CCct|dS)Nrrrs rorrs T? 33rpc ~t|dd}|r|St|r tdyddlm}gg}}t t tt|r|jddg|d D]}|d |}t|r||vr ||d z}n||}t tttt|rnt|rnt!|s|d z}t|st#|s t%|r|j'd|j'|d j)||z} | sd} | S)Nrr)rzF|H >rpcLg|jdg}}|djDcgc]}t|d|s||vr|}}||z}d|vrA|dD]}||vs|j||D]}||vs|j|||fS||dz}||fScc}w)Nrrr)rjrr/r)rrrrauxvarss ror r s&"-dHv,++-"Qd6l1o1ND="G" T>DTj! #ADy" # #A " # >T&\) >"s B!B!c^d|vryd}|ddk(r |d|df}|dj|dS)Nf2pymultilinesrz python modulerr)rks rorrsIt# A G}' M4< '  ! % %a ..rpcNdt|z dz dz}d|dzd|d|dzdS)NPz/*r z*/rQ)rlns ror r s< s4y.1  "B Sz4&"s(2 ..rpcPt|trttfd|gS|gS)Nc|||zSrr)xyrs rozflatlist..sq1Q4xrp)rrrflatlist)lsts rorrs%#tX7bAA 5Lrpc$|r |ddk(r|ddS|S)Nrrr)rs ror`r`#sQrUc\"v Hrpc t|tr|Dcgc]}t|||c}St|tr|Dcgc]}t|||c}Sdt|jzD]|}|dk(r d|vr||dvr |d|}n|}t||tr2|jd|d|j t ||}d|jd|d||}~|Scc}wcc}w)Nr separatorsfor#)rrr^rrr)rr defaultsep_mrseps ror^r^)s!T789R,99#t589rAz*99 affh  .    a A?);$;O$Q'CC adD !++!Ah!A$(@AC++!Ah!-C . J:9s C4C9cZt|tr|D]}t||}|S|jD]}|ddk(r ||vrt||tr ||g||<t||tr:t||tr||||z||<a||j ||yt||t st||t s|dk(r/||jD]}|||vs ||||||<t||||||<||||<|S)Nr_r)rrr rrrdict)rdarrrk1s ror r <sC"d #AB"B # WWY Q43;  7"Q%%A1"Q%&beT*qEBqEMBqEqELLA'BqE4(beT*O+"$Q%**,6B!A,.qE"I1b 6!+2a5"Q% 81qEBqE)* Irpc :i}t|tr)|D]"}t|||}t||}d|vs!|S|Sd|vr |d|s|Sd|vr.td|di||}d|vrt j |d|j D]}|dk(r ||||<t||trt|||||<nt||tr   G - ZZ\$  1XCF  eAh $U1Xq)CF a$ 'CF1X )A3/7FMM"Q%( )qTS[  a$ 'CFAhmmo 5b%"4"45"S'!%(2,5!&q"9A)!T2&0+q1A1c&J$'GGK$<FMM'!Q-8 9 "!HRL%a.",k1-=q"AC # R 8AA gam4 5 0eAh0@D E c!fd #3q6{aQA1v|FI$J Jrpz%\s*python\s*module\s*(?P[\w_]+)z4\s*python\s*module\s*(?P[\w_]*?__user__[\w_]*)cd}t|5}|D].}t|}|st|r|jd}nddd|S#1swY|SxYw)Nr)open_f2py_module_name_match_f2py_user_module_name_matchgroup)sourcerrlinems rorPrPse D f D'-A/5wwv   K KsA  A  Ac g}|dD]_}|dD]U}|jds|j|jdjDcgc] }d|vs| c}Wa|Scc}w)Nrause__)rjrr)pymodall_usesinnermodblockrs rorcrcszHvZf  ZH||E"HLL,?,D,D,F Xq$VW- XY ZZ O!Ys  A, A, cfg}i}|jD]I\}}|jD cic]\}} |j| } }} | ||j<K|jD]\}}||vri||<|jD]\}} | |vrV|||vrtd|d|d|||d| d | |||<|rtd|d|d| d |j| `|sct d |d|d| d | d t |j d ||fScc} }w)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. z Warning: redefinition of {'z':{'z':'z'->'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_lowerrd1rv1d1_lowers rordrdsOLMM,213r=r$r-rUrYrrWrrrrJrrrCrBr*r+rOrQrbrrrHr<rAr?r%r&rNrrRrrDr)rrGr#r5r6r9r4r8r0r-r2r:r1r7r/r;r>rAr3rErFrrYrrrrerfrfrirrrmrp ExceptionrrrarZr\r[r(rrrr rrrrr rr rr`r^r rcompileImatchrrrPrcrdrrprorsL  ! :"" }}   "  ;C?7=9@ 6B@ >>;6  !!!! !! @ ! " " " " ! ! ! ! B9 9;E =8 .:2            54 +I ?L9K  $L *E "(,+0/.*//0k>>|]MZZ!#3"$5"$5#%7 >%    9  .    ,+)  :4')#L/:2  "//   &: 5p%"**%M%'TT++05)rzz+=>@dd DDIE B%rp