def get_bandwidth(width, threshold):
    """Approximates the bandwidth needed to achieve a threshold.

    :param width:     = bands * rows  # = elements in signature
    :param threshold: = (1/bands) ** (1/rows) where
    :returns:         number of rows per band
    :rtype: int

    """

    best = width
    min_err = float("inf")
    for rows_per_band in range(1, width + 1):
        try:
            num_bands = 1. / (threshold ** rows_per_band)
        except ZeroDivisionError:
            return best
        err = abs(width - num_bands * rows_per_band)
        if err < min_err:
            best = rows_per_band
            min_err = err
    return best