403Webshell
Server IP : 217.160.0.135  /  Your IP : 216.73.217.85
Web Server : Apache
System : Linux www 6.18.52-i1-ampere #1203 SMP Mon Sep 14 18:29:59 CEST 2026 aarch64
User : sws1074145052 ( 1074145052)
PHP Version : 8.3.32
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /lib/python3/dist-packages/scipy/io/matlab/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /lib/python3/dist-packages/scipy/io/matlab/__pycache__/_mio4.cpython-311.pyc
�

d�c�P���dZddlZddlZddlZddlZddlmZm	Z	m
Z
mZmZm
Z
mZddlmZmZddlmZgd�ZejdkZdZdZd	Zd
ZdZdZed
edededededdgd�ddiZeeeeeeeeeeed�ZdZdZ d	Z!dddddd�Z"ede de!diZ#Gd �d!��Z$Gd"�d#��Z%Gd$�d%e��Z&d,d'�Z'Gd(�d)��Z(Gd*�d+��Z)dS)-z1 Classes for read / write of matlab (TM) 4 files
�N�)�
MatFileReader�	docfiller�matdims�
read_dtype�convert_dtypes�arr_to_chars�arr_dtype_number)�squeeze_element�chars_to_strings)�reduce)�MatFile4Reader�MatFile4Writer�SYS_LITTLE_ENDIAN�
VarHeader4�
VarReader4�
VarWriter4�	arr_to_2d�mclass_info�mdtypes_template�miDOUBLE�miINT16�miINT32�miSINGLE�miUINT16�miUINT8�mxCHAR_CLASS�mxFULL_CLASS�mxSPARSE_CLASS�np_to_mtypes�order_codes�little�����f8�f4�i4�i2�u2�u1�header))�moptr))�mrowsr))�ncolsr))�imagfr))�namlenr)�U1)r'�c32�c24�c16r(�c8r)r*r+r,�S1�<�>zVAX D-floatzVAX G-float�Cray)rrr#r$r%�double�char�sparsec��eZdZdZdZd�ZdS)rFc�L�||_||_||_||_||_dS�N)�name�dtype�mclass�dims�
is_complex)�selfrBrCrDrErFs      �7/usr/lib/python3/dist-packages/scipy/io/matlab/_mio4.py�__init__zVarHeader4.__init__Ys+����	���
������	�$�����N)�__name__�
__module__�__qualname__�
is_logical�	is_globalrI�rJrHrrTs-�������J��I�
%�
%�
%�
%�
%rJrc�F�eZdZdZd�Zd�Zdd�Zdd�Zd�Zd�Z	d	�Z
d
�ZdS)
rz" Class to read matlab 4 variables c�t�||_|j|_|j|_|j|_|j|_dSrA)�file_reader�
mat_stream�dtypes�chars_as_strings�
squeeze_me)rGrSs  rHrIzVarReader4.__init__is7��&���%�0���!�(��� +� <���%�0����rJc��t|j|jd��}|j�t	|d�����d��}|ddks|ddkrt
d���t|dd��\}}|d	vr(tj	d
t|zt��t|d��\}}|dkrt
d���t|d
��\}}|}|d|df}|ddk}	|j|}
t||
|||	��S)z% Read and return header for variable r-r2�r.r�z.Mat 4 mopt wrong format, byteswapping problem?��)rrzBWe do not support byte ordering '%s'; returned data may be corrupt�dz,O in MOPT integer should be 0, wrong format?�
r/r0r1r)
rrTrU�read�int�strip�
ValueError�divmod�warnings�warnr!�UserWarningr)rG�datarB�M�rest�O�P�TrErFrCs           rH�read_headerzVarReader4.read_headerpsO���$�/�4�;�x�+@�A�A����#�#�C��X��$7�$7�8�8�>�>�w�G�G����<�!���t�F�|�d�2�2��M�N�N�N���f��t�,�,���4��F�?�?��M�0�2=�a�.�A�%�
'�
'�
'���s�#�#���4���6�6��K�L�L�L���r�"�"���4����W�
�t�G�}�-���'�]�a�'�
���A������
�����	rJTc�\�|j}|tkr|�|��}nk|tkr.|�|��}|r|jrt
|��}n2|tkr|�|��Std|z���|r|j
rt|��S|S)N�No reader for class code %s)rDr�read_full_arrayr�read_char_arrayrVrr�read_sparse_array�	TypeErrorrWr)rG�hdr�processrD�arrs     rH�array_from_headerzVarReader4.array_from_header�s�������\�!�!��&�&�s�+�+�C�C�
�|�
#�
#��&�&�s�+�+�C��
,�4�0�
,�&�s�+�+���
�~�
%�
%��)�)�#�.�.�.��9�F�B�C�C�C��	(�t��	(�"�3�'�'�'��
rJc�B�|j}|j}|j}|D]}||z}�|j�t|����}t
|��|krtd|jz���tj
|||d���}|r|���}|S)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�Not enough bytes to read matrix '%s'; is this a badly-formed file? Consider listing matrices with `whosmat` and loading named matrices with `variable_names` kwarg to `loadmat`�F)�shaperC�buffer�order)rCrE�itemsizerTr^r_�lenrarB�np�ndarray�copy)	rGrsr��dtrE�	num_bytes�drzrus	         rH�read_sub_arrayzVarReader4.read_sub_array�s���"�Y���x���K�	��	�	�A���N�I�I���%�%�c�)�n�n�5�5���v�;�;�)�#�#��C�FI�X�N�O�O�
O��j�t�!� &�"�$�$�$���	��(�(�*�*�C��
rJc��|jr6|�|d���}|�|d���}||dzzS|�|��S)aM Full (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�?)rFr�)rGrs�res�res_js    rHrozVarReader4.read_full_array�sa���>�	&��%�%�c��%�6�6�C��'�'��%�'�8�8�E��%�"�*�%�%��"�"�3�'�'�'rJc�X�|�|���tj��}|����d��}tj|jtjd��tj	|������
��S)z� latin-1 text matrix (char matrix) reader

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

        Returns
        -------
        arr : ndarray
            with dtype 'U1', shape given by `hdr` ``dims``
        �latin-1r3�ryrCrz)r��astyper~�uint8�tobytes�decoderrErC�arrayr�)rGrsru�Ss    rHrpzVarReader4.read_char_array�s~���!�!�#�&�&�-�-�b�h�7�7���K�K�M�M� � ��+�+���z��� "�����!#��!���.�.�.�.2�d�f�f�	5rJc�>�|�|��}|dd�dd�f}t|d��t|d��f}tj|dd�dfd���}tj|dd�dfd���}|dz}|dz}|jdd	kr!tj|dd�d
fd���}n1tj|dd�d
fd���}|dd�d	f|_tj�|||ff|��S)
a� Read and return sparse matrix type

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

        Returns
        -------
        arr : ``scipy.sparse.coo_matrix``
            with dtype ``float`` and shape read from the sparse matrix 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.
        N���)r�r)r�rr�intc�rCrr$r#�float�complex)	r�r_r~�ascontiguousarrayry�imag�scipyr>�
coo_matrix)rGrsr��tmprE�I�J�Vs        rHrqzVarReader4.read_sparse_array�s&��6�!�!�#�&�&���#�2�#�a�a�a�%�j���C��I����C��I���/��� ��Q�Q�Q�q�S���7�7�7��� ��Q�Q�Q�q�S���7�7�7��	�Q���	�Q����9�Q�<�1����$�S����1��X�G�<�<�<�A�A��$�S����1��X�I�>�>�>�A�����1��X�A�F��|�&�&��1�Q�%�y�$�7�7�7rJc��|j}|tkr)ttt|j����}�n}|tkr:ttt|j����}|jr
|dd�}�n8|tk�r|j	}|j}t|��dkr|ddkr|ddksdS|j�|j
|ddz
zd��tjd||j�|j
�����}|j�|j
|ddz
zd��tjd||j�|j
�����}t	|��t	|��f}nt#d|z���|jrtd	�|D����}|S)
zwRead the shape of the array described by the header.
        The file position after this call is unspecified.
        Nr�r#rrrPr�rnc��g|]
}|dk�|��S)rrP)�.0�xs  rH�
<listcomp>z0VarReader4.shape_from_header.<locals>.<listcomp>0s��6�6�6��q�A�v�v�1�v�v�vrJ)rDr�tuple�mapr_rErrVrrCr}rT�seekr|r~rr^rrrW)rGrsrDryr�rE�rows�colss        rH�shape_from_headerzVarReader4.shape_from_headers�������\�!�!��#�c�3�8�,�,�-�-�E�E�
�|�
#�
#��#�c�3�8�,�,�-�-�E��$�
#��c�r�c�
���
�~�
%�
%���B��8�D���I�I��N�N�t�A�w�!�|�|��Q��1����r�
�O� � ����Q��!��!<�a�@�@�@��:�B�b�%)�_�%9�%9�"�+�%F�%F�H�H�H�D��O� � ����Q��!��!<�a�@�@�@��:�B�b�%)�_�%9�%9�"�+�%F�%F�H�H�H�D���Y�Y��D�	�	�*�E�E��9�F�B�C�C�C��?�	8��6�6�e�6�6�6�7�7�E��rJN�T)rKrLrM�__doc__rIrlrvr�rorprqr�rPrJrHrrfs�������,�,�1�1�1����4����""�"�"�"�H(�(�(�,5�5�5�$(8�(8�(8�T � � � � rJrc�Z��eZdZdZe�fd���Zd�Zd�Zd�Zdd�Z	dd	�Z
d
�Z�xZS)
rz Reader for Mat4 files c�P��t��j|g|�Ri|��d|_dS)zR Initialize matlab 4 file reader

    %(matstream_arg)s
    %(load_args)s
        N)�superrI�_matrix_reader)rGrT�args�kwargs�	__class__s    �rHrIzMatFile4Reader.__init__6s:���	������5�d�5�5�5�f�5�5�5�"����rJc��|j�d��t|jtjd����}|j�d��|dkrdS|dks|dkrt
rdpdSt
rdpdS)Nrr)r9rZr:)rTr�rr~rCr)rGr.s  rH�guess_byte_orderzMatFile4Reader.guess_byte_order@s�������Q�����$�/�2�8�D�>�>�:�:������Q�����1�9�9��3��!�8�8�t�d�{�{�$�,��3��3� �(�S�/�C�/rJc�l�tt|j��|_t	|��|_dS)za Run when beginning read of variables

        Sets up readers from parameters in `self`
        N)rr�
byte_orderrUrr�)rGs rH�initialize_readzMatFile4Reader.initialize_readLs.��
%�%5�t��G�G���(��.�.����rJc��|j���}td�|jd��}|jj|z}|jr|jtks|dz}|j	�
��|z}||fS)ab 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
        c��||zSrArP)r��ys  rH�<lambda>z0MatFile4Reader.read_var_header.<locals>.<lambda>ds
���!��rJrr#)r�rlr
rErCr|rFrDrrT�tell)rGrs�n�remaining_bytes�
next_positions     rH�read_var_headerzMatFile4Reader.read_var_headerTs����!�-�-�/�/���#�#�S�X�q�1�1���)�,�q�0���>�	!�#�*��">�">��q� �O���,�,�.�.��@�
��M�!�!rJTc�8�|j�||��S)a� 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�rv)rGr-rts   rH�read_var_arrayzMatFile4Reader.read_var_arrayks�� �"�4�4�V�W�E�E�ErJNc�z�t|t��r|g}n|�t|��}|j�d��|���i}|���s�|���\}}|j�dn|j�	d��}|�||vr|j�|���o|�
|��||<|j�|��|�)|�|��t|��dkrn|�����|S)a, get 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.
        Nr�None�latin1)
�
isinstance�str�listrTr�r��
end_of_streamr�rBr�r��remover})rG�variable_names�mdictrsr�rBs      rH�
get_variableszMatFile4Reader.get_variables}sK���n�c�*�*�	2�,�-�N�N�
�
'�!�.�1�1�N�����Q�������������$�$�&�&�	�!%�!5�!5�!7�!7��C�� �X�-�6�6�3�8�?�?�8�3L�3L�D��)�d�.�.H�.H���$�$�]�3�3�3���-�-�c�2�2�E�$�K��O� � ��/�/�/��)��%�%�d�+�+�+��~�&�&�!�+�+���$�$�&�&�	��rJc��|j�d��|���g}|���s�|���\}}|j�dn|j�d��}|j�|��}t�
|jd��}|�|||f��|j�|��|�����|S)z list variables from stream rNr�r��unknown)
rTr�r�r�r�rBr�r�r�r�getrD�append)rG�varsrsr�rBry�infos       rH�list_variableszMatFile4Reader.list_variables�s�������Q�������������$�$�&�&�	0�!%�!5�!5�!7�!7��C�� �X�-�6�6�3�8�?�?�8�3L�3L�D��'�9�9�#�>�>�E��?�?�3�:�y�9�9�D��K�K��u�d�+�,�,�,��O� � ��/�/�/��$�$�&�&�	0��rJr�rA)
rKrLrMr�rrIr�r�r�r�r�r��
__classcell__)r�s@rHrr4s��������!�!��#�#�#�#��Y�#�
0�
0�
0�/�/�/�"�"�"�.F�F�F�F�$����>������rJr�rowc��t||��}t|��dkrtd���|�|��S)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
    r#z=Matlab 4 files cannot save arrays with more than 2 dimensions)rr}ra�reshape)ru�oned_asrEs   rHrr�sK��"�3�� � �D�
�4�y�y�1�}�}��(�)�)�	)��;�;�t���rJc�F�eZdZd�Zd�Zd�Zeedfd�Zd�Z	d�Z
d�Zd	�Zd
S)rc�6�|j|_|j|_dSrA)�file_streamr�)rG�file_writers  rHrIzVarWriter4.__init__�s��&�2���"�*����rJc�b�|j�|�d�����dS)Nrx)r{)r��writer�)rGrus  rH�write_byteszVarWriter4.write_bytes�s-������s�{�{��{�5�5�6�6�6�6�6rJc�:�|j�|��dSrA)r�r�)rG�ss  rH�write_stringzVarWriter4.write_string�s������q�!�!�!�!�!rJrc�l�tjdtd��}t}d}|dz|dzz|dzz|z|d<|d|d<|d	|d
<||d<t	|��d	z|d<|�|��|d
z}	|�|	�d����dS)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
        rPr-rr[r\r]r.r/rr0r1r2�r�N)r~�emptyrrr}r�r��encode)
rGrBryrjrkr1r-rgrirfs
          rH�write_headerzVarWriter4.write_header�s���$��"�.�x�8�9�9��!�!��
���d�(��c�'�"��b�&�!����v�� ��(��w����(��w����w���t�9�9�q�=��x������ � � ��d�{�����$�+�+�h�/�/�0�0�0�0�0rJc��tj�|��r|�||��dSt	j|��}|j}|js(|�|�	d����}|j
}|tjurtd���|tj
urtd���|tjtjfvr|�||��dS|�||��dS)z� Write 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 Mat4zCannot save void type arrays)r�r>�issparse�write_sparser~�asarrayrC�isnativer��newbyteorder�type�object_rr�void�unicode_�string_�
write_char�
write_numeric)rGrurBr��dtts     rHr�zVarWriter4.write�s����<� � ��%�%�	����c�4�(�(�(��F��j��o�o��
�Y���{�	3��*�*�R�_�_�S�1�1�2�2�C��g���"�*����?�@�@�@�
�B�G�^�^��:�;�;�;�
�R�[�"�*�-�
-�
-��O�O�C��&�&�&��F����3��%�%�%�%�%rJc��t||j��}|jjdk}	t|jjdd�}nD#t$r7|r|�d��}n|�d��}t}YnwxYw|�	||j
|t|���|r6|�|j
��|�|j��dS|�|��dS)N�cr�c128r')rjrkr1)rr�rC�kindr r��KeyErrorr�rr�ryrr��realr�)rGrurBr1rjs     rHr�zVarWriter4.write_numerics����T�\�*�*���	��#�%��	��S�Y�]�1�2�2�.�/�A�A���	�	�	��
'��j�j��(�(����j�j��&�&���A�A�A�	����	
���$��)��(� %�		�	'�	'�	'�
�	"����S�X�&�&�&����S�X�&�&�&�&�&����S�!�!�!�!�!s�A�>B�Bc���t|��}t||j��}|j}|�||t
t���|jjdkrwtj
|��}tjdt||��|���}|�
���d��}tj|d|���}|�|��dS)N�rjrk�UrPr�r�r8)r	rr�ryr�rrrCr�r~�prodrr
�itemr�r�)rGrurBrE�n_chars�st_arr�sts       rHr�zVarWriter4.write_char$s����3������T�\�*�*���y���������		�	�	�	�
�9�>�S� � ��g�d�m�m�G��Z�b�&6�s�G�&D�&D�'*�,�,�,�F������%�%�i�0�0�B��*�4�t�B�?�?�?�C���������rJc��|���}|jjdk}tj|jdzd|zfd���}|j|dd�df<|j|dd�df<|dd�dd	�fxxdz
cc<|r'|jj	|dd�d	f<|jj
|dd�df<n|j|dd�d	f<|j|ddd	�f<|�||jtt�
��|�|��dS)zY Sparse matrices are 2-D

        See docstring for VarReader4.read_sparse_array
        r�rr$r'r�Nr�rr#r�)�tocoorCr�r~�zeros�nnzr��colrfr�r�ryr�rrr�)rGrurB�Ar1�ijvs      rHr�zVarWriter4.write_sparse7s+��

�I�I�K�K������#���h����	�1�U�7�+�4�8�8�8���U��C�R�C��E�
��U��C�R�C��E�
��C�R�C��!��G����������	 ����C����A��J����C����A��J�J���C����A��J��g��B�q��s�F�������I���		�	�	�	�
	
��������rJN)
rKrLrMrIr�r�rrr�r�r�r�r�rPrJrHrr�s�������+�+�+�7�7�7�"�"�"�+3�l�!�1�1�1�1�B&�&�&�:"�"�"�,���&����rJrc�"�eZdZdZdd�Zdd�ZdS)rz) Class for writing matlab 4 format files Nc�8�||_|�d}||_d|_dS)Nr�)r�r��_matrix_writer)rGr�r�s   rHrIzMatFile4Writer.__init__Rs)��&����?��G����"����rJc��t|��|_|���D] \}}|j�||���!dS)a� 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)rr�itemsr�)rGr�r�rB�vars     rH�
put_variableszMatFile4Writer.put_variablesYsU��()��.�.��������	1�	1�I�D�#���%�%�c�4�0�0�0�0�	1�	1rJrA)rKrLrMr�rIrrPrJrHrrPsB������3�3�#�#�#�#�1�1�1�1�1�1rJr)r�)*r��sysrc�numpyr~�scipy.sparser��_miobaserrrrrr	r
�
_mio_utilsrr�	functoolsr
�__all__�	byteorderrrrrrrrrr rrrr!rrrrrrrrPrJrH�<module>rs�����
�
�
�
�������������F�F�F�F�F�F�F�F�F�F�F�F�F�F�F�F�F�F�:�9�9�9�9�9�9�9������������M�X�-������
��
����
��
�d��d��T��T��d��T��!�!�!�
	�$�
�� ����
�
�
�
�
�
�
�����������
���
�����(��&��H���%�%�%�%�%�%�%�%�$K�K�K�K�K�K�K�K�\v�v�v�v�v�]�v�v�v�r����0H�H�H�H�H�H�H�H�V1�1�1�1�1�1�1�1�1�1rJ

Youez - 2016 - github.com/yon3zu
LinuXploit