ó
    Eñia  ã                   ó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  O¤UR                   S:X  a  UR                  UR                  S9  OzUR                   S:X  aO  UR
                  S:X  a%  UR                  UR                  UR                  S9  O5U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Úcol)Úcoordsz4Save is not implemented for sparse matrix of format Ú.Úascii)ÚformatÚshapeÚdataT)Ú	_is_arrayN)r   Úupdater   r   r   Úndimr   r   r   ÚNotImplementedErrorÚencoder   r   Ú
isinstanceÚspÚsparseÚsparrayÚnpÚsavez_compressedÚsavez)ÚfileÚmatrixÚ
compressedÚarrays_dictÚmsgs        ÚT/home/mande/repo/quber/.venv/lib/python3.13/site-packages/scipy/sparse/_matrix_io.pyr   r      s=  € ð\ €KØ‡}�}Ð-Ó-Ø×Ñ 6§>¡>¸&¿-¹-ÐÒHØ	�‰˜%Ó	Ø×Ñ 6§>¡>ÐÒ2Ø	�‰˜%Ó	Ø�;‰;˜!Óà×Ñ 6§:¡:°6·:±:ÐÒ>à×Ñ f§m¡mÐÒ4àDÀVÇ]Á]ÀOÐSTÐUˆÜ! #Ó&Ð&Ø×ÑØ�}‰}×#Ñ# GÓ,Ø�l‰lØ�[‰[ð ñ ô
 �&œ"Ÿ)™)×+Ñ+×,Ñ,Ø×Ñ TÐÑ*ÞÜ
×Ò˜DÑ0 KÓ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  aA  SU;   a  U" US   US   4US   S9sSSS5        $ 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   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   T   sØ  € ôl 
�Š�Ñ	'œÒ	'¨6ØŸ
™
 8Ó,ˆØÑ Ü˜y¨¨ð /9ð :ó ;ð ;à%×*Ñ*Ó,ˆä˜-¬×-Ñ-ð *×0Ñ0°Ó9ˆMà�:‰:�k×"Ñ"Ø'¨(Ñ2‰Kà'¨)Ñ3ˆKð	GÜœ"Ÿ)™)¨ }Ó6ˆCð Ð1Ó1Ù˜˜v™¨¨yÑ(9¸6À(Ñ;KÐLØ# G™_ñ.÷/ 
(Ñ	'ð2 ˜eÓ#Ù˜˜v™¨¨yÑ(9Ð:À&ÈÁ/ÑR÷5 
(Ñ	'ð6 ˜eÓ#Ø˜6Ó!Ù˜F 6™N¨F°8Ñ,<Ð=ÀVÈGÁ_ÑU÷; 
(Ñ	'ñ< ˜˜v™¨°©¸¸u¹Ð(FÐGØ# G™_ñ.÷= 
(Ñ	'ôB &ð )AØANÀÈqð'Ró Sð Søô ó 	GÜÐ/°¨}¸AÐ>Ó?ÀQÐFûð	Gú÷' 
(Õ	'úsH   œA;E1ÂEÂ3E1ÃE1Ã9E1Ä E1Å E1Å
E.ÅE)Å)E.Å.E1Å1
E?)T)	Únumpyr"   Úscipyr   Ú__all__Údictr1   r   r   © r+   r*   Ú<module>rC      s/   ðÛ Û à�zÐ
"€ñ  %Ñ(€ôF&óRXSr+   