Minimally divide the given chunks so as to make the largest chunk width less or equal than *max_width*.
(desired_chunks, max_width)
| 430 | |
| 431 | |
| 432 | def divide_to_width(desired_chunks, max_width): |
| 433 | """Minimally divide the given chunks so as to make the largest chunk |
| 434 | width less or equal than *max_width*. |
| 435 | """ |
| 436 | chunks = [] |
| 437 | for c in desired_chunks: |
| 438 | nb_divides = int(np.ceil(c / max_width)) |
| 439 | for i in range(nb_divides): |
| 440 | n = c // (nb_divides - i) |
| 441 | chunks.append(n) |
| 442 | c -= n |
| 443 | assert c == 0 |
| 444 | return tuple(chunks) |
| 445 | |
| 446 | |
| 447 | def merge_to_number(desired_chunks, max_number): |
no outgoing calls