| 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/sparse/__pycache__/ |
Upload File : |
�
d�c � �D � d dl Zd dlZddgZ ed�� � Zd d�Zd� ZdS )
� N�save_npz�load_npzF)�allow_pickleTc � � i }|j dv r"|� |j |j �� � n{|j dk r|� |j �� � nT|j dk r"|� |j |j �� � n't d� |j � � � � �|� |j � d� � |j |j
� � � |rt j | fi |�� d
S t j
| fi |�� 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 �9/usr/lib/python3/dist-packages/scipy/sparse/_matrix_io.pyr r s0 � �Z �K�
�}�-�-�-����6�>�&�-��H�H�H�H� ��%� � ����6�>��2�2�2�2� ��%� � ����v�z�v�z��:�:�:�:�!�"[�"b�"b�ci�cp�"q�"q�r�r�r�����}�#�#�G�,�,��l�
�[� � � � �
� &�
��D�0�0�K�0�0�0�0�0�
���%�%��%�%�%�%�%� c � � t j | fi t ��5 } |d }n5# t $ r(}t d� | � � � � |�d}~ww xY w|� � � }t |t � � s|� d� � } t t j d� |� � � � }n5# t $ r(}t d� |� � � � |�d}~ww xY w|dv r4 ||d |d |d
f|d �� � cddd� � S |d
k r- ||d |d f|d �� � cddd� � S |dk r5 ||d |d |d ff|d �� � cddd� � S t d� |� � � � �# 1 swxY w Y dS )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 {}_matrixzUnknown 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�,�M�M��� b� b� b��L�S�S�TX�Y�Y�Z�Z�`a�a����� b���� &�*�*�,�,�
��-��-�-� :� *�0�0��9�9�M� X��%�,��(:�(:�=�(I�(I�J�J�C�C��� X� X� X��9�@�@��O�O�P�P�VW�W����� X���� �1�1�1��3��v���y�(9�6�(�;K�L�TZ�[b�Tc�d�d�d�'[� [� [� [� [� [� [� [�( �e�
#�
#��3��v���y�(9�:�&��/�R�R�R�+[� [� [� [� [� [� [� [�, �e�
#�
#��3��v������u�
�(F�G�v�V]��_�_�_�/[� [� [� [� [� [� [� [�2 &� 'D�DJ�F�=�DY�DY�[� [�
[�3[� [� [� [���� [� [� [� [� [� [sg �G�#�G�
A�#A�A�AG�-C�G�
C7�#C2�2C7�7.G�2&G�%.G� "G�G� G)T) �numpyr �scipy.sparser, �__all__�dictr$ r r � r! r �<module>r8 ss �� � � � � � � � ��z�
"�� ��%�(�(�(�
�>&� >&� >&� >&�BK[� K[� K[� K[� K[r!