def parse_n_features(n_features, total):
    """Parse either the `n_features` for forward
    and backward selection. Namely
    (a) if `param` is an int, ensure it lies on (0, `total`),
    (a) if `param` is a float, ensure it lies on (0, 1).

    Args:
        n_features : int
            An `n_features` parameter passed to forward or backward selection.
        total : int
            The total features in the data

    Returns:
        int
            * number of features to select.
            If `n_features` and it lies on (0, `total`),
            it will be returned 'as is'.

    """
    if isinstance(n_features, int) and not 0 < n_features < total:
        raise ValueError(
            "If an int, `n_features` must be on (0, {}).".format(
                total
            )
        )
    if isinstance(n_features, float) and not 0 < n_features < 1:
        raise ValueError(
            "If a float, `n_features` must be on (0, 1)."
        )

    if isinstance(n_features, float):
        return int(n_features * total)
    else:
        return n_features