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