(
root: str, n_per_bucket: int, seed: int
)
| 47 | |
| 48 | |
| 49 | def sample_files( |
| 50 | root: str, n_per_bucket: int, seed: int |
| 51 | ) -> list[tuple[tuple[int, int], str]]: |
| 52 | by_bucket = collect_files(root) |
| 53 | rng = random.Random(seed) |
| 54 | out: list[tuple[tuple[int, int], str]] = [] |
| 55 | for b in BUCKETS: |
| 56 | pool = by_bucket.get(b, []) |
| 57 | rng.shuffle(pool) |
| 58 | for p in pool[:n_per_bucket]: |
| 59 | out.append((b, p)) |
| 60 | return out |
| 61 | |
| 62 | |
| 63 | def opt_key(o: Option) -> tuple: |