Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
hendrikmakait committed Mar 7, 2024
1 parent e748ed6 commit 3c4e9e8
Showing 1 changed file with 12 additions and 25 deletions.
37 changes: 12 additions & 25 deletions distributed/shuffle/tests/test_graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,10 @@ def test_raise_on_complex_numbers(dtype):
df = dd.from_pandas(
pd.DataFrame({"x": pd.array(range(10), dtype=dtype)}), npartitions=5
)

if dd._dask_expr_enabled():
np = pytest.importorskip("numpy")
with pytest.raises(np.exceptions.ComplexWarning):
df.shuffle("x").optimize()
else:
with pytest.raises(
TypeError, match=f"p2p does not support data of type '{df.x.dtype}'"
), dask.config.set({"dataframe.shuffle.method": "p2p"}):
df.shuffle("x")
with pytest.raises(
TypeError, match=f"p2p does not support data of type '{df.x.dtype}'"
), dask.config.set({"dataframe.shuffle.method": "p2p"}):
df.shuffle("x")


@pytest.mark.xfail(
Expand All @@ -66,25 +60,18 @@ def test_raise_on_sparse_data():
df = dd.from_pandas(
pd.DataFrame({"x": pd.array(range(10), dtype="Sparse[float64]")}), npartitions=5
)
if dd._dask_expr_enabled():
df.shuffle("x").optimize()
else:
with pytest.raises(
TypeError, match="p2p does not support sparse data"
), dask.config.set({"dataframe.shuffle.method": "p2p"}):
df.shuffle("x")
with pytest.raises(
TypeError, match="p2p does not support sparse data"
), dask.config.set({"dataframe.shuffle.method": "p2p"}):
df.shuffle("x")


def test_raise_on_non_string_column_name():
df = dd.from_pandas(pd.DataFrame({"a": range(10), 1: range(10)}), npartitions=5)

if dd._dask_expr_enabled():
df.shuffle("a").optimize()
else:
with pytest.raises(
TypeError, match="p2p requires all column names to be str"
), dask.config.set({"dataframe.shuffle.method": "p2p"}):
df.shuffle("a")
with pytest.raises(
TypeError, match="p2p requires all column names to be str"
), dask.config.set({"dataframe.shuffle.method": "p2p"}):
df.shuffle("a")


def test_does_not_raise_on_stringified_numeric_column_name():
Expand Down

0 comments on commit 3c4e9e8

Please sign in to comment.