def eval_func(excel_formula, cse_array_address=None): """ Call the compiled lambda to evaluate the cell """ if excel_formula.compiled_lambda is None: missing = load_function(excel_formula, locals()) if missing: msg_fmt = 'Function {} is not implemented. ' excel_formula.msg = '\n'.join( msg_fmt.format(f.upper()) + func_status_msg(f)[1] for f in sorted(missing)) try: with in_array_formula_context(cse_array_address): ret_val = in_array_formula_context.fit_to_range( excel_formula.compiled_lambda()) except NameError: error_logger('error', excel_formula.python_code, msg=excel_formula.msg, exc=UnknownFunction) except Exception: error_logger('error', excel_formula.python_code, exc=FormulaEvalError) if error_messages: level = 'warning' if ret_val in ERROR_CODES else 'info' error_logger(level, excel_formula.python_code) return ret_val if ret_val not in (None, EMPTY) else 0
def test_func_status_msg(function, known, group, introduced): is_known, msg = func_status_msg(function) assert known == is_known assert group in msg assert ('not a known' in msg) != (function in all_excel_functions) if introduced: assert introduced in msg else: assert 'introduced' not in msg