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

Function test_array_assignment

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

Source from the content-addressed store, hash-verified

3617
3618
3619def test_array_assignment():
3620 df = pd.DataFrame({"x": np.random.normal(size=50), "y": np.random.normal(size=50)})
3621 ddf = dd.from_pandas(df, npartitions=2)
3622 orig = ddf.copy()
3623
3624 arr = np.array(np.random.normal(size=50))
3625 darr = da.from_array(arr, chunks=25)
3626
3627 df["z"] = arr
3628 ddf["z"] = darr
3629 assert_eq(df, ddf)
3630 assert "z" not in orig.columns
3631
3632 arr = np.array(np.random.normal(size=(50, 50)))
3633 darr = da.from_array(arr, chunks=25)
3634 msg = "Array assignment only supports 1-D arrays"
3635 with pytest.raises(ValueError, match=msg):
3636 ddf["z"] = darr
3637
3638 arr = np.array(np.random.normal(size=50))
3639 darr = da.from_array(arr, chunks=10)
3640 msg = "Number of partitions do not match"
3641 with pytest.raises(ValueError, match=msg):
3642 ddf["z"] = darr
3643
3644
3645def test_columns_assignment():

Callers

nothing calls this directly

Calls 3

assert_eqFunction · 0.90
normalMethod · 0.45
copyMethod · 0.45

Tested by

no test coverage detected