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
Matrix Market I/O library.
pip install fast_matrix_market
Usage
import fast_matrix_market as fmm
# SciPy-like
>>> 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
# Coordinate/Triplet
>>> (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.]))
# Dense Array
>>> a = fmm.read_array("eye3.mtx")
>>> a
array([[1., 0., 0.],
[0., 1., 0.],
[0., 0., 1.]])
# Write to 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.
Compared to scipy.io.mmread
fast_matrix_market
includes mmread()
and mmwrite()
methods that are direct replacements for their respective SciPy versions.
Compared to SciPy version 1.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
scipy.io.mmread()
crashes on large matrices (dimensions > 231) because it uses 32-bit indices on most platforms.
fast_matrix_market
switches to int64
if the matrix dimensions require it.
Directly write CSC/CSR matrices
scipy.io.mmwrite
converts CSC and CSR matrices to COO first. fast_matrix_market
can write them directly with no conversion.
longdouble
Read and write longdouble
/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 use longdouble
arrays. SciPy can write longdouble
matrices but reads use double
precision.
Note: Many platforms do not offer any precision greater than double
even if the longdouble
type exists.
On those platforms longdouble == double
so check your Numpy for support. As of writing only Linux tends to have longdouble > double
.
Vector files
Read vector files. scipy.io.mmread()
throws a ValueError
.
Differences
Differences between fast_matrix_market.mmwrite
and scipy.io.mmwrite
:
- 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. 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 is currently ignored. Floats may be written with more precision than desired.
Quick way to try
Replace scipy.io.mmread
with fast_matrix_market.mmread
to quickly see if your scripts would benefit:
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()
).
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.3.0-pp39-pypy39_pp73-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c96d0e4cfa1ac85f550d85809ac6d3e127572e6562be174dcaeec529b651e6bf |
|
MD5 | 1b11154942bfbab383e287c396e8c7ce |
|
BLAKE2b-256 | e3dbbed305cb89c6db664aa3e012e462af9d3b58216baa937d0b1e9fc356db4b |
Hashes for fast_matrix_market-1.3.0-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f95e4384b78291d4054d178bdbb78908ded3aff47241bf2b0b127b955b173457 |
|
MD5 | b44d007598a03e2a50ba1b0008aa7381 |
|
BLAKE2b-256 | d3e7f128a04baa4200c13ada9ee56a25436bff80b63535b6cb42dd9a31a46930 |
Hashes for fast_matrix_market-1.3.0-pp39-pypy39_pp73-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7346d0280b171d61320d35453d495cd1b3763857d8cc91b1fbae786b542e2007 |
|
MD5 | 6964788648101628b1689b73a505a850 |
|
BLAKE2b-256 | b370afa7e8eea350e8bdd1f5399f2b926bd50859d4aa0a408a11552ff03e2918 |
Hashes for fast_matrix_market-1.3.0-pp38-pypy38_pp73-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cbf0e8198429d2735286b1e9084b7874ccb687410e7d1ec3469e6e3254e1a2eb |
|
MD5 | 58274b99e2c42964eed0e415df935b4d |
|
BLAKE2b-256 | 2f6f3d3a934a75f0ee606bed495f0cc4e7f64e4d3f178c280c9b96fdfb63dbe9 |
Hashes for fast_matrix_market-1.3.0-pp38-pypy38_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 37dbaae0fe4271a9f1220e0c6d64df5cf2bc94d90d72e3415ad150d0c27a746c |
|
MD5 | 6e09f388458e067e662c607762854451 |
|
BLAKE2b-256 | 071cf3098eac3f61345d50bfa72d1abe30937f7521a02998dd7c096803a6dcd5 |
Hashes for fast_matrix_market-1.3.0-pp38-pypy38_pp73-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5a0d70bbfcd8637d07a477b2edcb04cef24b90cd9ae598351eb06186c115470e |
|
MD5 | 75c96e6bcc937c979488d5ed5d80ab8d |
|
BLAKE2b-256 | 75c87d4683a3477d06a9d78ef284bfd7690691ba23a7c6c8c7b9c181c9a1ada2 |
Hashes for fast_matrix_market-1.3.0-pp37-pypy37_pp73-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ee8b76efbb1944caf1604f4000f53d3bc9615b25e34c812c2c2faf4a10220485 |
|
MD5 | 6e2978d5fdd5cffc111c68bec6b8fbad |
|
BLAKE2b-256 | ed8e5445cbeb25f05e73663e9b26a95fef1083e495e014c162ef065c0302981d |
Hashes for fast_matrix_market-1.3.0-pp37-pypy37_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 97d5b7f30ecad3fc29f961c56ca702de852699ee850ce5e113be1721a2970829 |
|
MD5 | 8a944d29ee58ca99990865c77b8151a9 |
|
BLAKE2b-256 | f0c71bbfbf15936e32c782eae6484bff1de2f1fea6f1e0fe69f28b831367586b |
Hashes for fast_matrix_market-1.3.0-pp37-pypy37_pp73-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 750415926b42cfe2baa83250533d3a4635a7095d5c58bebe1ef9494e64d65014 |
|
MD5 | 4de243da682822f836af119678531d60 |
|
BLAKE2b-256 | a68181a501471a544d7ea6b39591954d3154173fd7770e1e908af0b7da265a32 |
Hashes for fast_matrix_market-1.3.0-cp311-cp311-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7e8664daaab7637decf9fcdaeaa389da46e0c196075ff6bbcde0b8079b34e27a |
|
MD5 | 5660faf63c3d0908ab903320cc76a619 |
|
BLAKE2b-256 | 72449f16ac7763bfa99ae402b10eb846e19f202ea440f6403326f87730ae4d5a |
Hashes for fast_matrix_market-1.3.0-cp311-cp311-musllinux_1_1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 76f53436057550973e2c0d9ee1834c3e59613c8b392e2a9125dc732ec0c01b16 |
|
MD5 | f8005cde843fc5c521dd822a16f6effc |
|
BLAKE2b-256 | 5561e8ec6909a7059984b18dac96a2429418871c5404afeacaede58c1a32fbae |
Hashes for fast_matrix_market-1.3.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4cfe6a7a7240450504579f6fc71ffcf3d18a2642a03f894575c98d32bbef9b4c |
|
MD5 | 857cd72e6ebae1bffc22d541c2ad5313 |
|
BLAKE2b-256 | def8738f2fe907005e837ed87a37a401550ba8c7d434b479bb4a06c0676905f2 |
Hashes for fast_matrix_market-1.3.0-cp311-cp311-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8f7e4729c22448e570eb3c8ad6d0a6d88ab4c55eb8c56f26a01f450f7439f3d9 |
|
MD5 | 6960745bbac14281bcab5b89f001d5d8 |
|
BLAKE2b-256 | 07d0f37a12d28e0ede2cb4ce6e4215d11defe98b703dadba13deb53887a0708e |
Hashes for fast_matrix_market-1.3.0-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d0376660cfb5b39017807a5acc6ede2b7eff284071cfacb49ccee4a35626c6c9 |
|
MD5 | b763981e633e505be5d9bd75e3b1b19a |
|
BLAKE2b-256 | 95ffc2a334cf329712d65e2ed7e5f955fa81cf823fdbcfb1dc19ca775f76a2cb |
Hashes for fast_matrix_market-1.3.0-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c9281c16ecca2c41c8ae853eac039b434654125326de06ac8fe99bfe736d0ef2 |
|
MD5 | 7e2a4ca54702fb33fec9232d4bea7f36 |
|
BLAKE2b-256 | 4556d988c8ebf1b64cecb3496a6d699e440e3725f1da9ef16304a6ede8fe6636 |
Hashes for fast_matrix_market-1.3.0-cp310-cp310-musllinux_1_1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6e9f607536fd28bc87184a9d2198ddb4394e5aeff68ceea3c97ef5d6e8ff6761 |
|
MD5 | fad83ea4421cc020d946927634d15f4f |
|
BLAKE2b-256 | 131dfd25ceff341fe13daaf1edded098f4b4924dc6e195d37b76e5c31e7eca82 |
Hashes for fast_matrix_market-1.3.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9a744d1456f3c6f553ceaf83510a61eceb2259461c193a2778d823bd6baa0547 |
|
MD5 | 3932394398b23ee0af84cdaff95f16f3 |
|
BLAKE2b-256 | d2731513f4c376021a376ee57163df05da4ff4bfd896294c144b560bd2530c06 |
Hashes for fast_matrix_market-1.3.0-cp310-cp310-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8f26be01088b932a683688c4bda7573f28d3ca0c2f1d4c7a81f1f7998ad630dc |
|
MD5 | 724bfbdeacd6f51ee82bfacbb549e3d3 |
|
BLAKE2b-256 | d29fb82c347c8fccfa1e899283ddb8298ca8ac522294b25791eae73627a2ab41 |
Hashes for fast_matrix_market-1.3.0-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1684b072d0462b6333210316ff0da14ed6990ec9db12d4e9d03b0b4b747bc2c5 |
|
MD5 | 4664644742d19a8b42d9d7a64f4ae648 |
|
BLAKE2b-256 | 6409ce4b98103c5c4682ff217ecb543878a01f5cb4df42b874b71c66383df20e |
Hashes for fast_matrix_market-1.3.0-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 890b8841fe587e3c851f3d33db55ec3677338940bd7f4c7b896c7be4f43b9d70 |
|
MD5 | 28cb8f76ebb37ddd0eadeb7126d9c0fd |
|
BLAKE2b-256 | a695efe9b20766a90d5f2232d53359ab12de252b44504df446f67ebb43e685c9 |
Hashes for fast_matrix_market-1.3.0-cp39-cp39-musllinux_1_1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f2d9a841f501ebf839b9d8a79162147c31f8682fe0cad99b28a30337230df1bc |
|
MD5 | 94ffb69bf56735d59159a70e34af87bb |
|
BLAKE2b-256 | 520a0802f8b3e9ecf74d4e1059428c4d8f190b9062f86987e7bef378f3f510b1 |
Hashes for fast_matrix_market-1.3.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f29bad83a34fb80d0a0d84f6107f23d2eaa7e1c45466f61de008a829111878dc |
|
MD5 | 362180ec4167098f8035e258d4dc4c52 |
|
BLAKE2b-256 | 83c38f18d58b9458b9136e95d9fe4c9d81be3d99443827b8a197b4e677384f49 |
Hashes for fast_matrix_market-1.3.0-cp39-cp39-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 750ae6ec0be6a540ed9e53bc8748a3a62a0280c510ddb42363cef656e6bb2e63 |
|
MD5 | 90cfbee029e7b88d11a07d482c2b54a6 |
|
BLAKE2b-256 | 5f59ae98ced8bd4b7c5cfb91ee8517a1e9dfde7e50a699b906110864c57038ac |
Hashes for fast_matrix_market-1.3.0-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f328f468bc44243eb8cad8588630e5f471fa38121d06fbb1f57d48688776705c |
|
MD5 | b76affd4b5f9e21730a0d536a3a6c348 |
|
BLAKE2b-256 | 7e748ce6dfae106ee1db0f37aecec85bc54e46be786776e0b04b043389a42300 |
Hashes for fast_matrix_market-1.3.0-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 10c3858788a33fac061c609198ad345e876eb1e847348e0fe7cfbb51de565c8f |
|
MD5 | 1396ffaec4957bb4f4331085806726c6 |
|
BLAKE2b-256 | 8b67000296bd9fe3116f557b69e1d574a4a122a8dc30e5c1a6d222def7257e00 |
Hashes for fast_matrix_market-1.3.0-cp38-cp38-musllinux_1_1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 45ffdd0b471a01867ac86feaaff9c0257281f9cc33a6ccb3a3ed4b55b0936160 |
|
MD5 | 01db95dbe1881e0cd685243c03e26b7a |
|
BLAKE2b-256 | f62420a4bf2271c4826c8ea7b314cceb780df0b89a4a28e215dbddedb9e32388 |
Hashes for fast_matrix_market-1.3.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0dbf3c98f0d029ce2ef7e848385054d195bc0df2c7456c43db9cde3ccf9b94d4 |
|
MD5 | ae3e73afc7e7e12c0c9107b5049321ba |
|
BLAKE2b-256 | 7b776ac363a3ee1ddd3973e77cf027e9c012944c7f965b32bb677ca1678c0155 |
Hashes for fast_matrix_market-1.3.0-cp38-cp38-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a3bf3bcd6bd4982a36e790c5713e5337efd077aa04f77bf4b50735f5b77840e1 |
|
MD5 | fa90b113bc5beb84c464f70222e54be2 |
|
BLAKE2b-256 | 439d87a273cb2ec20cb4e324e5ed4f27cb670a3ab2bf44fd7c826f7e8b153686 |
Hashes for fast_matrix_market-1.3.0-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4e37b687e72e896a5665e0435f9eeaf724ef5947f3396e407029faf1bbd766a2 |
|
MD5 | 110df590e68abca07d7d12496a493e5e |
|
BLAKE2b-256 | 3d02aff9e3fcbecd617556cf157fbcde58a7d11a57292eee276fd8504d29df6e |
Hashes for fast_matrix_market-1.3.0-cp37-cp37m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 13b7851e3ac2f1719c277c8c479bee4a847fd777766435cddfcc0b6b62346016 |
|
MD5 | a4b9afd2c4f4ef9a3786c7311d5a839f |
|
BLAKE2b-256 | e7e4acbb4e3383aa42b1747dd8a738eaaef1f1c8191ac7a310a1cecd8b102d4a |
Hashes for fast_matrix_market-1.3.0-cp37-cp37m-musllinux_1_1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9d4bab6218693e6211a4485be42332fad0de89f2d9632d5c66cbce4a2cfcd7e0 |
|
MD5 | d0ee63864cab726b4998db5b0b645c47 |
|
BLAKE2b-256 | b5e96401bbd6e69954c86ff8c340302b746fc6e88d5db94e634581f5d796a5f8 |
Hashes for fast_matrix_market-1.3.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2071545bac0184bbb9609bf5fbc29c67ed0c9e2e13e74509ba206ae62c884d3d |
|
MD5 | f1628c851ba7dcd34ede9f776fdbd321 |
|
BLAKE2b-256 | adaf9042df13598986ef6de0a179bcbd5c382d89a5f041ea208c2d981ee8c8e6 |
Hashes for fast_matrix_market-1.3.0-cp37-cp37m-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | af3d31a2c4f174f2167e3121065a4e54a0ba6471a5a7d893f36f33222a3c072f |
|
MD5 | 531e3315e3d29af03bbf1371d2b35f7b |
|
BLAKE2b-256 | e2e4de3d9cfd6134f018b8a1f6798b0f50d6632aff0ef906706f119ca638e283 |