def luminance_to_contrast_ratio(luminance1, luminance2):
    """Calculate contrast ratio from a pair of relative luminance.

    :param luminance1: Relative luminance
    :type luminance1: float
    :param luminance2: Relative luminance
    :type luminance2: float
    :return: Contrast ratio
    :rtype: float
    """
    (l1, l2) = sorted((luminance1, luminance2), reverse=True)
    return (l1 + 0.05) / (l2 + 0.05)