Fast and full-featured Matrix Market file I/O
Project description
Fast and full-featured Matrix Market file I/O package for Python.
Fastest way to read and write any Matrix Market .mtx
file into a dense ndarray, sparse coordinate (triplet) arrays, or SciPy sparse matrix.
Implemented as a Python binding of the C++ fast_matrix_market library.
pip install fast_matrix_market
Compared to scipy.io.mmread()
The fast_matrix_market.mmread()
and mmwrite()
methods are direct replacements for their respective SciPy versions.
Compared to SciPy v1.10.0:
-
Significant performance boost
All cores on the system are used by default, use the
parallelism
argument to override. SciPy's routines are single-threaded. -
64-bit indices, but only if the matrix dimensions require it.
scipy.io.mmread()
crashes on large matrices (dimensions > 231) because it uses 32-bit indices on most platforms. -
Directly write CSC/CSR matrices with no COO intermediary.
-
longdouble
Read and writelongdouble
/longcomplex
values for more floating-point precision on platforms that support it (e.g. 80-bit floats).Just pass
long_type=True
argument to any read method to uselongdouble
arrays. SciPy can writelongdouble
matrices but reads usedouble
precision.Note: Many platforms do not offer any precision greater than
double
even if thelongdouble
type exists. On those platformslongdouble == double
so check your Numpy for support. As of writing only Linux tends to havelongdouble > double
. -
Vector files
Read 1D vector files.scipy.io.mmread()
throws aValueError
.
Differences
- If no symmetry is specified
scipy.io.mmwrite
will search the matrix for one. This is a very slow process that significantly impacts writing time for all matrices, including non-symmetric ones. It can be disabled by settingsymmetry="general"
, but that is easily forgotten.fast_matrix_market.mmwrite()
only looks for symmetries if thefind_symmetry=True
argument is passed. precision
argument tommwrite()
is currently ignored. Floats may be written with more precision than desired.
Usage
import fast_matrix_market as fmm
Read as scipy sparse matrix
>>> a = fmm.mmread("eye3.mtx")
>>> a
<3x3 sparse matrix of type '<class 'numpy.float64'>'
with 3 stored elements in COOrdinate format>
>>> print(a)
(0, 0) 1.0
(1, 1) 1.0
(2, 2) 1.0
Read as raw coordinate/triplet arrays
>>> (data, (rows, cols)), shape = fmm.read_coo("eye3.mtx")
>>> rows, cols, data
(array([0, 1, 2], dtype=int32), array([0, 1, 2], dtype=int32), array([1., 1., 1.]))
Read as dense ndarray
>>> a = fmm.read_array("eye3.mtx")
>>> a
array([[1., 0., 0.],
[0., 1., 0.],
[0., 0., 1.]])
Write any of the above to a file
>>> fmm.mmwrite("matrix_out.mtx", a)
Write to streams (read from streams too)
>>> bio = io.BytesIO()
>>> fmm.mmwrite(bio, a)
Read only the header
>>> header = fmm.read_header("eye3.mtx")
header(shape=(3, 3), nnz=3, comment="3-by-3 identity matrix", object="matrix", format="coordinate", field="real", symmetry="general")
>>> header.shape
(3, 3)
>>> header.to_dict()
{'shape': (3, 3), 'nnz': 3, 'comment': '3-by-3 identity matrix', 'object': 'matrix', 'format': 'coordinate', 'field': 'real', 'symmetry': 'general'}
Note: SciPy is only a runtime dependency for the mmread
and mmwrite
methods. All others depend only on NumPy.
Quick way to try
Replace scipy.io.mmread
with fast_matrix_market.mmread
to quickly see if your scripts would benefit from a refactor:
import scipy.io
import fast_matrix_market as fmm
scipy.io.mmread = fmm.mmread
scipy.io.mmwrite = fmm.mmwrite
Dependencies
- No dependencies to read/write MatrixMarket headers.
numpy
to read/write arrays (i.e.read_array()
andread_coo()
). SciPy is not required.scipy
to read/writescipy.sparse
sparse matrices (i.e.read_scipy()
andmmread()
).
Development
This Python binding is implemented using pybind11 and built with scikit-build-core.
All code is in the python/ directory. If you make any changes simply install the package directory to build it:
pip install python/ -v
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Hashes for fast_matrix_market-1.4.2-pp39-pypy39_pp73-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 59fb3ed3776753c0afe434ccda728ecb7ee58e67d616d53801453a7198c0c541 |
|
MD5 | b528c9b3a2759fb46ddecdbf556fdba6 |
|
BLAKE2b-256 | 7e6b228a3009d72d0cfde720cb63c7063ce3d22ad847f4b3978c44689b2ab377 |
Hashes for fast_matrix_market-1.4.2-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 384f6803b62bac003bfd0d9ecd88d865f06dbd78165f352d332ce23adc07ec11 |
|
MD5 | 0a89fa4e5590b2fb68e5aab629366efb |
|
BLAKE2b-256 | 097fb81602c213697620c2edb2a37998b46fca51cd5b43b00231cb57cea9946a |
Hashes for fast_matrix_market-1.4.2-pp39-pypy39_pp73-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b99443ca01e2248db4f5e1d5d00b751882b25bdec7a5183ac3c4bb3604f853d1 |
|
MD5 | 037dac16efc09dd5b40818688a95dd1f |
|
BLAKE2b-256 | 4bc3a63b1eec4421aa25bafc0090ebb14be3965e3580673bbcaa4d39a62100e9 |
Hashes for fast_matrix_market-1.4.2-pp38-pypy38_pp73-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3e7b27a68e9601adf1003afa1f3d21e8b4ace7f63d8d39c4855bdf85b5178412 |
|
MD5 | 0cd69ae9b8bac2e4b87a37aeef661642 |
|
BLAKE2b-256 | d5666bfd7f3fcbd9bd1af9510e49897223a57d08748ad818df982a73fbe71577 |
Hashes for fast_matrix_market-1.4.2-pp38-pypy38_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b8829a40e37d1171ee3f2c4cd83758b9f6f4162b95ea2d6fa9d7eb68101dee43 |
|
MD5 | f827e6c4c354a0c2e0ae5ac0613491ad |
|
BLAKE2b-256 | 5fa4a59c9cf6871b9240f59e112fbe9c8abb0d53dadc2ba6611ef9b7aeac2510 |
Hashes for fast_matrix_market-1.4.2-pp38-pypy38_pp73-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8db49a81885a6d61e5b0d8851bbab5f8fc53ef10b69542120f00ce203d61a28f |
|
MD5 | aacf81badadd922e0d8275fc246381b6 |
|
BLAKE2b-256 | 2f40623f6864a7aa1e732a9790af481a29a3210919f77aeb11c053ac3ae57976 |
Hashes for fast_matrix_market-1.4.2-pp37-pypy37_pp73-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c2d90a8bfac24385a39f355a79151da82ff5b7c170583ef597f45b93e8299239 |
|
MD5 | 6457c78b5ec3498ed0829aefc33b41be |
|
BLAKE2b-256 | 45052fe9110fa14090ab036959bdda8297a4f6a196a5e9c3f9ab2cf974f5641f |
Hashes for fast_matrix_market-1.4.2-pp37-pypy37_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 93b5454d03be25be920a1d02029fc2e7790812e87f3fa084f4b1a3ebf7c2be35 |
|
MD5 | 4e8933ebe5ea647a3fede9efdbe6ea0a |
|
BLAKE2b-256 | 03d2ba30f4372a5ed42b9de9287f760a90ee1ad9c404c300a13029c40e592726 |
Hashes for fast_matrix_market-1.4.2-pp37-pypy37_pp73-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7b4a3dda6677c0dc36736db9711ae4d4c401988b6587c0cd2686acb688663aac |
|
MD5 | 9e6de77c48fe8070aafd06c844c2c8c4 |
|
BLAKE2b-256 | d4ec40f51edfe6a4c3090da80c82c128b4051458c73e7f3f22c896394b048167 |
Hashes for fast_matrix_market-1.4.2-cp311-cp311-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 02933a6b93a04794dd634a970b47bca27f88749f6c515a364c6066a897a5612f |
|
MD5 | f07c616e90780b0125d104a6220c46d5 |
|
BLAKE2b-256 | 3d86818c3850a59ed8e5e20d915007bb9697793678a8958dafd7c1adc9a8e4e8 |
Hashes for fast_matrix_market-1.4.2-cp311-cp311-musllinux_1_1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 38ba9aa0e29eff45a54dd0d31e05a873f219218d09320d7e77c834191c197d34 |
|
MD5 | 7fbada7e62791253648d10c627a95185 |
|
BLAKE2b-256 | 25d7eb3a142fd064ce0e4073575af55ff637ffa89f182c7a339df21145a193f6 |
Hashes for fast_matrix_market-1.4.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 80b76c601a28a0c2dce3bd9260b65876891dca9edd02c3d064bd92c6f17cc7cb |
|
MD5 | 68aedbc70e26e11dd2463bce645f2b11 |
|
BLAKE2b-256 | c1c337e06a634d1e499d30eb09c6b58aa84331fdbe8b0396572385d4bfbe6d97 |
Hashes for fast_matrix_market-1.4.2-cp311-cp311-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 36d8c4704bbdfb141846f071ddde4efe2469c859a937d1646b1ce4f776b539ae |
|
MD5 | 294bbc2a2f588c419c234f45248b08fb |
|
BLAKE2b-256 | 7a1efe5417439e0cb504078082845a7c02f5a202b467cd802fd24d84707d64e5 |
Hashes for fast_matrix_market-1.4.2-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f13925e505ae1aaf80a384d93eea02fb1a629ec73100ca07640a0b0015eaa970 |
|
MD5 | 31ada2c91412974ce9894dcb1d6c84bb |
|
BLAKE2b-256 | 13cf31401a2205f54f65a137e5ee0f6709453507f1e8d4c1f4b6d434cbcab471 |
Hashes for fast_matrix_market-1.4.2-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 04adc65120f55b2b4b141d56a6601750b62d8e0a4beade8f89769d13251aa996 |
|
MD5 | 72984c3dde213820796efcfe0ccb12a5 |
|
BLAKE2b-256 | ce682925ab0641215eabe20907795c0cf37a55410ede8cbc6269947100e04b34 |
Hashes for fast_matrix_market-1.4.2-cp310-cp310-musllinux_1_1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9b7889d0c6a0f7fecf5e0844f137547b6a0a71cb9ed73a69edb96d3b6d05b67e |
|
MD5 | de6da2e34732c32f11bf18ebbc64f1c9 |
|
BLAKE2b-256 | 8209025bcba55c5037065df84bde3794e218f12241eac9da745a0a6296f83775 |
Hashes for fast_matrix_market-1.4.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 59336b0d1ee1e8cb4fd9f466d57fadb38a7ed0da513c345b910bb1e09aed16df |
|
MD5 | 88e869c55ac7dbe5a058c33c2f52de13 |
|
BLAKE2b-256 | 7b2f94f6ddb7deb1f8bbdcd0580ec9f973dbe52b838b0a45c1da4b0b2c2d3bcb |
Hashes for fast_matrix_market-1.4.2-cp310-cp310-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 66024dc0fd61c3ac102fa24af3c31cee4f85c270bbf6a6cfbacbdc4662b7a350 |
|
MD5 | 70a06295f6356d7e92bd4afa36730483 |
|
BLAKE2b-256 | 3b301c26dae15c7a266a38eee824909b54ba98c82efba7870e4560b629a98e67 |
Hashes for fast_matrix_market-1.4.2-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4c3ecde87698b5737f1a2f6be2ade17e40f79512430a3bfe9e59c3d77a3b9ba7 |
|
MD5 | c9ccf7698c2bfb7a607c58e5c5c45421 |
|
BLAKE2b-256 | f882f65b85c9e2c4b37efccafbc92131927bd0627f64d20401aba2a64e721171 |
Hashes for fast_matrix_market-1.4.2-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5fb02a976dae764d6a8b48085ca18261cc8693d085406351acad3e52f322a38f |
|
MD5 | eeef270f59e708da5cb174558427392f |
|
BLAKE2b-256 | 474c19f09642e79e2458474c1b9bee37a0b8516ef33df1b7d9aa342c2e2a35cf |
Hashes for fast_matrix_market-1.4.2-cp39-cp39-musllinux_1_1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e545913dd64fd62d9246399fd1b59d8b4fadc2d93bfb7bfcc040a44e9f53c9d3 |
|
MD5 | c4f387d0efb3b7d35ebd18830ab3d494 |
|
BLAKE2b-256 | 554ace701149f757ebec1063708f5d74d8d80000899d33e2256d66edfa7453b5 |
Hashes for fast_matrix_market-1.4.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cdefcc7a67b10d1a2d588c6110f5dda46e1da9dd9b9e1849ce2be35ce1ef7144 |
|
MD5 | 5476186164b6548be30870c7869a76db |
|
BLAKE2b-256 | abf603942f8a4c89a1dfb70da7eb454370337f0dea092421a7f0ebc17c5318b8 |
Hashes for fast_matrix_market-1.4.2-cp39-cp39-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 50ffec464aa39b7d4cd9b8e8847ce6b49e4d7076f8ca30e18e6728b84ac6ffa0 |
|
MD5 | 6acaa54050417c090f3c55f1825d9548 |
|
BLAKE2b-256 | 9ecaf979022d3f810481f24ad4004700adbc354ede2f086f96cc0911a59c02c9 |
Hashes for fast_matrix_market-1.4.2-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1e5606686278c4e5e0beadcb1f6972d54bba7c2bf89b815bef5806a88ee30fd9 |
|
MD5 | 9cc63cd8fcf48c96ecf83bd9c08cc52f |
|
BLAKE2b-256 | 8970c798ecf0efae1b0dafa26615bf96d1fd74c4f36baa435008c0227200ea1c |
Hashes for fast_matrix_market-1.4.2-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 70901d6a3d7acc1a76fe569906827bfc0f4e21014b1b6c891333c76475dde3b2 |
|
MD5 | 10a5f3e72b06c7468b031ff369ea3842 |
|
BLAKE2b-256 | 68885321fe3acaba34d7840dc864fded132f932914ea5d29034d6cbb2e791501 |
Hashes for fast_matrix_market-1.4.2-cp38-cp38-musllinux_1_1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 777d6b21d15fad4b3b5269a784de6e847a18cfbde89e92044f2d93d7d5cd1e4e |
|
MD5 | 8ac3d1b933d2a9683ce2860f1085652b |
|
BLAKE2b-256 | 01200fe1806d4c8dfe2790e31266480b89ba16b163dc532b38a64b7b49078ae2 |
Hashes for fast_matrix_market-1.4.2-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c90b48aee1b6318d58d53f3c8a258aa558008f33a38454c78340c2f323002500 |
|
MD5 | bdcb1b00c774b8ddd4c128c382710e5e |
|
BLAKE2b-256 | 731042ccc7b3040b01fddde12713c5b311b1c31b6a69662192cc30175619ebc3 |
Hashes for fast_matrix_market-1.4.2-cp38-cp38-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e8f9970dce449e59caeb03e1b4e76df2b201b580869e746836d04cf151d44d44 |
|
MD5 | 4995ec57d930c73493cd4736c4497bda |
|
BLAKE2b-256 | 86ca070457dd45a453e2cd7aff99a2937869d59e2d677fbb81ccc638300e4864 |
Hashes for fast_matrix_market-1.4.2-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9c1a19446f89c9a587f141c561fcadd428a528060084a0daaeb7ab43312e57dd |
|
MD5 | dc9f42ca6705cf6a614070bd607c486d |
|
BLAKE2b-256 | ba8fcab0b46cbd766aaf5a72192712d290a787522dc5cb00b29d380db0b3b7a8 |
Hashes for fast_matrix_market-1.4.2-cp37-cp37m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 365c6fe90aed042c74529bca16c8a4229eafeba485e01540a1b1e3ef70ef1b24 |
|
MD5 | ac69f84a5654eda86e3861bf885b8dfd |
|
BLAKE2b-256 | 7e2023a87c47216e73cc2dd9fce1ba8c84c5523934f861cb73ab0c55363e545c |
Hashes for fast_matrix_market-1.4.2-cp37-cp37m-musllinux_1_1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6ff58ee50965ee33987b72235e4c679538ae0655ef42852eefc37f2b4431f760 |
|
MD5 | 9494d8f7c227ddbbaadcb209c6906e53 |
|
BLAKE2b-256 | 63ca93da657d7076d5a161abbe85386d9168cd06d46b7177cc0c357510a7a41b |
Hashes for fast_matrix_market-1.4.2-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | dc102395be583a8b3ea7b9625aa5128b725b9a98c0fe47eb33c815b4388d66eb |
|
MD5 | bf261c7de6405022f5cb16aa7d198a8a |
|
BLAKE2b-256 | e4a05060ec1f2d97cd4886d3b7c8019ff357f456a968f832d38bc47b06fda74d |
Hashes for fast_matrix_market-1.4.2-cp37-cp37m-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cc04eac496d174ac1e6d868df88126e91027213dcbda341949c6afc856e81648 |
|
MD5 | 518fad97acc67b3b86c2214fc6664f59 |
|
BLAKE2b-256 | 6738d6d174566014a00c4aff763b62cef065c3754c6a0406f5cd7144ac233a15 |