root_numpy.evaluate¶
-
root_numpy.
evaluate
(obj, array)¶ 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.])