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

Function test_map_partition_array

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

Source from the content-addressed store, hash-verified

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