diff --git a/dask/dataframe/partitionquantiles.py b/dask/dataframe/partitionquantiles.py index 0318d3d7f7a..ee19226a1aa 100644 --- a/dask/dataframe/partitionquantiles.py +++ b/dask/dataframe/partitionquantiles.py @@ -263,7 +263,11 @@ def percentiles_to_weights(qs, vals, length): return () diff = np.ediff1d(qs, 0.0, 0.0) weights = 0.5 * length * (diff[1:] + diff[:-1]) - return tolist_dispatch(vals), weights.tolist() + try: + # Try using tolist_dispatch first + return tolist_dispatch(vals), weights.tolist() + except TypeError: + return vals.tolist(), weights.tolist() def merge_and_compress_summaries(vals_and_weights): diff --git a/dask/dataframe/tests/test_shuffle.py b/dask/dataframe/tests/test_shuffle.py index 9df246f73e6..590b250c2be 100644 --- a/dask/dataframe/tests/test_shuffle.py +++ b/dask/dataframe/tests/test_shuffle.py @@ -1488,6 +1488,8 @@ def test_sort_values(nelem, by, ascending): @pytest.mark.parametrize("by", ["x", "z", ["x", "z"], ["z", "x"]]) @pytest.mark.parametrize("ascending", [True, False]) def test_sort_values_tasks_backend(backend, by, ascending): + if backend == "cudf": + pytest.importorskip("dask_cudf") pdf = pd.DataFrame( {"x": range(10), "y": [1, 2, 3, 4, 5] * 2, "z": ["cat", "dog"] * 5} )