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

Function test_dot

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

Source from the content-addressed store, hash-verified

4944
4945
4946def test_dot():
4947 s1 = pd.Series([1, 2, 3, 4])
4948 s2 = pd.Series([4, 5, 6, 6])
4949 df = pd.DataFrame({"one": s1, "two": s2})
4950
4951 dask_s1 = dd.from_pandas(s1, npartitions=1)
4952 dask_df = dd.from_pandas(df, npartitions=1)
4953 dask_s2 = dd.from_pandas(s2, npartitions=1)
4954
4955 assert_eq(s1.dot(s2), dask_s1.dot(dask_s2))
4956 assert_eq(s1.dot(df), dask_s1.dot(dask_df))
4957
4958 # With partitions
4959 partitioned_s1 = dd.from_pandas(s1, npartitions=2)
4960 partitioned_df = dd.from_pandas(df, npartitions=2)
4961 partitioned_s2 = dd.from_pandas(s2, npartitions=2)
4962
4963 assert_eq(s1.dot(s2), partitioned_s1.dot(partitioned_s2))
4964 assert_eq(s1.dot(df), partitioned_s1.dot(partitioned_df))
4965
4966 # Test passing meta kwarg
4967 res = dask_s1.dot(dask_df, meta=pd.Series([1], name="test_series")).compute()
4968 assert res.name == "test_series"
4969
4970 # Test validation of second operand
4971 with pytest.raises(TypeError):
4972 dask_s1.dot(da.array([1, 2, 3, 4]))
4973
4974
4975def 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