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

Function test_dot

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

Source from the content-addressed store, hash-verified

4923
4924
4925def test_dot():
4926 s1 = pd.Series([1, 2, 3, 4])
4927 s2 = pd.Series([4, 5, 6, 6])
4928 df = pd.DataFrame({"one": s1, "two": s2})
4929
4930 dask_s1 = dd.from_pandas(s1, npartitions=1)
4931 dask_df = dd.from_pandas(df, npartitions=1)
4932 dask_s2 = dd.from_pandas(s2, npartitions=1)
4933
4934 assert_eq(s1.dot(s2), dask_s1.dot(dask_s2))
4935 assert_eq(s1.dot(df), dask_s1.dot(dask_df))
4936
4937 # With partitions
4938 partitioned_s1 = dd.from_pandas(s1, npartitions=2)
4939 partitioned_df = dd.from_pandas(df, npartitions=2)
4940 partitioned_s2 = dd.from_pandas(s2, npartitions=2)
4941
4942 assert_eq(s1.dot(s2), partitioned_s1.dot(partitioned_s2))
4943 assert_eq(s1.dot(df), partitioned_s1.dot(partitioned_df))
4944
4945 # Test passing meta kwarg
4946 res = dask_s1.dot(dask_df, meta=pd.Series([1], name="test_series")).compute()
4947 assert res.name == "test_series"
4948
4949 # Test validation of second operand
4950 with pytest.raises(TypeError):
4951 dask_s1.dot(da.array([1, 2, 3, 4]))
4952
4953
4954def test_dot_nan():

Callers

nothing calls this directly

Calls 3

assert_eqFunction · 0.90
dotMethod · 0.45
computeMethod · 0.45

Tested by

no test coverage detected