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

Function test_array_assignment

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

Source from the content-addressed store, hash-verified

3596
3597
3598def test_array_assignment():
3599 df = pd.DataFrame({"x": np.random.normal(size=50), "y": np.random.normal(size=50)})
3600 ddf = dd.from_pandas(df, npartitions=2)
3601 orig = ddf.copy()
3602
3603 arr = np.array(np.random.normal(size=50))
3604 darr = da.from_array(arr, chunks=25)
3605
3606 df["z"] = arr
3607 ddf["z"] = darr
3608 assert_eq(df, ddf)
3609 assert "z" not in orig.columns
3610
3611 arr = np.array(np.random.normal(size=(50, 50)))
3612 darr = da.from_array(arr, chunks=25)
3613 msg = "Array assignment only supports 1-D arrays"
3614 with pytest.raises(ValueError, match=msg):
3615 ddf["z"] = darr
3616
3617 arr = np.array(np.random.normal(size=50))
3618 darr = da.from_array(arr, chunks=10)
3619 msg = "Number of partitions do not match"
3620 with pytest.raises(ValueError, match=msg):
3621 ddf["z"] = darr
3622
3623
3624def 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