def select_from_data(n, select=1.):
    """Calculate number of data based on a fraction or selection value.

    Args:
        n (int): Size of data.
        select (int, float, optional): Fraction or selection value. A
            floating-point value is used as a ratio with respect to n, [0, n*N]
            (value is bounded by 1.0). An integer value is used as a selection
            value with respect to n, [0, n] (if greater than n, it is set to
            n). Negative values are set to 0. Default is 1.0.

    Returns:
        int: Number of elements.

    Raises:
        ValueError: If *select* is a negative value.
        TypeError: If *select* is non-numeric.
    """
    if isinstance(select, int):
        if select < 0:
            raise ValueError("negative select value, {}".format(select))
        return min(select, int(n))
    elif isinstance(select, float):
        if select < 0.:
            raise ValueError("negative select value, {}".format(select))
        return round(min(select, 1.) * int(n))
    else:
        raise TypeError("invalid select type, {}".format(select))