import decimal


def create_decimal(x, digits, rounding=decimal.ROUND_HALF_UP):
    """Create `Decimal` object from `float` with desired significant figures.

    Parameters
    ----------
    x : float
        Value to convert to decimal.
    digits : int
        Number of signficant figures to keep in `x`, must be >= 1.
    rounding : str
        Rounding mode, must be one of the rounding modes accepted as in
        `decimal.Context.rounding`.

    Returns
    -------
    y : Decimal
        Conversion of `x` to `Decimal`.
    """
    assert digits >= 1  # Makes not sense otherwise
    with decimal.localcontext() as ctx:
        ctx.prec = digits
        ctx.rounding = rounding
        y = +decimal.Decimal(x)
    return y