
    Kh                        S SK r S SKrS SKrS SKrS SKrS SKrS SKrS SKrS SKr	S SK
Jr  SSKJr   " S S\R                  5      r " S S\5      r " S	 S
\R                  5      r " S S\R                  5      r " S S\R                  5      r\R(                  R*                  \R(                  R-                  \R.                  " 5       R1                  5       S:H  SSS9 " S S\R                  5      5       5       rg)    N)IS_PYPY   )utilc                      \ rS rSr\R
                  " SSSS5      /r\R                  R                  SSR                  S5      5      \R                  R                  S	 5       5       r\R                  R                  \S
S9S 5       rS r\R                  R#                  \R&                  S:H  SS9S 5       r\R                  R#                  \R&                  S:H  SS9S 5       rS rS rSrg)TestF77Callback   testssrccallbackzfoo.fnamezt,t2,c                 &    U R                  U5        g N)check_function)selfr   s     P/var/www/html/env/lib/python3.13/site-packages/numpy/f2py/tests/test_callback.pytest_allTestF77Callback.test_all   s     	D!    z,PyPy cannot modify tp_doc after PyType_Ready)reasonc                 |    [         R                  " S5      nU R                  R                  R                  U:X  d   eg )Na          a = t(fun,[fun_extra_args])

        Wrapper for ``t``.

        Parameters
        ----------
        fun : call-back function

        Other Parameters
        ----------------
        fun_extra_args : input tuple, optional
            Default: ()

        Returns
        -------
        a : int

        Notes
        -----
        Call-back functions::

            def fun(): return a
            Return objects:
                a : int
        )textwrapdedentmodulet__doc__)r   expecteds     r   test_docstringTestF77Callback.test_docstring   s5     ?? $ 4 {{}}$$000r   c                    [        U R                  U5      nU" S 5      nUS:X  d   eU" S SS9nUS:X  d   eU" S SS9nUS:X  d   eU" S	 S
S9nUS:X  d   eU" S [        R                  4S9nUS:X  d   eU" [        R                  [        R                  4S9nUS:X  d   eU" U R                  R
                  SS9nUS:X  d   eU" U R                  R                  5      nUS:X  d   eU" U R                  R                  R                  5      nUS:X  d   e " S S5      nU" 5       nU" U5      nUS:X  d   eU" UR                  5      nUS:X  d   eg )Nc                      g)N    r#   r   r   <lambda>0TestF77Callback.check_function.<locals>.<lambda>8   s    ar   r"   c                     gN   r#   as    r   r$   r%   :   s    r   )   )fun_extra_argsr(   c                     U $ r   r#   r)   s    r   r$   r%   <   s    r   r+   c                     SU -   $ r'   r#   r)   s    r   r$   r%   >   s    Ar   )      c                 .    [         R                  " U 5      $ r   )mathdegreesr)   s    r   r$   r%   @   s    Qr            c                        \ rS rSrS rS rSrg))TestF77Callback.check_function.<locals>.AL   c                     g)Nr/   r#   r   s    r   __call__2TestF77Callback.check_function.<locals>.A.__call__M       r   c                     g)N	   r#   r;   s    r   mth-TestF77Callback.check_function.<locals>.A.mthP   r>   r   r#   N)__name__
__module____qualname____firstlineno__r<   rA   __static_attributes__r#   r   r   Ar8   L   s    r   rH   r/   r@   )	getattrr   r2   pir3   funcfunc0	_cpointerrA   )r   r   r   rrH   r*   s         r   r   TestF77Callback.check_function6   sN   DKK&iLAvvk%0Avvk%0Avvoe4Bww'DCxxdllDGG;7Cxxdkku5Bwwdkk Bwwdkk))*Bww	 	 CaDAvvaeeHAvvr   win32z)Fails with MinGW64 Gfortran (Issue #9673)c                 V    S nU R                   R                  nU" U5      nUS:X  d   eg )Nc                     U S:X  a  gg)NrN   r   r   r#   )codes    r   r   6TestF77Callback.test_string_callback.<locals>.callback\   s    s{r   r   )r   string_callback)r   r   frN   s       r   test_string_callback$TestF77Callback.test_string_callbackY   s,    	 KK''hKAvvr   c                    [         R                  " SS5      n[         R                  " SS5      n[         R                  " S/S5      nS nU R                  R                  nXU4 H  nU" XFUR
                  5      nUS:X  a  M   e   g )N)r   S8)r      c c                     U R                   U4:w  a  gU R                  S:w  a  g[        R                  " U S:H  5      (       d  gg)Nr   rZ      r      r   )shapedtypenpall)culencus     r   r   <TestF77Callback.test_string_callback_array.<locals>.callbackn   s;    xxE8#xx466")$$r   r   )rc   zerosarrayr   string_callback_arraysize)r   cu1cu2cu3r   rV   re   ress           r   test_string_callback_array*TestF77Callback.test_string_callback_arrayf   su     hhud#hhvs#hhtT"	 KK--S/BH"''*C!8O8 "r   c           
      T  ^ ^^ / mU 4S jmUUU 4S jnS VVs/ s H+  n[        S5        H  n[        R                  " X4S9PM     M-     nnnU H  nUR                  5         M     U H  nUR	                  5         M     SR	                  T5      mT(       a  [        T5      eg s  snnf )Nc                  z   > [         R                  " S5        TR                  R                  S 5      n U S:X  d   eg)NgMbP?c                      gN{   r#   r#   r   r   r$   ?TestF77Callback.test_threadsafety.<locals>.cb.<locals>.<lambda>   s    cr   rv   *   )timesleepr   r   )rN   r   s    r   cb-TestF77Callback.test_threadsafety.<locals>.cb   s3     JJt k*A8O8r   c                    >  [        S5       H7  nTR                  R                  T5      nUS:X  d   eTR                  U 5        M9     g ! [         a'    TR                  [        R                  " 5       5         g f = f)N2   rx   )ranger   r   r   	Exceptionappend	traceback
format_exc)r   jrN   r{   errorsr   s      r   runner1TestF77Callback.test_threadsafety.<locals>.runner   sg    6rAb)A7N7''- #  6i22456s   AA
 
.A;:A;)r   t2   )targetargsz

)r   	threadingThreadstartjoinAssertionError)r   r   argnthreadsr   r{   r   s   `     @@r   test_threadsafety!TestF77Callback.test_threadsafety|   s     			6 #
"E"Iq F9,5 :" 	 

 AGGI  AFFH  V$ (( 
s   2B$c                     U R                   R                  S5         U R                   R                  S5        S U R                   l        U R                   R                  S5      nUS:X  d   eS U R                   l        U R                   R                  S5      nUS:X  d   eU R                   ? U R                   R                  S5        S
S jU R                   l        U R                   R                  S5      nUS	:X  d   eU R                   R                  S5      nUS:X  d   eg ! [         a,  n[        U5      R	                  S5      (       d   e S nAGN:S nAff = f! [         a,  n[        U5      R	                  S5      (       d   e S nAGNWS nAff = f! [         a+  n[        U5      R	                  S5      (       d   e S nANS nAff = f)Nr_   zCallback global_f not definedz!cb: Callback global_f not definedc                     U S-   $ )Nr   r#   xs    r   r$   6TestF77Callback.test_hidden_callback.<locals>.<lambda>       Qr   r`   c                     U S-   $ )Nr_   r#   r   s    r   r$   r      r   r   r"   c                     U S-   $ )Nr`   r#   r   s    r   r$   r      s    1q5r   r(   )r   )r   hidden_callbackr   str
startswithhidden_callback2global_f)r   msgrN   s      r   test_hidden_callback$TestF77Callback.test_hidden_callback   s   	HKK''*	LKK((+  /KK''*Avv.KK''*AvvKK 	HKK''*  1KK''*Avv KK((+Avv9  	Hs8&&'FGGGG	H
  	Ls8&&'JKKKK	L  	Hs8&&'FGGGG	HsF   D& E 0F &
E0!EE
F)!FF
G"!GGr#   N)rC   rD   rE   rF   r   getpathsourcespytestmarkparametrizesplitslowr   xfailr   r   r   skipifsysplatformrW   rp   r   r   rG   r#   r   r   r   r      s   ||GUJ@AG[[VV\\#%67[["  8" [[wL  N1N1:!F [[/J  L	L	 [[/J  LL(&)Pr   r   c                       \ rS rSrSrS/rSrg)TestF77CallbackPythonTLS   zO
Callback tests using Python thread-local storage instead of
compiler-provided
z-DF2PY_USE_PYTHON_TLSr#   N)rC   rD   rE   rF   r   optionsrG   r#   r   r   r   r      s    
 ''Gr   r   c                   x    \ rS rSr\R
                  " SSSS5      /r\R                  R                  S 5       r
Srg)	TestF90Callback   r	   r
   r   zgh17797.f90c                     S n[         R                  " / SQ[         R                  S9nU R                  R	                  X5      nUS:X  d   eg )Nc                     U S-   $ ru   r#   r   s    r   incr*TestF90Callback.test_gh17797.<locals>.incr   s    s7Nr   )r   r_   r`   )rb      )rc   ri   int64r   gh17797)r   r   yrN   s       r   test_gh17797TestF90Callback.test_gh17797   s?    	 HHYbhh/KK(O###r   r#   N)rC   rD   rE   rF   r   r   r   r   r   r   r   rG   r#   r   r   r   r      s5    ||GUJFGG[[$ $r   r   c                   |    \ rS rSrSr\R                  " SSSS5      /r\R                  R                  S 5       rSrg	)
TestGH18335   zThe reproduction of the reported issue requires specific input that
extensions may break the issue conditions, so the reproducer is
implemented as a separate test class. Do not extend this test with
other tests!
r	   r
   r   zgh18335.f90c                 P    S nU R                   R                  U5      nUS:X  d   eg )Nc                     U S==   S-  ss'   g )Nr   r   r#   r   s    r   foo%TestGH18335.test_gh18335.<locals>.foo   s    aDAIDr   |   )r   gh18335)r   r   rN   s      r   test_gh18335TestGH18335.test_gh18335   s)    	 KK$G||r   r#   N)rC   rD   rE   rF   r   r   r   r   r   r   r   r   rG   r#   r   r   r   r      s<    
 ||GUJFGG[[ r   r   c                   r    \ rS rSr\R
                  " SSSS5      \R
                  " SSSS5      /rSrS rS	r	g
)TestGH25211   r	   r
   r   z	gh25211.fzgh25211.pyf	callback2c                 P    S nU R                   R                  U5      nUS:X  d   eg )Nc                 
    X -  $ r   r#   r   s    r   bar%TestGH25211.test_gh25211.<locals>.bar   s	    3Jr   n   )r   r   )r   r   ro   s      r   test_gh25211TestGH25211.test_gh25211   s'    	 kkooc"czzr   r#   N)
rC   rD   rE   rF   r   r   r   module_namer   rG   r#   r   r   r   r      s8    ||GUJD||GUJFHGKr   r   darwinFz*Callback aborts cause CI failures on macOS)	conditionrunr   c                   L    \ rS rSr\R
                  " SSSS5      /rS/rS rSr	g	)
TestCBFortranCallstatement   r	   r
   r   zgh26681.f90z--lowerc                    [         R                  " [        SS9 nU R                  R                  R
                  U R                  l        U R                  R                  R                  S5        S S S 5        g ! , (       d  f       g = f)Nhelpme)match)r   raises
ValueErrorr   utilsmy_abort
mypy_abortdo_something)r   excs     r   test_callstatement_fortran5TestCBFortranCallstatement.test_callstatement_fortran  sR    ]]:X6#%)[[%6%6%?%?DKK"KK**84 766s   AA88
Br#   N)
rC   rD   rE   rF   r   r   r   r   r   rG   r#   r   r   r   r      s'    
 ||GUJFGGkG5r   r   )r2   r   r   r   r   r   ry   r   numpyrc   numpy.testingr   r]   r   F2PyTestr   r   r   r   r   r   r   r   systemlowerr   r#   r   r   <module>r      s      
       ! tdmm tn( (
$dmm 
$$-- "
$-- 
 hoo/5578CF  H5 5H 5r   