import hashlib


def ab_split(id_obj: str, salt: str, control_group_size: float):
    """Split object into test or control group based on the ID and salt.

    Parameters
    ----------
    id_obj : str
        Object id.
    salt : str
        Salt value.
    control_group_size : float
        Sets how big the control group is desired in percentage.
        Must be between 0 and 1.

    Returns
    -------
        True (for test) or False (for control) : bool

    Examples
    --------
        >>> users = pandas.DataFrame({'id': numpy.arange(100**2)})
        >>> users['test_group'] = users.id.apply(
        ...     lambda id: ab_split(id, 'E1F53135E559C253', 0.25))
        >>> users.test_group.value_counts(normalize=True)
        True     0.7465
        False    0.2535
        Name: test_group, dtype: float64
    """
    test_id = str(id_obj) + '-' + str(salt)
    test_id_digest = hashlib.md5(test_id.encode('ascii')).hexdigest()  # nosec
    test_id_first_digits = test_id_digest[:6]
    test_id_last_int = int(test_id_first_digits, 16)
    split = test_id_last_int / 0xFFFFFF
    return split > control_group_size