MCPcopy
hub / github.com/dask/dask / test_nlargest_nsmallest

Function test_nlargest_nsmallest

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

Source from the content-addressed store, hash-verified

3307
3308
3309def test_nlargest_nsmallest():
3310 from string import ascii_lowercase
3311
3312 df = pd.DataFrame(
3313 {
3314 "a": np.random.permutation(20),
3315 "b": list(ascii_lowercase[:20]),
3316 "c": np.random.permutation(20).astype("float64"),
3317 }
3318 )
3319 ddf = dd.from_pandas(df, npartitions=3)
3320
3321 for m in ["nlargest", "nsmallest"]:
3322 f = lambda df=df, m=m, *args, **kwargs: getattr(df, m)(*args, **kwargs)
3323
3324 res = f(ddf, m, 5, "a")
3325 res2 = f(ddf, m, 5, "a", split_every=2)
3326 sol = f(df, m, 5, "a")
3327 assert_eq(res, sol)
3328 assert_eq(res2, sol)
3329 assert res._name != res2._name
3330
3331 res = f(ddf, m, 5, ["a", "c"])
3332 res2 = f(ddf, m, 5, ["a", "c"], split_every=2)
3333 sol = f(df, m, 5, ["a", "c"])
3334 assert_eq(res, sol)
3335 assert_eq(res2, sol)
3336 assert res._name != res2._name
3337
3338 res = f(ddf.a, m, 5)
3339 res2 = f(ddf.a, m, 5, split_every=2)
3340 sol = f(df.a, m, 5)
3341 assert_eq(res, sol)
3342 assert_eq(res2, sol)
3343 assert res._name != res2._name
3344
3345
3346def 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

Used in the wild real call sites across dependent graphs

searching dependent graphs…