
    (ph^}                         S r SSKrSSKrSSKJrJrJrJrJrJ	r	J
r
JrJr  SSKJrJrJr  / SQrS rS rSS	.S
 jrSS jr " S S5      rS rg)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                 d    [        U [        5      (       a  U R                  S5      $ [        U 5      $ )Nlatin1)
isinstancebytesdecodestr)ss    A/var/www/html/venv/lib/python3.13/site-packages/scipy/io/_mmio.pyasstrr      s'    !Uxx!!q6M    c                 ,    [         R                  U 5      $ )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)sources    r   r   r      s    ` ;;vr   Tspmatrixc                0    [        5       R                  XS9$ )aH  
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!   s     r   r   r   T   s    ^ 8===33r   c                 :    [        5       R                  XX#XE5        g)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symmetrys         r   r   r      s    X HNN6giBr   c            
          \ rS rSrSr\S 5       r\S 5       r\S 5       r\S 5       r	\S 5       r
\S 5       r\S	 5       rS
rSr\\4r\S 5       rSrSrSrSrSr\\\\\4r\S 5       rSrSrSrSr\\\\4r\S 5       r\S\S\S\S\S0r\ S 5       r!\ S 5       r"\S 5       r#\ S-S j5       r$\ S  5       r%\ S! 5       r&S" r'S#S$.S% jr(  S.S' jr)S( r*S) r+S* r,  S.S+ jr-S,r.g&)/r      )_rows_cols_entries_format_field	_symmetryc                     U R                   $ N)r.   selfs    r   rowsMMFile.rows       zzr   c                     U R                   $ r5   )r/   r6   s    r   colsMMFile.cols  r:   r   c                     U R                   $ r5   )r0   r6   s    r   entriesMMFile.entries  s    }}r   c                     U R                   $ r5   )r1   r6   s    r   formatMMFile.format  s    ||r   c                     U R                   $ r5   )r2   r6   s    r   r)   MMFile.field  s    {{r   c                     U R                   $ r5   )r3   r6   s    r   r+   MMFile.symmetry  s    ~~r   c                 b    U R                   U R                  U R                  U R                  4;   $ r5   )r3   SYMMETRY_SYMMETRICSYMMETRY_SKEW_SYMMETRICSYMMETRY_HERMITIANr6   s    r   has_symmetryMMFile.has_symmetry  s2    ~~$"9"9"&">">"&"9"9"; ; 	;r   
coordinatearrayc                 \    XR                   ;  a  SU SU R                    3n[        U5      eg )Nzunknown format type , must be one of )FORMAT_VALUES
ValueError)r7   rB   msgs      r   _validate_formatMMFile._validate_format#  s7    +++(0A$BTBTAUVCS/! ,r   integerunsigned-integerr   complexpatternc                 \    XR                   ;  a  SU SU R                    3n[        U5      eg )Nzunknown field type rQ   )FIELD_VALUESrS   )r7   r)   rT   s      r   _validate_fieldMMFile._validate_field2  s7    )))'w.?@Q@Q?RSCS/! *r   general	symmetriczskew-symmetric	hermitianc                 X    XR                   ;  a  [        SU SU R                    35      eg )Nzunknown symmetry type rQ   )SYMMETRY_VALUESrS   )r7   r+   s     r   _validate_symmetryMMFile._validate_symmetry@  sA    ///5hZ @//3/C/C.DF G G 0r   intpuint64dDc                      g r5    rk   r   r   readerMMFile.readerM      r   c                      g r5   rk   rk   r   r   writerMMFile.writerR  rn   r   c                    U R                  U5      u  p# UR                  5       nS UR                  5        5       u  pVpxn	UR                  S5      (       d  [	        S5      eUR                  5       S:X  d  [	        SU-   5      eUR                  5       S:X  a  U R                  nO UR                  5       S:X  a  U R                  nU(       aG  UR                  5       (       a(  UR                  5       S   S	;   a  UR                  5       nOO	U(       a  MG  UR                  5       (       d'  UR                  5       nUR                  5       (       d  M'  UR                  5       n
XpR                  :X  aC  [        U
5      S
:X  d  [	        SUR                  S5      -   5      e[        [        U
5      u  pX-  nO?[        U
5      S:X  d  [	        SUR                  S5      -   5      e[        [        U
5      u  pnXXUR                  5       U	R                  5       4U(       a  UR                  5         $ $ ! U(       a  UR                  5         f f = f)aK  
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              3   T   #    U  H  n[        UR                  5       5      v   M      g 7fr5   )r   strip).0parts     r   	<genexpr>MMFile.info.<locals>.<genexpr>y  s     >tzz|$$s   &(z%%MatrixMarketz%source is not in Matrix Market formatmatrixzProblem reading file header: rO   rN   r   %%      zHeader line not of length 2: ascii   zHeader line not of length 3: )_openreadlinesplit
startswithrS   lowerFORMAT_ARRAYFORMAT_COORDINATElstriprt   lenr   mapintclose)r7   r   streamclose_itlinemmidry   rB   r)   r+   
split_liner8   r<   r?   s                 r   r   MMFile.infoW  s   6  ::f-/	 ??$D>> 2D&??#344 !HII<<>X- !@4!GHH ||~(**</// ;;==T[[]1%5%B!??,D	 $ jjll( jjll J***:!+$%D%)[[%9&: ; ; j1
+:!+$%D%)[[%9&: ; ;&)#z&:#GNN$&  x s   C;H) :H) CH) )Ic                     [         R                  " U 5      n US   S:X  Ga  [         R                  R	                  U 5      (       d  [         R                  R	                  U S-   5      (       a  U S-   n OY[         R                  R	                  U S-   5      (       a  U S-   n O,[         R                  R	                  U S-   5      (       a  U S-   n U R                  S5      (       a  SSKnUR                  X5      nUS4$ U R                  S	5      (       a  SSKnUR                  U S
5      nUS4$ [        X5      n US4$ U SS S:w  a  U S-   n [        X5      nUS4$ ! [         a    U S4s $ f = f)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.bz2rbT)
osfspath	TypeErrorpathisfileendswithgzipopenbz2BZ2File)filespecmoder   r   r   s        r   r   MMFile._open  s^   4	#yy*H 7c> 77>>(++77>>(6/22'&0HWW^^HY$677')3HWW^^HZ$788'*4H  ''82 t| ""6**Xt4 t| h- t|	 }&#f,()Ft|A  	#U?"	#s   E E)(E)c                   ^ ^ T R                   u  nmUT:w  a  [        R                  $ SnSnT R                  R                  S;   n[        T 5      (       ao  T R                  5       m T R                  5       u  pVXV:  R                  5       XV:  R                  5       :w  a  [        R                  $ T R                  5       m U 4S jnOU U4S jnU" 5        H  u  pn
U(       a  U
(       a	  US:w  a  SnORU(       a  X:w  a  Sn[        R                  " SS9   U(       a  X* :w  a  SnS S S 5        U(       a  U[        U	5      :w  a  SnU(       a  Mx  U(       a  M  U(       a  M    O   U(       a  [        R                  $ U(       a  [        R                  $ U(       a  [        R                  $ [        R                  $ ! , (       d  f       N= f)	NTFDc               3      >#    TR                  5        H(  u  u  pnX:  a  TX4   nX#S4v   M  X:X  d  M"  X"S4v   M*     g 7f)NFT)items)ijaijajir'   s       r   symm_iterator+MMFile._get_symmetry.<locals>.symm_iterator  sG     %&WWYMVaSug"//".. &/s
   /AAc               3      >#    [        T5       H-  n [        U T5       H  nTU   U    TU    U   p2X#X:H  4v   M     M/     g 7fr5   )range)r   r   r   r   r'   ns       r   r   r     sH     qA"1a[#$Q47AaDGS"00 ) "s   >Ar   Fignore)over)shaper   SYMMETRY_GENERALdtypecharr   tocoononzerosumtodoknperrstater   rI   rJ   rK   )r'   missymmisskewishermrowcolr   r   r   is_diagonalr   s   `          @r   _get_symmetryMMFile._get_symmetry  sX   ww16***% A;; 	AJS	 SYOO$55... 	A/1 (5#S{+#(cj"F[[h/#+!& 0 cT#Y."FFff (7  ,,,111,,,&&&! 0/s   F55
G	c           
          [         R                  SU-  [         R                  S[         R                  S[         R                  SX4-  0R                  U S 5      $ )Nz%%.%ie
z%i
z%u
z%%.%ie %%.%ie
)r   
FIELD_REALFIELD_INTEGERFIELD_UNSIGNEDFIELD_COMPLEXget)r)   r*   s     r   _field_templateMMFile._field_template&  sW    !!:	#9$$f%%v$$&7*'+
 #eT"	#r   c                 (    U R                   " S0 UD6  g )Nrk   )_init_attrs)r7   kwargss     r   __init__MMFile.__init__0  s    "6"r   Tr    c                (   U R                  U5      u  p4 U R                  U5        U R                  U5      nU(       a  UR                  5         U(       a   [	        U[
        5      (       a  [        U5      nU$ ! U(       a  UR                  5         f f = f)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 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.
)r   _parse_header_parse_bodyr   r   r   r   )r7   r   r!   r   r   datas         r   r#   MMFile.read4  sy    $  ::f-	v&##F+D 
433d#D	  s   "A7 7BNc                     U R                  US5      u  px U R                  XrX4XV5        U(       a  UR                  5         gUR                  5         g! U(       a  UR                  5         f UR                  5         f = f)a  
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)r   _writer   flush)	r7   r&   r'   r(   r)   r*   r+   r   r   s	            r   r%   MMFile.writeU  s\    .  ::fd3	KK79G  s   A *A<c           
      >   U R                   R                  nU Vs/ s H  o3SS PM	     nn[        UR                  5       5      [        U5      -
  nU(       a  [	        S[        U5       SU 35      eU H"  n[        XUR                  USS S5      5        M$     gs  snf )zZ
Initialize each attributes with the corresponding keyword arg value
or a default of None
   Nzfound z, invalid keyword arguments, please only use )	__class__	__slots__setkeysrS   tuplesetattrr   )r7   r   attrsattrpublic_attrsinvalid_keyss         r   r   MMFile._init_attrsx  s     ((-23UTQRU36;;=)C,==veL&9%: ;;;G.J K K DD

48T :;  4s   Bc           	      d    U R                   R                  U5      u  p#pEpgU R                  X#XEXgS9  g )N)r8   r<   r?   rB   r)   r+   )r   r   r   )r7   r   r8   r<   r?   rB   r)   r+   s           r   r   MMFile._parse_header  s9    NN' 	5GUdw$ 	 	9r   c           	         U R                   U R                  U R                  U R                  U R                  U R
                  4u  p#pEpgU R                  R                  US 5      nU R                  n	X`R                  :H  n
X`R                  :H  nX`R                  :H  nXpR                  :H  nXpR                  :H  nX`R                  :H  nXPR                  :X  Ga  [!        X#4US9nSnSu  nnU(       a  SUUU4'   UUS-
  :  a  US-  nU(       Ga  UR#                  5       nU(       a  US   S;   d  UR%                  5       (       d  M?  U
(       a  ['        U5      nOJU(       a  ['        U5      nO7U(       a%  [)        [+        [,        UR/                  5       5      6 nO[-        U5      nUUUU4'   U	(       a5  UU:w  a/  U(       a	  U* UUU4'   OU(       a  [1        U5      UUU4'   OUUUU4'   UUS-
  :  a  US-   nO-US-   nU	(       d  SnOUnU(       a  SUUU4'   UUS-
  :  a  US-  nU(       a  GM  U(       a  USU4;   a	  UUS-
  :X  d  [3        S5      e U$ USU4;   a  UU:X  d  [3        S5      e U$ XPR4                  :X  Ga  US:X  a  [7        X#4US9$ [!        USS9n[!        USS9nU(       a  [9        USS9nO@U
(       a  [!        US	S9nO.U(       a  [!        US
S9nOU(       a  [!        USS9nO
[!        USS9nSnU H  nU(       a  US   S;   d  UR%                  5       (       d  M*  US-   U:  a  [3        S5      eUR/                  5       n[+        [&        US S 5      u  UU'   UU'   U(       dg  U
(       a  ['        US   5      UU'   ONU(       a  ['        US   5      UU'   O5U(       a  [)        [+        [,        USS  5      6 UU'   O[-        US   5      UU'   US-  nM     UU:  a  [3        S5      eUS-  nUS-  nU	(       a_  UU:g  nUU   nUU   nUU   n[;        UU45      n[;        UU45      nU(       a  US-  nOU(       a  UR=                  5       n[;        UU45      n[7        UUU44X#4US9nU$ [?        U5      e)N)r   r   )r   r   r   rz   z$Parse error, did not read all lines.intcint8rf   rg   rY   floatz5'entries' in header is smaller than number of entriesr}   z4'entries' in header is larger than number of entries)r   r   ) r8   r<   r?   rB   r)   r+   DTYPES_BY_FIELDr   rL   r   r   r   rJ   rK   FIELD_PATTERNr   r   r   rt   r   rY   r   r   r   r   rS   r   r   r
   r	   	conjugateNotImplementedError)r7   r   r8   r<   r?   rB   r)   symmr   rL   
is_integeris_unsigned_integer
is_complexis_skewis_herm
is_patternr'   r   r   r   r   IJVentry_numberlmaskod_Iod_Jod_Vs                                 r   r   MMFile._parse_body  s   48IItyy48LL$++48JJ4O0GU $$((5((000
#':'::000
666111000
&&&tl%0ADDAq!Q$tax<FA(tAw)34::<<d)C(d)C!3udjjl#;<C+C!Q$AF#&$!Q$ "&s)!Q$"%!Q$tAv:AAAA'"&'AadG 46z !QA $D aVTAX$%KLL )6V Q aVT	$%KLL )2P K --- !| $U;;gV,AgV,A/'0$'2'3'1LtAw)34::<<>G+$ &9 : :JJL36sAbqE?0,<!!*-ad),,*-ad),#*13uae3D*E,*/!+,!) * g%  "5 6 6 FAFAQwwwD	*D	*BJD>>+DD	*1q!f+d\GA  &f--r   c                    [        U[        5      (       d<  [        U[        5      (       d'  [        U[        5      (       d  [	        US5      (       Ga	  U R
                  n[        U5      n[        UR                  5      S:w  a  [        S5      eUR                  u  pUb  X@R                  :X  a8  [        UR                  S5      (       d  [        S5      eUR                  S5      nOX@R                  :X  a,  UR                  R                   S;  a  UR                  S5      nOrX@R"                  :X  a+  UR                  R                   S;  a  UR                  S	5      nO7[%        U5      (       d  [        S
['        U5       35      eSnUR                  u  pUR                  R                   n
Uc  U
S;   a  SnOSnUcn  UR                  R(                  nUS:X  a)  [        UR                  S5      (       d  [        S5      eSnO)US:X  a  SnO US:X  a  SnOUS:X  a  SnO[+        SU-   5      eUc  U R-                  U5      nU R.                  R1                  U5        U R.                  R3                  U5        U R.                  R5                  U5        SU SU SU S3nUR7                  UR9                  S5      5        UR;                  S5       H)  nSU S3nUR7                  UR9                  S5      5        M+     U R=                  XE5      nXpR
                  :X  Gai  SX4-  nUR7                  UR9                  S5      5        X@R                  U R                  U R>                  4;   Ga  X`R@                  :X  aN  [C        U	5       H>  n[C        U5       H,  nXUU4   -  nUR7                  UR9                  S5      5        M.     M@     g X`RD                  :X  aR  [C        U	5       HB  n[C        US-   U5       H,  nXUU4   -  nUR7                  UR9                  S5      5        M.     MD     g [C        U	5       H>  n[C        X5       H,  nXUU4   -  nUR7                  UR9                  S5      5        M.     M@     g X@R"                  :X  a  X`R@                  :X  ae  [C        U	5       HU  n[C        U5       HC  nUUU4   nU[G        U5      [I        U5      4-  nUR7                  UR9                  S5      5        ME     MW     g [C        U	5       HU  n[C        X5       HC  nUUU4   nU[G        U5      [I        U5      4-  nUR7                  UR9                  S5      5        ME     MW     g X@RJ                  :X  a  [        S5      e[+        S U 35      eURM                  5       nX`R@                  :w  aX  URN                  URP                  :  n[S        URT                  U   URN                  U   URP                  U   44UR                  S!9nS"XURV                  4-  nUR7                  UR9                  S5      5        U R=                  XES-
  5      nX@RJ                  :X  aX  [Y        URN                  S-   URP                  S-   5       H-  u  nnSUU4-  nUR7                  UR9                  S5      5        M/     g X@R                  U R                  U R>                  4;   aj  [Y        URN                  S-   URP                  S-   URT                  5       H4  u  nnnS#UU4-  UU-  -   nUR7                  UR9                  S5      5        M6     g X@R"                  :X  a  [Y        URN                  S-   URP                  S-   URT                  5       HJ  u  nnnS#UU4-  UURF                  URH                  4-  -   nUR7                  UR9                  S5      5        ML     g [+        S U 35      e)$N	__array__r}   zExpected 2 dimensional arrayrf   zBmmwrite does not support integer dtypes larger than native 'intp'.fdrh   r   ri   zunknown matrix type: rN   fF      r   rW   fr   crY   urX   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   hasattrr   r   r   r   rS   r   r   r   OverflowErrorastyper   r   r   r   typekindr   r   r   rU   r]   rd   r%   encoder   r   r   r   r   rJ   r   r   r   r   r   r   r   r   nnzzip)r7   r   r'   r(   r)   r*   r+   repr8   r<   typecoder  r   r   templater   r   r   coolower_triangle_maskr   r  rh   s                          r   r   MMFile._write  s   a*Q"8"8a71k#:#:##C
A177|q  !?@@JD ...#AGGV44+ -P Q Q(Aoo-ww||4/HHSM000ww||4/HHSM A;; #8a	!BCCCJD77<<4		=77<<Ds{00' )L M M!!* 84 ?@@))!,H 	'',&&u-))(3 (uAeWAhZrBT[[*+ MM$'DtfB<DLLX./ ( ''9###|+DLLX./++T__,,. .444"4[!&tA#+1g#5D"LLX)>? "- )
 !=!=="4[!&q1ud!3A#+1g#5D"LLX)>? "4 ) #4[!&qA#+1g#5D"LLX)>? "0 )
 ,,,444"4[!&tA"#AqD'C#+tCy$s).D#DD"LLX)>? "- ) #4[!&qA"#AqD'C#+tCy$s).D#DD"LLX)>? "0 ) ,,, !MNN  "5eW =>> '')C 000&)gg&8#*=!>!$)<!=!$)<!=!?!@ '*ii1  4sww"77DLLX./++EQ;?H***	377195DAq$1v-DLLX!67 6 --t..0 0"37719cggaiBGAq!$1v-(Q,?DLLX!67  C ,,,"37719cggaiBGAq!$1v-(affaff=M2MNDLLX!67  C  "5eW =>>r   rk   )r    NNN)/__name__
__module____qualname____firstlineno__r   propertyr8   r<   r?   rB   r)   r+   rL   r   r   rR   classmethodrU   r   r   r   r   r   r\   r]   r   rI   rJ   rK   rc   rd   r   staticmethodrl   rp   r   r   r   r   r   r#   r%   r   r   r   r   __static_attributes__rk   r   r   r   r      s$   I             ; ; %L&5M" " M'NJMM!>:}!#L " " !$.$');.0BDO G G
 %f%x!3$c$c	+O     K K\ ; ;| =' ='@ # ## (, B BF F<$9EP CGW?r   r   c                     / n SSK nUR                  UR                  5         SSKnUR                  UR
                  5        [        U5      n[        X5      (       + $ ! [         a     NGf = f! [         a     N7f = f)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   )r   bad_clsr   r   s       r   _is_fromfile_compatibler.    sy     Gt}}%s{{# GnG&***  
  s"   A A. 
A+*A+.
A;:A;r  )__doc__r   numpyr   r   r   r   r   r   r   r	   r
   r   scipy.sparser   r   r   __all__r   r   r   r   r   r.  rk   r   r   <module>r3     s^    
 # # # 9 8
30j  $ /4hlC`x
? x
?v+r   