
    (phH                     8    S SK rS SKrSS/r\" SS9rSS jrS rg)	    Nsave_npzload_npzF)allow_picklec                    0 nUR                   S;   a%  UR                  UR                  UR                  S9  OzUR                   S:X  a  UR                  UR                  S9  OPUR                   S:X  a%  UR                  UR
                  UR                  S9  OSUR                    S3n[        U5      eUR                  UR                   R                  S	5      UR                  UR                  S
9  [        U[        R                  R                  5      (       a  UR                  SS9  U(       a  [        R                   " U 40 UD6  g[        R"                  " U 40 UD6  g)a  Save a sparse matrix or array 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 or sparray
    The sparse matrix or array to save.
    Supported formats: ``csc``, ``csr``, ``bsr``, ``dia`` or ``coo``.
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 as sp
>>> sparse_matrix = sp.sparse.csc_matrix([[0, 0, 3], [4, 0, 0]])
>>> sparse_matrix
<Compressed Sparse Column sparse matrix of dtype 'int64'
    with 2 stored elements and shape (2, 3)>
>>> sparse_matrix.toarray()
array([[0, 0, 3],
       [4, 0, 0]], dtype=int64)

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

>>> sparse_matrix
<Compressed Sparse Column sparse matrix of dtype 'int64'
    with 2 stored elements and shape (2, 3)>
>>> sparse_matrix.toarray()
array([[0, 0, 3],
       [4, 0, 0]], dtype=int64)
csccsrbsr)indicesindptrdia)offsetscoo)rowcolz4Save is not implemented for sparse matrix of format .ascii)formatshapedataT)	_is_arrayN)r   updater   r   r   r   r   NotImplementedErrorencoder   r   
isinstancespsparsesparraynpsavez_compressedsavez)filematrix
compressedarrays_dictmsgs        J/var/www/html/venv/lib/python3.13/site-packages/scipy/sparse/_matrix_io.pyr   r      s   \ K}}--6>>&--H	%	6>>2	%	vzzvzz:DV]]OSTU!#&&}}##G,ll[[  
 &"))++,,T*
D0K0
%%    c                    [         R                  " U 40 [        D6 nUR                  S5      nUc  [	        SU  S35      eUR                  5       n[        U[        5      (       d  UR                  S5      nUR                  S5      (       a  US-   nOUS-   n [        [        R                  U 5      nUS;   a  U" US   US   US   4US   S9sSSS5        $ US:X  a  U" US   US   4US   S9sSSS5        $ US:X  a   U" US   US   US   44US   S9sSSS5        $ [        SU S35      e! [         a  n[	        S	U S
35      UeSnAff = f! , (       d  f       g= f)a7  Load a sparse array/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_array, csr_array, bsr_array, dia_array or coo_array
    A sparse array/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 array/matrix to a file using ``.npz`` format.
numpy.load: Load several arrays from a ``.npz`` archive.

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

>>> import numpy as np
>>> import scipy as sp
>>> sparse_array = sp.sparse.csc_array([[0, 0, 3], [4, 0, 0]])
>>> sparse_array
<Compressed Sparse Column sparse array of dtype 'int64'
    with 2 stored elements and shape (2, 3)>
>>> sparse_array.toarray()
array([[0, 0, 3],
       [4, 0, 0]], dtype=int64)

>>> sp.sparse.save_npz('/tmp/sparse_array.npz', sparse_array)
>>> sparse_array = sp.sparse.load_npz('/tmp/sparse_array.npz')

>>> sparse_array
<Compressed Sparse Column sparse array of dtype 'int64'
    with 2 stored elements and shape (2, 3)>
>>> sparse_array.toarray()
array([[0, 0, 3],
       [4, 0, 0]], dtype=int64)

In this example we force the result to be csr_array from csr_matrix
>>> sparse_matrix = sp.sparse.csc_matrix([[0, 0, 3], [4, 0, 0]])
>>> sp.sparse.save_npz('/tmp/sparse_matrix.npz', sparse_matrix)
>>> tmp = sp.sparse.load_npz('/tmp/sparse_matrix.npz')
>>> sparse_array = sp.sparse.csr_array(tmp)
r   Nz	The file z+ does not contain a sparse array or matrix.r   r   _array_matrixzUnknown format ""r   r   r   r   r   )r   r   r   r   r   r   z4Load is not implemented for sparse matrix of format r   )r   loadPICKLE_KWARGSget
ValueErroritemr   strdecodegetattrr   r   AttributeErrorr   )r"   loadedsparse_formatsparse_typeclses         r'   r   r   P   s   l 
	'	'6

8, y /9 : ; ;%**,--- *009M::k""'(2K')3K	G"))}6C 11vy(96(;KL#G_./ 
(	'2 e#vy(9:#G_.5 
(	'8 e#vu(FG#G_.; 
(	'@ & )AANq'R S S  	G/}A>?QF	G' 
(	'sB   A;ED.3EE9EE.
E8EEE
E)T)	numpyr   scipyr   __all__dictr.   r   r    r(   r'   <module>r@      s/     z
" %(B&JWSr(   