How to use the pycel.lib.function_helpers.excel_math_func function in pycel

To help you get started, we’ve selected a few pycel examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github dgorissen / pycel / tests / lib / test_function_helpers.py View on Github external
def test_math_wrap_domain_error():
    func = apply_meta(excel_math_func(lambda x: math.log(x)), name_space={})[0]
    assert func(-1) == NUM_ERROR
github dgorissen / pycel / src / pycel / excellib.py View on Github external
@excel_math_func
def trunc(number, num_digits=0):
    # Excel reference: https://support.office.com/en-us/article/
    #   TRUNC-function-8B86A64C-3127-43DB-BA14-AA5CEB292721
    factor = 10 ** int(num_digits)
    return int(number * factor) / factor
github dgorissen / pycel / src / pycel / excellib.py View on Github external
@excel_math_func
def odd(value):
    # Excel reference: https://support.office.com/en-us/article/
    #   odd-function-deae64eb-e08a-4c88-8b40-6d0b42575c98
    return math.copysign(math.ceil((abs(value) - 1) / 2) * 2 + 1, value)
github dgorissen / pycel / src / pycel / excellib.py View on Github external
@excel_math_func
def xatan2(x_num, y_num):
    # Excel reference: https://support.office.com/en-us/article/
    #   ATAN2-function-C04592AB-B9E3-4908-B428-C96B3A565033

    # swap arguments
    return math.atan2(y_num, x_num)
github dgorissen / pycel / src / pycel / excellib.py View on Github external
@excel_math_func
def x_abs(value1):
    # Excel reference: https://support.office.com/en-us/article/
    #   ABS-function-3420200F-5628-4E8C-99DA-C99D7C87713C
    return abs(value1)
github dgorissen / pycel / src / pycel / excellib.py View on Github external
@excel_math_func
def floor_precise(number, significance=1):
    # Excel reference: https://support.office.com/en-us/article/
    #   floor-precise-function-f769b468-1452-4617-8dc3-02f842a0702e
    if significance == 0:
        return 0

    significance = abs(significance)
    return significance * math.floor(number / significance)
github dgorissen / pycel / src / pycel / excellib.py View on Github external
@excel_math_func
def even(value):
    # Excel reference: https://support.office.com/en-us/article/
    #   even-function-197b5f06-c795-4c1e-8696-3c3b8a646cf9
    return math.copysign(math.ceil(abs(value) / 2) * 2, value)
github dgorissen / pycel / src / pycel / excellib.py View on Github external
@excel_math_func
def log(number, base=10):
    # Excel reference: https://support.office.com/en-us/article/
    #   LOG-function-4E82F196-1CA9-4747-8FB0-6C4A3ABB3280
    return math.log(number, base)
github dgorissen / pycel / src / pycel / excellib.py View on Github external
@excel_math_func
def ln(arg):
    # Excel reference: https://support.office.com/en-us/article/
    #   LN-function-81FE1ED7-DAC9-4ACD-BA1D-07A142C6118F
    return math.log(arg)
github dgorissen / pycel / src / pycel / excellib.py View on Github external
@excel_math_func
def floor(number, significance):
    # Excel reference: https://support.office.com/en-us/article/
    #   FLOOR-function-14BB497C-24F2-4E04-B327-B0B4DE5A8886
    if significance < 0 < number:
        return NUM_ERROR

    if number == 0:
        return 0

    if significance == 0:
        return DIV0

    return significance * math.floor(number / significance)