def districts_within_tolerance(partition, attribute_name="population", percentage=0.1):
    """Check if all districts are within a certain percentage of the "smallest"
    district, as defined by the given attribute.

    :param partition: partition class instance
    :param attrName: string that is the name of an updater in partition
    :param percentage: what percent difference is allowed
    :return: whether the districts are within specified tolerance
    :rtype: bool
    """
    if percentage >= 1:
        percentage *= 0.01

    values = partition[attribute_name].values()
    max_difference = max(values) - min(values)

    within_tolerance = max_difference <= percentage * min(values)
    return within_tolerance