+
    LV-j.3  ã                   ó^  a € R, t 0 t R t^ RIHt ^ RIt^ RIHt ^RIH	t
 . R-Ot ! R	 R]4      t ! R
 R]4      t ! R R]4      t ! R R]4      tRRRRRRRRRRRRRRRRRR/	t]P&                  ! ]4      t] ^ k  R tR  tR!R"/R# lt]t^tR$ tR.R% lt ! R& R'4      t ! R( R)4      tR* tR+ tR# )/zf
Base classes for MATLAB file stream reading.

MATLAB is a registered trademark of the Mathworks inc.
)ÚFinalN)Údoccer)Ú_byteordercodesÚMatReadErrorÚMatReadWarningÚMatWriteErrorÚMatWriteWarningc                   ó   € ] tR t^tRtRtR# )r   z"Exception indicating a read issue.© N©Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__Ú__static_attributes__r
   ó    Úi/Volumes/fast/ai/experiments/ui-tars-smoke/.venv/lib/python3.14/site-packages/scipy/io/matlab/_miobase.pyr   r      s   † Ý,r   c                   ó   € ] tR t^tRtRtR# )r   z#Exception indicating a write issue.r
   Nr   r
   r   r   r   r      s   † Ý-r   c                   ó   € ] tR t^tRtRtR# )r   zWarning class for read issues.r
   Nr   r
   r   r   r   r      s   † Ý(r   c                   ó   € ] tR t^tRtRtR# )r   zWarning class for write issues.r
   Nr   r
   r   r   r   r      s   † Ý)r   Úfile_argzfile_name : str
   Name of the mat file (do not need .mat extension if
   appendmat==True) Can also pass open file-like object.Ú
append_argz�appendmat : bool, optional
   True to append the .mat extension to the end of the given
   filename, if not already present. Default is True.Ú	load_argsaž  byte_order : str or None, optional
   None by default, implying byte order guessed from mat
   file. Otherwise can be one of ('native', '=', 'little', '<',
   'BIG', '>').
mat_dtype : bool, optional
   If True, return arrays in same dtype as would be loaded into
   MATLAB (instead of the dtype with which they are saved).
squeeze_me : bool, optional
   Whether to squeeze unit matrix dimensions or not.
chars_as_strings : bool, optional
   Whether to convert char arrays to string arrays.
matlab_compatible : bool, optional
   Returns matrices as would be loaded by MATLAB (implies
   squeeze_me=False, chars_as_strings=False, mat_dtype=True,
   struct_as_record=True).Ú
struct_argab  struct_as_record : bool, optional
   Whether to load MATLAB structs as NumPy record arrays, or as
   old-style NumPy arrays with dtype=object. Setting this flag to
   False replicates the behavior of SciPy version 0.7.x (returning
   numpy object arrays). The default setting is True, because it
   allows easier round-trip load and save of MATLAB files.Úmatstream_argzAmat_stream : file-like
   Object with file API, open for reading.Úlong_fieldsa  long_field_names : bool, optional
   * False - maximum field name length in a structure is 31 characters
     which is the documented maximum length. This is the default.
   * True - maximum field name length in a structure is 63 characters
     which works for MATLAB 7.6Údo_compressionz[do_compression : bool, optional
   Whether to compress matrices on write. Default is False.Úoned_asz’oned_as : {'row', 'column'}, optional
   If 'column', write 1-D NumPy arrays as column vectors.
   If 'row', write 1D NumPy arrays as row vectors.Úunicode_stringszbunicode_strings : bool, optional
   If True, write strings as Unicode, else MATLAB usual encoding.c                ó’   € V P                  4       pV F0  p\        P                  ! W#,          4      P                  V4      W#&   K2  	  V# )am  Convert dtypes in mapping to given order

Parameters
----------
dtype_template : mapping
   mapping with values returning numpy dtype from ``np.dtype(val)``
order_code : str
   an order code suitable for using in ``dtype.newbyteorder()``

Returns
-------
dtypes : mapping
   mapping where values have been replaced by
   ``np.dtype(val).newbyteorder(order_code)``

)ÚcopyÚnpÚdtypeÚnewbyteorder)Údtype_templateÚ
order_codeÚdtypesÚks   &&  r   Úconvert_dtypesr)   †   s>   € ð" × Ñ Ó"€FÛˆÜ—H’H˜V�YÓ'×4Ñ4°ZÓ@ˆ‹	ñ à€Mr   c                óp   € VP                   p\        P                  ! RVV P                  V4      RR7      pV# )a2  
Generic get of byte stream data of known type

Parameters
----------
mat_stream : file_like object
    MATLAB (tm) mat file stream
a_dtype : dtype
    dtype of array to read. `a_dtype` is assumed to be correct
    endianness.

Returns
-------
arr : ndarray
    Array of dtype `a_dtype` read from stream.

ÚF)Úshaper#   ÚbufferÚorderr
   )Úitemsizer"   ÚndarrayÚread)Ú
mat_streamÚa_dtypeÚ	num_bytesÚarrs   &&  r   Ú
read_dtyper6   �   s8   € ð$ × Ñ €IÜ
�*Š*˜2Ø"Ø&ŸO™O¨IÓ6Øô €Cð €Jr   Ú	appendmatTc               ó„   € ^RI Hp V! WR7      ;_uu_ 4       p\        V4      uuRRR4       #   + '       g   i     R# ; i)a$  
Return major, minor tuple depending on apparent mat file type

Where:

 #. 0,x -> version 4 format mat files
 #. 1,x -> version 5 format mat files
 #. 2,x -> version 7.3 format mat files (HDF format)

Parameters
----------
file_name : str
   Name of the mat file (do not need .mat extension if
   appendmat==True). Can also pass open file-like object.
appendmat : bool, optional
   True to append the .mat extension to the end of the given
   filename, if not already present. Default is True.

Returns
-------
major_version : {0, 1, 2}
    major MATLAB File format version
minor_version : int
    minor MATLAB file format version

Raises
------
MatReadError
    If the file is empty.
ValueError
    The matfile version is unknown.

Notes
-----
Has the side effect of setting the file read pointer to 0
)Ú_open_file_context)r7   N)Ú_mior9   Ú_get_matfile_version)Ú	file_namer7   r9   Úfileobjs   &$  r   Úmatfile_versionr>   ·   s,   € õJ )Ù	˜I×	;Õ	;¸wÜ# GÓ,÷ 
<×	;×	;Ó	;ús   ˜.®?	c                 ó¤  € V P                  ^ 4       V P                  \        4      p\        V4      \        8  d   \	        R4      hVP                  ^ 4      \        8X  d   \	        R\         R24      h\        P                  ! R\        P                  VR,          R7      p^ V9   d   V P                  ^ 4       R# V P                  ^|4       V P                  ^4      pV P                  ^ 4       \        V^,          ^I8H  4      p\        W4,          4      p\        V^V,
          ,          4      pWV3pVR	9   d   V# \        RP                  ! V!  4      h)
é    z Mat file appears to be truncatedz&Mat file appears to be corrupt (first z bytes == 0):Né   N©r,   r#   r-   z%Unknown mat file type, version {}, {})rA   ©r@   r@   )é   é   )Úseekr1   Ú_HDR_N_BYTESÚlenr   Úcountr"   r0   Úuint8ÚintÚ
ValueErrorÚformat)r=   Ú	hdr_bytesÚ	mopt_intsÚtst_strÚmaj_indÚmaj_valÚmin_valÚrets   &       r   r;   r;   ç   s  € à‡L�L�„OØ—‘œ\Ó*€IÜ
ˆ9ƒ~œÔ$ÜÐ=Ó>Ð>Ø‡��qÓœ\Ô)Üð %Ü%1 N°,ð@ó Að 	Aä—
’
 ¬R¯X©X¸iÈ½mÔL€IØˆI„~Ø�‰�QŒØˆð ‡L�L�ÔØ�l‰l˜1‹o€GØ‡L�L�„OÜ�'˜!•* Ñ'Ó(€GÜ�'Õ"Ó#€GÜ�'˜!˜g�+Õ&Ó'€GØÐ
€CØ�&ÔØˆ
Ü
Ð<×CÒCÀSÑIÓ
JÐJr   c                óÎ   € V P                   pVR8X  d   R# \        V4      ^8X  d@   V^ ,          ^ 8X  d   R# VR8X  d
   VR,           # VR8X  d
   RV,           # \        RV R24      hV# )	a.  
Determine equivalent MATLAB dimensions for given array

Parameters
----------
arr : ndarray
    Input array
oned_as : {'column', 'row'}, optional
    Whether 1-D arrays are returned as MATLAB row or column matrices.
    Default is 'column'.

Returns
-------
dims : tuple
    Shape tuple, in the form MATLAB expects it.

Notes
-----
We had to decide what shape a 1 dimensional array would be by
default. ``np.atleast_2d`` thinks it is a row vector. The
default for a vector in MATLAB (e.g., ``>> 1:12``) is a row vector.

Versions of scipy up to and including 0.11 resulted (accidentally)
in 1-D arrays being read as column vectors. For the moment, we
maintain the same tradition here.

Examples
--------
>>> import numpy as np
>>> from scipy.io.matlab._miobase import matdims
>>> matdims(np.array(1)) # NumPy scalar
(1, 1)
>>> matdims(np.array([1])) # 1-D array, 1 element
(1, 1)
>>> matdims(np.array([1,2])) # 1-D array, 2 elements
(2, 1)
>>> matdims(np.array([[2],[3]])) # 2-D array, column vector
(2, 1)
>>> matdims(np.array([[2,3]])) # 2-D array, row vector
(1, 2)
>>> matdims(np.array([[[2,3]]])) # 3-D array, rowish vector
(1, 1, 2)
>>> matdims(np.array([])) # empty 1-D array
(0, 0)
>>> matdims(np.array([[]])) # empty 2-D array
(0, 0)
>>> matdims(np.array([[[]]])) # empty 3-D array
(0, 0, 0)

Optional argument flips 1-D shape behavior.

>>> matdims(np.array([1,2]), 'row') # 1-D array, 2 elements
(1, 2)

The argument has to make sense though

>>> matdims(np.array([1,2]), 'bizarre')
Traceback (most recent call last):
   ...
ValueError: 1-D option "bizarre" is strange

ÚcolumnÚrowz1-D option "z" is stranger
   )rD   rD   rC   ©rD   )r,   rH   rL   )r5   r   r,   s   && r   ÚmatdimsrY     sr   € ð~ �I‰I€EØ�„{ØˆÜ
ˆ5ƒz�Q„Ø��8�qŒ=ØˆMØ˜Ô Ø˜4•<ÐØ˜ÔØ˜%•<Ðä˜|¨G¨9°LÐAÓBÐBØ€Lr   c                   ó6   a € ] tR tRt o RtR tR tR tRtV t	R# )ÚMatVarReaderiQ  z:Abstract class defining required interface for var readersc                ó   € R # )Nr
   )ÚselfÚfile_readers   &&r   Ú__init__ÚMatVarReader.__init__S  s   € Ùr   c                ó   € R# )zReturns header Nr
   ©r]   s   &r   Úread_headerÚMatVarReader.read_headerV  ó   € ár   c                ó   € R# )zReads array given header Nr
   )r]   Úheaders   &&r   Úarray_from_headerÚMatVarReader.array_from_headerZ  re   r   r
   N)
r   r   r   r   r   r_   rc   rh   r   Ú__classdictcell__©Ú__classdict__s   @r   r[   r[   Q  s   ø‡ € ÙEòò÷ð r   r[   c                   óJ   a € ] tR tRt o Rt]R	R l4       tR tR tR t	Rt
V tR# )
ÚMatFileReaderi_  zøBase object for reading mat files

To make this class functional, you will need to override the
following methods:

matrix_getter_factory   - gives object to fetch next matrix from stream
guess_byte_order        - guesses file byte order from file
Nc
                ó4  € Wn         / V n        V'       g   V P                  4       pM\        P                  ! V4      pW n        Wpn        V'       d   V P                  4        MW@n        WPn	        W0n
        W€n        W�n        V	'       d   RV n        RV n        R# R# )z‚
    Initializer for mat file reader

    mat_stream : file-like
        object with file API, open for reading
%(load_args)s
    TFN)r2   r'   Úguess_byte_orderÚbocÚto_numpy_codeÚ
byte_orderÚstruct_as_recordÚset_matlab_compatibleÚ
squeeze_meÚchars_as_stringsÚ	mat_dtypeÚ verify_compressed_data_integrityÚsimplify_cells)
r]   r2   rs   rx   rv   rw   Úmatlab_compatiblert   ry   rz   s
   &&&&&&&&&&r   r_   ÚMatFileReader.__init__i  s~   € ð$ %ŒØˆŒßØ×.Ñ.Ó0‰Jä×*Ò*¨:Ó6ˆJØ$ŒØ 0ÔßØ×&Ñ&Õ(à(ŒOØ$4Ô!Ø&ŒNØ0PÔ-Ø,ÔßØ"ˆDŒOØ$)ˆDÖ!ñ r   c                ó0   € RV n         RV n        RV n        R# )z3Sets options to return arrays as MATLAB loads them TFN)rx   rv   rw   rb   s   &r   ru   Ú#MatFileReader.set_matlab_compatible�  s   € àˆŒØˆŒØ %ˆÖr   c                ó"   € \         P                  # )z8As we do not know what file type we have, assume native )rq   Únative_coderb   s   &r   rp   ÚMatFileReader.guess_byte_order•  s   € ä�‰Ðr   c                óÌ   € V P                   P                  ^4      pV P                   P                  4       pV P                   P                  V^,
          4       \	        V4      ^ 8H  # rX   )r2   r1   ÚtellrF   rH   )r]   ÚbÚcurposs   &  r   Úend_of_streamÚMatFileReader.end_of_stream™  sL   € Ø�O‰O× Ñ  Ó#ˆØ—‘×%Ñ%Ó'ˆØ�‰×Ñ˜V A�XÔ&Ü�1‹v˜‰{Ðr   )	rs   rw   r'   rx   r2   rz   rv   rt   ry   )NFFTFTTF)r   r   r   r   r   Ú	docfillerr_   ru   rp   r†   r   rj   rk   s   @r   rn   rn   _  s3   ø‡ € ñð ó#*ó ð#*òJ&ò÷ð r   rn   c                ó„   € \         P                  ! V P                  P                  R,          \        V4      ,           4      # )z2Return dtype for given number of items per element:NrE   N)r"   r#   Ústr)r5   Únums   &&r   Úarr_dtype_numberrŒ      s'   € ä�8Š8�C—I‘I—M‘M "Õ%¬¨C«Õ0Ó1Ð1r   c                óº  € \        V P                  4      pV'       g   ^.pVP                  \        V P                  P
                  R,          4      4       \        P                  ! V\        V ^4      V R7      p V \        P                  ! RV P                  R7      8H  .p\        P                  ! V4      '       g   V # V P                  4       p RV \        V4      &   V # )z#Convert string array to char array :rE   NNrB   Ú )r#   Ú )Úlistr,   ÚappendrK   r#   rŠ   r"   r0   rŒ   ÚarrayÚanyr!   Útuple)r5   ÚdimsÚemptiess   &  r   Úarr_to_charsr—   ¥  s¢   € ä�—	‘	‹?€DßØˆsˆØ‡K�K”�C—I‘I—M‘M "Õ%Ó&Ô'Ü
�*Š*˜4Ü+¨C°Ó3Øô!€Cð ”b—h’h˜r¨¯©Ô3Ñ3Ð4€GÜ�6Š6�'�?Š?Øˆ
Ø
�(‰(‹*€CØ€CŒˆg‹ÑØ€Jr   c                ó@   € V ^8„  d   Qh/ ^ \         9   d
   \        ;R&   # )rE   rˆ   )Ú__conditional_annotations__r   )rM   s   "r   Ú__annotate__rš      s    € ÷ ñ ÷h ,Ò +Œ5Ñ +òir   )r   r   r   r   )rV   )!r™   r   Útypingr   Únumpyr"   Ú
scipy._libr   rŽ   r   rq   Ú__all__Ú	Exceptionr   r   ÚUserWarningr   r   Údoc_dictÚfilldocrˆ   r)   r6   r>   Úget_matfile_versionrG   r;   rY   r[   rn   rŒ   r—   rš   )r™   s   @r   Ú<module>r¤      s  øðöõ ã Ý å $ò€ô-�9ô -ô.�Iô .ô)�[ô )ô*�kô *ð
 ð
<ð ð
9ð ð
ð ð
>ð ð
.àð
#ð
 ð
?àð
6ð ð
Eða1Fð 	ðh —>’> (Ó+€	Ó +ð*òZò.ð4'-¨Dô '-ðT &Ð ð €òKô8K÷\ñ ÷>ñ >òB2ô
r   