I want to check if two sparse arrays are (almost) equal. Whereas for numpy arrays you can do:
import numpy as np
a = np.ones(200)
np.testing.assert_array_almost_equal(a, a)
This does not work for sparse arrays, which I can understand (either returns error AttributeError: ravel not found
for smaller matrices or errors related to size of array). Is there a scipy equivalent to test sparse matrices? I could convert my sparse matrices are to dense matrices and use the numpy testing function, but sometimes this is not possible due to (memory/size) constraints. E.g.:
from scipy import sparse
b = sparse.rand(80000,8000,density=0.01)
type(b) # <class 'scipy.sparse.coo.coo_matrix'>
c = b.toarray() # ValueError: array is too big; `arr.size * arr.dtype.itemsize` is larger than the maximum possible size.
Is it possible to test these larger scipy arrays for equality, or should I test smaller samples?