def check_function(<EOL>state,<EOL>name,<EOL>index=<NUM_LIT:0>,<EOL>missing_msg=None,<EOL>params_not_matched_msg=None,<EOL>expand_msg=None,<EOL>signature=True,<EOL>):
append_missing = missing_msg is None<EOL>append_params_not_matched = params_not_matched_msg is None<EOL>if missing_msg is None:<EOL><INDENT>missing_msg = MISSING_MSG<EOL><DEDENT>if expand_msg is None:<EOL><INDENT>expand_msg = PREPEND_MSG<EOL><DEDENT>if params_not_matched_msg is None:<EOL><INDENT>params_not_matched_msg = SIG_ISSUE_MSG<EOL><DEDENT>stu_out = state.ast_dispatcher("<STR_LIT>", state.student_ast)<EOL>sol_out = state.ast_dispatcher("<STR_LIT>", state.solution_ast)<EOL>student_mappings = state.ast_dispatcher("<STR_LIT>", state.student_ast)<EOL>fmt_kwargs = {<EOL>"<STR_LIT>": get_times(index + <NUM_LIT:1>),<EOL>"<STR_LIT>": get_ord(index + <NUM_LIT:1>),<EOL>"<STR_LIT:index>": index,<EOL>"<STR_LIT>": get_mapped_name(name, student_mappings),<EOL>}<EOL>try:<EOL><INDENT>sol_parts = {**sol_out[name][index]}<EOL><DEDENT>except KeyError:<EOL><INDENT>raise InstructorError(<EOL>"<STR_LIT>"<EOL>% name<EOL>)<EOL><DEDENT>except IndexError:<EOL><INDENT>raise InstructorError(<EOL>"<STR_LIT>"<EOL>% (index + <NUM_LIT:1>, name)<EOL>)<EOL><DEDENT>try:<EOL><INDENT>stu_parts = {**stu_out[name][index]}<EOL><DEDENT>except (KeyError, IndexError):<EOL><INDENT>_msg = state.build_message(missing_msg, fmt_kwargs, append=append_missing)<EOL>state.report(Feedback(_msg, state))<EOL><DEDENT>if signature:<EOL><INDENT>signature = None if isinstance(signature, bool) else signature<EOL>get_sig = partial(<EOL>getSignatureInProcess,<EOL>name=name,<EOL>signature=signature,<EOL>manual_sigs=state.get_manual_sigs(),<EOL>)<EOL>try:<EOL><INDENT>sol_sig = get_sig(<EOL>mapped_name=sol_parts["<STR_LIT:name>"], process=state.solution_process<EOL>)<EOL>sol_parts["<STR_LIT:args>"] = bind_args(sol_sig, sol_parts["<STR_LIT:args>"])<EOL><DEDENT>except Exception as e:<EOL><INDENT>raise InstructorError(<EOL>"<STR_LIT>"<EOL>% (get_ord(index + <NUM_LIT:1>), name, e)<EOL>)<EOL><DEDENT>try:<EOL><INDENT>stu_sig = get_sig(<EOL>mapped_name=stu_parts["<STR_LIT:name>"], process=state.student_process<EOL>)<EOL>stu_parts["<STR_LIT:args>"] = bind_args(stu_sig, stu_parts["<STR_LIT:args>"])<EOL><DEDENT>except Exception:<EOL><INDENT>_msg = state.build_message(<EOL>params_not_matched_msg, fmt_kwargs, append=append_params_not_matched<EOL>)<EOL>state.report(<EOL>Feedback(<EOL>_msg, StubState(stu_parts["<STR_LIT>"], state.highlighting_disabled)<EOL>)<EOL>)<EOL><DEDENT><DEDENT>append_message = {"<STR_LIT>": expand_msg, "<STR_LIT>": fmt_kwargs}<EOL>child = part_to_child(<EOL>stu_parts, sol_parts, append_message, state, node_name="<STR_LIT>"<EOL>)<EOL>return child<EOL>
Check whether a particular function is called.

    ``check_function()`` is typically followed by:

    - ``check_args()`` to check whether the arguments were specified.
      In turn, ``check_args()`` can be followed by ``has_equal_value()`` or ``has_equal_ast()``
      to assert that the arguments were correctly specified.
    - ``has_equal_value()`` to check whether rerunning the function call coded by the student
      gives the same result as calling the function call as in the solution.

    Checking function calls is a tricky topic. Please visit the
    `dedicated article <articles/checking_function_calls.html>`_ for more explanation,
    edge cases and best practices.

    Args:
        name (str): the name of the function to be tested. When checking functions in packages, always
            use the 'full path' of the function.
        index (int): index of the function call to be checked. Defaults to 0.
        missing_msg (str): If specified, this overrides an automatically generated feedback message in case
            the student did not call the function correctly.
        params_not_matched_msg (str): If specified, this overrides an automatically generated feedback message
            in case the function parameters were not successfully matched.
        expand_msg (str): If specified, this overrides any messages that are prepended by previous SCT chains.
        signature (Signature): Normally, check_function() can figure out what the function signature is,
            but it might be necessary to use ``sig_from_params()`` to manually build a signature and pass this along.
        state (State): State object that is passed from the SCT Chain (don't specify this).

    :Examples:

        Student code and solution code::

            import numpy as np
            arr = np.array([1, 2, 3, 4, 5])
            np.mean(arr)

        SCT::

            # Verify whether arr was correctly set in np.mean
            Ex().check_function('numpy.mean').check_args('a').has_equal_value()

            # Verify whether np.mean(arr) produced the same result
            Ex().check_function('numpy.mean').has_equal_value()