(mx)
| 93 | def sparse_to_tuple(sparse_mx): |
| 94 | """Convert sparse matrix to tuple representation.""" |
| 95 | def to_tuple(mx): |
| 96 | if not sp.isspmatrix_coo(mx): |
| 97 | mx = mx.tocoo() |
| 98 | coords = np.vstack((mx.row, mx.col)).transpose() |
| 99 | values = mx.data |
| 100 | shape = mx.shape |
| 101 | return coords, values, shape |
| 102 | |
| 103 | if isinstance(sparse_mx, list): |
| 104 | for i in range(len(sparse_mx)): |