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

Function test_sample_raises

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

Source from the content-addressed store, hash-verified

2514
2515
2516def test_sample_raises():
2517 df = pd.DataFrame(
2518 {"x": [1, 2, 3, 4, None, 6], "y": list("abdabd")},
2519 index=[10, 20, 30, 40, 50, 60],
2520 )
2521 a = dd.from_pandas(df, 2)
2522
2523 # Make sure frac is replaced with n when 0 <= n <= 1
2524 # This is so existing code (i.e. ddf.sample(0.5)) won't break
2525 with pytest.warns(UserWarning):
2526 b = a.sample(0.5, random_state=1234)
2527 c = a.sample(frac=0.5, random_state=1234)
2528 assert_eq(b, c)
2529
2530 with pytest.raises(ValueError):
2531 a.sample(n=10)
2532
2533 # Make sure frac is provided
2534 with pytest.raises(ValueError):
2535 a.sample(frac=None)
2536
2537
2538def test_query():

Callers

nothing calls this directly

Calls 2

assert_eqFunction · 0.90
sampleMethod · 0.80

Tested by

no test coverage detected