+
    /iR                        R t ^ RIt^ RIt^ RIt^ RIHt ^ RIt^ RIt	^RI
HtHtHtHtHtHtHt ^RIHtHt ^ RIHt . R'Ot]P0                  R8H  t^ t^t^t^t^t^t]R]R]R]R]R]RR. R(ORR/t R]R]R]R]R]R]R]R]R]R]R]/t!^ t"^t#^t$^ R^R^R^R^R/t%]"R]#R]$R /t&]PN                  ! ]PP                  4      PR                  t* ! R! R4      t+ ! R" R	4      t, ! R# R]4      t-R)R$ lt. ! R% R
4      t/ ! R& R4      t0R# )*z0Classes for read / write of matlab (TM) 4 files
N)mul)MatFileReader	docfillermatdims
read_dtypeconvert_dtypesarr_to_charsarr_dtype_number)squeeze_elementchars_to_strings)reduceMatFile4ReaderMatFile4Writer
VarHeader4
VarReader4
VarWriter4littlef8f4i4i2u2u1headerU1c32c24c16c8S1<>zVAX D-floatzVAX G-floatCraydoublecharsparsec                   .   a  ] tR t^Yt o RtRtR tRtV tR# )r   Fc                B    Wn         W n        W0n        W@n        WPn        R # N)namedtypemclassdims
is_complex)selfr)   r*   r+   r,   r-   s   &&&&&&S/var/www/html/photoedit/myenv/lib/python3.14/site-packages/scipy/io/matlab/_mio4.py__init__VarHeader4.__init__^   s     	
	$    )r,   r*   r-   r+   r)   N)	__name__
__module____qualname____firstlineno__
is_logical	is_globalr0   __static_attributes____classdictcell____classdict__s   @r/   r   r   Y   s     JI
% 
%r2   c                   \   a  ] tR t^kt o RtR tR tRR ltRR ltR t	R t
R tR	 tR
tV tR# )r   z!Class to read matlab 4 variables c                    Wn         VP                  V n        VP                  V n        VP                  V n        VP                  V n        R # r(   )file_reader
mat_streamdtypeschars_as_strings
squeeze_me)r.   r?   s   &&r/   r0   VarReader4.__init__n   s=    &%00!(( + < <%00r2   c                   \        V P                  V P                  R,          4      pV P                  P                  \	        VR,          4      4      P                  R4      pVR,          ^ 8  g   VR,          R8  d   \        R4      h\        VR,          R4      w  r4VR9  d-   \        P                  ! R\        V,           R	2\        ^R
7       \        V^d4      w  rTV^ 8w  d   \        R4      h\        V^
4      w  rdTpVR,          VR,          3pVR,          ^8H  p	V P                  V,          p
\        VV
VVV	4      # )z$Read and return header for variable r   namlen    mopt  z.Mat 4 mopt wrong format, byteswapping problem?  z!We do not support byte ordering 'z'; returned data may be corrupt)
stacklevelz,O in MOPT integer should be 0, wrong format?mrowsncolsimagf)       )r   r@   rA   readintstrip
ValueErrordivmodwarningswarnorder_codesUserWarningr   )r.   datar)   MrestOPTr,   r-   r*   s   &          r/   read_headerVarReader4.read_headeru   s&   $//4;;x+@A##CX$78>>wG<!tF|d2MNNft,F?MM=k!n=M N: :%!5 s#6KLLr"WtG}-']a'
A 	r2   c                z   VP                   pV\        8X  d   V P                  V4      pMlV\        8X  d8   V P	                  V4      pV'       d   V P
                  '       d   \        V4      pM*V\        8X  d   V P                  V4      # \        R V 24      hV'       d   V P                  '       d   \        V4      # V# )No reader for class code )r+   mxFULL_CLASSread_full_arraymxCHAR_CLASSread_char_arrayrB   r   mxSPARSE_CLASSread_sparse_array	TypeErrorrC   r
   )r.   hdrprocessr+   arrs   &&&  r/   array_from_headerVarReader4.array_from_header   s    \!&&s+C|#&&s+C4000&s+~%))#..7x@AAt"3''
r2   c                   VP                   p\        \        VP                  \        P
                  ! VP                  4      4      pV\        8  d)   \        RVP                  P                  R4       R24      hV P                  P                  V4      p\        V4      V8w  d)   \        RVP                  P                  R4       R24      h\        P                  ! VP                  VVRR7      pV'       d   VP                  4       pV# )a  Mat4 read using header `hdr` dtype and dims

Parameters
----------
hdr : object
   object with attributes ``dtype``, ``dims``. dtype is assumed to be
   the correct endianness
copy : bool, optional
   copies array before return if True (default True)
   (buffer is usually read only)

Returns
-------
arr : ndarray
    of dtype given by `hdr` ``dtype`` and shape given by `hdr` ``dims``
z
Variable 'latin1zL' has byte length longer than largest possible NumPy array on this platform.z!Not enough bytes to read matrix 'z'; is this a badly-formed file? Consider listing matrices with `whosmat` and loading named matrices with `variable_names` kwarg to `loadmat`F)shaper*   bufferorder)r*   r   r   r,   npint64itemsize	_MAX_INTPrT   r)   decoder@   rQ   lenndarraycopy)r.   rk   r}   dt	num_bytesrt   rm   s   &&&    r/   read_sub_arrayVarReader4.read_sub_array   s    " YY3"((2;;*?@	y SXX__X67 8M NO O %%i0v;)#HHOOH-. /DEF F
 jjsxx! &"$ ((*C
r2   c                    VP                   '       d6   V P                  VRR7      pV P                  VRR7      pW#R,          ,           # V P                  V4      # )zFull (rather than sparse) matrix getter

Read matrix (array) can be real or complex

Parameters
----------
hdr : ``VarHeader4`` instance

Returns
-------
arr : ndarray
    complex array if ``hdr.is_complex`` is True, otherwise a real
    numeric array
F)r}   y              ?)r-   r   )r.   rk   resres_js   &&  r/   re   VarReader4.read_full_array   sU     >>>%%c%6C''%'8E"*%%""3''r2   c                N   V P                  V4      P                  \        P                  4      pVP	                  4       P                  R4      p\        P                  ! VP                  \        P                  ! R4      \        P                  ! V4      R7      P                  4       # )zlatin-1 text matrix (char matrix) reader

Parameters
----------
hdr : ``VarHeader4`` instance

Returns
-------
arr : ndarray
    with dtype 'U1', shape given by `hdr` ``dims``
latin-1r   rs   r*   rt   )r   astyperv   uint8tobytesrz   r|   r,   r*   arrayr}   )r.   rk   rm   Ss   &&  r/   rg   VarReader4.read_char_array   sm     !!#&--bhh7KKM  +zz "!#!..2df	5r2   c                6   V P                  V4      pVRR1R3,          p\        VR,          4      \        VR	,          4      3p\        P                  ! VR
,          RR7      p\        P                  ! VR,          RR7      pV^,          pV^,          pVP                  ^,          ^8X  d!   \        P                  ! VR,          RR7      pM-\        P                  ! VR,          RR7      pVR,          Vn        \        P                  P                  WuV33V4      # )a  Read and return sparse matrix type

Parameters
----------
hdr : ``VarHeader4`` instance

Returns
-------
arr : coo_array
    with dtype ``float`` and shape read from the sparse array data

Notes
-----
MATLAB 4 real sparse arrays are saved in a N+1 by 3 array format, where
N is the number of non-zero values. Column 1 values [0:N] are the
(1-based) row indices of the each non-zero value, column 2 [0:N] are the
column indices, column 3 [0:N] are the (real) values. The last values
[-1,0:2] of the rows, column indices are shape[0] and shape[1]
respectively of the output matrix. The last value for the values column
is a padding 0. mrows and ncols values from the header give the shape of
the stored matrix, here [N+1, 3]. Complex data are saved as a 4 column
matrix, where the fourth column contains the imaginary component; the
last value is again 0. Complex sparse data do *not* have the header
``imagf`` field set to True; the fact that the data are complex is only
detectable because there are 4 storage columns.
NNNNintcr*   floatcomplex)r   rO   )r   rP   )r   rO   )r   rP   )r      )r      )	r   rR   rv   ascontiguousarrayrs   imagscipyr%   	coo_array)r.   rk   r   tmpr,   IJVs   &&      r/   ri   VarReader4.read_sparse_array   s    6 !!#&#2#a%jCICI/  S7  S7	Q	Q99Q<1$$SXG<A$$SXI>AXAF||%%qAi66r2   c                J   VP                   pV\        8X  d&   \        \        \        VP
                  4      4      pEMV\        8X  d=   \        \        \        VP
                  4      4      pV P                  '       d   VRR pEMeV\        8X  EdL   VP                  pVP
                  p\        V4      ^8X  d   V^ ,          ^8  d   V^,          ^8  g   R# V P                  P                  VP                  V^ ,          ^,
          ,          ^4       \        P                  ! RVV P                  P!                  VP                  4      R7      pV P                  P                  VP                  V^ ,          ^,
          ,          ^4       \        P                  ! RVV P                  P!                  VP                  4      R7      p\	        V4      \	        V4      3pM\#        RV 24      hV P$                  '       d$   \        V Uu. uF  q^8w  g   K  VNK  	  up4      pV# u upi )zgRead the shape of the array described by the header.
The file position after this call is unspecified.
Nr   rc   r    )r+   rd   tuplemaprR   r,   rf   rB   rh   r*   r{   r@   seekrx   rv   r|   rQ   rj   rC   )	r.   rk   r+   rs   r~   r,   rowscolsxs	   &&       r/   shape_from_headerVarReader4.shape_from_header  s    \!#c388,-E|##c388,-E$$$cr
~%B88DINtAw!|Q1	 OO  Q!!<a@::Bb%)__%9%9"++%FHDOO  Q!!<a@::Bb%)__%9%9"++%FHD YD	*E7x@AA???e6eAv11e67E 7s   H H )rB   rA   r?   r@   rC   NT)r3   r4   r5   r6   __doc__r0   r`   rn   r   re   rg   ri   r   r9   r:   r;   s   @r/   r   r   k   s7     ,14"%N(,5$(7T   r2   c                   l   a a ] tR tRt oRt]V 3R l4       tR tR tR t	RR lt
RR ltR	 tR
tVtV ;t# )r   i<  zReader for Mat4 files c                >   < \         SV `  ! V.VO5/ VB  RV n        R# )zEInitialize matlab 4 file reader

%(matstream_arg)s
%(load_args)s
    N)superr0   _matrix_reader)r.   r@   argskwargs	__class__s   &&*,r/   r0   MatFile4Reader.__init__>  s$     	5d5f5"r2   c                X   V P                   P                  ^ 4       \        V P                   \        P                  ! R4      4      pV P                   P                  ^ 4       V^ 8X  d   R# V^ 8  g   VR8  d   \
        ;'       d    R;'       g    R# \
        ;'       d    R;'       g    R# )rO   r   r    rI   r!   )r@   r   r   rv   r*   SYS_LITTLE_ENDIAN)r.   rH   s   & r/   guess_byte_orderMatFile4Reader.guess_byte_orderH  s    Q$//288D>:Q19!8td{$,,333 ((S//C/r2   c                d    \        \        V P                  4      V n        \	        V 4      V n        R# )zPRun when beginning read of variables

Sets up readers from parameters in `self`
N)r   mdtypes_template
byte_orderrA   r   r   )r.   s   &r/   initialize_readMatFile4Reader.initialize_readT  s$    
 %%5tG(.r2   c                d   V P                   P                  4       p\        \        VP                  \
        P                  ! VP                  P                  4      4      pVP                  '       d   VP                  \        8X  g
   V^,          pV P                  P                  4       V,           pW3# )a	  Read and return header, next position

Parameters
----------
None

Returns
-------
header : object
   object that can be passed to self.read_var_array, and that
   has attributes ``name`` and ``is_global``
next_position : int
   position in stream of next variable
)r   r`   r   r   r,   rv   rw   r*   rx   r-   r+   rh   r@   tell)r.   rk   remaining_bytesnext_positions   &   r/   read_var_headerMatFile4Reader.read_var_header\  s{     !!--/ chh9K9K0LM>>>#**">q O,,.@!!r2   c                8    V P                   P                  W4      # )aD  Read array, given `header`

Parameters
----------
header : header object
   object with fields defining variable header
process : {True, False}, optional
   If True, apply recursive post-processing during loading of array.

Returns
-------
arr : array
   array with post-processing applied or not according to
   `process`.
)r   rn   )r.   r   rl   s   &&&r/   read_var_arrayMatFile4Reader.read_var_arrays  s      ""44VEEr2   c                Z   \        V\        4      '       d   V.pMVe   \        V4      pV P                  P	                  ^ 4       V P                  4        / pV P                  4       '       g   V P                  4       w  r4VP                  f   RMVP                  P                  R4      pVe$   WQ9  d   V P                  P	                  V4       Kz  V P                  V4      W%&   V P                  P	                  V4       Vf   K  VP                  V4       \        V4      ^ 8X  g   K   V# V# )zget variables from stream as dictionary

Parameters
----------
variable_names : None or str or sequence of str, optional
    variable name, or sequence of variable names to get from Mat file /
    file stream. If None, then get all variables in file.
Nonerq   )
isinstancestrlistr@   r   r   end_of_streamr   r)   rz   r   remover{   )r.   variable_namesmdictrk   r   r)   s   &&    r/   get_variablesMatFile4Reader.get_variables  s     nc**,-N'!.1NQ$$&&!%!5!5!7C XX-6388??83LD)d.H$$]3--c2EKOO  /)%%d+~&!+ur2   c                   V P                   P                  ^ 4       V P                  4        . pV P                  4       '       g   V P	                  4       w  r#VP
                  f   RMVP
                  P                  R4      pV P                  P                  V4      p\        P                  VP                  R4      pVP                  WEV34       V P                   P                  V4       K  V# )zlist variables from stream r   rq   unknown)r@   r   r   r   r   r)   rz   r   r   mclass_infogetr+   append)r.   varsrk   r   r)   rs   infos   &      r/   list_variablesMatFile4Reader.list_variables  s    Q$$&&!%!5!5!7C XX-6388??83LD''99#>E??3::y9DKKd+,OO  /r2   )r   rA   r   r(   )r3   r4   r5   r6   r   r   r0   r   r   r   r   r   r   r9   r:   __classcell__)r   r<   s   @@r/   r   r   <  s>     !# #
0/".F$> r2   c                p    \        W4      p\        V4      ^8  d   \        R4      hV P                  V4      # )a[  Make ``arr`` exactly two dimensional

If `arr` has more than 2 dimensions, raise a ValueError

Parameters
----------
arr : array
oned_as : {'row', 'column'}, optional
   Whether to reshape 1-D vectors as row vectors or column vectors.
   See documentation for ``matdims`` for more detail

Returns
-------
arr2d : array
   2-D version of the array
z=Matlab 4 files cannot save arrays with more than 2 dimensions)r   r{   rT   reshape)rm   oned_asr,   s   && r/   	arr_to_2dr     s:    " 3 D
4y1} ( ) 	);;tr2   c                   Z   a  ] tR tRt o R tR tR t]]^ 3R lt	R t
R tR tR	 tR
tV tR# )r   i  c                J    VP                   V n         VP                  V n        R # r(   file_streamr   )r.   file_writers   &&r/   r0   VarWriter4.__init__  s    &22"**r2   c                \    V P                   P                  VP                  R R7      4       R# )rr   )ru   N)r   writer   )r.   rm   s   &&r/   write_bytesVarWriter4.write_bytes  s!    s{{{56r2   c                <    V P                   P                  V4       R # r(   )r   r   )r.   ss   &&r/   write_stringVarWriter4.write_string  s    q!r2   c                   \         P                  ! R\        R,          4      p\        '       * p^ pVR,          V^d,          ,           V^
,          ,           V,           VR&   V^ ,          VR&   V^,          VR&   WVR&   \	        V4      ^,           VR&   V P                  V4       VR,           p	V P                  V	P                  R	4      4       R
# )a  Write header for given data options

Parameters
----------
name : str
    name of variable
shape : sequence
    Shape of array as it will be read in matlab
P : int, optional
    code for mat4 data type, one of ``miDOUBLE, miSINGLE, miINT32,
    miINT16, miUINT16, miUINT8``
T : int, optional
    code for mat4 matrix class, one of ``mxFULL_CLASS, mxCHAR_CLASS,
    mxSPARSE_CLASS``
imagf : int, optional
    flag indicating complex
r   rJ   rH   rL   rM   rN   rF    rq   Nr   )rv   emptyr   r   r{   r   r   encode)
r.   r)   rs   r^   r_   rN   r   r[   r]   rZ   s
   &&&&&&    r/   write_headerVarWriter4.write_header  s    $ ".x89!!d(c'"b&! v  (w(wwt9q=x d{$++h/0r2   c                D   \         P                  P                  V4      '       d   V P                  W4       R# \        P
                  ! V4      pVP                  pVP                  '       g!   VP                  VP                  R4      4      pVP                  pV\        P                  J d   \        R4      hV\        P                  J d   \        R4      hV\        P                  \        P                  39   d   V P!                  W4       R# V P#                  W4       R# )zWrite matrix `arr`, with name `name`

Parameters
----------
arr : array_like
   array to write
name : str
   name in matlab workspace
N=z!Cannot save object arrays in Mat4zCannot save void type arrays)r   r%   issparsewrite_sparserv   asarrayr*   isnativer   newbyteordertypeobject_rj   voidstr_bytes_
write_charwrite_numeric)r.   rm   r)   r~   dtts   &&&  r/   r   VarWriter4.write  s     <<  %%c(jjoYY{{{**R__S12Cgg"**?@@BGG^:;;RWWbii((OOC&3%r2   c                "   \        WP                  4      pVP                  P                  R 8H  p \        VP                  P
                  R,          ,          pV P                  VVP                  V\        VR7       V'       d9   V P                  VP                  4       V P                  VP                  4       R# V P                  V4       R#   \         d5    T'       d   TP                  R4      pMTP                  R4      p\        p Li ; i)c:rP   NNc128r   )r^   r_   rN   N)r   r   r*   kindnp_to_mtypesr   KeyErrorr   miDOUBLEr   rs   rd   r   realr   )r.   rm   r)   rN   r^   s   &&&  r/   r  VarWriter4.write_numeric  s    \\*		#%	SYY]]2./A 	$))( %	 	 	'
 SXX&SXX&S!  	jj(jj&A	s   (C D")DDc                   VP                   P                  \        P                  8X  dE   VP                   P                  \        P                   ! R 4      P                  8w  d   \        V4      p\        WP                  4      pVP                  pV P                  VV\        \        R7       VP                   P                  R8X  dq   \        P                  ! V4      p\        P                  ! R\!        W4      VR7      pVP#                  4       P%                  R4      p\        P                  ! VRVR7      pV P'                  V4       R# )r   r^   r_   Ur   r   r   Nr   )r*   r   rv   r   rx   r   r   r   rs   r   miUINT8rf   r  mathprodr|   r	   itemr   r   )r.   rm   r)   r,   n_charsst_arrsts   &&&    r/   r   VarWriter4.write_char,  s    99>>RWW$););rxx~?V?V)Vs#C\\*yy	 	 	
 99>>S iioGZZb&6s&D'*,F %%i0B**4tB?Cr2   c                t   VP                  4       pVP                  P                  R8H  p\        P                  ! VP
                  ^,           ^V,           3RR7      pVP                  VRR1^ 3&   VP                  VRR1^3&   VRR1R3;;,          ^,          uu&   V'       d<   VP                  P                  VRR1^3&   VP                  P                  VRR1^3&   MVP                  VRR1^3&   VP                  VR&   V P                  VVP                  \        \        R7       V P                  V4       R# )	zHSparse matrices are 2-D

See docstring for VarReader4.read_sparse_array
r  r   r   NrO   r   Nr  r   )r   r  )tocoor*   r  rv   zerosnnzrowcolrZ   r  r   rs   r   r
  rh   r   )r.   rm   r)   ArN   ijvs   &&&   r/   r   VarWriter4.write_sparse@  s   
 IIK#hh	1U7+48UUCRCE
UUCRCE
CRCGCAJCAJCAJggFII	 	 	
 	r2   r   N)r3   r4   r5   r6   r0   r   r   r
  rd   r   r   r  r   r   r9   r:   r;   s   @r/   r   r     s<     +7" +3l! 1B&:",( r2   c                   8   a  ] tR tRt o RtRR ltRR ltRtV tR# )r   iY  z(Class for writing matlab 4 format files Nc                8    Wn         Vf   RpW n        R V n        R # )Nr  )r   r   _matrix_writer)r.   r   r   s   &&&r/   r0   MatFile4Writer.__init__[  s    &?G"r2   c                    \        V 4      V n        VP                  4        F   w  r4V P                  P                  WC4       K"  	  R# )av  Write variables in `mdict` to stream

Parameters
----------
mdict : mapping
   mapping with method ``items`` return name, contents pairs
   where ``name`` which will appeak in the matlab workspace in
   file load, and ``contents`` is something writeable to a
   matlab file, such as a NumPy array.
write_header : {None, True, False}
   If True, then write the matlab file header before writing the
   variables. If None (the default) then write the file header
   if we are at position 0 in the stream. By setting False
   here, and setting the stream position to the end of the file,
   you can append variables to a matlab file
N)r   r$  itemsr   )r.   r   r   r)   vars   &&&  r/   put_variablesMatFile4Writer.put_variablesb  s7    ( ).ID%%c0 'r2   )r$  r   r   r(   )	r3   r4   r5   r6   r   r0   r)  r9   r:   r;   s   @r/   r   r   Y  s     3#1 1r2   )r   r   r   r   r   r   r   r   r   r
  miINT16miINT32miSINGLEmiUINT16r  rf   rd   rh   r  rX   ))rH   r   )rL   r   )rM   r   )rN   r   )rF   r   )r  )1r   sysrV   r  operatorr   numpyrv   scipy.sparser   _miobaser   r   r   r   r   r   r	   
_mio_utilsr
   r   	functoolsr   __all__	byteorderr   r
  r-  r,  r+  r.  r  r   r  rd   rf   rh   rX   r   iinfointpmaxry   r   r   r   r   r   r   r   r2   r/   <module>r;     s   
     F F F :  MMX- 


 ddTTdT !
 	$   	(	8	8	8((''(''  ss}}v (&H HHRWW!!	% %$N Nbv] vr0I IX1 1r2   