+
    /ic,                     <   R t ^ RIt^ RIt^ RIt^ RIHt ^ RIHt ^ RIt^ RIt^ RI	H
t
Ht ^ RIt^ RIt^ RIHtHtHt ]P&                  ! ]P(                  ! ]4      R4      t]P.                  R 4       tR tR	 tR
 tR tR tR tR tR t R t!R t"R t#R t$R t%R t&R# )z#Tests for fortran sequential files N)path)iglob)assert_equalassert_allclose)FortranFileFortranEOFErrorFortranFormattingErrordatac                  ,    \         P                  ! 4       # )N)	threadingLock     Y/var/www/html/photoedit/myenv/lib/python3.14/site-packages/scipy/io/tests/test_fortran.pyio_lockr      s    >>r   c                 *   \        \        P                  ! \        R 4      4       EFV  p\        P
                  ! RV\        P                  4      pV'       g   \        RV R24      h\        VP                  ^4      4      \        VP                  ^4      4      \        VP                  ^4      4      3pVP                  ^4      P                  RR4      pV ;_uu_ 4        \        VRR4      pVP                  VR7      P                  VR	R
7      pVP                  4        RRR4       \        P                   ! \        P"                  ! V4      4      P                  V4      P%                  V4      p\'        XV4       EKY  	  R#   + '       g   i     Lk; i)fortran-*-*x*x*.dat%fortran-([^-]+)-(\d+)x(\d+)x(\d+).datCouldn't match  filename to regexs<r<u4dtypeForderN)r   r   join	DATA_PATHresearchIRuntimeErrorintgroupreplacer   read_recordreshapeclosenparangeprodastyper   )r   filenamemdimsr   fr	   expecteds   &       r   test_fortranfiles_readr4      s   $))I/DEFII>"$$O
:LMNNAGGAJQWWQZ#aggaj/B
""3,WHc51A==u=-55d#5FDGGI 
 99RWWT]+33D9@@GT8$ G Ws   AFFc           	         \         P                  ! \        R 4      pT ;_uu_ 4        \        VRR4      ;_uu_ 4       pVP	                  R4      pRRR4       RRR4       \        XR,          ^ ,          ^4       \        VR,          ^ ,          R4       \        VR,          ^ ,          ^4       \        VR	,          ^ ,          R
R.4       R#   + '       g   i     L; i  + '       g   i     L; i)zfortran-mixed.datr   r   z<i4,<f4,<i8,2<f8Nf0f1gffffff@f2f3gffffff@g333333@)r   r   r    r   r(   r   r   )r   r/   r2   records   &   r   test_fortranfiles_mixed_recordr;   /   s    yy$78H	3..!]]#56F / 
 a!$F4LOS)a!$F4LOc3Z0 /. 
s"   CC
	C
CCC-	c                     \        \        P                  ! \        R 4      4       EF  p \        P
                  ! RV \        P                  4      pV'       g   \        RV  R24      h\        VP                  ^4      4      \        VP                  ^4      4      \        VP                  ^4      4      3pVP                  ^4      P                  RR4      p\        P                  ! \        P                  ! V4      4      P                  V4      P                  V4      p\         P"                  ! 4       p \        P                  ! \%        \&        P(                  ! 4       4      V\        P*                  ! V 4      4      p\-        VRR4      pVP/                  VP0                  4       VP3                  4        \5        V R4      p\5        VR4      p	\7        VP9                  4       V	P9                  4       V R	7       VP3                  4        V	P3                  4        \:        P<                  ! V4       EK  	  R
#   \:        P<                  ! T4       i ; i)r   r   r   r   r   r   wr   rb)err_msgN)r   r   r   r    r!   r"   r#   r$   r%   r&   r'   r+   r,   r-   r)   r.   tempfilemkdtempstrr   get_native_idbasenamer   write_recordTr*   openr   readshutilrmtree)
r/   r0   r1   r   r	   tmpdirtestFiler2   originalfilenewfiles
             r   test_fortranfiles_writerO   ;   s   $))I/DEFII>"$$O
:LMNNAGGAJQWWQZ#aggaj/B
""3,yy'//5<<UC!!#	"yyY%<%<%>!?!'h(?AHHc%0ANN466"GGI$/L8T*G**,glln!)+ MMOMM&!/ G. MM&!s   2C"H11I	c           	      X   \         P                  ! \        R 4      pT ;_uu_ 4        \        VRR4      ;_uu_ 4       pVP	                  RR4      pRRR4       RRR4       \
        P                  ! ^	4      P                  ^^4      P                  \
        P                  4      p\
        P                  ! RR.\
        P                  R7      p\        X^ ,          VP                  4       \        V^,          VP                  4       R#   + '       g   i     L; i  + '       g   i     L; i)	zfortran-3x3d-2i.datr   r   z(3,3)<f8z2<i4Nr   )r   r   r    r   r(   r+   r,   r)   r.   float64arrayint32r   rF   )r   r/   r2   r:   axbxs   &     r   "test_fortranfile_read_mixed_recordrX   V   s     yy$9:H	3..!]]:v6F / 
 
3		1	%	,	,RZZ	8B	2r("((	+BBDD!BDD! /. 
s"   DD	DDDD)	c                 r   \         P                  ! \        V 4      \        \        P                  ! 4       4      R 4      p\
        P                  ! \         P                  ! V4      RR7       R\        P                  ! ^4      \        P                  ! ^4      \        P                  ! ^d4      33pR\        P                  P                  ^^.R7      P                  \        P                  4      \        P                  P                  ^^^.R7      P                  \        P                  4      \        P                  P                  ^^.R7      P                  \        P                  4      33pW#.pV F  w  rV\        VR4      ;_uu_ 4       pVP                  ! V!   RRR4       \        VR4      ;_uu_ 4       pVP                   ! V!  pRRR4       \#        \%        V4      \%        X4      4       \'        Wh4       F  w  r\#        W4       K  	  K  	  R#   + '       g   i     L; i  + '       g   i     Lf; i)	test.datTexist_ok)sizer=   Nr   )f4r^   i4)4f4z(3,3)f48i4)r   r   rB   r   rC   osmakedirsdirnamer+   float32rU   randomrandintr.   r   rE   r(   r   lenzip)rK   tfr1r2recordsr   ar2   baabbs   &          r   #test_fortranfile_write_mixed_recordrr   n   s   	3v;I$;$;$= >
	KBKKR 40
rzz!}bjjmRXXc]K	LB
#99Ss+222::>99S1v.55bjjA99Ss+22288<>
?B hGS!!QNNA " S!!Qu%A " 	SVSV$!iFB    !! "!s   
H7H&H#&H6c                   \        VP                  4       R4      ;_uu_ 4       pVP                  ^4       \        P                  ! V\        P
                  W,          V,          R7      pVP                  ^4       RRR4       XP                  W,          V,          8w  d)   \        RW,          V,           RVP                   24      hVP                  WV3RR7      #   + '       g   i     Lk; i)aJ  
Read a Fortran-style unformatted binary file written with a single write() call,
assuming it wraps the data with 4-byte record markers.

Returns:
    np.ndarray of shape (m, n, k) with dtype float64

Reference:
    Fortran implementation:
    https://github.com/scipy/scipy/blob/maintenance/1.15.x/scipy/io/_test_fortran.f#L1-L9
r>   r   countN	Expected  elements, got r   r   )	rG   striprH   r+   fromfilerS   r]   
ValueErrorr)   r0   nkr/   r2   r	   s   &&&&  r   read_unformatted_doubler~      s     
hnn	%	%	q	{{1BJJaeai@	q	 
&
 yyAEAI9QSUG?499+FGG<<q	<-- 
&	%   ACC-	c                   \        VP                  4       R4      ;_uu_ 4       pVP                  ^4       \        P                  ! V\        P
                  W,          R7      p\        P                  ! V\        P                  VR7      pVP                  ^4       RRR4       XP                  W3RR7      pVX3#   + '       g   i     L(; i)a  
Read a Fortran unformatted binary file that contains a mix of:
- a double precision array a(m, n)
- an integer array b(k)

Assumes a single write(10) a, b was used and file is wrapped
with Fortran record markers.

Returns:
    a: np.ndarray of shape (m, n) with dtype float64
    b: np.ndarray of shape (k,) with dtype int32

Reference:
    Fortran implementation:
    https://github.com/scipy/scipy/blob/maintenance/1.15.x/scipy/io/_test_fortran.f#L21-L30
r>   rt   Nr   r   )rG   rx   rH   r+   ry   rS   rU   r)   )r0   r|   r}   r/   r2   a_flatro   rn   s   &&&&    r   read_unformatted_mixedr      s    " 
hnn	%	%	q	 Qbjj> KK3	q	 
& 	vS)Aa4K 
&	%s   A7B::C
	c                   \        VP                  4       R4      ;_uu_ 4       pVP                  ^4       \        P                  ! V\        P
                  W,          V,          R7      pVP                  ^4       RRR4       XP                  W,          V,          8w  d)   \        RW,          V,           RVP                   24      hVP                  WV3RR7      #   + '       g   i     Lk; i)at  
Read a Fortran unformatted binary file
containing a 3D integer array (m, n, k).
Assumes the array is written with a single
write(10) a and wrapped with record markers.

Returns:
    np.ndarray: 3D array of shape (m, n, k) with dtype int32

Reference:
    Fortran implementation:
    https://github.com/scipy/scipy/blob/maintenance/1.15.x/scipy/io/_test_fortran.f#L11-L19
r>   rt   Nrv   rw   r   r   )	rG   rx   rH   r+   ry   rU   r]   rz   r)   r{   s   &&&&  r   read_unformatted_intr      s     
hnn	%	%	q	 {{1BHHAEAI>	q	 
& yyAEAI9QSUG?499+FGG<<q	<-- 
&	%r   c                    \         P                  ! \        V 4      \        \        P                  ! 4       4      R 4      p\
        P                  ! \         P                  ! V4      RR7       \        P                  P                  ^4      p^^^repVP                  WEV4      p\        VR4      ;_uu_ 4       pVP                  VP                  4       RRR4       V;_uu_ 4        \        WEWb4      p	RRR4       \        VR4      ;_uu_ 4       pVP!                  R4      P                  p
RRR4       \#        X	V4       \#        X
V4       ^^^repVP                  WEV4      P%                  \        P&                  4      p\        VR4      ;_uu_ 4       pVP                  VP                  4       RRR4       V;_uu_ 4        \)        WEWb4      p	RRR4       \        VR4      ;_uu_ 4       pVP!                  R4      P                  p
RRR4       \#        W4       \#        W4       ^^^repVP                  WE4      pVP                  V4      P%                  \        P*                  4      p\        VR4      ;_uu_ 4       pVP                  VP                  VP                  4       RRR4       V;_uu_ 4        \-        WEWb4      w  rRRR4       \        VR4      ;_uu_ 4       pVP!                  RR	4      w  rV
P                  p
RRR4       \#        W4       \#        W4       \#        XV4       \#        XV4       R#   + '       g   i     ELn; i  + '       g   i     ELc; i  + '       g   i     EL?; i  + '       g   i     EL; i  + '       g   i     EL; i  + '       g   i     EL; i  + '       g   i     EL; i  + '       g   i     EL
; i  + '       g   i     L; i)
rZ   Tr[   r=   Nr   z	(2,3,5)f8z	(2,3,5)i4z(3,5)f82i4)r   r   rB   r   rC   rb   rc   rd   r+   rf   RandomStaterandnr   rE   rF   r~   r(   r   r.   rU   r   intcr   )rK   r   r/   rngr0   r|   r}   rn   r2   a2a3ro   b2b3s   &&            r   test_fortran_roundtripr      s   yyVc)*A*A*C&D#%HKKX&6
))


"C A!A		!A	Xs	#	#q	qss 
$	$Q17 
 
Xs	#	#q]];')) 
$QQ A!A		!!!"((+A	Xs	#	#q	qss 
$	!!4 
	Xs	#	#q]];')) 
$ A!A		!A		!BGG$A	Xs	#	#q	qssACC  
$	'a: 
	Xs	#	#qy%0TT 
$ QQI 
$	#	#	 
$	#	# 
$	#	#		#	#	# 
$	#	#		#	#sl   4L5"M	MM1=N&N8'N-1O!O5M		M	M.	1N	N	N*	-N>	O	O%	c           	      t   \         P                  ! \        V 4      \        \        P                  ! 4       4      R 4      p\
        P                  ! \         P                  ! V4      RR7       \        P                  P                  ^4      p\        VR4      ;_uu_ 4       pVP                  VP                  ^4      4       VP                  VP                  ^4      4       RRR4       \        VR4      ;_uu_ 4       p\        VP                  4       4      ^8X  g   Q h\        VP                  4       4      ^8X  g   Q h\         P"                  ! \$        4      ;_uu_ 4        VP                  4        RRR4       RRR4       R#   + '       g   i     L; i  + '       g   i     L-; i  + '       g   i     R# ; i)scratchTr[   r=   Nr   )r   r   rB   r   rC   rb   rc   rd   r+   rf   r   r   rE   r   rh   
read_realspytestraisesr   rK   r/   r   r2   s   &   r   test_fortran_eof_okr     s   yyVc)*A*A*C&D"$HKKX&6
))


"C	Xs	#	#q	syy|$	syy|$ 
$ 
Xs	#	#q1<<>"a'''1<<>"a''']]?++LLN , 
$	# 
$	# ,+ 
$	#	#s2   AF :A#F&F	.F& F	F#F&&F7	c           	         \         P                  ! \        V 4      \        \        P                  ! 4       4      R 4      p\
        P                  ! \         P                  ! V4      RR7       \        P                  P                  ^4      p\        VR4      ;_uu_ 4       pVP                  VP                  ^4      4       VP                  VP                  ^4      4       RRR4       \        VR4      ;_uu_ 4       pVP                  R4       RRR4       \        VR4      ;_uu_ 4       p\!        VP#                  4       4      ^8X  g   Q h\!        VP#                  4       4      ^8X  g   Q h\$        P&                  ! \(        4      ;_uu_ 4        VP#                  4        RRR4       RRR4       R#   + '       g   i     L; i  + '       g   i     L; i  + '       g   i     L@; i  + '       g   i     R# ; i)r   Tr[   r=   Nab   r   )r   r   rB   r   rC   rb   rc   rd   r+   rf   r   r   rE   r   rG   writerh   r   r   r   r   r   s   &   r   test_fortran_eof_broken_sizer     s@   yyVc)*A*A*C&D"$HKKX&6
))


"C	Xs	#	#q	syy|$	syy|$ 
$ 
h			 
	Xs	#	#q1<<>"a'''1<<>"a''']]122LLN 3 
$	# 
$	# 
	
 32 
$	#	#s>   AF.:G(A#G'G	G'.F>	G	G$G''G8	c           	      v   \         P                  ! \        V 4      \        \        P                  ! 4       4      R 4      p\
        P                  ! \         P                  ! V4      RR7       \        P                  P                  ^4      p\        VR4      ;_uu_ 4       pVP                  VP                  ^4      4       VP                  VP                  ^4      4       RRR4       \        VR4      ;_uu_ 4       pVP                  R4       RRR4       \        VR4      ;_uu_ 4       p\         P"                  ! \$        4      ;_uu_ 4        VP'                  4        RRR4       RRR4       R#   + '       g   i     L; i  + '       g   i     L}; i  + '       g   i     L@; i  + '       g   i     R# ; i)r   Tr[   r=   Nzw+bs   r   )r   r   rB   r   rC   rb   rc   rd   r+   rf   r   r   rE   r   rG   r   r   r   r   r   r   s   &   r   test_fortran_bogus_sizer   (  s   yyVc)*A*A*C&D"$HKKX&6
))


"C	Xs	#	#q	syy|$	syy|$ 
$ 
h		!	 
	Xs	#	#q]]122LLN 3 
$	# 
$	# 
	 32 
$	#	#s=   AE.:F(#F'F	F'.E>	F	F$F''F8	c           	         \         P                  ! \        V 4      \        \        P                  ! 4       4      R 4      p\
        P                  ! \         P                  ! V4      RR7       \        P                  P                  ^4      p\        VR4      ;_uu_ 4       pVP                  VP                  ^4      4       VP                  VP                  ^4      4       RRR4       \        VR4      ;_uu_ 4       pVP                  \         P                   ! V4      ^,
          4       RRR4       \        VR4      ;_uu_ 4       p\#        VP%                  4       4      ^8X  g   Q h\&        P(                  ! \*        4      ;_uu_ 4        VP%                  4        RRR4       RRR4       R#   + '       g   i     L; i  + '       g   i     L; i  + '       g   i     L@; i  + '       g   i     R# ; i)r   Tr[   r=   Nr   r   )r   r   rB   r   rC   rb   rc   rd   r+   rf   r   r   rE   r   rG   truncategetsizerh   r   r   r   r   r   s   &   r   test_fortran_eof_broken_recordr   7  s5   yyVc)*A*A*C&D"$HKKX&6
))


"C	Xs	#	#q	syy|$	syy|$ 
$ 
h			

4<<)",- 
	Xs	#	#q1<<>"a''']]122LLN 3 
$	# 
$	# 
	 32 
$	#	#s>   AF):-F<AG"G	G")F9	<G	GG""G3	c           	      x   \         P                  ! \        V 4      \        \        P                  ! 4       4      R 4      p\
        P                  ! \         P                  ! V4      RR7       ^^^rCp\        P                  ! R\        P                  W#33.4      p\        P                  ! WER7      p\        VR4      ;_uu_ 4       pVP                  V^ ,          4       VP                  V4       VP                  V4       RRR4       \        VR4      ;_uu_ 4       pVP                  \         P                   ! V4      ^,
          4       RRR4       \        VR4      ;_uu_ 4       p\#        VP%                  VR7      4      ^8X  g   Q h\#        VP%                  VR7      4      V8X  g   Q h\&        P(                  ! \*        4      ;_uu_ 4        VP%                  VR7       RRR4       RRR4       R#   + '       g   i     L; i  + '       g   i     L; i  + '       g   i     L@; i  + '       g   i     R# ; i)	r   Tr[   fieldr   r=   Nr   r   )r   r   rB   r   rC   rb   rc   rd   r+   r   rS   zerosr   rE   rG   r   r   rh   r(   r   r   r   )rK   r/   r|   r0   qdtrn   r2   s   &       r   !test_fortran_eof_multidimensionalr   G  s   yyVc)*A*A*C&D"$HKKX&6A!A	GRZZ!01	2B
A	Xs	#	#q	qt	q	q 
$ 
h			

4<<)",- 
	Xs	#	#q1==r=*+q0001==r=*+q000]]122MMM# 3 
$	# 
$	# 
	
 32 
$	#	#s=   ;G/-H#A'H(
H	H(/G?	H	H% H((H9	)'__doc__r@   rI   rb   r   globr   r   r!   numpy.testingr   r   numpyr+   r   scipy.ior   r   r   r   rd   __file__r    fixturer   r4   r;   rO   rX   rr   r~   r   r   r   r   r   r   r   r   r   r   r   <module>r      s    *   	    	 7  . .
 IIdll8,f5	  %&	1"6"0!..,B.6.b" $r   