bundles / scipy latest / scipy / io / _mmio / mmwrite
function
scipy.io._mmio:mmwrite
source: /scipy/io/_mmio.py :136
Signature
def mmwrite ( target , a , comment = '' , field = None , precision = None , symmetry = None ) Summary
Writes the sparse or dense array a to Matrix Market file-like target.
Parameters
target: str or file-likeMatrix Market filename (extension .mtx) or open file-like object.
a: array likeSparse or dense 2-D array.
comment: str, optionalComments to be prepended to the Matrix Market file.
field: None or str, optionalEither 'real', 'complex', 'pattern', or 'integer'.
precision: None or int, optionalNumber of digits to display for real or complex values.
symmetry: None or str, optionalEither '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✓
a = np.array([[1.0, 0, 0, 0], [0, 2.5, 0, 6.25]]) target = BytesIO() mmwrite(target, a)✓
print(target.getvalue().decode('latin1'))
✗target = BytesIO() mmwrite(target, a, comment='\n Some test data.\n', precision=3)✓
print(target.getvalue().decode('latin1'))
✗target = BytesIO() mmwrite(target, coo_array(a), precision=3)✓
print(target.getvalue().decode('latin1'))
✗z = np.array([[3, 1+2j, 4-3j], [1-2j, 1, -5j], [4+3j, 5j, 2.5]]) z✓
target = BytesIO() mmwrite(target, z, precision=2)✓
print(target.getvalue().decode('latin1'))
✗Aliases
-
scipy.io._mmio.mmwrite