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

Function test_map_partition_sparse

dask/dataframe/tests/test_dataframe.py:4515–4535  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

4513
4514
4515def test_map_partition_sparse():
4516 sparse = pytest.importorskip("sparse")
4517 # Avoid searchsorted failure.
4518 pytest.importorskip("numba", minversion="0.40.0")
4519
4520 df = pd.DataFrame(
4521 {"x": [1, 2, 3, 4, 5], "y": [6.0, 7.0, 8.0, 9.0, 10.0]},
4522 index=["a", "b", "c", "d", "e"],
4523 )
4524 ddf = dd.from_pandas(df, npartitions=2)
4525
4526 def f(d):
4527 return sparse.COO(np.array(d))
4528
4529 for pre in [lambda a: a, lambda a: a.x]:
4530 expected = f(pre(df))
4531 result = pre(ddf).map_partitions(f)
4532 assert isinstance(result, da.Array)
4533 computed = result.compute()
4534 assert (computed.data == expected.data).all()
4535 assert (computed.coords == expected.coords).all()
4536
4537
4538def test_mixed_dask_array_operations():

Callers

nothing calls this directly

Calls 4

fFunction · 0.70
map_partitionsMethod · 0.45
computeMethod · 0.45
allMethod · 0.45

Tested by

no test coverage detected