MCPcopy Index your code
hub / github.com/dask/dask / test_array_assignment

Function test_array_assignment

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

Source from the content-addressed store, hash-verified

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

Used in the wild real call sites across dependent graphs

searching dependent graphs…