()
| 4522 | |
| 4523 | |
| 4524 | def test_map_partition_sparse(): |
| 4525 | sparse = pytest.importorskip("sparse") |
| 4526 | # Avoid searchsorted failure. |
| 4527 | pytest.importorskip("numba", minversion="0.40.0") |
| 4528 | |
| 4529 | df = pd.DataFrame( |
| 4530 | {"x": [1, 2, 3, 4, 5], "y": [6.0, 7.0, 8.0, 9.0, 10.0]}, |
| 4531 | index=["a", "b", "c", "d", "e"], |
| 4532 | ) |
| 4533 | ddf = dd.from_pandas(df, npartitions=2) |
| 4534 | |
| 4535 | def f(d): |
| 4536 | return sparse.COO(np.array(d)) |
| 4537 | |
| 4538 | for pre in [lambda a: a, lambda a: a.x]: |
| 4539 | expected = f(pre(df)) |
| 4540 | result = pre(ddf).map_partitions(f) |
| 4541 | assert isinstance(result, da.Array) |
| 4542 | computed = result.compute() |
| 4543 | assert (computed.data == expected.data).all() |
| 4544 | assert (computed.coords == expected.coords).all() |
| 4545 | |
| 4546 | |
| 4547 | def test_mixed_dask_array_operations(): |
nothing calls this directly
no test coverage detected