MCPcopy Create free account
hub / github.com/dask/dask / test_scipy_sparse_indexing

Function test_scipy_sparse_indexing

dask/array/tests/test_array_core.py:5596–5615  ·  view source on GitHub ↗
(index, sparse_module_path, container)

Source from the content-addressed store, hash-verified

5594 ],
5595)
5596def 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])

Callers

nothing calls this directly

Calls 6

setMethod · 0.80
randomMethod · 0.45
map_blocksMethod · 0.45
sumMethod · 0.45
computeMethod · 0.45

Tested by

no test coverage detected