sizeof() must handle the sparse array API, not just sparse matrices.
()
| 111 | |
| 112 | |
| 113 | def test_sparse_array(): |
| 114 | """sizeof() must handle the sparse array API, not just sparse matrices.""" |
| 115 | sparse = pytest.importorskip("scipy.sparse") |
| 116 | |
| 117 | from dask.array.scipy_compat import SCIPY_GE_111 |
| 118 | |
| 119 | if not SCIPY_GE_111: |
| 120 | pytest.skip(reason="scipy.sparse.sparray required") |
| 121 | |
| 122 | import numpy as np |
| 123 | |
| 124 | sp = sparse.csr_array(np.eye(10)) |
| 125 | assert sizeof(sp.todia()) >= 152 |
| 126 | assert sizeof(sp.tobsr()) >= 232 |
| 127 | assert sizeof(sp.tocoo()) >= 240 |
| 128 | assert sizeof(sp.tocsc()) >= 232 |
| 129 | assert sizeof(sp.tocsr()) >= 232 |
| 130 | assert sizeof(sp.todok()) >= 184 |
| 131 | assert sizeof(sp.tolil()) >= 204 |
| 132 | |
| 133 | |
| 134 | @requires_pandas |