| 3423 | |
| 3424 | |
| 3425 | def _split_up_single_chunk( |
| 3426 | c: int, this_chunksize_tolerance: float, max_chunk_size: int, proposed: int |
| 3427 | ) -> list[int]: |
| 3428 | # Calculate by what factor we have to split this chunk |
| 3429 | m = c / proposed |
| 3430 | if math.ceil(m) / m > this_chunksize_tolerance: |
| 3431 | # We want to smooth things potentially if rounding up would change the result |
| 3432 | # by a lot |
| 3433 | m = math.ceil(c / max_chunk_size) |
| 3434 | else: |
| 3435 | m = math.ceil(m) |
| 3436 | # split the chunk |
| 3437 | new_c, remainder = divmod(c, min(m, c)) |
| 3438 | x = [new_c] * min(m, c) |
| 3439 | for i in range(remainder): |
| 3440 | x[i] += 1 |
| 3441 | return x |
| 3442 | |
| 3443 | |
| 3444 | def round_to(c, s): |