+
   a7                      ^ 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 ]P                  P                    ! R R]P"                  4      4       t ! R R4      t ! R	 R
4      t]P                  P                    ! R R]P"                  4      4       t]P                  P                    ! R R]P"                  4      4       t ! R R4      t]P                  P                    ! R R]P"                  4      4       t ! R R4      t]P                  P                    ! R R]P"                  4      4       t]P                  P                    ! R R]P"                  4      4       t]P                  P                    ! R R]P"                  4      4       t ! R R4      t]P                  P                    ! R R]P"                  4      4       t]P                  P                    ! R R ]P"                  4      4       t ! R! R"4      t  ! R# R$4      t!]P                  P                    ! R% R&]P"                  4      4       t"R# )'    N)crackfortran)markinnerspacesnameargspattern)utilc                   R   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                   \         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# )   )dtypeN)r         )nparrayfloat64modulesubbsubc)selfkws   &  G/usr/lib/python3.14/site-packages/numpy/f2py/tests/test_crackfortran.pytest_moduleTestNoSpace.test_module   sP    HHYbjj1HHYbjj1!      N)
__name__
__module____qualname____firstlineno__r   getpathsourcesr   __static_attributes____classdictcell____classdict__s   @r   r   r      s(      ||GUNKHIG, ,r   r   c                   8   a  ] tR t^ t o R tR tR tR tRtV t	R# )TestPublicPrivatec                    \         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mods   &  r   test_defaultPrivate%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.   s   &&  r   test_defaultPublic$TestPublicPrivate.test_defaultPublic-   5    We^_M''U5!fr   c                    \         P                  ! R RRR4      p\        P                  ! \        V4      .4      pV^ ,          R,          pR# )r	   r
   r   zaccesstype.f90varsNr+   )r   r4   r-   r.   tts   &&   r   test_access_type"TestPublicPrivate.test_access_type7   s:    We^=MN''U5VF^r   c                    \         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,   crack2fortran)r   r4   r-   r.   pyfs   &&   r   test_nowrap_private_procedures0TestPublicPrivate.test_nowrap_private_procedures@   s<    We^]K''U5((-r   r   N)
r   r   r    r!   r/   r5   r;   r@   r$   r%   r&   s   @r   r)   r)       s     
;;6' 'r   r)   c                   ,   a  ] tR t^Gt o R tR tRtV tR# )TestModuleProcedurec                    \         P                  ! R RRR4      p\        P                  ! \        V4      .4      pV^ ,          pR# )r	   r
   r   zoperators.f90Nr+   r3   s   &&  r   test_moduleOperators(TestModuleProcedure.test_moduleOperatorsH   r7   r   c                    \         P                  ! R RRR4      p\        P                  ! \        V4      .4      pV^ ,          pR# )r	   r
   r   zpubprivmod.f90Nr+   r3   s   &&  r   test_notPublicPrivate)TestModuleProcedure.test_notPublicPrivateZ   r1   r   r   N)r   r   r    r!   rE   rH   r$   r%   r&   s   @r   rC   rC   G   s     $$? ?r   rC   c                   X   a  ] tR t^dt 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 ^{,           # {   r   xs   &r   incr5TestExternal.test_external_as_statement.<locals>.incrj       s7Nr   N)r   external_as_statementr   rR   rs   &  r   test_external_as_statement'TestExternal.test_external_as_statementi       	 KK--d3r   c                B    R  pV P                   P                  V4      pR# )c                     V ^{,           # rN   r   rP   s   &r   rR   5TestExternal.test_external_as_attribute.<locals>.incrq   rT   r   N)r   external_as_attributerV   s   &  r   test_external_as_attribute'TestExternal.test_external_as_attributep   rZ   r   r   N)r   r   r    r!   r   r"   r#   rX   r_   r$   r%   r&   s   @r   rK   rK   d   s-      ||GUNKHIG r   rK   c                      a  ] tR t^xt 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                >    V P                   P                  ^^4      pR# )r   N)r   gh2848)r   rW   s   & r   test_gh2848TestCrackFortran.test_gh2848   s    KKq!$r   c                    R # Nr   r   s   &r   test_common_with_division*TestCrackFortran.test_common_with_division       r   r   N)r   r   r    r!   r   r"   r#   re   rj   r$   r%   r&   s   @r   rb   rb   x   sB      ||GUNLI||GUN<TUG2 2r   rb   c                   8   a  ] tR t^t o R tR tR tR tRtV t	R# )TestMarkinnerspacesc                     . ROpV F  pK  	  R# )a N)rp   z aza b cz'abcdefghij'r   )r   	test_listis   &  r   test_do_not_touch_normal_spaces3TestMarkinnerspaces.test_do_not_touch_normal_spaces   s    9	Ar   c                    R # rh   r   ri   s   &r   test_one_relevant_space+TestMarkinnerspaces.test_one_relevant_space   rl   r   c                    R # rh   r   ri   s   &r   test_ignore_inner_quotes,TestMarkinnerspaces.test_ignore_inner_quotes   rl   r   c                    R # rh   r   ri   s   &r   test_multiple_relevant_spaces1TestMarkinnerspaces.test_multiple_relevant_spaces   rl   r   r   N)
r   r   r    r!   rs   rv   ry   r|   r$   r%   r&   s   @r   rn   rn      s"     +
GOI Ir   rn   c            	         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      R 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 ,:1z, )countdimspecfirstr   c                    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         )all_dimspecsindexgetattrr   )r   r   r   get_arr_sizenszas   &&     r   test_array_sizeTestDimSpec.test_array_size   sH     !!''0t{{mE7,CD A OEB !r   c                   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# )r   get_inv_arr_size_Nr   )r   r   r   r   nonlinear_dimspecs)r   r   r   r   get_inv_arr_sizer   r   r   n1sz1_s   &&         r   test_inv_array_size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)r   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!   __doc__suffixtextwrapdedentcode_templatelinear_dimspecsr   r   code	enumerater   r   splitlstformatjoinpytestmarkparametrizer   r   r$   r%   )dr'   s   0@r   r   r      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   *C8r   c                   &   a  ] tR tRt o R tRtV tR# )TestModuleDeclarationi  c                x    \         P                  ! R RRR4      p\        P                  ! \        V4      .4      pR# )r	   r
   r   zfoo_deps.f90Nr+   r3   s   &&  r   test_dependencies'TestModuleDeclaration.test_dependencies  s,    We^^L''U5r   r   N)r   r   r    r!   r   r$   r%   r&   s   @r   r   r     s     < <r   r   c                   &   a  ] tR tRt o R tRtV tR# )TestEvali
  c                &    \         P                  pR # rh   )r   _eval_scalar)r   eval_scalars   & r   test_eval_scalarTestEval.test_eval_scalar  s    "//r   r   N)r   r   r    r!   r   r$   r%   r&   s   @r   r   r   
  s     3 3r   r   c                   h   a  ] tR tRt o ]P
                  P                  R. RO4      R 4       tRtV t	R# )TestFortranReaderi  encodingc                    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)input_with_z_encoding.f90r   )r   zd
                     subroutine foo()
                     end subroutine foo
                     N)openwriter   r,   )r   r4   r   f_pathffr.   s   &&&   r   test_input_encoding%TestFortranReader.test_input_encoding  sc     k(=AA[[x[00BHH   1
 ''V6 10s   A%%A5	r   N)asciizutf-8zutf-16zutf-32)
r   r   r    r!   r   r   r   r   r$   r%   r&   s   @r   r   r     s-     [[ZCE	'E	'r   r   c                      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.f90charset_normalizerNz7test requires charset_normalizer which is not installed)reasonc                <    V P                   P                  ^4       R# )r   N)r   foori   s   &r   test_encoding_comment(TestUnicodeComment.test_encoding_comment)  s    
 	r   r   )r   r   r    r!   r   r"   r#   r   r   skipif	importlib	find_specr   r$   r%   r&   s   @r   r   r   %  s^     ||GUN<QRSG[[		!	!"6	74	?H  	r   r   c                   j   a  ] tR tRt o ]P
                  P                  R.. RO4      R 4       tRtV t	R# )TestNameArgsPatternBacktrackingi1  	adversaryc                R   ^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)rangetimeperf_counterr   searchappend)r   r   trials_per_batchbatches_per_regex
start_repsend_repsiirepeated_adversaryr   timest0mtchgood_version_of_adversarys   &&           r   !test_nameargspattern_backtrackingATestNameArgsPatternBacktracking.test_nameargspattern_backtracking2  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   r   r$   r%   r&   s   @r   r   r   1  s2     [[		
EEr   r   c                   R   a  ] tR tRt o ]P
                  ! RRRR4      .tR tRtV t	R# )	TestFunctionReturniU  r	   r
   r   zgh23598.f90c                    R # rh   r   ri   s   &r   test_function_rettype(TestFunctionReturn.test_function_rettypeY  rl   r   r   N)
r   r   r    r!   r   r"   r#   r   r$   r%   r&   s   @r   r   r   U  s&     ||GUNMJKG2 2r   r   c                   &   a  ] tR tRt o R tRtV tR# )TestFortranGroupCountersi^  c                    \         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,   	Exception)r   r-   excs   &  r   test_end_if_comment,TestFortranGroupCounters.test_end_if_comment`  sH    We^[I	S%%s5zl3 	S 	S 	Ss    = AAr   N)r   r   r    r!   r   r$   r%   r&   s   @r   r   r   ^  s     S Sr   r   c                   &   a  ] tR tRt o R tRtV tR# )TestF77CommonBlockReaderii  c                   \         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"   
contextlibredirect_stdoutioStringIOr   r,   )r   r4   r-   stdout_f2pyr.   s   &&   r   test_gh22648%TestF77CommonBlockReader.test_gh22648j  sT    We^]K''66+++SZL9C 7666s   !A66B	r   N)r   r   r    r!   r   r$   r%   r&   s   @r   r   r   i  s     8 8r   r   c                   >   a  ] tR tRt o R tR tR tR tR tRt	V t
R# )	TestParamEvalip  c                    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_kinddpintparamarraynestedz(2)r   Nr   
_kind_func_selected_int_kind_func_selected_real_kind_func
param_evalr   vg_paramsparamsr   rets   &     r   test_param_eval_nested$TestParamEval.test_param_eval_nestedr  ss    L33#\%I%I$l&K&KM ?Q1aLQ1aA.0%%a6Kr   c                    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  s   &     r   !test_param_eval_nonstandard_range/TestParamEval.test_param_eval_nonstandard_range}  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# )6r   r   r  r   r  Nr   r  r  r	  r   raises
ValueErrorr
  r   r  r  r  r   s   &    r   test_param_eval_empty_range)TestParamEval.test_param_eval_empty_range  sY    L33#\%I%I$l&K&KM j,"9"91%	'r   c                    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  s   &    r   test_param_eval_non_array_param-TestParamEval.test_param_eval_non_array_param  sK    L33#\%I%I$l&K&KM %%a64Hr   c           	         R pR\         P                  R\         P                  R\         P                  /p/ pRp\        P
                  ! \        \         P                  WVVR7       R# )z*reshape((/ (i, i=1, 250) /), (/5, 10, 5/))r   r   r  z(0:4, 3:12, 5)r  Nr  r  s   &    r   test_param_eval_too_many_dims+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&   s   @r   r   r   p  s#     	(*' ' 'r   r   c                   X   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                    \         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)matchN)r   r  r  r   utilsmy_abort)r   r   s   & r   test_no_lower_fail)TestLowerF2PYDirective.test_no_lower_fail  s?    ]]:-@AASKK&&':; BAAAs   &AA&	r   N)r   r   r    r!   r   r"   r#   optionsr)  r$   r%   r&   s   @r   r$  r$    s-     ||GUNMJKGkG< <r   r$  )#r   r   r   r   r   r   numpyr   
numpy.f2pyr   numpy.f2py.crackfortranr   r   r   r   r   slowF2PyTestr   r)   rC   rK   rb   rn   r   r   r   r   r   r   r   r   r   r   r$  r   r   r   <module>r1     s     	     # D  ,$-- , ,%' %'N? ?: 4==  & 2t}} 2 2I I* c/$-- c/ c/L< < 3t}} 3 3 ' ' '   "E "EH 2 2 2 St}} S S8 82' 2'h <T]] < <r   