
     h                     D    d dl Zd dlZddgZ ed          Zd	dZd ZdS )
    Nsave_npzload_npzF)allow_pickleTc                    i }|j         dv r"|                    |j        |j                   n{|j         dk    r|                    |j                   nT|j         dk    r"|                    |j        |j                   n't          d                     |j                             |                    |j                             d          |j	        |j
        	           |rt          j        | fi | d
S t          j        | fi | d
S )ac   Save a sparse matrix to a file using ``.npz`` format.

    Parameters
    ----------
    file : str or file-like object
        Either the file name (string) or an open file (file-like object)
        where the data will be saved. If file is a string, the ``.npz``
        extension will be appended to the file name if it is not already
        there.
    matrix: spmatrix (format: ``csc``, ``csr``, ``bsr``, ``dia`` or coo``)
        The sparse matrix to save.
    compressed : bool, optional
        Allow compressing the file. Default: True

    See Also
    --------
    scipy.sparse.load_npz: Load a sparse matrix from a file using ``.npz`` format.
    numpy.savez: Save several arrays into a ``.npz`` archive.
    numpy.savez_compressed : Save several arrays into a compressed ``.npz`` archive.

    Examples
    --------
    Store sparse matrix to disk, and load it again:

    >>> import numpy as np
    >>> import scipy.sparse
    >>> sparse_matrix = scipy.sparse.csc_matrix(np.array([[0, 0, 3], [4, 0, 0]]))
    >>> sparse_matrix
    <2x3 sparse matrix of type '<class 'numpy.int64'>'
       with 2 stored elements in Compressed Sparse Column format>
    >>> sparse_matrix.toarray()
    array([[0, 0, 3],
           [4, 0, 0]], dtype=int64)

    >>> scipy.sparse.save_npz('/tmp/sparse_matrix.npz', sparse_matrix)
    >>> sparse_matrix = scipy.sparse.load_npz('/tmp/sparse_matrix.npz')

    >>> sparse_matrix
    <2x3 sparse matrix of type '<class 'numpy.int64'>'
       with 2 stored elements in Compressed Sparse Column format>
    >>> sparse_matrix.toarray()
    array([[0, 0, 3],
           [4, 0, 0]], dtype=int64)
    csccsrbsr)indicesindptrdia)offsetscoo)rowcolz7Save is not implemented for sparse matrix of format {}.ascii)formatshapedataN)r   updater   r   r   r   r   NotImplementedErrorencoder   r   npsavez_compressedsavez)filematrix
compressedarrays_dicts       S/var/www/html/Sam_Eipo/venv/lib/python3.11/site-packages/scipy/sparse/_matrix_io.pyr   r      s0   Z K}---6>&-HHHH	%		6>2222	%		vzvz::::!"["b"bcicp"q"qrrr}##G,,l[    
  &
D00K00000
%%%%%%%    c                    t          j        | fi t          5 }	 |d         }n5# t          $ r(}t	          d                    |                     |d}~ww xY w|                                }t          |t                    s|	                    d          }	 t          t          j        d                    |                    }n5# t          $ r(}t	          d                    |                    |d}~ww xY w|dv r4 ||d         |d	         |d
         f|d                   cddd           S |dk    r- ||d         |d         f|d                   cddd           S |dk    r5 ||d         |d         |d         ff|d                   cddd           S t          d                    |                    # 1 swxY w Y   dS )a   Load a sparse matrix from a file using ``.npz`` format.

    Parameters
    ----------
    file : str or file-like object
        Either the file name (string) or an open file (file-like object)
        where the data will be loaded.

    Returns
    -------
    result : csc_matrix, csr_matrix, bsr_matrix, dia_matrix or coo_matrix
        A sparse matrix containing the loaded data.

    Raises
    ------
    OSError
        If the input file does not exist or cannot be read.

    See Also
    --------
    scipy.sparse.save_npz: Save a sparse matrix to a file using ``.npz`` format.
    numpy.load: Load several arrays from a ``.npz`` archive.

    Examples
    --------
    Store sparse matrix to disk, and load it again:

    >>> import numpy as np
    >>> import scipy.sparse
    >>> sparse_matrix = scipy.sparse.csc_matrix(np.array([[0, 0, 3], [4, 0, 0]]))
    >>> sparse_matrix
    <2x3 sparse matrix of type '<class 'numpy.int64'>'
       with 2 stored elements in Compressed Sparse Column format>
    >>> sparse_matrix.toarray()
    array([[0, 0, 3],
           [4, 0, 0]], dtype=int64)

    >>> scipy.sparse.save_npz('/tmp/sparse_matrix.npz', sparse_matrix)
    >>> sparse_matrix = scipy.sparse.load_npz('/tmp/sparse_matrix.npz')

    >>> sparse_matrix
    <2x3 sparse matrix of type '<class 'numpy.int64'>'
        with 2 stored elements in Compressed Sparse Column format>
    >>> sparse_matrix.toarray()
    array([[0, 0, 3],
           [4, 0, 0]], dtype=int64)
    r   z-The file {} does not contain a sparse matrix.Nr   z	{}_matrixzUnknown matrix format "{}"r   r   r   r   r   )r   r   r   r   r   r   z7Load is not implemented for sparse matrix of format {}.)r   loadPICKLE_KWARGSKeyError
ValueErrorr   item
isinstancestrdecodegetattrscipysparseAttributeErrorr   )r   loadedmatrix_formateclss        r    r   r   L   s   b 
	'	'	'	' [6	b"8,MM 	b 	b 	bLSSTXYYZZ`aa	b &**,,--- 	: *0099M	X%,(:(:=(I(IJJCC 	X 	X 	X9@@OOPPVWW	X 1113vy(96(;KLTZ[bTcddd'[ [ [ [ [ [ [ [( e##3vy(9:&/RRR+[ [ [ [ [ [ [ [, e##3vu(FGvV]___/[ [ [ [ [ [ [ [2 & 'DDJF=DYDY[ [ [3[ [ [ [ [ [ [ [ [ [sg   G#G
A#AAAG-CG
C7#C22C77.G2&G%.G "GG	G)T)	numpyr   scipy.sparser,   __all__dictr$   r   r    r!   r    <module>r8      ss           z
" %(((>& >& >& >&BK[ K[ K[ K[ K[r!   