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

Function test_map_partition_array

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

Source from the content-addressed store, hash-verified

4513
4514@pytest.mark.parametrize("func", [np.asarray, M.to_records])
4515def test_map_partition_array(func):
4516 from dask.array.utils import assert_eq
4517
4518 df = pd.DataFrame(
4519 {"x": [1, 2, 3, 4, 5], "y": [6.0, 7.0, 8.0, 9.0, 10.0]},
4520 index=["a", "b", "c", "d", "e"],
4521 )
4522 ddf = dd.from_pandas(df, npartitions=2)
4523
4524 for pre in [lambda a: a, lambda a: a.x, lambda a: a.y, lambda a: a.index]:
4525 try:
4526 expected = func(pre(df))
4527 except Exception:
4528 continue
4529 x = pre(ddf).map_partitions(func)
4530 assert_eq(x, expected, check_type=False) # TODO: make check_type pass
4531
4532 assert isinstance(x, da.Array)
4533 assert x.chunks[0] == (np.nan, np.nan)
4534
4535
4536def 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