'Deterministically choose a percentage-based variant.
The algorithm satisfies two conditions:
1. It\'s deterministic (that is, every call with the same bucket and
variants will result in the same answer).
2. An increase in any of the variant percentages will keep the same
buckets in the same variants as at the smaller percentage (that is,
all buckets previously put in variant A will still be in variant A,
all buckets previously put in variant B will still be in variant B,
etc. and the increased percentages will be made of up buckets
previously not assigned to a bucket).
These attributes make it suitable for use in A/B experiments that may
see an increase in their variant percentages post-enabling.
:param bucket -- an integer bucket representation
:param variants -- a dictionary of
<string:variant name>:<float:percentage> pairs.  If
any percentage exceeds 1/n percent, where n is the
number of variants, the percentage will be capped to
1/n.  These variants will be added to
DEFAULT_CONTROL_GROUPS to create the effective
variant set.
:return string -- the variant name, or None if bucket doesn\'t fall into
any of the variants'

@classmethod
def _choose_variant(cls, bucket, variants):

    all_variants = dict(cls.DEFAULT_CONTROL_GROUPS)
    all_variants.update(variants)
    num_variants = len(all_variants)
    variant_names = sorted(all_variants.keys())
    candidate_variant = variant_names[(bucket % num_variants)]
    variant_fraction = (all_variants[candidate_variant] / 100.0)
    variant_cap = (1.0 / num_variants)
    if (variant_fraction > variant_cap):
        g.log.warning('Variant    %s    exceeds    allowable    percentage    (%.2f    >    %.2f)', candidate_variant, variant_fraction, variant_cap)
    bucket_multiplier = (cls.NUM_BUCKETS / 100)
    if (bucket < ((all_variants[candidate_variant] * num_variants) * bucket_multiplier)):
        return candidate_variant
    else:
        return None
