def round_sig_fig(x, sf):
    """
    Rounds a number to the specified number of significant figures.

    Parameters
    ----------
    x : float
        number to round
    sf : float
        number of significant figures

    Returns
    -------
    y : float
        rounded number
    """

    format_str = "%." + str(sf) + "e"
    x_dig, x_ord = map(float, (format_str % x).split("e"))
    return round(x, int(-x_ord) + 1)