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

Function test_nlargest_nsmallest

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

Source from the content-addressed store, hash-verified

3298
3299
3300def test_nlargest_nsmallest():
3301 from string import ascii_lowercase
3302
3303 df = pd.DataFrame(
3304 {
3305 "a": np.random.permutation(20),
3306 "b": list(ascii_lowercase[:20]),
3307 "c": np.random.permutation(20).astype("float64"),
3308 }
3309 )
3310 ddf = dd.from_pandas(df, npartitions=3)
3311
3312 for m in ["nlargest", "nsmallest"]:
3313 f = lambda df=df, m=m, *args, **kwargs: getattr(df, m)(*args, **kwargs)
3314
3315 res = f(ddf, m, 5, "a")
3316 res2 = f(ddf, m, 5, "a", split_every=2)
3317 sol = f(df, m, 5, "a")
3318 assert_eq(res, sol)
3319 assert_eq(res2, sol)
3320 assert res._name != res2._name
3321
3322 res = f(ddf, m, 5, ["a", "c"])
3323 res2 = f(ddf, m, 5, ["a", "c"], split_every=2)
3324 sol = f(df, m, 5, ["a", "c"])
3325 assert_eq(res, sol)
3326 assert_eq(res2, sol)
3327 assert res._name != res2._name
3328
3329 res = f(ddf.a, m, 5)
3330 res2 = f(ddf.a, m, 5, split_every=2)
3331 sol = f(df.a, m, 5)
3332 assert_eq(res, sol)
3333 assert_eq(res2, sol)
3334 assert res._name != res2._name
3335
3336
3337def test_nlargest_nsmallest_raises():

Callers

nothing calls this directly

Calls 4

assert_eqFunction · 0.90
fFunction · 0.70
permutationMethod · 0.45
astypeMethod · 0.45

Tested by

no test coverage detected