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

Function test_map_partition_array

dask/dataframe/tests/test_dataframe.py:4490–4508  ·  view source on GitHub ↗
(func)

Source from the content-addressed store, hash-verified

4488
4489@pytest.mark.parametrize("func", [np.asarray, M.to_records])
4490def test_map_partition_array(func):
4491 from dask.array.utils import assert_eq
4492
4493 df = pd.DataFrame(
4494 {"x": [1, 2, 3, 4, 5], "y": [6.0, 7.0, 8.0, 9.0, 10.0]},
4495 index=["a", "b", "c", "d", "e"],
4496 )
4497 ddf = dd.from_pandas(df, npartitions=2)
4498
4499 for pre in [lambda a: a, lambda a: a.x, lambda a: a.y, lambda a: a.index]:
4500 try:
4501 expected = func(pre(df))
4502 except Exception:
4503 continue
4504 x = pre(ddf).map_partitions(func)
4505 assert_eq(x, expected, check_type=False) # TODO: make check_type pass
4506
4507 assert isinstance(x, da.Array)
4508 assert x.chunks[0] == (np.nan, np.nan)
4509
4510
4511def test_map_partition_sparse():

Callers

nothing calls this directly

Calls 3

assert_eqFunction · 0.90
funcFunction · 0.70
map_partitionsMethod · 0.45

Tested by

no test coverage detected