def sign(x):
    """
    Returns -1 or 1 based on the numeric sign of x.
    Any number equivalent to False, including -0.0, will return itself.
    """

    # From https://www.quora.com/How-do-I-get-sign-of-integer-in-Python
    return x and (1, -1)[x < 0]