import warnings


def ratio(class_label, data):
    """Compute ratio of all data that is `class_label`."""
    try:
        return float(data.count(class_label)) / len(data)
    except ZeroDivisionError:
        warnings.warn("data {} is empty".format(id(data)))
        return 0.