o
    Ö­j^}  ã                   @   sž   d Z ddlZddlZddlmZmZmZmZmZm	Z	m
Z
mZmZ ddlmZmZmZ g d¢Zdd„ Zdd	„ Zd
dœdd„Zddd„ZG dd„ dƒZdd„ ZdS )z‡
  Matrix Market I/O in Python.
  See http://math.nist.gov/MatrixMarket/formats.html
  for information about the Matrix Market format.
é    N)	ÚasarrayÚrealÚimagÚconjÚzerosÚndarrayÚconcatenateÚonesÚcan_cast)Ú	coo_arrayÚissparseÚ
coo_matrix)ÚmminfoÚmmreadÚmmwriteÚMMFilec                 C   s   t | tƒr
|  d¡S t| ƒS )NÚlatin1)Ú
isinstanceÚbytesÚdecodeÚstr)Ús© r   úK/var/www/html/CropPilot/venv/lib/python3.10/site-packages/scipy/io/_mmio.pyÚasstr   s   

r   c                 C   s
   t  | ¡S )a­  
    Return size and storage parameters from Matrix Market file-like 'source'.

    Parameters
    ----------
    source : str or file-like
        Matrix Market filename (extension .mtx) or open file-like object

    Returns
    -------
    rows : int
        Number of matrix rows.
    cols : int
        Number of matrix columns.
    entries : int
        Number of non-zero entries of a sparse matrix
        or rows*cols for a dense matrix.
    format : str
        Either 'coordinate' or 'array'.
    field : str
        Either 'real', 'complex', 'pattern', or 'integer'.
    symmetry : str
        Either 'general', 'symmetric', 'skew-symmetric', or 'hermitian'.

    Examples
    --------
    >>> from io import StringIO
    >>> from scipy.io import mminfo

    >>> text = '''%%MatrixMarket matrix coordinate real general
    ...  5 5 7
    ...  2 3 1.0
    ...  3 4 2.0
    ...  3 5 3.0
    ...  4 1 4.0
    ...  4 2 5.0
    ...  4 3 6.0
    ...  4 4 7.0
    ... '''


    ``mminfo(source)`` returns the number of rows, number of columns,
    format, field type and symmetry attribute of the source file.

    >>> mminfo(StringIO(text))
    (5, 5, 7, 'coordinate', 'real', 'general')
    )r   Úinfo)Úsourcer   r   r   r      s   
0r   T©Úspmatrixc                C   s   t ƒ j| |d�S )aä  
    Reads the contents of a Matrix Market file-like 'source' into a matrix.

    Parameters
    ----------
    source : str or file-like
        Matrix Market filename (extensions .mtx, .mtz.gz)
        or open file-like object.
    spmatrix : bool, optional (default: True)
        If ``True``, return sparse ``coo_matrix``. Otherwise return ``coo_array``.

    Returns
    -------
    a : ndarray or coo_array or coo_matrix
        Dense or sparse array depending on the matrix format in the
        Matrix Market file.

    Examples
    --------
    >>> from io import StringIO
    >>> from scipy.io import mmread

    >>> text = '''%%MatrixMarket matrix coordinate real general
    ...  5 5 7
    ...  2 3 1.0
    ...  3 4 2.0
    ...  3 5 3.0
    ...  4 1 4.0
    ...  4 2 5.0
    ...  4 3 6.0
    ...  4 4 7.0
    ... '''

    ``mmread(source)`` returns the data as sparse matrix in COO format.

    >>> m = mmread(StringIO(text), spmatrix=False)
    >>> m
    <COOrdinate sparse array of dtype 'float64'
         with 7 stored elements and shape (5, 5)>
    >>> m.toarray()
    array([[0., 0., 0., 0., 0.],
           [0., 0., 1., 0., 0.],
           [0., 0., 0., 2., 3.],
           [4., 5., 6., 7., 0.],
           [0., 0., 0., 0., 0.]])
    r   )r   Úread)r   r   r   r   r   r   T   s   /r   Ú c                 C   s   t ƒ  | |||||¡ dS )a  
    Writes the sparse or dense array `a` to Matrix Market file-like `target`.

    Parameters
    ----------
    target : str or file-like
        Matrix Market filename (extension .mtx) or open file-like object.
    a : array like
        Sparse or dense 2-D array.
    comment : str, optional
        Comments to be prepended to the Matrix Market file.
    field : None or str, optional
        Either 'real', 'complex', 'pattern', or 'integer'.
    precision : None or int, optional
        Number of digits to display for real or complex values.
    symmetry : None or str, optional
        Either 'general', 'symmetric', 'skew-symmetric', or 'hermitian'.
        If symmetry is None the symmetry type of 'a' is determined by its
        values.

    Returns
    -------
    None

    Examples
    --------
    >>> from io import BytesIO
    >>> import numpy as np
    >>> from scipy.sparse import coo_array
    >>> from scipy.io import mmwrite

    Write a small NumPy array to a matrix market file.  The file will be
    written in the ``'array'`` format.

    >>> a = np.array([[1.0, 0, 0, 0], [0, 2.5, 0, 6.25]])
    >>> target = BytesIO()
    >>> mmwrite(target, a)
    >>> print(target.getvalue().decode('latin1'))
    %%MatrixMarket matrix array real general
    %
    2 4
    1
    0
    0
    2.5
    0
    0
    0
    6.25

    Add a comment to the output file, and set the precision to 3.

    >>> target = BytesIO()
    >>> mmwrite(target, a, comment='\n Some test data.\n', precision=3)
    >>> print(target.getvalue().decode('latin1'))
    %%MatrixMarket matrix array real general
    %
    % Some test data.
    %
    2 4
    1.00e+00
    0.00e+00
    0.00e+00
    2.50e+00
    0.00e+00
    0.00e+00
    0.00e+00
    6.25e+00

    Convert to a sparse matrix before calling ``mmwrite``.  This will
    result in the output format being ``'coordinate'`` rather than
    ``'array'``.

    >>> target = BytesIO()
    >>> mmwrite(target, coo_array(a), precision=3)
    >>> print(target.getvalue().decode('latin1'))
    %%MatrixMarket matrix coordinate real general
    %
    2 4 3
    1 1 1.00e+00
    2 2 2.50e+00
    2 4 6.25e+00

    Write a complex Hermitian array to a matrix market file.  Note that
    only six values are actually written to the file; the other values
    are implied by the symmetry.

    >>> z = np.array([[3, 1+2j, 4-3j], [1-2j, 1, -5j], [4+3j, 5j, 2.5]])
    >>> z
    array([[ 3. +0.j,  1. +2.j,  4. -3.j],
           [ 1. -2.j,  1. +0.j, -0. -5.j],
           [ 4. +3.j,  0. +5.j,  2.5+0.j]])

    >>> target = BytesIO()
    >>> mmwrite(target, z, precision=2)
    >>> print(target.getvalue().decode('latin1'))
    %%MatrixMarket matrix array complex hermitian
    %
    3 3
    3.0e+00 0.0e+00
    1.0e+00 -2.0e+00
    4.0e+00 3.0e+00
    1.0e+00 0.0e+00
    0.0e+00 5.0e+00
    2.5e+00 0.0e+00

    N)r   Úwrite)ÚtargetÚaÚcommentÚfieldÚ	precisionÚsymmetryr   r   r   r   ˆ   s   lr   c                
   @   s‚  e Zd ZdZedd„ ƒZedd„ ƒZedd„ ƒZedd	„ ƒZed
d„ ƒZ	edd„ ƒZ
edd„ ƒZdZdZeefZedd„ ƒZdZdZdZdZdZeeeeefZedd„ ƒZdZdZdZdZeeeefZedd „ ƒZed!ed"ed#ed$ed#iZed%d&„ ƒZ ed'd(„ ƒZ!ed)d*„ ƒZ"edDd,d-„ƒZ#ed.d/„ ƒZ$ed0d1„ ƒZ%d2d3„ Z&d4d5œd6d7„Z'	9	9dEd:d;„Z(d<d=„ Z)d>d?„ Z*d@dA„ Z+	9	9dEdBdC„Z,d9S )Fr   )Ú_rowsÚ_colsÚ_entriesÚ_formatÚ_fieldÚ	_symmetryc                 C   ó   | j S ©N)r(   ©Úselfr   r   r   Úrows   ó   zMMFile.rowsc                 C   r.   r/   )r)   r0   r   r   r   Úcols  r3   zMMFile.colsc                 C   r.   r/   )r*   r0   r   r   r   Úentries  r3   zMMFile.entriesc                 C   r.   r/   )r+   r0   r   r   r   Úformat  r3   zMMFile.formatc                 C   r.   r/   )r,   r0   r   r   r   r%     r3   zMMFile.fieldc                 C   r.   r/   )r-   r0   r   r   r   r'     r3   zMMFile.symmetryc                 C   s   | j | j| j| jfv S r/   )r-   ÚSYMMETRY_SYMMETRICÚSYMMETRY_SKEW_SYMMETRICÚSYMMETRY_HERMITIANr0   r   r   r   Úhas_symmetry  s   þzMMFile.has_symmetryÚ
coordinateÚarrayc                 C   ó(   || j vrd|› d| j › �}t|ƒ‚d S )Nzunknown format type ú, must be one of )ÚFORMAT_VALUESÚ
ValueError)r1   r6   Úmsgr   r   r   Ú_validate_format#  ó   
þzMMFile._validate_formatÚintegerúunsigned-integerr   ÚcomplexÚpatternc                 C   r=   )Nzunknown field type r>   )ÚFIELD_VALUESr@   )r1   r%   rA   r   r   r   Ú_validate_field2  rC   zMMFile._validate_fieldÚgeneralÚ	symmetriczskew-symmetricÚ	hermitianc                 C   s$   || j vrtd|› d| j › �ƒ‚d S )Nzunknown symmetry type r>   )ÚSYMMETRY_VALUESr@   )r1   r'   r   r   r   Ú_validate_symmetry@  s
   

ÿÿzMMFile._validate_symmetryÚintpÚuint64ÚdÚDc                   C   ó   d S r/   r   r   r   r   r   ÚreaderM  ó   zMMFile.readerc                   C   rS   r/   r   r   r   r   r   ÚwriterR  rU   zMMFile.writerc                 C   sv  |   |¡\}}z«| ¡ }dd„ | ¡ D ƒ\}}}}}	| d¡s#tdƒ‚| ¡ dks/td| ƒ‚| ¡ dkr9| j}n	| ¡ dkrB| j}|rX| ¡ rU| ¡ d	 d
v rU| ¡ }nn|sD| 	¡ sd| ¡ }| 	¡ r\| ¡ }
|| jkrˆt
|
ƒdks|td| d¡ ƒ‚tt|
ƒ\}}|| }nt
|
ƒdks—td| d¡ ƒ‚tt|
ƒ\}}}||||| ¡ |	 ¡ fW |r²| ¡  S S |rº| ¡  w w )aó  
        Return size, storage parameters from Matrix Market file-like 'source'.

        Parameters
        ----------
        source : str or file-like
            Matrix Market filename (extension .mtx) or open file-like object

        Returns
        -------
        rows : int
            Number of matrix rows.
        cols : int
            Number of matrix columns.
        entries : int
            Number of non-zero entries of a sparse matrix
            or rows*cols for a dense matrix.
        format : str
            Either 'coordinate' or 'array'.
        field : str
            Either 'real', 'complex', 'pattern', or 'integer'.
        symmetry : str
            Either 'general', 'symmetric', 'skew-symmetric', or 'hermitian'.
        c                 s   s   � | ]	}t | ¡ ƒV  qd S r/   )r   Ústrip)Ú.0Úpartr   r   r   Ú	<genexpr>y  s   € zMMFile.info.<locals>.<genexpr>z%%MatrixMarketz%source is not in Matrix Market formatÚmatrixzProblem reading file header: r<   r;   r   ©ú%é%   é   zHeader line not of length 2: Úasciié   zHeader line not of length 3: )Ú_openÚreadlineÚsplitÚ
startswithr@   ÚlowerÚFORMAT_ARRAYÚFORMAT_COORDINATEÚlstriprW   Úlenr   ÚmapÚintÚclose)r1   r   ÚstreamÚclose_itÚlineÚmmidr[   r6   r%   r'   Ú
split_liner2   r4   r5   r   r   r   r   W  sT   ÿ

üÿ
ÿ
ÿÿ
ÿ
ÿzMMFile.infoÚrbc                 C   s  zt  | ¡} W n ty   | df Y S w |d dkrvt j | ¡sGt j | d ¡r.| d } nt j | d ¡r;| d } nt j | d ¡rG| d } |  d¡rZddl}| | |¡}|dfS |  d	¡rmddl}| 	| d
¡}|dfS t| |ƒ}|dfS | dd… dkr‚| d } t| |ƒ}|dfS )a—   Return an open file stream for reading based on source.

        If source is a file name, open it (after trying to find it with mtx and
        gzipped mtx extensions). Otherwise, just return source.

        Parameters
        ----------
        filespec : str or file-like
            String giving file name or file-like object
        mode : str, optional
            Mode with which to open file, if `filespec` is a file name.

        Returns
        -------
        fobj : file-like
            Open file-like object.
        close_it : bool
            True if the calling function should close this file when done,
            false otherwise.
        Fr   Úrz.mtxz.mtx.gzz.mtx.bz2z.gzNz.bz2rs   éüÿÿÿT)
ÚosÚfspathÚ	TypeErrorÚpathÚisfileÚendswithÚgzipÚopenÚbz2ÚBZ2File)ÚfilespecÚmoder|   rn   r~   r   r   r   rb   ¦  s6   ÿ



ô

øü
zMMFile._openc              	      sH  ˆ j \}‰|ˆkrtjS d}d}ˆ jjdv }tˆ ƒr>ˆ  ¡ ‰ ˆ  ¡ \}}||k  ¡ ||k ¡ kr3tjS ˆ  	¡ ‰ ‡ fdd„}n‡ ‡fdd„}|ƒ D ]I\}}	}
|rX|
rX|dkrXd}n1|r`||	kr`d}t
jdd	�� |rp||	 krpd}W d   ƒ n1 szw   Y  |r‰|t|	ƒkr‰d}|s‘|s‘|s‘ nqH|r—tjS |rœtjS |r¡tjS tjS )
NTÚFDc                  3   sR   � ˆ   ¡ D ]!\\} }}| |krˆ || f }||dfV  q| |kr&||dfV  qd S )NFT)Úitems)ÚiÚjÚaijÚaji)r#   r   r   Úsymm_iteratorú  s   €€ûz+MMFile._get_symmetry.<locals>.symm_iteratorc                  3   sN   � t ˆƒD ]} t | ˆƒD ]}ˆ | |  ˆ |  | }}|||| kfV  qqd S r/   )Úrange)r…   r„   r†   r‡   ©r#   Únr   r   rˆ     s   €þÿr   FÚignore)Úover)Úshaper   ÚSYMMETRY_GENERALÚdtypeÚcharr   ÚtocooÚnonzeroÚsumÚtodokÚnpÚerrstater   r7   r8   r9   )r#   ÚmÚissymmÚisskewÚishermÚrowÚcolrˆ   r†   r‡   Úis_diagonalr   rŠ   r   Ú_get_symmetryå  sH   
€ý€zMMFile._get_symmetryc              
   C   s0   t jd| t jdt jdt jd||f i | d ¡S )Nz%%.%ie
z%i
z%u
z%%.%ie %%.%ie
)r   Ú
FIELD_REALÚFIELD_INTEGERÚFIELD_UNSIGNEDÚFIELD_COMPLEXÚget)r%   r&   r   r   r   Ú_field_template&  s   
ÿýûzMMFile._field_templatec                 K   s   | j di |¤Ž d S )Nr   )Ú_init_attrs)r1   Úkwargsr   r   r   Ú__init__0  s   zMMFile.__init__Tr   c                C   s^   |   |¡\}}z|  |¡ |  |¡}W |r| ¡  n|r!| ¡  w w |r-t|tƒr-t|ƒ}|S )aB  
        Reads the contents of a Matrix Market file-like 'source' into a matrix.

        Parameters
        ----------
        source : str or file-like
            Matrix Market filename (extensions .mtx, .mtz.gz)
            or open file object.
        spmatrix : bool, optional (default: True)
            If ``True``, return sparse ``coo_matrix``. Otherwise return ``coo_array``.

        Returns
        -------
        a : ndarray or coo_array or coo_matrix
            Dense or sparse array depending on the matrix format in the
            Matrix Market file.
        )rb   Ú_parse_headerÚ_parse_bodyrm   r   r   r   )r1   r   r   rn   ro   Údatar   r   r   r   4  s   
€ÿ
ÿzMMFile.readr    Nc           	      C   s\   |   |d¡\}}z|  ||||||¡ W |r| ¡  dS | ¡  dS |r)| ¡  w | ¡  w )a7  
        Writes sparse or dense array `a` to Matrix Market file-like `target`.

        Parameters
        ----------
        target : str or file-like
            Matrix Market filename (extension .mtx) or open file-like object.
        a : array like
            Sparse or dense 2-D array.
        comment : str, optional
            Comments to be prepended to the Matrix Market file.
        field : None or str, optional
            Either 'real', 'complex', 'pattern', or 'integer'.
        precision : None or int, optional
            Number of digits to display for real or complex values.
        symmetry : None or str, optional
            Either 'general', 'symmetric', 'skew-symmetric', or 'hermitian'.
            If symmetry is None the symmetry type of 'a' is determined by its
            values.
        ÚwbN)rb   Ú_writerm   Úflush)	r1   r"   r#   r$   r%   r&   r'   rn   ro   r   r   r   r!   U  s   ý

zMMFile.writec              	   K   sp   | j j}dd„ |D ƒ}t| ¡ ƒt|ƒ }|r#tdt|ƒ› d|› �ƒ‚|D ]}t| || |dd… d¡ƒ q%dS )zr
        Initialize each attributes with the corresponding keyword arg value
        or a default of None
        c                 S   s   g | ]}|d d… ‘qS )é   Nr   )rX   Úattrr   r   r   Ú
<listcomp>  s    z&MMFile._init_attrs.<locals>.<listcomp>zfound z, invalid keyword arguments, please only use r¯   N)Ú	__class__Ú	__slots__ÚsetÚkeysr@   ÚtupleÚsetattrr¤   )r1   r§   ÚattrsÚpublic_attrsÚinvalid_keysr°   r   r   r   r¦   x  s   ÿÿzMMFile._init_attrsc                 C   s2   | j  |¡\}}}}}}| j||||||d� d S )N)r2   r4   r5   r6   r%   r'   )r²   r   r¦   )r1   rn   r2   r4   r5   r6   r%   r'   r   r   r   r©   Š  s
   
ÿ
ÿzMMFile._parse_headerc                 C   s<  | j | j| j| j| j| jf\}}}}}}| j |d ¡}| j}	|| j	k}
|| j
k}|| jk}|| jk}|| jk}|| jk}|| jk�r
t||f|d�}d}d\}}|rbd|||f< ||d k rb|d7 }|rä| ¡ }|rt|d dv st| ¡ suqb|
r|t|ƒ}n|rƒt|ƒ}n|r�ttt| ¡ ƒŽ }nt|ƒ}||||f< |	rº||krº|r©| |||f< n|r´t|ƒ|||f< n||||f< ||d k rÅ|d }n|d }|	sÎd}n|}|râd|||f< ||d k râ|d7 }|sd|rø|d|fv rò||d ksötdƒ‚|S |d|fv �r||k�stdƒ‚|S || jk�r|dk�rt||f|d�S t|dd�}t|dd�}|�r3t|dd�}n$|
�r=t|d	d�}n|�rGt|d
d�}n|�rQt|dd�}nt|dd�}d}|D ]j}|�rl|d dv �sl| ¡ �sn�q[|d |k�rytdƒ‚| ¡ }tt|d d… ƒ\||< ||< |�sÀ|
�r›t|d ƒ||< n%|�r§t|d ƒ||< n|�r¸ttt|dd … ƒŽ ||< nt|d ƒ||< |d7 }�q[||k �rÏtdƒ‚|d8 }|d8 }|	�r||k}|| }|| }|| }t||fƒ}t||fƒ}|�rþ|d9 }n|�r| ¡ }t||fƒ}t|||ff||f|d�}|S t|ƒ‚)N)r�   r¯   )r   r   r   r\   z$Parse error, did not read all lines.ÚintcÚint8rO   rP   rF   Úfloatz5'entries' in header is smaller than number of entriesr_   z4'entries' in header is larger than number of entrieséÿÿÿÿ)rŽ   r�   ) r2   r4   r5   r6   r%   r'   ÚDTYPES_BY_FIELDr¤   r:   r¡   r¢   r£   r8   r9   ÚFIELD_PATTERNrg   r   rc   rW   rl   rF   rk   r½   rd   r   r@   rh   r   r	   r   Ú	conjugateÚNotImplementedError)r1   rn   r2   r4   r5   r6   r%   Úsymmr�   r:   Ú
is_integerÚis_unsigned_integerÚ
is_complexÚis_skewÚis_hermÚ
is_patternr#   rp   r„   r…   r†   ÚIÚJÚVÚentry_numberÚlÚmaskÚod_IÚod_JÚod_Vr   r   r   rª   ‘  sÔ   þ








à"J¸G»


þzMMFile._parse_bodyc                 C   sÀ  t |tƒst |tƒst |tƒst|dƒrf| j}t|ƒ}t|jƒdkr&t	dƒ‚|j\}}	|d ure|| j
krDt|jdƒs>tdƒ‚| d¡}n6|| jkrU|jjdvrT| d¡}n%|| jkre|jjdvre| d	¡}nt|ƒsst	d
t|ƒ› �ƒ‚d}|j\}}	|jj}
|d u r‹|
dv r‰d}nd}|d u r¿|jj}|dkr¤t|jdƒs¡tdƒ‚d}n|dkr«d}n|dkr²d}n|dkr¹d}ntd| ƒ‚|d u rÈ|  |¡}| j |¡ | j |¡ | j |¡ d|› d|› d|› d�}| | d¡¡ | d¡D ]}d|› d�}| | d¡¡ qó|  ||¡}|| jk�rd||	f }| | d¡¡ || j
| j| jfv �rŸ|| j k�rQt!|	ƒD ]}t!|ƒD ]}||||f  }| | d¡¡ �q9�q3d S || j"k�r|t!|	ƒD ]}t!|d |ƒD ]}||||f  }| | d¡¡ �qd�q[d S t!|	ƒD ]}t!||ƒD ]}||||f  }| | d¡¡ �q‡�q€d S || jk�r || j k�rÕt!|	ƒD ]#}t!|ƒD ]}|||f }|t#|ƒt$|ƒf }| | d¡¡ �qµ�q¯d S t!|	ƒD ]$}t!||ƒD ]}|||f }|t#|ƒt$|ƒf }| | d¡¡ �qà�qÙd S || j%k�r
t	dƒ‚td |› �ƒ‚| &¡ }|| j k�r5|j'|j(k}t)|j*| |j'| |j(| ff|jd!�}d"||	|j+f }| | d¡¡ |  ||d ¡}|| j%k�rtt,|j'd |j(d ƒD ]\}}d||f }| | d¡¡ �q^d S || j
| j| jfv �r§t,|j'd |j(d |j*ƒD ]\}}}d#||f ||  }| | d¡¡ �qŒd S || jk�rÙt,|j'd |j(d |j*ƒD ]\}}}d#||f ||j#|j$f  }| | d¡¡ �qºd S td |› �ƒ‚)$NÚ	__array__r_   zExpected 2 dimensional arrayrO   zBmmwrite does not support integer dtypes larger than native 'intp'.ÚfdrQ   r‚   rR   zunknown matrix type: r;   ÚfFé   é   r„   rD   Úfr   ÚcrF   ÚurE   zunexpected dtype kind z%%MatrixMarket matrix ú Ú
r   r]   z%i %i
r¯   z*pattern type inconsisted with dense formatzUnknown field type )rŽ   z	%i %i %i
z%i %i )-r   Úlistr   r¶   Úhasattrrg   r   rj   rŽ   r@   r¡   r
   r�   ÚOverflowErrorÚastyper    r‘   r£   r   ÚtypeÚkindrx   rŸ   r²   rB   rI   rN   r!   Úencoderd   r¥   r¢   r�   r‰   r8   r   r   rÀ   r’   rœ   r�   r   r«   ÚnnzÚzip)r1   rn   r#   r$   r%   r&   r'   Úrepr2   r4   Útypecoderâ   r«   rp   Útemplater…   r„   r†   ÚcooÚlower_triangle_maskrt   rÙ   rQ   r   r   r   r­     s  ÿÿ



€

€


ÿþÿþÿþÿýÿýÿ
ÿÿýþ
ÿ$þ$þzMMFile._write)rs   ©r    NNN)-Ú__name__Ú
__module__Ú__qualname__r³   Úpropertyr2   r4   r5   r6   r%   r'   r:   rh   rg   r?   ÚclassmethodrB   r¡   r¢   r    r£   rÀ   rH   rI   r�   r7   r8   r9   rM   rN   r¿   ÚstaticmethodrT   rV   r   rb   rŸ   r¥   r¨   r   r!   r¦   r©   rª   r­   r   r   r   r   r   ø   sŒ    







ÿ
ÿ
ü


N>
@
	!
ÿ# 	ÿr   c                 C   sp   g }zddl }| |j¡ W n	 ty   Y nw zddl}| |j¡ W n	 ty-   Y nw t|ƒ}t| |ƒ S )z¡
    Check whether `stream` is compatible with numpy.fromfile.

    Passing a gzipped file object to ``fromfile/fromstring`` doesn't work with
    Python 3.
    r   N)r|   ÚappendÚGzipFileÚImportErrorr~   r   r¶   r   )rn   Úbad_clsr|   r~   r   r   r   Ú_is_fromfile_compatible³  s   ÿÿrö   rë   )Ú__doc__rv   Únumpyr–   r   r   r   r   r   r   r   r	   r
   Úscipy.sparser   r   r   Ú__all__r   r   r   r   r   rö   r   r   r   r   Ú<module>   s"    ,5
4p     @