(width, multiplier, min_width=1, divisor=1, verbose=False)
| 6 | |
| 7 | |
| 8 | def round_width(width, multiplier, min_width=1, divisor=1, verbose=False): |
| 9 | if not multiplier: |
| 10 | return width |
| 11 | width *= multiplier |
| 12 | min_width = min_width or divisor |
| 13 | if verbose: |
| 14 | logger.info(f"min width {min_width}") |
| 15 | logger.info(f"width {width} divisor {divisor}") |
| 16 | logger.info(f"other {int(width + divisor / 2) // divisor * divisor}") |
| 17 | |
| 18 | width_out = max(min_width, int(width + divisor / 2) // divisor * divisor) |
| 19 | if width_out < 0.9 * width: |
| 20 | width_out += divisor |
| 21 | return int(width_out) |
no outgoing calls
no test coverage detected