3 from scipy.sparse
import csr_matrix
5 m = sparse_matrix.emptyMatrix()
6 assert m.shape == (0, 0)
8 v = sparse_matrix.emptyVector()
9 assert v.shape == (0, 0)
11 m = sparse_matrix.matrix1x1(2)
12 assert m.toarray() == np.array([2])
14 v = sparse_matrix.vector1x1(2)
15 assert v.toarray() == np.array([2])
17 rng = np.random.default_rng()
18 diag_values = rng.random(10)
19 diag_mat = sparse_matrix.diagonal(diag_values)
20 assert (diag_mat.toarray() == np.diag(diag_values)).all()
22 diag_mat_copy = sparse_matrix.copy(diag_mat)
23 assert (diag_mat_copy != diag_mat).nnz == 0
25 diag_mat_csr = csr_matrix(diag_mat)
26 assert (sparse_matrix.copy(diag_mat_csr) != diag_mat_csr).nnz == 0
29 zero_mat = csr_matrix(np.zeros((10, 1)))
30 zero_mat_copy = sparse_matrix.copy(zero_mat)
31 assert (zero_mat_copy != zero_mat).nnz == 0