def test_from_spmatrix_raises(self): import scipy.sparse mat = scipy.sparse.eye(5, 4, format='csc') with pytest.raises(ValueError, match="not '4'"): SparseArray.from_spmatrix(mat)
def test_from_spmatrix_raises(self): import scipy.sparse mat = scipy.sparse.eye(5, 4, format='csc') with pytest.raises(ValueError, match="not '4'"): SparseArray.from_spmatrix(mat)
def test_from_spmatrix(self, size, format): import scipy.sparse mat = scipy.sparse.random(size, 1, density=0.5, format=format) result = SparseArray.from_spmatrix(mat) result = np.asarray(result) expected = mat.toarray().ravel() tm.assert_numpy_array_equal(result, expected)
def test_from_spmatrix(self, size, format): import scipy.sparse mat = scipy.sparse.random(size, 1, density=0.5, format=format) result = SparseArray.from_spmatrix(mat) result = np.asarray(result) expected = mat.toarray().ravel() tm.assert_numpy_array_equal(result, expected)