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.1-pp39-pypy39_pp73-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 63ced08bfc171e590df46f176368b1ccc4d974a58f509a2f9ce1f41f45c1caa1 |
|
MD5 | f520d4ec58aafb4ab8bcde8b64fdacc6 |
|
BLAKE2b-256 | 626f3bd5372829ba9df5655ff90deac610654868b8638e9a394602bdf03a6332 |
Hashes for fast_matrix_market-1.4.1-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8e34418cff465f60ee5fd178f092e77e95923446baeb31b0a81d6a2b7b197a95 |
|
MD5 | 84c98efb0a52ab76908c511830824ab4 |
|
BLAKE2b-256 | f200ee3a911ad561458e868c2bc41f06197c358d285c39b873184b2cdff7ff8c |
Hashes for fast_matrix_market-1.4.1-pp39-pypy39_pp73-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2af9a2f565c077b2a803544e5db84c79fbf80569e005f201e81c959c2141a2f6 |
|
MD5 | 64a58a7fc87967b34c8abdfd3af860a2 |
|
BLAKE2b-256 | 9ddee48afc739946ee85a75f9bc1c61af83ca689da77f09b350724d302293e87 |
Hashes for fast_matrix_market-1.4.1-pp38-pypy38_pp73-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d1ca2a3c864b64faddf30cc7fd1ea9e3d780f64135ba3692636697227fc91008 |
|
MD5 | 08d7f5a67a64cc0bcd5af039a0d38418 |
|
BLAKE2b-256 | 541ca968fb2ddb9dcf00343395e5e5b50a19d387513a4456d60f28ecd9fe7947 |
Hashes for fast_matrix_market-1.4.1-pp38-pypy38_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 32d4386694b933623880c4c3043ba1c715cabc445832c9475a4dcb47dfa9498f |
|
MD5 | 4c40a8fb5e24397ac761b13c3db4e8ca |
|
BLAKE2b-256 | 62a2f040a76d4f8ddc7bc2692788584b948d43f25df57ffe73840c012057d0be |
Hashes for fast_matrix_market-1.4.1-pp38-pypy38_pp73-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 623e42e99aad9dd2bf8c695c6366912d360bc09d6cfeff7d06de1db5890402e8 |
|
MD5 | 5724e59f70026b322a5411dcda25321f |
|
BLAKE2b-256 | 1936c736f826e2336911a19a3b1c42ea197cbf74cf6813d0eb5408148160b6ab |
Hashes for fast_matrix_market-1.4.1-pp37-pypy37_pp73-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e1da2206a239f33fcacea0eb3faf8f6a66ebc62c331e3a00b2d1d05edebbd9d7 |
|
MD5 | 44fec3f124b05506435eae9515015b51 |
|
BLAKE2b-256 | 6ba381adb6e58f5cff05700f9c8923e627ed84bdcc9fd7dbd2a9a2a732f75f55 |
Hashes for fast_matrix_market-1.4.1-pp37-pypy37_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 00af42544ef9c64e8d08dcc295ac08e5342c9d17b72dc74eaed1a601166c9f5e |
|
MD5 | d28aa7bba6cde13f711ad610c368c4c7 |
|
BLAKE2b-256 | 144ccd53d20a5874f3448efe27e0f8b463f1fe1c18edf0a6e0756613a87c96da |
Hashes for fast_matrix_market-1.4.1-pp37-pypy37_pp73-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 44ae95c52b91586b94cfc8c96d6aa8c65f878d918bccf764cf28c5fc369417e8 |
|
MD5 | 32a4a376db868c13da32fdf67726135e |
|
BLAKE2b-256 | b23451b1441237dd89ad522381695296e070cba03e5a2eb7d61669808c8f0e9c |
Hashes for fast_matrix_market-1.4.1-cp311-cp311-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6c70852d9e7c5a90636752f4ba92684f7370a15ebe59cd602c1a0a977cb1942b |
|
MD5 | f1eb64a796db71dd91d9e233d83865b0 |
|
BLAKE2b-256 | bb7bed46fefe3f455acc9afa48adf6ca554d29df940e0eeaf9428346818f9bfc |
Hashes for fast_matrix_market-1.4.1-cp311-cp311-musllinux_1_1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7e566391636ab1151587e66df8888cc7da05bbc0a567dd997f0ef8870d569e38 |
|
MD5 | 51860de97ca1e305dc8b0145fe120a27 |
|
BLAKE2b-256 | 2491bc6f1712285ba6a2ea899b9f56b2dd5ef394b701d6c491586f4035b08262 |
Hashes for fast_matrix_market-1.4.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 999344fac4ed0057f190f937a56436276887c083e0069fecaea8c82546758532 |
|
MD5 | 37b3f0cf3cae6e50d2ec2b5c328811c7 |
|
BLAKE2b-256 | a558552bf73e73a75f5b19b64ea820997357ee611a108ef797e322090bb2521c |
Hashes for fast_matrix_market-1.4.1-cp311-cp311-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f1e9bd3093d2a17208da2739099f89388c72792929ff55bba11f36a8de4c0b63 |
|
MD5 | 62e01f1fb932fc101bf9f11978296dd1 |
|
BLAKE2b-256 | 2bba900a7b981007d03916d6f389ea903b28c568bf88f5aae0ee6b7b11ec75dd |
Hashes for fast_matrix_market-1.4.1-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1eb22a0b7aa0d30236c611e7db1c6bd2c0a578055fa57d496eab8d97b7425b7f |
|
MD5 | 7e0187239a13f15780f354ba71336659 |
|
BLAKE2b-256 | c0e3267e4f676e50e85bbfb4a28324b882ab3d881a1f4cc6a8fba16e0954db94 |
Hashes for fast_matrix_market-1.4.1-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7cbe8c919363478dec821a328ed57cf4b4a2f24bbb9f83c45f05ab52825f8172 |
|
MD5 | 92033b226f9707dbb0bef83866284820 |
|
BLAKE2b-256 | a831bda2f2f1d7417ed6fee8f97f9d56fb623eeb3e7edd521983afc1bb138006 |
Hashes for fast_matrix_market-1.4.1-cp310-cp310-musllinux_1_1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5a6772b57b439413969c803b0025cb240cd2486ee0ae5a8586772835b55b2f7a |
|
MD5 | 3e9f48337941206d150868fd9bd514e3 |
|
BLAKE2b-256 | 082934dc85a3ab85a241e39f734ffbd961d9cab38c84205176232cd8cc493e6a |
Hashes for fast_matrix_market-1.4.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 17e3e848f4b2aa210f639af454e19329a1617621c6472b3b36c5449b8daba1fc |
|
MD5 | 077848ed2aa985ef217dbd33d5b03b5d |
|
BLAKE2b-256 | d5e5244183c691a79a2c4589db0584313d10daa1dfe4752bf8e0ba8286c8c3a3 |
Hashes for fast_matrix_market-1.4.1-cp310-cp310-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2b138bee499345bd271b11cd43a4c1402a4b36faaabfa64394a2f8492149516d |
|
MD5 | ac2cf1e28215607d232711ef5549f9bb |
|
BLAKE2b-256 | 450d174594fe4e5005ae85368f65126eb450341ad26d674b10c9c51c0d3d6660 |
Hashes for fast_matrix_market-1.4.1-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 17609e5ae7b5e59602d6678e9b468eb17972c9c0cdb45c17e4c9fda6d5879435 |
|
MD5 | 8b3db8953b6b894009d57bebf43acd1c |
|
BLAKE2b-256 | 43df225ee782cf3456da107aa1846df3b467362be4ab86790df7de30b4313381 |
Hashes for fast_matrix_market-1.4.1-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 67fd408764c06956175985bb56ffee67eab5047925355b4b0f16b473542e3ae7 |
|
MD5 | 2f742a50d5326f9c723c8cbe017d746d |
|
BLAKE2b-256 | e2a7a9c7cb911c19f5647094b908cc83d0a6adbc5ac89eae437168d3d9aa5276 |
Hashes for fast_matrix_market-1.4.1-cp39-cp39-musllinux_1_1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 53264547218bf9d4752dd51269093a270c434ef571d245aad2020aeba1c87a19 |
|
MD5 | 6c039543ce148fbfd1a9787d4d54666b |
|
BLAKE2b-256 | 309ee757a0e78a935dd95a17879a50eb5a83869d1934813d02c9d52067abd56b |
Hashes for fast_matrix_market-1.4.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7f2d13f2422f4c5a7d57f2c5d8dd48eedb2a1ac4691f8a27706693e9618fba21 |
|
MD5 | 4ae309a29316ed58e7c1b391e5736a7e |
|
BLAKE2b-256 | a44973120abb30304b86afa1a7e5ed2ce51346d58b0494c1500a5bbf04cbc145 |
Hashes for fast_matrix_market-1.4.1-cp39-cp39-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 11f881b805225e2e2273a5e5a77858219c8458457bc9b29d8d4dc8ff1e9fe48b |
|
MD5 | f386160a843ca0ef4df96388c755d4e1 |
|
BLAKE2b-256 | 89cb9a7773c7b4f6c3c82f3b1c4aea8d1ab4af6bee8c485f795caf3065b49036 |
Hashes for fast_matrix_market-1.4.1-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a52145ad917260fc2f6fd3ea38b43de241a79607ec1ad011dedb1fbe71f1b84f |
|
MD5 | 1f8fe109597bf6afe6c1e7fdac1fb070 |
|
BLAKE2b-256 | 3236af945e781a5f382fe118ece047f825c75c3f4e1c046993a6d1e2e57ada9b |
Hashes for fast_matrix_market-1.4.1-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 03e4098d91698ec5537b3d57d3f74da0b3da525785b90c84f3f57223167dfbf9 |
|
MD5 | e6e1b39cb360a08c3d4a288d67225af6 |
|
BLAKE2b-256 | 207c4790ff864130e829ba98bdb612a6cf3ea5a9bc13ce082fe1d7998c13431c |
Hashes for fast_matrix_market-1.4.1-cp38-cp38-musllinux_1_1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 87980238909133a6c0c0f3fc3327e61e808bf308c1f3d63e88d1cc942a51ffdb |
|
MD5 | 3c88a11bb0db324b1b5bd1db34387387 |
|
BLAKE2b-256 | 84f2b4b9995f296be5ea28f4d7396f26189efda4699f0df1e24cbaf8efec3536 |
Hashes for fast_matrix_market-1.4.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ca10577ec8b1c6e871079cbd228f6ed3b288fd80fee4d530b08a67a3c614ea02 |
|
MD5 | def60452d750c01e7d51dbed427cc680 |
|
BLAKE2b-256 | 064c8a93c99e5a5b3315e34a6d65de32238bb6d788fce7fd5be1eff63c5c6ec4 |
Hashes for fast_matrix_market-1.4.1-cp38-cp38-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 83416d67d4363aa9ae01ce151409879dc9546380358528d657ee0540f0d134fe |
|
MD5 | 905a9c75f24822df9931c3f0265c3efa |
|
BLAKE2b-256 | 113dcb1d5a2a7acd1c2be5ed40884110e0db6dd6d8d9d4f570e26d311123e2e9 |
Hashes for fast_matrix_market-1.4.1-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 69c2a697cabdca4344b7c8c42fb7c274f71eb71b468cb6e9ff6bc3136c3d61a0 |
|
MD5 | 47de5104669b328a8692d1cb02f68903 |
|
BLAKE2b-256 | c243bd7ca66b6d4b3e90b4a625d91423a0f9ce9203fecddb31d32d3f8176b7f8 |
Hashes for fast_matrix_market-1.4.1-cp37-cp37m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 28f09268bff1bcfd90ad6bae5184e2459156c0542bcca3ed4a5c6043c238f1b2 |
|
MD5 | 1898960813f8a85145e54becadebdf75 |
|
BLAKE2b-256 | fdfeafb60609ca6333e19f39927403572cbcdd0ef4a50584d20cfabbc30b5e32 |
Hashes for fast_matrix_market-1.4.1-cp37-cp37m-musllinux_1_1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1e2b833ffa21750bc161c939fd409733c2726415573de08a20625047f072765f |
|
MD5 | 42b4a1214be2255644413a96c43a11ff |
|
BLAKE2b-256 | 5cc96e48532e9d161bada0692aa1113fdc3f79cb5e5c241ffe0caa3303bb9865 |
Hashes for fast_matrix_market-1.4.1-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5cfba369b927724e6dc2f9d0d484b40f357f380517740c344e63e34672ca7858 |
|
MD5 | 58841e93c0df552d8604408ed587dfbc |
|
BLAKE2b-256 | eccda0fa4b53669bf4d9108c43a3e37f146ae468cc7b5ab7142fd094eaab21cc |
Hashes for fast_matrix_market-1.4.1-cp37-cp37m-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4664f04138bc60887ba951630c51a59f510cf85ce2483aa867dba640b6fdb4c5 |
|
MD5 | 698b0a58af7f8d506cfb472513ff77ee |
|
BLAKE2b-256 | fa3f5c4faf7a401d1ad2b60f9f0552ee92f720b2615ae9e4ebadef99fe46a357 |