+
    ei@  c                   s   ^ RI t ^ RIt^ RIt^ RIt^ RIt^ RIt^ RIt^ RIH	t	 ^ RI
HtHt ^RIHt  ! R R]P                  4      t ! R R4      t ! R	 R
4      t ! R R]P                  4      t ! R R]P                  4      t ! R R4      t ! R R]P                  4      t ! R R4      t ! R R]P                  4      t ! R R]P                  4      t]P4                  P6                   ! R R]P                  4      4       t ! R R4      t ! R R]P                  4      t ! R R ]P                  4      t ! R! R"4      t  ! R# R$4      t!]P4                  P6                   ! R% R&]P                  4      4       t"R# )'i    N)crackfortran)markinnerspacesnameargspattern)utilc                   sR   a  ] tR t^t o ]P
                  ! RRRR4      .tR tRtV t	R# )TestNoSpacetestssrcr    z	gh15035.fc                s   \         P                  ! . RO\         P                  R7      p\         P                  ! . RO\         P                  R7      pV P                  P	                  V4       V P                  P                  W!.4       R# )   )ZdtypeN)r         )npZarrayZfloat64moduleZsubbZsubc)selfZkw   &  I/usr/lib64/python3.14/site-packages/numpy/f2py/tests/test_crackfortran.pytest_moduleZTestNoSpace.test_module   sP    HHYbjj1HHYbjj1!      N)
__name__
__module____qualname____firstlineno__r   getpathsourcesr   __static_attributes____classdictcell____classdict__   @r   r   r      s(      ||GUNKHIG, ,r   r   c                   s8   a  ] tR t^t o R tR tR tR tRtV t	R# )TestPublicPrivatec                s    \         P                  ! R RRR4      p\        P                  ! \        V4      .4      pV^ ,          pR# )r   r   r    zprivatemod.f90Nr   r   r    str)r   fpathmodr   r   test_defaultPrivateZ%TestPublicPrivate.test_defaultPrivate    6    We^=MN''U5!fr   c                    \         P                  ! R RRR4      p\        P                  ! \        V4      .4      pV^ ,          pR# )r   r   r    zpublicmod.f90Nr   r   tmp_pathr!   r"      &&  r   test_defaultPublicZ$TestPublicPrivate.test_defaultPublic,   5    We^_M''U5!fr   c                s    \         P                  ! R RRR4      p\        P                  ! \        V4      .4      pV^ ,          R,          pR# )r   r   r    zaccesstype.f90ZvarsNr   )r   r'   r!   r"   Ztt   &&   r   test_access_typeZ"TestPublicPrivate.test_access_type6   s:    We^=MN''U5VF^r   c                s    \         P                  ! R RRR4      p\        P                  ! \        V4      .4      p\        P                  ! V4      pR# )r   r   r    zgh23879.f90N)r   r   r    r    Zcrack2fortran)r   r'   r!   r"   Zpyfr+   r   test_nowrap_private_proceeduresZ1TestPublicPrivate.test_nowrap_private_proceedures?   s<    We^]K''U5((-r   r   N)
r   r   r   r   r#   r)   r,   r-   r   r   r   r   r   r   r      s     
;;6   r   r   c                   s,   a  ] tR t^Ft o R tR tRtV tR# )TestModuleProcedurec                r%   )r   r   r    zoperators.f90Nr   r&   r(   r   test_moduleOperatorsZ(TestModuleProcedure.test_moduleOperatorsG   r*   r   c                r%   )r   r   r    zpubprivmod.f90Nr   r&   r(   r   test_notPublicPrivateZ)TestModuleProcedure.test_notPublicPrivateY   r$   r   r   N)r   r   r   r   r/   r0   r   r   r   r   r   r.   r.   F   s     $$? ?r   r.   c                   sX   a  ] tR t^ct o ]P
                  ! RRRR4      .tR tR tRt	V t
R# )	TestExternalr   r   r    z	gh17859.fc                B    R  pV P                   P                  V4      pR# )c                     V ^{,           # i{   r   Zx   &r   incrZ5TestExternal.test_external_as_statement.<locals>.incrh       s7Nr   N)r   Zexternal_as_statementr   r7   rr   r   test_external_as_statementZ'TestExternal.test_external_as_statementg       	 KK--d3r   c                r2   )c                 r3   r4   r   r5   r6   r   r7   Z5TestExternal.test_external_as_attribute.<locals>.incro   r8   r   N)r   Zexternal_as_attributer9   r   r   test_external_as_attributeZ'TestExternal.test_external_as_attributen   r<   r   r   N)r   r   r   r   r   r   r   r;   r=   r   r   r   r   r   r1   r1   c   s+     ||GUNKHIG r   r1   c                   s   a  ] tR t^vt o ]P
                  ! RRRR4      ]P
                  ! RRRR4      .tR tR tRt	V t
R	# )
TestCrackFortranr   r   r    z
gh2848.f90zcommon_with_division.fc                s>    V P                   P                  ^^4      pR# )r   N)r   Zgh2848)r   r:      & r   test_gh2848ZTestCrackFortran.test_gh2848|   s    KKq!$r   c                    R # Nr   r   r6   r   test_common_with_divisionZ*TestCrackFortran.test_common_with_division       r   r   N)r   r   r   r   r   r   r   r@   rD   r   r   r   r   r   r>   r>   v   s@     ||GUNLI||GUN<TUG2 2r   r>   c                   s8   a  ] tR t^t o R tR tR tR tRtV t	R# )TestMarkinnerspacesc                s     . ROpV F  pK  	  R# )a N)rG   z aza b cz'abcdefghij'r   )r   Z	test_listZir   r   test_do_not_touch_normal_spacesZ3TestMarkinnerspaces.test_do_not_touch_normal_spaces   s    9	Ar   c                rA   rB   r   rC   r6   r   test_one_relevant_spaceZ+TestMarkinnerspaces.test_one_relevant_space   rE   r   c                rA   rB   r   rC   r6   r   test_ignore_inner_quotesZ,TestMarkinnerspaces.test_ignore_inner_quotes   rE   r   c                rA   rB   r   rC   r6   r   test_multiple_relevant_spacesZ1TestMarkinnerspaces.test_multiple_relevant_spaces   rE   r   r   N)
r   r   r   r   rH   rI   rJ   rK   r   r   r   r   r   rF   rF      s"     +
GOI Ir   rF   c            	       s,  a ] tR t^t oRtRt]P                  ! R4      t. ROt	R.t
]	]
,           tRt]! ]4       Fp  w  tt]P!                  R4       U u. uF$  p RV 9   d   V P!                  R4      ^ ,          MRNK&  	  up t]]P%                  ]]R	P'                  ]4      R
7      ,          tKr  	  ]P*                  P-                  R]4      ]P*                  P.                  R 4       4       t]P*                  P-                  R]4      R 4       tRtVtR# u up i )TestDimSpecan  This test suite tests various expressions that are used as dimension
specifications.

There exists two usage cases where analyzing dimensions
specifications are important.

In the first case, the size of output arrays must be defined based
on the inputs to a Fortran function. Because Fortran supports
arbitrary bases for indexing, for instance, `arr(lower:upper)`,
f2py has to evaluate an expression `upper - lower + 1` where
`lower` and `upper` are arbitrary expressions of input parameters.
The evaluation is performed in C, so f2py has to translate Fortran
expressions to valid C expressions (an alternative approach is
that a developer specifies the corresponding C expressions in a
.pyf file).

In the second case, when user provides an input array with a given
size but some hidden parameters used in dimensions specifications
need to be determined based on the input array size. This is a
harder problem because f2py has to solve the inverse problem: find
a parameter `p` such that `upper(p) - lower(p) + 1` equals to the
size of input array. In the case when this equation cannot be
solved (e.g. because the input array size is wrong), raise an
error before calling the Fortran function (that otherwise would
likely crash Python process when the size of input arrays is
wrong). f2py currently supports this case only when the equation
is linear with respect to unknown parameter.

z.f90a
  
      function get_arr_size_{count}(a, n) result (length)
        integer, intent(in) :: n
        integer, dimension({dimspec}), intent(out) :: a
        integer length
        length = size(a)
      end function

      subroutine get_inv_arr_size_{count}(a, n)
        integer :: n
        ! the value of n is computed in f2py wrapper
        !f2py intent(out) n
        integer, dimension({dimspec}), intent(in) :: a
        if (a({first}).gt.0) then
          ! print*, "a=", a
        endif
      end subroutine
    z2*n:3*n*n+2*n Z,Z:Z1z, )countdimspecZfirstrO   c                s    V P                   P                  V4      p\        V P                  R V 24      pR F  pV! V4      w  rVK  	  R# )get_arr_size_Nr   r   r	   i   i   )all_dimspecsindexgetattrr   )r   rO   rN   get_arr_sizenszas   &&     r   test_array_sizeZTestDimSpec.test_array_size   sH     !!''0t{{mE7,CD A OEB !r   c                s   V P                   P                  V4      p\        V P                  R V 24      p\        V P                  RV 24      pR F8  pV! V4      w  rgWP                  9   d
   V! Wu4      pMV! V4      pV! V4      w  rK:  	  R# )rP   Zget_inv_arr_size_NrQ   )rR   rS   rT   r   nonlinear_dimspecs)r   rO   rN   rU   Zget_inv_arr_sizerV   rW   rX   Zn1Zsz1_s   &&         r   test_inv_array_sizeZTestDimSpec.test_inv_array_size   s     !!''0t{{mE7,CD"4;;2CE70KL A OEB111 &a+ &a( ""%FC !r   r   N)rV   z2*nz2:nzn/2z5 - n/2z3*n:20zn*(n+1):n*(n+5)z2*n, n)r   r   r   r   Z__doc__ZsuffixtextwrapZdedentZcode_templateZlinear_dimspecsrZ   rR   ZcodeZ	enumeraterN   rO   ZsplitZlstZformatZjoinpytestmarkparametrizeslowrY   r\   r   r   )Zdr   s   0@r   rL   rL      s    < FOO % 	M&O **"%77LD#L1w?F}}S?QR?Q!3!8Q4?QR$$))C. % 
 	
 2 [[Y5[[   6  [[Y5/ 6/' Ss   *DrL   c                   s&   a  ] tR t^t o R tRtV tR# )TestModuleDeclarationc                sx    \         P                  ! R RRR4      p\        P                  ! \        V4      .4      pR# )r   r   r    zfoo_deps.f90Nr   r&   r(   r   test_dependenciesZ'TestModuleDeclaration.test_dependencies   s,    We^^L''U5r   r   N)r   r   r   r   rc   r   r   r   r   r   rb   rb      s     < <r   rb   c                   &   a  ] tR tRt o R tRtV tR# )TestEvali  c                s&    \         P                  pR # rB   )r    Z_eval_scalar)r   Zeval_scalarr?   r   test_eval_scalarZTestEval.test_eval_scalar  s    "//r   r   N)r   r   r   r   rf   r   r   r   r   r   re   re     s     3 3r   re   c                   sh   a  ] tR tRt o ]P
                  P                  R. RO4      R 4       tRtV t	R# )TestFortranReaderi  encodingc                s    VR V R2,          pVP                  RVR7      ;_uu_ 4       pVP                  R4       RRR4       \        P                  ! \        V4      .4      pR#   + '       g   i     L2; i)Zinput_with_z_encoding.f90r   )rh   zd
                     subroutine foo()
                     end subroutine foo
                     N)ZopenZwriter    r    )r   r'   rh   Zf_pathZffr"   s   &&&   r   test_input_encodingZ%TestFortranReader.test_input_encoding  sc     k(=AA[[x[00BHH   1
 ''V6 10s   A%%A5	r   N)Zasciizutf-8zutf-16zutf-32)
r   r   r   r   r^   r_   r`   ri   r   r   r   r   r   rg   rg     s-     [[ZCE	'E	'r   rg   c                   s   a  ] tR tRt o ]P
                  ! RRRR4      .t]P                  P                  ]
P                  P                  R4      RJ RR	7      R
 4       tRtV tR# )TestUnicodeCommenti   r   r   r    zunicode_comment.f90Zcharset_normalizerNz7test requires charset_normalizer which is not installed)Zreasonc                s<    V P                   P                  ^4       R# )r	   N)r   ZfoorC   r6   r   test_encoding_commentZ(TestUnicodeComment.test_encoding_comment$  s    
 	r   r   )r   r   r   r   r   r   r   r^   r_   Zskipif	importlibZ	find_specrk   r   r   r   r   r   rj   rj      s^     ||GUN<QRSG[[		!	!"6	74	?H  	r   rj   c                   sj   a  ] tR tRt o ]P
                  P                  R.. RO4      R 4       tRtV t	R# )TestNameArgsPatternBacktrackingi,  	adversaryc                sR   ^p^p^^rT\        WE4       F  pW,          p\        V4       Fm  p. p	\        V4       FY  p\        P                  ! 4       p
\        P                  ! V4      pV	P                  \        P                  ! 4       V
,
          4       K[  	  Ko  	  VR,           pK  	  R# )zHaddress ReDOS vulnerability:
https://github.com/numpy/numpy/issues/23338z@)@N)ZrangetimeZperf_counterr   ZsearchZappend)r   rn   Ztrials_per_batchZbatches_per_regexZ
start_repsZend_repsZiiZrepeated_adversaryr[   ZtimesZt0ZmtchZgood_version_of_adversarys   &&           r   !test_nameargspattern_backtrackingZATestNameArgsPatternBacktracking.test_nameargspattern_backtracking-  s     !2H
-B!* ,-/0A**,B*112DEDLL!2!2!4r!9: 1 . );U(B%% .r   r   N))z
@)@bind@(@)z#@)@bind                         @(@)z@)@bind foo bar baz@(@)
r   r   r   r   r^   r_   r`   rp   r   r   r   r   r   rm   rm   ,  s2     [[		
EEr   rm   c                   s   a  ] tR tRt o ]P
                  ! RRRR4      .t]P                  P                  R 4       t
RtV tR# )	TestFunctionReturniP  r   r   r    zgh23598.f90c                rA   rB   r   rC   r6   r   test_function_rettypeZ(TestFunctionReturn.test_function_rettypeS  rE   r   r   N)r   r   r   r   r   r   r   r^   r_   ra   rr   r   r   r   r   r   rq   rq   P  s8     ||GUNMJKG[[2 2r   rq   c                   rd   )TestFortranGroupCountersiY  c                s    \         P                  ! R RRR4      p \        P                  ! \        V4      .4       R#   \         d   p Rp?R# Rp?ii ; i)r   r   r    z	gh23533.fN)r   r   r    r    Z	Exception)r   r!   excr   r   test_end_if_commentZ,TestFortranGroupCounters.test_end_if_commentZ  sH    We^[I	S%%s5zl3 	S 	S 	Ss    = AAr   N)r   r   r   r   ru   r   r   r   r   r   rs   rs   Y  s     S Sr   rs   c                   rd   )TestF77CommonBlockReaderic  c                s   \         P                  ! R RRR4      p\        P                  ! \        P
                  ! 4       4      ;_uu_ 4       p\        P                  ! \        V4      .4      pRRR4       R#   + '       g   i     R# ; i)r   r   r    zgh22648.pyfN)r   r   
contextlibZredirect_stdoutioZStringIOr    r    )r   r'   r!   Zstdout_f2pyr"   r+   r   test_gh22648Z%TestF77CommonBlockReader.test_gh22648d  sT    We^]K''66+++SZL9C 7666s   !A66B	r   N)r   r   r   r   ry   r   r   r   r   r   rv   rv   c  s     8 8r   rv   c                   s>   a  ] tR tRt o R tR tR tR tR tRt	V t
R# )	TestParamEvalij  c                s    R pR\         P                  R\         P                  R\         P                  /pR^R^^^^/R^^^^^^//pRp\         P                  ! WW4R7      pR	# )
z(/3.14, 4./)kindselected_int_kindselected_real_kindZdpZintparamarrayZnestedz(2)rO   Nr    
_kind_func_selected_int_kind_func_selected_real_kind_func
param_evalr   vg_paramsparamsrO   ret   &     r   test_param_eval_nestedZ$TestParamEval.test_param_eval_nestedl  ss    L33#\%I%I$l&K&KM ?Q1aLQ1aA.0%%a6Kr   c                s    R pR\         P                  R\         P                  R\         P                  /p/ pRp\         P                  ! WW4R7      pR# )z(/ 6, 3, 1 /)r{   r|   r}   z(-1:1)r~   Nr   r   r   r   !test_param_eval_nonstandard_rangeZ/TestParamEval.test_param_eval_nonstandard_rangew  sN    L33#\%I%I$l&K&KM %%a6Kr   c           	         R pR\         P                  R\         P                  R\         P                  /p/ pRp\        P
                  ! \        \         P                  WVVR7       R# )Z6r{   r|   r}   rM   r~   Nr    r   r   r   r^   raises
ValueErrorr   r   r   r   r   rO      &    r   test_param_eval_empty_rangeZ)TestParamEval.test_param_eval_empty_range  sY    L33#\%I%I$l&K&KM j,"9"91%	'r   c                s    R pR\         P                  R\         P                  R\         P                  /p/ p\         P                  ! WVRR7      pR# )z3.14_dpr{   r|   r}   Nr~   r   )r   r   r   r   r   r   r   test_param_eval_non_array_paramZ-TestParamEval.test_param_eval_non_array_param  sK    L33#\%I%I$l&K&KM %%a64Hr   c           	     r   )z*reshape((/ (i, i=1, 250) /), (/5, 10, 5/))r{   r|   r}   z(0:4, 3:12, 5)r~   Nr   r   r   r   test_param_eval_too_many_dimsZ+TestParamEval.test_param_eval_too_many_dims  sY    8L33#\%I%I$l&K&KM "j,"9"91%	'r   r   N)r   r   r   r   r   r   r   r   r   r   r   r   r   r   rz   rz   j  s#     	(*' ' 'r   rz   c                   sX   a  ] tR tRt o ]P
                  ! RRRR4      .tR.tR tRt	V t
R	# )
TestLowerF2PYDirectivei  r   r   r    zgh27697.f90z--lowerc                s    \         P                  ! \        R R7      ;_uu_ 4       pV P                  P                  P                  R 4       RRR4       R#   + '       g   i     R# ; i)zaborting directly)ZmatchN)r^   r   r   r   ZutilsZmy_abort)r   rt   r?   r   test_no_lower_failZ)TestLowerF2PYDirective.test_no_lower_fail  s?    ]]:-@AASKK&&':; BAAAs   &AA&	r   N)r   r   r   r   r   r   r   Zoptionsr   r   r   r   r   r   r   r     s-     ||GUNMJKGkG< <r   r   )#rw   rl   rx   r]   ro   r^   Znumpyr
   Z
numpy.f2pyr    Znumpy.f2py.crackfortranr   r   rM   r   ZF2PyTestr   r   r.   r1   r>   rF   rL   rb   re   rg   r_   ra   rj   rm   rq   rs   rv   rz   r   r   r   r   <module>r      sG     	     # D ,$-- ,%  % N? ?:4== &2t}} 2I I*d/$-- d/N< <3t}} 3' '   "E "EH2 2St}} S8 82' 2'h <T]] < <r   