I am trying to create a matrix using scipy.sparse.bmat from smaller csr matrices - my function call is here: sparse.bmat(HList, format='csr'). The resulting matrix will be a square matrix with ~2.6 billion columns/rows. However, I have the following error when I attempt to construct this matrix:
Traceback (most recent call last):
[...]/lib/python3.7/site-packages/scipy/sparse/construct.py", line 623, in bmat
return coo_matrix((data, (row, col)), shape=shape).asformat(format)
[...]/lib/python3.7/site-packages/scipy/sparse/coo.py", line 192, in __init__
self._check()
[...]/lib/python3.7/site-packages/scipy/sparse/coo.py", line 283, in _check
raise ValueError('negative row index found')
ValueError: negative row index found
The problem appears to occur when the combined matrix is converted into coo format. I believe the problem has something to do with indices overflowing, as the indices of the full matrix wouldn't fit in a 32 bit format (2.6 billion > 2^31). I have tested my matrix construction script for a smaller version of this problem, and it worked correctly.
This post has a very similar problem to mine, however, the solutions listed there didn't work for my situation. Running the test described there,
>>> scipy.sparse.sputils.get_index_dtype((np.array(10**10),))
<class 'numpy.int64'>
I can confirm that numpy is using 64-bit indices.
Is there some other part of my program causing overflow? Or is the source of the problem something else entirely?
Any help is greatly appreciated!