def evaluate(obj, array):
import ROOT<EOL>array = np.asarray(array, dtype=np.double)<EOL>if isinstance(obj, ROOT.TH1):<EOL><INDENT>if isinstance(obj, ROOT.TH3):<EOL><INDENT>if array.ndim != <NUM_LIT:2>:<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT>if array.shape[<NUM_LIT:1>] != <NUM_LIT:3>:<EOL><INDENT>raise ValueError(<EOL>"<STR_LIT>"<EOL>"<STR_LIT>")<EOL><DEDENT>return _librootnumpy.evaluate_h3(<EOL>ROOT.AsCObject(obj), array)<EOL><DEDENT>elif isinstance(obj, ROOT.TH2):<EOL><INDENT>if array.ndim != <NUM_LIT:2>:<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT>if array.shape[<NUM_LIT:1>] != <NUM_LIT:2>:<EOL><INDENT>raise ValueError(<EOL>"<STR_LIT>"<EOL>"<STR_LIT>")<EOL><DEDENT>return _librootnumpy.evaluate_h2(<EOL>ROOT.AsCObject(obj), array)<EOL><DEDENT>if array.ndim != <NUM_LIT:1>:<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT>return _librootnumpy.evaluate_h1(<EOL>ROOT.AsCObject(obj), array)<EOL><DEDENT>elif isinstance(obj, ROOT.TF1):<EOL><INDENT>if isinstance(obj, ROOT.TF3):<EOL><INDENT>if array.ndim != <NUM_LIT:2>:<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT>if array.shape[<NUM_LIT:1>] != <NUM_LIT:3>:<EOL><INDENT>raise ValueError(<EOL>"<STR_LIT>"<EOL>"<STR_LIT>")<EOL><DEDENT>return _librootnumpy.evaluate_f3(<EOL>ROOT.AsCObject(obj), array)<EOL><DEDENT>elif isinstance(obj, ROOT.TF2):<EOL><INDENT>if array.ndim != <NUM_LIT:2>:<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT>if array.shape[<NUM_LIT:1>] != <NUM_LIT:2>:<EOL><INDENT>raise ValueError(<EOL>"<STR_LIT>"<EOL>"<STR_LIT>")<EOL><DEDENT>return _librootnumpy.evaluate_f2(<EOL>ROOT.AsCObject(obj), array)<EOL><DEDENT>if array.ndim != <NUM_LIT:1>:<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT>return _librootnumpy.evaluate_f1(<EOL>ROOT.AsCObject(obj), array)<EOL><DEDENT>elif isinstance(obj, (string_types, ROOT.TFormula)):<EOL><INDENT>if isinstance(obj, string_types):<EOL><INDENT>obj = ROOT.TFormula(uuid.uuid4().hex, obj)<EOL><DEDENT>ndim = obj.GetNdim()<EOL>if ndim == <NUM_LIT:0>:<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT>if ndim == <NUM_LIT:1>:<EOL><INDENT>if array.ndim != <NUM_LIT:1>:<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT>return _librootnumpy.evaluate_formula_1d(<EOL>ROOT.AsCObject(obj), array)<EOL><DEDENT>if array.ndim != <NUM_LIT:2>:<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT>if array.shape[<NUM_LIT:1>] != ndim:<EOL><INDENT>raise ValueError(<EOL>"<STR_LIT>"<EOL>"<STR_LIT>")<EOL><DEDENT>if ndim == <NUM_LIT:2>:<EOL><INDENT>return _librootnumpy.evaluate_formula_2d(<EOL>ROOT.AsCObject(obj), array)<EOL><DEDENT>elif ndim == <NUM_LIT:3>:<EOL><INDENT>return _librootnumpy.evaluate_formula_3d(<EOL>ROOT.AsCObject(obj), array)<EOL><DEDENT>return _librootnumpy.evaluate_formula_4d(<EOL>ROOT.AsCObject(obj), array)<EOL><DEDENT>elif isinstance(obj, ROOT.TGraph):<EOL><INDENT>if array.ndim != <NUM_LIT:1>:<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT>return _librootnumpy.evaluate_graph(<EOL>ROOT.AsCObject(obj), array)<EOL><DEDENT>elif isinstance(obj, ROOT.TSpline):<EOL><INDENT>if array.ndim != <NUM_LIT:1>:<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT>return _librootnumpy.evaluate_spline(<EOL>ROOT.AsCObject(obj), array)<EOL><DEDENT>raise TypeError(<EOL>"<STR_LIT>"<EOL>"<STR_LIT>")<EOL>
Evaluate a ROOT histogram, function, graph, or spline over an array.

    Parameters
    ----------
    obj : TH[1|2|3], TF[1|2|3], TFormula, TGraph, TSpline, or string
        A ROOT histogram, function, formula, graph, spline, or string. If a
        string is specified, a TFormula is created.
    array : ndarray
        An array containing the values to evaluate the ROOT object on. The
        shape must match the dimensionality of the ROOT object.

    Returns
    -------
    y : array
        An array containing the values of the ROOT object evaluated at each
        value in the input array.

    Raises
    ------
    TypeError
        If the ROOT object is not a histogram, function, graph, or spline.
    ValueError
        If the shape of the array is not compatible with the dimensionality of
        the ROOT object being evaluated. If the string expression does not
        compile to a valid TFormula expression.

    Examples
    --------
    >>> from root_numpy import evaluate
    >>> from ROOT import TF1, TF2
    >>> func = TF1("f1", "x*x")
    >>> evaluate(func, [1, 2, 3, 4])
    array([  1.,   4.,   9.,  16.])
    >>> func = TF2("f2", "x*y")
    >>> evaluate(func, [[1, 1], [1, 2], [3, 1]])
    array([ 1.,  2.,  3.])
    >>> evaluate("x*y", [[1, 1], [1, 2], [3, 1]])
    array([ 1.,  2.,  3.])