(index, sparse_module_path, container)
| 5594 | ], |
| 5595 | ) |
| 5596 | def test_scipy_sparse_indexing(index, sparse_module_path, container): |
| 5597 | sp = pytest.importorskip(sparse_module_path) |
| 5598 | |
| 5599 | if sparse_module_path == "cupyx.scipy.sparse": |
| 5600 | backend = "cupy" |
| 5601 | else: |
| 5602 | backend = "numpy" |
| 5603 | |
| 5604 | with dask.config.set({"array.backend": backend}): |
| 5605 | x = da.random.default_rng().random((1000, 10), chunks=(100, 10)) |
| 5606 | x[x < 0.9] = 0 |
| 5607 | with assert_scipy_sparse_matrix_deprecated( |
| 5608 | sparse_module_path == "scipy.sparse" and container == "csr_matrix" |
| 5609 | ): |
| 5610 | y = x.map_blocks(getattr(sp, container)) |
| 5611 | |
| 5612 | assert not ( |
| 5613 | x[index, :].compute(scheduler="single-threaded") |
| 5614 | != y[index, :].compute(scheduler="single-threaded") |
| 5615 | ).sum() |
| 5616 | |
| 5617 | |
| 5618 | @pytest.mark.parametrize("axis", [0, 1]) |
nothing calls this directly
no test coverage detected