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

Function test_sort_values_custom_function

dask/dataframe/tests/test_shuffle.py:1174–1189  ·  view source on GitHub ↗
(by, nparts)

Source from the content-addressed store, hash-verified

1172@pytest.mark.parametrize("by", [["a", "b"], ["b", "a"]])
1173@pytest.mark.parametrize("nparts", [1, 10])
1174def test_sort_values_custom_function(by, nparts):
1175 df = pd.DataFrame({"a": [1, 2, 3] * 20, "b": [4, 5, 6, 7] * 15})
1176 ddf = dd.from_pandas(df, npartitions=nparts)
1177
1178 def f(partition, by_columns, ascending, na_position, **kwargs):
1179 return partition.sort_values(
1180 by_columns, ascending=ascending, na_position=na_position
1181 )
1182
1183 # run on single-threaded scheduler for debugging purposes
1184 with dask.config.set(scheduler="single-threaded"):
1185 got = ddf.sort_values(
1186 by=by[0], sort_function=f, sort_function_kwargs={"by_columns": by}
1187 )
1188 expect = df.sort_values(by=by)
1189 dd.assert_eq(got, expect, check_index=False)
1190
1191
1192def test_sort_values_bool_ascending():

Callers

nothing calls this directly

Calls 2

sort_valuesMethod · 0.95
setMethod · 0.80

Tested by

no test coverage detected