+
    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       \         P
                  ! W^,           4      '       g   Q hV P                  P                  W!.4       \         P
                  ! W^,           4      '       g   Q hV P                  P                  R4      R8X  g   Q hR# )   )ZdtypeZ23s   2N)r         )npZarrayZfloat64moduleZsubbZallcloseZsubct0)selfZkw   &  I/usr/lib64/python3.14/site-packages/numpy/f2py/tests/test_crackfortran.pytest_moduleZTestNoSpace.test_module   s    HHYbjj1HHYbjj1{{1!e$$$$! {{1!e$$$${{~~d#t+++     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4      ^8X  g   Q hV^ ,          pRVR,          R,          R,          9   g   Q hRVR,          R,          R,          9  g   Q hRVR,          R	,          R,          9   g   Q hRVR,          R	,          R,          9  g   Q hRVR,          R
,          R,          9  g   Q hRVR,          R
,          R,          9   g   Q hR# )r   r   r    zprivatemod.f90privatevarsaattrspecpublicbsetaNr   r   r    strlen)r   fpathmodr   r   test_defaultPrivateZ%TestPublicPrivate.test_defaultPrivate    s    We^=MN''U53x1}}!fCK,Z8888s6{3/
;;;;CK,Z8888s6{3/
;;;;FF 3J ????3v;v.z::::r   c                s   \         P                  ! R RRR4      p\        P                  ! \        V4      .4      p\	        V4      ^8X  g   Q hV^ ,          pRVR,          R,          R,          9   g   Q hRVR,          R,          R,          9  g   Q hRVR,          R	,          R,          9  g   Q hRVR,          R	,          R,          9   g   Q hR
# )r   r   r    zpublicmod.f90r    r!   r"   r#   r$   r&   Nr'   r   tmp_pathr*   r+      &&  r   test_defaultPublicZ$TestPublicPrivate.test_defaultPublic,   s    We^_M''U53x1}}!fCK,Z8888s6{3/
;;;;FF 3J ????3v;v.z::::r   c                s   \         P                  ! R RRR4      p\        P                  ! \        V4      .4      p\	        V4      ^8X  g   Q hV^ ,          R,          p\        VR,          R,          4      RR08X  g   Q h\        VR	,          R,          4      R
R08X  g   Q h\        VR,          R,          4      R
08X  g   Q hR# )r   r   r    zaccesstype.f90r!   r"   r#   r    zbind(c)Zb_r$   ZcN)r   r   r    r(   r)   Zset)r   r.   r*   r+   Ztt   &&   r   test_access_typeZ"TestPublicPrivate.test_access_type6   s    We^=MN''U53x1}}VF^2c7:&'Iy+AAAA2d8J'(Xy,AAAA2c7:&'H:555r   c                s    \         P                  ! R RRR4      p\        P                  ! \        V4      .4      p\	        V4      ^8X  g   Q h\        P
                  ! V4      pRV9  g   Q hR# )r   r   r    zgh23879.f90ZbarN)r   r   r    r(   r)   Zcrack2fortran)r   r.   r*   r+   Zpyfr1   r   test_nowrap_private_proceeduresZ1TestPublicPrivate.test_nowrap_private_proceedures?   sZ    We^]K''U53x1}}((-Cr   r   N)
r   r   r   r   r,   r0   r2   r3   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                s   \         P                  ! R RRR4      p\        P                  ! \        V4      .4      p\	        V4      ^8X  g   Q hV^ ,          pRV9   d   \	        VR,          4      ^	8X  g   Q hVR,          ^,          R,          R8X  g   Q hRVR,          ^,          9   g   Q hVR,          ^,          R,          RR	.8X  g   Q hVR,          ^,          R,          R
8X  g   Q hRVR,          ^,          9   g   Q hVR,          ^,          R,          R.8X  g   Q hVR,          ^,          R,          R8X  g   Q hRVR,          ^,          9   g   Q hVR,          ^,          R,          RR.8X  g   Q hR# )r   r   r    zoperators.f90Zbodynamezoperator(.item.)ZimplementedbyZitem_intZ	item_realzoperator(==)Zitems_are_equalzassignment(=)Zget_intZget_realNr'   r-   r/   r   test_moduleOperatorsZ(TestModuleProcedure.test_moduleOperatorsG   sc   We^_M''U53x1}}!f}S[!1Q!6666{1~f%);;;;#f+a.0006{1~o.%& 	& &6{1~f%777#f+a.0006{1~o.3D2EEEE6{1~f%888#f+a.0006{1~o.
#$ 	$ $r   c                sh   \         P                  ! R RRR4      p\        P                  ! \        V4      .4      p\	        V4      ^8X  g   Q hV^ ,          pVR,          R,          R,          R.8X  g   Q hVR,          R,          R,          R	.8X  g   Q hVR,          R
,          R,          R	.8X  g   Q hR# )r   r   r    zpubprivmod.f90r!   r"   r#   r    r%   r$   r&   Nr'   r-   r/   r   test_notPublicPrivateZ)TestModuleProcedure.test_notPublicPrivateY   s    We^=MN''U53x1}}!f6{3
+	}<<<6{3
+|;;;6{6":.8,>>>r   r   N)r   r   r   r   r6   r7   r   r   r   r   r   r4   r4   F   s     $$? ?r   r4   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                T    R  pV P                   P                  V4      pV^{8X  g   Q hR# )c                     V ^{,           # i{   r   Zx   &r   incrZ5TestExternal.test_external_as_statement.<locals>.incrh       s7Nr   N)r   Zexternal_as_statementr   r>   rr   r   test_external_as_statementZ'TestExternal.test_external_as_statementg   (    	 KK--d3Cxxr   c                r9   )c                 r:   r;   r   r<   r=   r   r>   Z5TestExternal.test_external_as_attribute.<locals>.incro   r?   r   N)r   Zexternal_as_attributer@   r   r   test_external_as_attributeZ'TestExternal.test_external_as_attributen   rC   r   r   N)r   r   r   r   r   r   r   rB   rD   r   r   r   r   r   r8   r8   c   s+     ||GUNKHIG r   r8   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                sP    V P                   P                  ^^4      pVR8X  g   Q hR# )r   N)r   r   )r   Zgh2848)r   rA      & r   test_gh2848ZTestCrackFortran.test_gh2848|   s$    KKq!$F{{r   c                sf    \        V P                  P                  P                  4      ^8X  g   Q hR# )i   N)r)   r   ZmortmpZctmpr   r=   r   test_common_with_divisionZ*TestCrackFortran.test_common_with_division   s%    4;;%%**+r111r   r   N)r   r   r   r   r   r   r   rG   rI   r   r   r   r   r   rE   rE   v   s@     ||GUNLI||GUN<TUG2 2r   rE   c                   s8   a  ] tR t^t o R tR tR tR tRtV t	R# )TestMarkinnerspacesc                sD    . ROpV F  p\        V4      V8X  d   K  Q h	  R# )a N)rK   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"1%*** r   c                N    \        R 4      R8X  g   Q h\        R4      R8X  g   Q hR# )za 'b c' \' \'za 'b@_@c' \' \'za "b c" \" \"za "b@_@c" \" \"NrL   rH   r=   r   test_one_relevant_spaceZ+TestMarkinnerspaces.test_one_relevant_space   s,    015HHHH/04FFFFr   c                rN   )za 'b c" " d' eza 'b@_@c"@_@"@_@d' eza "b c' ' d" eza "b@_@c'@_@'@_@d" eNrL   rH   r=   r   test_ignore_inner_quotesZ,TestMarkinnerspaces.test_ignore_inner_quotes   s,    126NNNN126NNNNr   c                rN   )za 'b c' 'd e'za 'b@_@c' 'd@_@e'za "b c" "d e"za "b@_@c" "d@_@e"NrL   rH   r=   r   test_multiple_relevant_spacesZ1TestMarkinnerspaces.test_multiple_relevant_spaces   s+    /3FFFF/04HHHHr   r   N)
r   r   r   r   rM   rO   rP   rQ   r   r   r   r   r   rJ   rJ      s"     +
GOI Ir   rJ   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firstrU   c                s    V P                   P                  V4      p\        V P                  R V 24      pR F   pV! V4      w  rVVP                  V8X  d   K   Q h	  R# )get_arr_size_Nr   r   r	   i   i   )all_dimspecsindexgetattrr   Zsize)r   rU   rT   get_arr_sizenszr"   s   &&     r   test_array_sizeZTestDimSpec.test_array_size   sV     !!''0t{{mE7,CD A OEB66R<< !r   c                s:   V P                   P                  V4      p\        V P                  R V 24      p\        V P                  RV 24      pR FG  pV! V4      w  rgWP                  9   d
   V! Wu4      pMV! V4      pV! V4      w  rWi8X  d   K@  Q WXWi34       h	  R# )rV   Zget_inv_arr_size_NrW   )rX   rY   rZ   r   nonlinear_dimspecs)r   rU   rT   r[   Zget_inv_arr_sizer\   r]   r"   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9.qb..9 !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   Z__doc__ZsuffixtextwrapZdedentZcode_templateZlinear_dimspecsr_   rX   ZcodeZ	enumeraterT   rU   ZsplitZlstZformatZjoinpytestmarkparametrizeslowr^   ra   r   r   )Zdr   s   0@r   rR   rR      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rR   c                   s&   a  ] tR t^t o R tRtV tR# )TestModuleDeclarationc                s    \         P                  ! R RRR4      p\        P                  ! \        V4      .4      p\	        V4      ^8X  g   Q hV^ ,          R,          R,          R,          R8X  g   Q hR# )	r   r   r    zfoo_deps.f90r!   ZabarZ=zbar('abar')Nr'   r-   r/   r   test_dependenciesZ'TestModuleDeclaration.test_dependencies   s\    We^^L''U53x1}}1vf~f%c*m;;;r   r   N)r   r   r   r   rh   r   r   r   r   r   rg   rg      s     < <r   rg   c                   &   a  ] tR tRt o R tRtV tR# )TestEvali  c                s    \         P                  pV! R / 4      R 8X  g   Q hV! R/ 4      R8X  g   Q hV! RR^R^/4      R8X  g   Q hV! R/ 4      R8X  g   Q hR	# )
Z123z12 + 3Z15za + br"   r%   Z3z"123"z'123'N)r    Z_eval_scalar)r   Zeval_scalarrF   r   test_eval_scalarZTestEval.test_eval_scalar  sj    "//5"%...8R(D0007S!S!$45<<<7B'7222r   r   N)r   r   r   r   rk   r   r   r   r   r   rj   rj     s     3 3r   rj   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V^ ,          R,          R8X  g   Q hR#   + '       g   i     LI; i)Zinput_with_z_encoding.f90r   )rm   zd
                     subroutine foo()
                     end subroutine foo
                     Nr5   foo)ZopenZwriter    r(   )r   r.   rm   Zf_pathZffr+   s   &&&   r   test_input_encodingZ%TestFortranReader.test_input_encoding  sy     k(=AA[[x[00BHH   1
 ''V61vf~&&& 10s   A<<B	r   N)Zasciizutf-8zutf-16zutf-32)
r   r   r   r   rc   rd   re   ro   r   r   r   r   r   rl   rl     s-     [[ZCE	'E	'r   rl   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   rn   rH   r=   r   test_encoding_commentZ(TestUnicodeComment.test_encoding_comment$  s    
 	r   r   )r   r   r   r   r   r   r   rc   rd   Zskipif	importlibZ	find_specrr   r   r   r   r   r   rp   rp      s^     ||GUN<QRSG[[		!	!"6	74	?H  	r   rp   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                s   ^p^p^^rT\        WE4       F  pW,          p\        V4       F  p. p	\        V4       FY  p\        P                  ! 4       p
\        P                  ! V4      pV	P                  \        P                  ! 4       V
,
          4       K[  	  \        P                  ! V	4      R8  d   K  Q h	  X'       d   Q hVR,           p\        P                  ! V4      '       d   K  Q h	  R# )zHaddress ReDOS vulnerability:
https://github.com/numpy/numpy/issues/23338g?z@)@N)ZrangetimeZperf_counterr   ZsearchZappendr
   Zmedian)r   ru   Ztrials_per_batchZbatches_per_regexZ
start_repsZend_repsZiiZrepeated_adversaryr`   Ztimesr   Z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 yy'#--- . O8 );U(B%"))*CDDDD' .r   r   N))z
@)@bind@(@)z#@)@bind                         @(@)z@)@bind foo bar baz@(@)
r   r   r   r   rc   rd   re   rw   r   r   r   r   r   rt   rt   ,  s2     [[		
EEr   rt   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                sL    V P                   P                  ^^4      ^8X  g   Q hR# rq   )r   Z
intproductrH   r=   r   test_function_rettypeZ(TestFunctionReturn.test_function_rettypeS  s#     {{%%a+r111r   r   N)r   r   r   r   r   r   r   rc   rd   rf   ry   r   r   r   r   r   rx   rx   P  s8     ||GUNMJKG[[2 2r   rx   c                   ri   )TestFortranGroupCountersiY  c                s    \         P                  ! R RRR4      p \        P                  ! \        V4      .4       R#   \         d   pQ RT 24       hRp?ii ; i)r   r   r    z	gh23533.fz0'crackfortran.crackfortran' raised an exception N)r   r   r    r(   Z	Exception)r   r*   excr   r   test_end_if_commentZ,TestFortranGroupCounters.test_end_if_commentZ  sT    We^[I	S%%s5zl3 	SRLSERR5	Ss    = A
AAr   N)r   r   r   r   r|   r   r   r   r   r   rz   rz   Y  s     S Sr   rz   c                   ri   )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XP                  4       9  g   Q hR#   + '       g   i     L); i)r   r   r    zgh22648.pyfNZMismatch)	r   r   
contextlibZredirect_stdoutioZStringIOr    r(   Zgetvalue)r   r.   r*   Zstdout_f2pyr+   r1   r   test_gh22648Z%TestF77CommonBlockReader.test_gh22648d  sj    We^]K''66+++SZL9C 7!5!5!7777 76s   !BB	r   N)r   r   r   r   r   r   r   r   r   r   r}   r}   c  s     8 8r   r}   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V^R	^R
/8X  g   Q hR# )z(/3.14, 4./)kindselected_int_kindselected_real_kindZdpZintparamarrayZnestedz(2)rU   gQ	@g      @Nr    
_kind_func_selected_int_kind_func_selected_real_kind_func
param_evalr   vg_paramsparamsrU   ret   &     r   test_param_eval_nestedZ$TestParamEval.test_param_eval_nestedl  s    L33#\%I%I$l&K&KM ?Q1aLQ1aA.0%%a6Kq$3''''r   c                s    R pR\         P                  R\         P                  R\         P                  /p/ pRp\         P                  ! WW4R7      pVR^^ ^^^/8X  g   Q hR# )z(/ 6, 3, 1 /)r   r   r   z(-1:1)r   Nir   r   r   r   !test_param_eval_nonstandard_rangeZ/TestParamEval.test_param_eval_nonstandard_rangew  si    L33#\%I%I$l&K&KM %%a6Kr1aAq))))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   rS   r   Nr    r   r   r   rc   raises
ValueErrorr   r   r   r   r   rU      &    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VR 8X  g   Q h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  sY    L33#\%I%I$l&K&KM %%a64Hi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   r   r   j  s#     	(*' ' 'r   r   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)rc   r   r   r   ZutilsZmy_abort)r   r{   rF   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   )#r~   rs   r   rb   rv   rc   Znumpyr
   Z
numpy.f2pyr    Znumpy.f2py.crackfortranr   r   rS   r   ZF2PyTestr   r   r4   r8   rE   rJ   rR   rg   rj   rl   rd   rf   rp   rt   rx   rz   r}   r   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   