| 2514 | |
| 2515 | |
| 2516 | def 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 | |
| 2538 | def test_query(): |