repo stringlengths 7 55 | path stringlengths 4 127 | func_name stringlengths 1 88 | original_string stringlengths 75 19.8k | language stringclasses 1
value | code stringlengths 75 19.8k | code_tokens list | docstring stringlengths 3 17.3k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 87 242 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
rootpy/rootpy | rootpy/plotting/root2matplotlib.py | imshow | def imshow(h, axes=None, colorbar=False, **kwargs):
"""
Draw a matplotlib imshow plot from a 2D ROOT histogram.
Parameters
----------
h : Hist2D
A rootpy Hist2D
axes : matplotlib Axes instance, optional (default=None)
The axes to plot on. If None then use the global current ax... | python | def imshow(h, axes=None, colorbar=False, **kwargs):
"""
Draw a matplotlib imshow plot from a 2D ROOT histogram.
Parameters
----------
h : Hist2D
A rootpy Hist2D
axes : matplotlib Axes instance, optional (default=None)
The axes to plot on. If None then use the global current ax... | [
"def",
"imshow",
"(",
"h",
",",
"axes",
"=",
"None",
",",
"colorbar",
"=",
"False",
",",
"*",
"*",
"kwargs",
")",
":",
"kwargs",
".",
"setdefault",
"(",
"'aspect'",
",",
"'auto'",
")",
"if",
"axes",
"is",
"None",
":",
"axes",
"=",
"plt",
".",
"gc... | Draw a matplotlib imshow plot from a 2D ROOT histogram.
Parameters
----------
h : Hist2D
A rootpy Hist2D
axes : matplotlib Axes instance, optional (default=None)
The axes to plot on. If None then use the global current axes.
colorbar : Boolean, optional (default=False)
If... | [
"Draw",
"a",
"matplotlib",
"imshow",
"plot",
"from",
"a",
"2D",
"ROOT",
"histogram",
"."
] | 3926935e1f2100d8ba68070c2ab44055d4800f73 | https://github.com/rootpy/rootpy/blob/3926935e1f2100d8ba68070c2ab44055d4800f73/rootpy/plotting/root2matplotlib.py#L743-L785 | train |
rootpy/rootpy | rootpy/plotting/root2matplotlib.py | contour | def contour(h, axes=None, zoom=None, label_contour=False, **kwargs):
"""
Draw a matplotlib contour plot from a 2D ROOT histogram.
Parameters
----------
h : Hist2D
A rootpy Hist2D
axes : matplotlib Axes instance, optional (default=None)
The axes to plot on. If None then use the... | python | def contour(h, axes=None, zoom=None, label_contour=False, **kwargs):
"""
Draw a matplotlib contour plot from a 2D ROOT histogram.
Parameters
----------
h : Hist2D
A rootpy Hist2D
axes : matplotlib Axes instance, optional (default=None)
The axes to plot on. If None then use the... | [
"def",
"contour",
"(",
"h",
",",
"axes",
"=",
"None",
",",
"zoom",
"=",
"None",
",",
"label_contour",
"=",
"False",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"axes",
"is",
"None",
":",
"axes",
"=",
"plt",
".",
"gca",
"(",
")",
"x",
"=",
"np",
... | Draw a matplotlib contour plot from a 2D ROOT histogram.
Parameters
----------
h : Hist2D
A rootpy Hist2D
axes : matplotlib Axes instance, optional (default=None)
The axes to plot on. If None then use the global current axes.
zoom : float or sequence, optional (default=None)
... | [
"Draw",
"a",
"matplotlib",
"contour",
"plot",
"from",
"a",
"2D",
"ROOT",
"histogram",
"."
] | 3926935e1f2100d8ba68070c2ab44055d4800f73 | https://github.com/rootpy/rootpy/blob/3926935e1f2100d8ba68070c2ab44055d4800f73/rootpy/plotting/root2matplotlib.py#L788-L838 | train |
rootpy/rootpy | rootpy/tree/tree.py | BaseTree._post_init | def _post_init(self):
"""
The standard rootpy _post_init method that is used to initialize both
new Trees and Trees retrieved from a File.
"""
if not hasattr(self, '_buffer'):
# only set _buffer if model was not specified in the __init__
self._buffer = Tre... | python | def _post_init(self):
"""
The standard rootpy _post_init method that is used to initialize both
new Trees and Trees retrieved from a File.
"""
if not hasattr(self, '_buffer'):
# only set _buffer if model was not specified in the __init__
self._buffer = Tre... | [
"def",
"_post_init",
"(",
"self",
")",
":",
"if",
"not",
"hasattr",
"(",
"self",
",",
"'_buffer'",
")",
":",
"# only set _buffer if model was not specified in the __init__",
"self",
".",
"_buffer",
"=",
"TreeBuffer",
"(",
")",
"self",
".",
"read_branches_on_demand",... | The standard rootpy _post_init method that is used to initialize both
new Trees and Trees retrieved from a File. | [
"The",
"standard",
"rootpy",
"_post_init",
"method",
"that",
"is",
"used",
"to",
"initialize",
"both",
"new",
"Trees",
"and",
"Trees",
"retrieved",
"from",
"a",
"File",
"."
] | 3926935e1f2100d8ba68070c2ab44055d4800f73 | https://github.com/rootpy/rootpy/blob/3926935e1f2100d8ba68070c2ab44055d4800f73/rootpy/tree/tree.py#L49-L62 | train |
rootpy/rootpy | rootpy/tree/tree.py | BaseTree.always_read | def always_read(self, branches):
"""
Always read these branches, even when in caching mode. Maybe you have
caching enabled and there are branches you want to be updated for each
entry even though you never access them directly. This is useful if you
are iterating over an input tr... | python | def always_read(self, branches):
"""
Always read these branches, even when in caching mode. Maybe you have
caching enabled and there are branches you want to be updated for each
entry even though you never access them directly. This is useful if you
are iterating over an input tr... | [
"def",
"always_read",
"(",
"self",
",",
"branches",
")",
":",
"if",
"type",
"(",
"branches",
")",
"not",
"in",
"(",
"list",
",",
"tuple",
")",
":",
"raise",
"TypeError",
"(",
"\"branches must be a list or tuple\"",
")",
"self",
".",
"_always_read",
"=",
"b... | Always read these branches, even when in caching mode. Maybe you have
caching enabled and there are branches you want to be updated for each
entry even though you never access them directly. This is useful if you
are iterating over an input tree and writing to an output tree sharing
the ... | [
"Always",
"read",
"these",
"branches",
"even",
"when",
"in",
"caching",
"mode",
".",
"Maybe",
"you",
"have",
"caching",
"enabled",
"and",
"there",
"are",
"branches",
"you",
"want",
"to",
"be",
"updated",
"for",
"each",
"entry",
"even",
"though",
"you",
"ne... | 3926935e1f2100d8ba68070c2ab44055d4800f73 | https://github.com/rootpy/rootpy/blob/3926935e1f2100d8ba68070c2ab44055d4800f73/rootpy/tree/tree.py#L64-L82 | train |
rootpy/rootpy | rootpy/tree/tree.py | BaseTree.branch_type | def branch_type(cls, branch):
"""
Return the string representation for the type of a branch
"""
typename = branch.GetClassName()
if not typename:
leaf = branch.GetListOfLeaves()[0]
typename = leaf.GetTypeName()
# check if leaf has multiple elem... | python | def branch_type(cls, branch):
"""
Return the string representation for the type of a branch
"""
typename = branch.GetClassName()
if not typename:
leaf = branch.GetListOfLeaves()[0]
typename = leaf.GetTypeName()
# check if leaf has multiple elem... | [
"def",
"branch_type",
"(",
"cls",
",",
"branch",
")",
":",
"typename",
"=",
"branch",
".",
"GetClassName",
"(",
")",
"if",
"not",
"typename",
":",
"leaf",
"=",
"branch",
".",
"GetListOfLeaves",
"(",
")",
"[",
"0",
"]",
"typename",
"=",
"leaf",
".",
"... | Return the string representation for the type of a branch | [
"Return",
"the",
"string",
"representation",
"for",
"the",
"type",
"of",
"a",
"branch"
] | 3926935e1f2100d8ba68070c2ab44055d4800f73 | https://github.com/rootpy/rootpy/blob/3926935e1f2100d8ba68070c2ab44055d4800f73/rootpy/tree/tree.py#L85-L101 | train |
rootpy/rootpy | rootpy/tree/tree.py | BaseTree.create_buffer | def create_buffer(self, ignore_unsupported=False):
"""
Create this tree's TreeBuffer
"""
bufferdict = OrderedDict()
for branch in self.iterbranches():
# only include activated branches
if not self.GetBranchStatus(branch.GetName()):
continue... | python | def create_buffer(self, ignore_unsupported=False):
"""
Create this tree's TreeBuffer
"""
bufferdict = OrderedDict()
for branch in self.iterbranches():
# only include activated branches
if not self.GetBranchStatus(branch.GetName()):
continue... | [
"def",
"create_buffer",
"(",
"self",
",",
"ignore_unsupported",
"=",
"False",
")",
":",
"bufferdict",
"=",
"OrderedDict",
"(",
")",
"for",
"branch",
"in",
"self",
".",
"iterbranches",
"(",
")",
":",
"# only include activated branches",
"if",
"not",
"self",
"."... | Create this tree's TreeBuffer | [
"Create",
"this",
"tree",
"s",
"TreeBuffer"
] | 3926935e1f2100d8ba68070c2ab44055d4800f73 | https://github.com/rootpy/rootpy/blob/3926935e1f2100d8ba68070c2ab44055d4800f73/rootpy/tree/tree.py#L111-L127 | train |
rootpy/rootpy | rootpy/tree/tree.py | BaseTree.create_branches | def create_branches(self, branches):
"""
Create branches from a TreeBuffer or dict mapping names to type names
Parameters
----------
branches : TreeBuffer or dict
"""
if not isinstance(branches, TreeBuffer):
branches = TreeBuffer(branches)
sel... | python | def create_branches(self, branches):
"""
Create branches from a TreeBuffer or dict mapping names to type names
Parameters
----------
branches : TreeBuffer or dict
"""
if not isinstance(branches, TreeBuffer):
branches = TreeBuffer(branches)
sel... | [
"def",
"create_branches",
"(",
"self",
",",
"branches",
")",
":",
"if",
"not",
"isinstance",
"(",
"branches",
",",
"TreeBuffer",
")",
":",
"branches",
"=",
"TreeBuffer",
"(",
"branches",
")",
"self",
".",
"set_buffer",
"(",
"branches",
",",
"create_branches"... | Create branches from a TreeBuffer or dict mapping names to type names
Parameters
----------
branches : TreeBuffer or dict | [
"Create",
"branches",
"from",
"a",
"TreeBuffer",
"or",
"dict",
"mapping",
"names",
"to",
"type",
"names"
] | 3926935e1f2100d8ba68070c2ab44055d4800f73 | https://github.com/rootpy/rootpy/blob/3926935e1f2100d8ba68070c2ab44055d4800f73/rootpy/tree/tree.py#L129-L139 | train |
rootpy/rootpy | rootpy/tree/tree.py | BaseTree.update_buffer | def update_buffer(self, treebuffer, transfer_objects=False):
"""
Merge items from a TreeBuffer into this Tree's TreeBuffer
Parameters
----------
buffer : rootpy.tree.buffer.TreeBuffer
The TreeBuffer to merge into this Tree's buffer
transfer_objects : bool, o... | python | def update_buffer(self, treebuffer, transfer_objects=False):
"""
Merge items from a TreeBuffer into this Tree's TreeBuffer
Parameters
----------
buffer : rootpy.tree.buffer.TreeBuffer
The TreeBuffer to merge into this Tree's buffer
transfer_objects : bool, o... | [
"def",
"update_buffer",
"(",
"self",
",",
"treebuffer",
",",
"transfer_objects",
"=",
"False",
")",
":",
"self",
".",
"_buffer",
".",
"update",
"(",
"treebuffer",
")",
"if",
"transfer_objects",
":",
"self",
".",
"_buffer",
".",
"set_objects",
"(",
"treebuffe... | Merge items from a TreeBuffer into this Tree's TreeBuffer
Parameters
----------
buffer : rootpy.tree.buffer.TreeBuffer
The TreeBuffer to merge into this Tree's buffer
transfer_objects : bool, optional (default=False)
If True then all objects and collections on t... | [
"Merge",
"items",
"from",
"a",
"TreeBuffer",
"into",
"this",
"Tree",
"s",
"TreeBuffer"
] | 3926935e1f2100d8ba68070c2ab44055d4800f73 | https://github.com/rootpy/rootpy/blob/3926935e1f2100d8ba68070c2ab44055d4800f73/rootpy/tree/tree.py#L141-L156 | train |
rootpy/rootpy | rootpy/tree/tree.py | BaseTree.set_buffer | def set_buffer(self, treebuffer,
branches=None,
ignore_branches=None,
create_branches=False,
visible=True,
ignore_missing=False,
ignore_duplicates=False,
transfer_objects=False):
... | python | def set_buffer(self, treebuffer,
branches=None,
ignore_branches=None,
create_branches=False,
visible=True,
ignore_missing=False,
ignore_duplicates=False,
transfer_objects=False):
... | [
"def",
"set_buffer",
"(",
"self",
",",
"treebuffer",
",",
"branches",
"=",
"None",
",",
"ignore_branches",
"=",
"None",
",",
"create_branches",
"=",
"False",
",",
"visible",
"=",
"True",
",",
"ignore_missing",
"=",
"False",
",",
"ignore_duplicates",
"=",
"Fa... | Set the Tree buffer
Parameters
----------
treebuffer : rootpy.tree.buffer.TreeBuffer
a TreeBuffer
branches : list, optional (default=None)
only include these branches from the TreeBuffer
ignore_branches : list, optional (default=None)
ignore... | [
"Set",
"the",
"Tree",
"buffer"
] | 3926935e1f2100d8ba68070c2ab44055d4800f73 | https://github.com/rootpy/rootpy/blob/3926935e1f2100d8ba68070c2ab44055d4800f73/rootpy/tree/tree.py#L158-L255 | train |
rootpy/rootpy | rootpy/tree/tree.py | BaseTree.glob | def glob(self, patterns, exclude=None):
"""
Return a list of branch names that match ``pattern``.
Exclude all matched branch names which also match a pattern in
``exclude``. ``exclude`` may be a string or list of strings.
Parameters
----------
patterns: str or li... | python | def glob(self, patterns, exclude=None):
"""
Return a list of branch names that match ``pattern``.
Exclude all matched branch names which also match a pattern in
``exclude``. ``exclude`` may be a string or list of strings.
Parameters
----------
patterns: str or li... | [
"def",
"glob",
"(",
"self",
",",
"patterns",
",",
"exclude",
"=",
"None",
")",
":",
"if",
"isinstance",
"(",
"patterns",
",",
"string_types",
")",
":",
"patterns",
"=",
"[",
"patterns",
"]",
"if",
"isinstance",
"(",
"exclude",
",",
"string_types",
")",
... | Return a list of branch names that match ``pattern``.
Exclude all matched branch names which also match a pattern in
``exclude``. ``exclude`` may be a string or list of strings.
Parameters
----------
patterns: str or list
branches are matched against this pattern or ... | [
"Return",
"a",
"list",
"of",
"branch",
"names",
"that",
"match",
"pattern",
".",
"Exclude",
"all",
"matched",
"branch",
"names",
"which",
"also",
"match",
"a",
"pattern",
"in",
"exclude",
".",
"exclude",
"may",
"be",
"a",
"string",
"or",
"list",
"of",
"s... | 3926935e1f2100d8ba68070c2ab44055d4800f73 | https://github.com/rootpy/rootpy/blob/3926935e1f2100d8ba68070c2ab44055d4800f73/rootpy/tree/tree.py#L337-L369 | train |
rootpy/rootpy | rootpy/tree/tree.py | BaseTree.CopyTree | def CopyTree(self, selection, *args, **kwargs):
"""
Copy the tree while supporting a rootpy.tree.cut.Cut selection in
addition to a simple string.
"""
return super(BaseTree, self).CopyTree(str(selection), *args, **kwargs) | python | def CopyTree(self, selection, *args, **kwargs):
"""
Copy the tree while supporting a rootpy.tree.cut.Cut selection in
addition to a simple string.
"""
return super(BaseTree, self).CopyTree(str(selection), *args, **kwargs) | [
"def",
"CopyTree",
"(",
"self",
",",
"selection",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"super",
"(",
"BaseTree",
",",
"self",
")",
".",
"CopyTree",
"(",
"str",
"(",
"selection",
")",
",",
"*",
"args",
",",
"*",
"*",
"kwa... | Copy the tree while supporting a rootpy.tree.cut.Cut selection in
addition to a simple string. | [
"Copy",
"the",
"tree",
"while",
"supporting",
"a",
"rootpy",
".",
"tree",
".",
"cut",
".",
"Cut",
"selection",
"in",
"addition",
"to",
"a",
"simple",
"string",
"."
] | 3926935e1f2100d8ba68070c2ab44055d4800f73 | https://github.com/rootpy/rootpy/blob/3926935e1f2100d8ba68070c2ab44055d4800f73/rootpy/tree/tree.py#L656-L661 | train |
rootpy/rootpy | rootpy/tree/tree.py | BaseTree.to_array | def to_array(self, *args, **kwargs):
"""
Convert this tree into a NumPy structured array
"""
from root_numpy import tree2array
return tree2array(self, *args, **kwargs) | python | def to_array(self, *args, **kwargs):
"""
Convert this tree into a NumPy structured array
"""
from root_numpy import tree2array
return tree2array(self, *args, **kwargs) | [
"def",
"to_array",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"from",
"root_numpy",
"import",
"tree2array",
"return",
"tree2array",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")"
] | Convert this tree into a NumPy structured array | [
"Convert",
"this",
"tree",
"into",
"a",
"NumPy",
"structured",
"array"
] | 3926935e1f2100d8ba68070c2ab44055d4800f73 | https://github.com/rootpy/rootpy/blob/3926935e1f2100d8ba68070c2ab44055d4800f73/rootpy/tree/tree.py#L858-L863 | train |
rootpy/rootpy | rootpy/roosh.py | color_key | def color_key(tkey):
"""
Function which returns a colorized TKey name given its type
"""
name = tkey.GetName()
classname = tkey.GetClassName()
for class_regex, color in _COLOR_MATCHER:
if class_regex.match(classname):
return colored(name, color=color)
return name | python | def color_key(tkey):
"""
Function which returns a colorized TKey name given its type
"""
name = tkey.GetName()
classname = tkey.GetClassName()
for class_regex, color in _COLOR_MATCHER:
if class_regex.match(classname):
return colored(name, color=color)
return name | [
"def",
"color_key",
"(",
"tkey",
")",
":",
"name",
"=",
"tkey",
".",
"GetName",
"(",
")",
"classname",
"=",
"tkey",
".",
"GetClassName",
"(",
")",
"for",
"class_regex",
",",
"color",
"in",
"_COLOR_MATCHER",
":",
"if",
"class_regex",
".",
"match",
"(",
... | Function which returns a colorized TKey name given its type | [
"Function",
"which",
"returns",
"a",
"colorized",
"TKey",
"name",
"given",
"its",
"type"
] | 3926935e1f2100d8ba68070c2ab44055d4800f73 | https://github.com/rootpy/rootpy/blob/3926935e1f2100d8ba68070c2ab44055d4800f73/rootpy/roosh.py#L49-L58 | train |
rootpy/rootpy | rootpy/plotting/contrib/plot_corrcoef_matrix.py | cov | def cov(m, y=None, rowvar=1, bias=0, ddof=None, weights=None, repeat_weights=0):
"""
Estimate a covariance matrix, given data.
Covariance indicates the level to which two variables vary together.
If we examine N-dimensional samples, :math:`X = [x_1, x_2, ... x_N]^T`,
then the covariance matrix elem... | python | def cov(m, y=None, rowvar=1, bias=0, ddof=None, weights=None, repeat_weights=0):
"""
Estimate a covariance matrix, given data.
Covariance indicates the level to which two variables vary together.
If we examine N-dimensional samples, :math:`X = [x_1, x_2, ... x_N]^T`,
then the covariance matrix elem... | [
"def",
"cov",
"(",
"m",
",",
"y",
"=",
"None",
",",
"rowvar",
"=",
"1",
",",
"bias",
"=",
"0",
",",
"ddof",
"=",
"None",
",",
"weights",
"=",
"None",
",",
"repeat_weights",
"=",
"0",
")",
":",
"import",
"numpy",
"as",
"np",
"# Check inputs",
"if"... | Estimate a covariance matrix, given data.
Covariance indicates the level to which two variables vary together.
If we examine N-dimensional samples, :math:`X = [x_1, x_2, ... x_N]^T`,
then the covariance matrix element :math:`C_{ij}` is the covariance of
:math:`x_i` and :math:`x_j`. The element :math:`C... | [
"Estimate",
"a",
"covariance",
"matrix",
"given",
"data",
"."
] | 3926935e1f2100d8ba68070c2ab44055d4800f73 | https://github.com/rootpy/rootpy/blob/3926935e1f2100d8ba68070c2ab44055d4800f73/rootpy/plotting/contrib/plot_corrcoef_matrix.py#L136-L285 | train |
rootpy/rootpy | rootpy/plotting/contrib/plot_corrcoef_matrix.py | corrcoef | def corrcoef(x, y=None, rowvar=1, bias=0, ddof=None, weights=None,
repeat_weights=0):
"""
Return correlation coefficients.
Please refer to the documentation for `cov` for more detail. The
relationship between the correlation coefficient matrix, `P`, and the
covariance matrix, `C`, is
... | python | def corrcoef(x, y=None, rowvar=1, bias=0, ddof=None, weights=None,
repeat_weights=0):
"""
Return correlation coefficients.
Please refer to the documentation for `cov` for more detail. The
relationship between the correlation coefficient matrix, `P`, and the
covariance matrix, `C`, is
... | [
"def",
"corrcoef",
"(",
"x",
",",
"y",
"=",
"None",
",",
"rowvar",
"=",
"1",
",",
"bias",
"=",
"0",
",",
"ddof",
"=",
"None",
",",
"weights",
"=",
"None",
",",
"repeat_weights",
"=",
"0",
")",
":",
"import",
"numpy",
"as",
"np",
"c",
"=",
"cov"... | Return correlation coefficients.
Please refer to the documentation for `cov` for more detail. The
relationship between the correlation coefficient matrix, `P`, and the
covariance matrix, `C`, is
.. math:: P_{ij} = \\frac{ C_{ij} } { \\sqrt{ C_{ii} * C_{jj} } }
The values of `P` are between -1 an... | [
"Return",
"correlation",
"coefficients",
"."
] | 3926935e1f2100d8ba68070c2ab44055d4800f73 | https://github.com/rootpy/rootpy/blob/3926935e1f2100d8ba68070c2ab44055d4800f73/rootpy/plotting/contrib/plot_corrcoef_matrix.py#L288-L355 | train |
rootpy/rootpy | rootpy/tree/cut.py | Cut.safe | def safe(self, parentheses=True):
"""
Returns a string representation with special characters
replaced by safer characters for use in file names.
"""
if not self:
return ""
string = str(self)
string = string.replace("**", "_pow_")
string = stri... | python | def safe(self, parentheses=True):
"""
Returns a string representation with special characters
replaced by safer characters for use in file names.
"""
if not self:
return ""
string = str(self)
string = string.replace("**", "_pow_")
string = stri... | [
"def",
"safe",
"(",
"self",
",",
"parentheses",
"=",
"True",
")",
":",
"if",
"not",
"self",
":",
"return",
"\"\"",
"string",
"=",
"str",
"(",
"self",
")",
"string",
"=",
"string",
".",
"replace",
"(",
"\"**\"",
",",
"\"_pow_\"",
")",
"string",
"=",
... | Returns a string representation with special characters
replaced by safer characters for use in file names. | [
"Returns",
"a",
"string",
"representation",
"with",
"special",
"characters",
"replaced",
"by",
"safer",
"characters",
"for",
"use",
"in",
"file",
"names",
"."
] | 3926935e1f2100d8ba68070c2ab44055d4800f73 | https://github.com/rootpy/rootpy/blob/3926935e1f2100d8ba68070c2ab44055d4800f73/rootpy/tree/cut.py#L222-L248 | train |
rootpy/rootpy | rootpy/tree/cut.py | Cut.latex | def latex(self):
"""
Returns a string representation for use in LaTeX
"""
if not self:
return ""
s = str(self)
s = s.replace("==", " = ")
s = s.replace("<=", " \leq ")
s = s.replace(">=", " \geq ")
s = s.replace("&&", r" \text{ and } ")... | python | def latex(self):
"""
Returns a string representation for use in LaTeX
"""
if not self:
return ""
s = str(self)
s = s.replace("==", " = ")
s = s.replace("<=", " \leq ")
s = s.replace(">=", " \geq ")
s = s.replace("&&", r" \text{ and } ")... | [
"def",
"latex",
"(",
"self",
")",
":",
"if",
"not",
"self",
":",
"return",
"\"\"",
"s",
"=",
"str",
"(",
"self",
")",
"s",
"=",
"s",
".",
"replace",
"(",
"\"==\"",
",",
"\" = \"",
")",
"s",
"=",
"s",
".",
"replace",
"(",
"\"<=\"",
",",
"\" \\le... | Returns a string representation for use in LaTeX | [
"Returns",
"a",
"string",
"representation",
"for",
"use",
"in",
"LaTeX"
] | 3926935e1f2100d8ba68070c2ab44055d4800f73 | https://github.com/rootpy/rootpy/blob/3926935e1f2100d8ba68070c2ab44055d4800f73/rootpy/tree/cut.py#L250-L262 | train |
rootpy/rootpy | rootpy/tree/cut.py | Cut.replace | def replace(self, name, newname):
"""
Replace all occurrences of name with newname
"""
if not re.match("[a-zA-Z]\w*", name):
return None
if not re.match("[a-zA-Z]\w*", newname):
return None
def _replace(match):
return match.group(0).re... | python | def replace(self, name, newname):
"""
Replace all occurrences of name with newname
"""
if not re.match("[a-zA-Z]\w*", name):
return None
if not re.match("[a-zA-Z]\w*", newname):
return None
def _replace(match):
return match.group(0).re... | [
"def",
"replace",
"(",
"self",
",",
"name",
",",
"newname",
")",
":",
"if",
"not",
"re",
".",
"match",
"(",
"\"[a-zA-Z]\\w*\"",
",",
"name",
")",
":",
"return",
"None",
"if",
"not",
"re",
".",
"match",
"(",
"\"[a-zA-Z]\\w*\"",
",",
"newname",
")",
":... | Replace all occurrences of name with newname | [
"Replace",
"all",
"occurrences",
"of",
"name",
"with",
"newname"
] | 3926935e1f2100d8ba68070c2ab44055d4800f73 | https://github.com/rootpy/rootpy/blob/3926935e1f2100d8ba68070c2ab44055d4800f73/rootpy/tree/cut.py#L273-L287 | train |
rootpy/rootpy | docs/sphinxext/ipython_directive.py | EmbeddedSphinxShell.save_image | def save_image(self, image_file):
"""
Saves the image file to disk.
"""
self.ensure_pyplot()
command = 'plt.gcf().savefig("%s")'%image_file
#print 'SAVEFIG', command # dbg
self.process_input_line('bookmark ipy_thisdir', store_history=False)
self.process_i... | python | def save_image(self, image_file):
"""
Saves the image file to disk.
"""
self.ensure_pyplot()
command = 'plt.gcf().savefig("%s")'%image_file
#print 'SAVEFIG', command # dbg
self.process_input_line('bookmark ipy_thisdir', store_history=False)
self.process_i... | [
"def",
"save_image",
"(",
"self",
",",
"image_file",
")",
":",
"self",
".",
"ensure_pyplot",
"(",
")",
"command",
"=",
"'plt.gcf().savefig(\"%s\")'",
"%",
"image_file",
"#print 'SAVEFIG', command # dbg",
"self",
".",
"process_input_line",
"(",
"'bookmark ipy_thisdir'",... | Saves the image file to disk. | [
"Saves",
"the",
"image",
"file",
"to",
"disk",
"."
] | 3926935e1f2100d8ba68070c2ab44055d4800f73 | https://github.com/rootpy/rootpy/blob/3926935e1f2100d8ba68070c2ab44055d4800f73/docs/sphinxext/ipython_directive.py#L393-L405 | train |
rootpy/rootpy | rootpy/plotting/base.py | Plottable.decorate | def decorate(self, other=None, **kwargs):
"""
Apply style options to a Plottable object.
Returns a reference to self.
"""
if 'color' in kwargs:
incompatible = []
for othercolor in ('linecolor', 'fillcolor', 'markercolor'):
if othercolor in... | python | def decorate(self, other=None, **kwargs):
"""
Apply style options to a Plottable object.
Returns a reference to self.
"""
if 'color' in kwargs:
incompatible = []
for othercolor in ('linecolor', 'fillcolor', 'markercolor'):
if othercolor in... | [
"def",
"decorate",
"(",
"self",
",",
"other",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"'color'",
"in",
"kwargs",
":",
"incompatible",
"=",
"[",
"]",
"for",
"othercolor",
"in",
"(",
"'linecolor'",
",",
"'fillcolor'",
",",
"'markercolor'",
... | Apply style options to a Plottable object.
Returns a reference to self. | [
"Apply",
"style",
"options",
"to",
"a",
"Plottable",
"object",
"."
] | 3926935e1f2100d8ba68070c2ab44055d4800f73 | https://github.com/rootpy/rootpy/blob/3926935e1f2100d8ba68070c2ab44055d4800f73/rootpy/plotting/base.py#L174-L231 | train |
rootpy/rootpy | rootpy/tree/treeobject.py | TreeCollection.getitem | def getitem(self, index):
"""
direct access without going through self.selection
"""
if index >= getattr(self.tree, self.size):
raise IndexError(index)
if self.__cache_objects and index in self.__cache:
return self.__cache[index]
obj = self.tree_ob... | python | def getitem(self, index):
"""
direct access without going through self.selection
"""
if index >= getattr(self.tree, self.size):
raise IndexError(index)
if self.__cache_objects and index in self.__cache:
return self.__cache[index]
obj = self.tree_ob... | [
"def",
"getitem",
"(",
"self",
",",
"index",
")",
":",
"if",
"index",
">=",
"getattr",
"(",
"self",
".",
"tree",
",",
"self",
".",
"size",
")",
":",
"raise",
"IndexError",
"(",
"index",
")",
"if",
"self",
".",
"__cache_objects",
"and",
"index",
"in",... | direct access without going through self.selection | [
"direct",
"access",
"without",
"going",
"through",
"self",
".",
"selection"
] | 3926935e1f2100d8ba68070c2ab44055d4800f73 | https://github.com/rootpy/rootpy/blob/3926935e1f2100d8ba68070c2ab44055d4800f73/rootpy/tree/treeobject.py#L219-L230 | train |
rootpy/rootpy | rootpy/defaults.py | configure_defaults | def configure_defaults():
"""
This function is executed immediately after ROOT's finalSetup
"""
log.debug("configure_defaults()")
global initialized
initialized = True
if use_rootpy_handler:
# Need to do it again here, since it is overridden by ROOT.
set_error_handler(pytho... | python | def configure_defaults():
"""
This function is executed immediately after ROOT's finalSetup
"""
log.debug("configure_defaults()")
global initialized
initialized = True
if use_rootpy_handler:
# Need to do it again here, since it is overridden by ROOT.
set_error_handler(pytho... | [
"def",
"configure_defaults",
"(",
")",
":",
"log",
".",
"debug",
"(",
"\"configure_defaults()\"",
")",
"global",
"initialized",
"initialized",
"=",
"True",
"if",
"use_rootpy_handler",
":",
"# Need to do it again here, since it is overridden by ROOT.",
"set_error_handler",
"... | This function is executed immediately after ROOT's finalSetup | [
"This",
"function",
"is",
"executed",
"immediately",
"after",
"ROOT",
"s",
"finalSetup"
] | 3926935e1f2100d8ba68070c2ab44055d4800f73 | https://github.com/rootpy/rootpy/blob/3926935e1f2100d8ba68070c2ab44055d4800f73/rootpy/defaults.py#L70-L104 | train |
rootpy/rootpy | rootpy/defaults.py | rp_module_level_in_stack | def rp_module_level_in_stack():
"""
Returns true if we're during a rootpy import
"""
from traceback import extract_stack
from rootpy import _ROOTPY_SOURCE_PATH
modlevel_files = [filename for filename, _, func, _ in extract_stack()
if func == "<module>"]
return any(path... | python | def rp_module_level_in_stack():
"""
Returns true if we're during a rootpy import
"""
from traceback import extract_stack
from rootpy import _ROOTPY_SOURCE_PATH
modlevel_files = [filename for filename, _, func, _ in extract_stack()
if func == "<module>"]
return any(path... | [
"def",
"rp_module_level_in_stack",
"(",
")",
":",
"from",
"traceback",
"import",
"extract_stack",
"from",
"rootpy",
"import",
"_ROOTPY_SOURCE_PATH",
"modlevel_files",
"=",
"[",
"filename",
"for",
"filename",
",",
"_",
",",
"func",
",",
"_",
"in",
"extract_stack",
... | Returns true if we're during a rootpy import | [
"Returns",
"true",
"if",
"we",
"re",
"during",
"a",
"rootpy",
"import"
] | 3926935e1f2100d8ba68070c2ab44055d4800f73 | https://github.com/rootpy/rootpy/blob/3926935e1f2100d8ba68070c2ab44055d4800f73/rootpy/defaults.py#L107-L116 | train |
rootpy/rootpy | rootpy/memory/deletion.py | monitor_deletion | def monitor_deletion():
"""
Function for checking for correct deletion of weakref-able objects.
Example usage::
monitor, is_alive = monitor_deletion()
obj = set()
monitor(obj, "obj")
assert is_alive("obj") # True because there is a ref to `obj` is_alive
del obj
... | python | def monitor_deletion():
"""
Function for checking for correct deletion of weakref-able objects.
Example usage::
monitor, is_alive = monitor_deletion()
obj = set()
monitor(obj, "obj")
assert is_alive("obj") # True because there is a ref to `obj` is_alive
del obj
... | [
"def",
"monitor_deletion",
"(",
")",
":",
"monitors",
"=",
"{",
"}",
"def",
"set_deleted",
"(",
"x",
")",
":",
"def",
"_",
"(",
"weakref",
")",
":",
"del",
"monitors",
"[",
"x",
"]",
"return",
"_",
"def",
"monitor",
"(",
"item",
",",
"name",
")",
... | Function for checking for correct deletion of weakref-able objects.
Example usage::
monitor, is_alive = monitor_deletion()
obj = set()
monitor(obj, "obj")
assert is_alive("obj") # True because there is a ref to `obj` is_alive
del obj
assert not is_alive("obj") # Tru... | [
"Function",
"for",
"checking",
"for",
"correct",
"deletion",
"of",
"weakref",
"-",
"able",
"objects",
"."
] | 3926935e1f2100d8ba68070c2ab44055d4800f73 | https://github.com/rootpy/rootpy/blob/3926935e1f2100d8ba68070c2ab44055d4800f73/rootpy/memory/deletion.py#L25-L52 | train |
rootpy/rootpy | rootpy/plotting/utils.py | canvases_with | def canvases_with(drawable):
"""
Return a list of all canvases where `drawable` has been painted.
Note: This function is inefficient because it inspects all objects on all
canvases, recursively. Avoid calling it if you have a large number of
canvases and primitives.
"""
return [... | python | def canvases_with(drawable):
"""
Return a list of all canvases where `drawable` has been painted.
Note: This function is inefficient because it inspects all objects on all
canvases, recursively. Avoid calling it if you have a large number of
canvases and primitives.
"""
return [... | [
"def",
"canvases_with",
"(",
"drawable",
")",
":",
"return",
"[",
"c",
"for",
"c",
"in",
"ROOT",
".",
"gROOT",
".",
"GetListOfCanvases",
"(",
")",
"if",
"drawable",
"in",
"find_all_primitives",
"(",
"c",
")",
"]"
] | Return a list of all canvases where `drawable` has been painted.
Note: This function is inefficient because it inspects all objects on all
canvases, recursively. Avoid calling it if you have a large number of
canvases and primitives. | [
"Return",
"a",
"list",
"of",
"all",
"canvases",
"where",
"drawable",
"has",
"been",
"painted",
"."
] | 3926935e1f2100d8ba68070c2ab44055d4800f73 | https://github.com/rootpy/rootpy/blob/3926935e1f2100d8ba68070c2ab44055d4800f73/rootpy/plotting/utils.py#L405-L414 | train |
rootpy/rootpy | rootpy/plotting/utils.py | tick_length_pixels | def tick_length_pixels(pad, xaxis, yaxis, xlength, ylength=None):
"""
Set the axes tick lengths in pixels
"""
if ylength is None:
ylength = xlength
xaxis.SetTickLength(xlength / float(pad.height_pixels))
yaxis.SetTickLength(ylength / float(pad.width_pixels)) | python | def tick_length_pixels(pad, xaxis, yaxis, xlength, ylength=None):
"""
Set the axes tick lengths in pixels
"""
if ylength is None:
ylength = xlength
xaxis.SetTickLength(xlength / float(pad.height_pixels))
yaxis.SetTickLength(ylength / float(pad.width_pixels)) | [
"def",
"tick_length_pixels",
"(",
"pad",
",",
"xaxis",
",",
"yaxis",
",",
"xlength",
",",
"ylength",
"=",
"None",
")",
":",
"if",
"ylength",
"is",
"None",
":",
"ylength",
"=",
"xlength",
"xaxis",
".",
"SetTickLength",
"(",
"xlength",
"/",
"float",
"(",
... | Set the axes tick lengths in pixels | [
"Set",
"the",
"axes",
"tick",
"lengths",
"in",
"pixels"
] | 3926935e1f2100d8ba68070c2ab44055d4800f73 | https://github.com/rootpy/rootpy/blob/3926935e1f2100d8ba68070c2ab44055d4800f73/rootpy/plotting/utils.py#L436-L443 | train |
rootpy/rootpy | rootpy/tree/treetypes.py | BaseArray.reset | def reset(self):
"""Reset the value to the default"""
if self.resetable:
for i in range(len(self)):
self[i] = self.default | python | def reset(self):
"""Reset the value to the default"""
if self.resetable:
for i in range(len(self)):
self[i] = self.default | [
"def",
"reset",
"(",
"self",
")",
":",
"if",
"self",
".",
"resetable",
":",
"for",
"i",
"in",
"range",
"(",
"len",
"(",
"self",
")",
")",
":",
"self",
"[",
"i",
"]",
"=",
"self",
".",
"default"
] | Reset the value to the default | [
"Reset",
"the",
"value",
"to",
"the",
"default"
] | 3926935e1f2100d8ba68070c2ab44055d4800f73 | https://github.com/rootpy/rootpy/blob/3926935e1f2100d8ba68070c2ab44055d4800f73/rootpy/tree/treetypes.py#L210-L214 | train |
rootpy/rootpy | rootpy/stats/fit.py | minimize | def minimize(func,
minimizer_type=None,
minimizer_algo=None,
strategy=None,
retry=0,
scan=False,
print_level=None):
"""
Minimize a RooAbsReal function
Parameters
----------
func : RooAbsReal
The function to minim... | python | def minimize(func,
minimizer_type=None,
minimizer_algo=None,
strategy=None,
retry=0,
scan=False,
print_level=None):
"""
Minimize a RooAbsReal function
Parameters
----------
func : RooAbsReal
The function to minim... | [
"def",
"minimize",
"(",
"func",
",",
"minimizer_type",
"=",
"None",
",",
"minimizer_algo",
"=",
"None",
",",
"strategy",
"=",
"None",
",",
"retry",
"=",
"0",
",",
"scan",
"=",
"False",
",",
"print_level",
"=",
"None",
")",
":",
"llog",
"=",
"log",
"[... | Minimize a RooAbsReal function
Parameters
----------
func : RooAbsReal
The function to minimize
minimizer_type : string, optional (default=None)
The minimizer type: "Minuit" or "Minuit2".
If None (the default) then use the current global default value.
minimizer_algo : st... | [
"Minimize",
"a",
"RooAbsReal",
"function"
] | 3926935e1f2100d8ba68070c2ab44055d4800f73 | https://github.com/rootpy/rootpy/blob/3926935e1f2100d8ba68070c2ab44055d4800f73/rootpy/stats/fit.py#L15-L113 | train |
rootpy/rootpy | rootpy/stl.py | make_string | def make_string(obj):
"""
If ``obj`` is a string, return that, otherwise attempt to figure out the
name of a type.
"""
if inspect.isclass(obj):
if issubclass(obj, Object):
return obj._ROOT.__name__
if issubclass(obj, string_types):
return 'string'
retu... | python | def make_string(obj):
"""
If ``obj`` is a string, return that, otherwise attempt to figure out the
name of a type.
"""
if inspect.isclass(obj):
if issubclass(obj, Object):
return obj._ROOT.__name__
if issubclass(obj, string_types):
return 'string'
retu... | [
"def",
"make_string",
"(",
"obj",
")",
":",
"if",
"inspect",
".",
"isclass",
"(",
"obj",
")",
":",
"if",
"issubclass",
"(",
"obj",
",",
"Object",
")",
":",
"return",
"obj",
".",
"_ROOT",
".",
"__name__",
"if",
"issubclass",
"(",
"obj",
",",
"string_t... | If ``obj`` is a string, return that, otherwise attempt to figure out the
name of a type. | [
"If",
"obj",
"is",
"a",
"string",
"return",
"that",
"otherwise",
"attempt",
"to",
"figure",
"out",
"the",
"name",
"of",
"a",
"type",
"."
] | 3926935e1f2100d8ba68070c2ab44055d4800f73 | https://github.com/rootpy/rootpy/blob/3926935e1f2100d8ba68070c2ab44055d4800f73/rootpy/stl.py#L302-L315 | train |
rootpy/rootpy | rootpy/stl.py | generate | def generate(declaration, headers=None, has_iterators=False):
"""Compile and load the reflection dictionary for a type.
If the requested dictionary has already been cached, then load that instead.
Parameters
----------
declaration : str
A type declaration (for example "vector<int>")
he... | python | def generate(declaration, headers=None, has_iterators=False):
"""Compile and load the reflection dictionary for a type.
If the requested dictionary has already been cached, then load that instead.
Parameters
----------
declaration : str
A type declaration (for example "vector<int>")
he... | [
"def",
"generate",
"(",
"declaration",
",",
"headers",
"=",
"None",
",",
"has_iterators",
"=",
"False",
")",
":",
"global",
"NEW_DICTS",
"# FIXME: _rootpy_dictionary_already_exists returns false positives",
"# if a third-party module provides \"incomplete\" dictionaries.",
"#if c... | Compile and load the reflection dictionary for a type.
If the requested dictionary has already been cached, then load that instead.
Parameters
----------
declaration : str
A type declaration (for example "vector<int>")
headers : str or list of str
A header file or list of header fi... | [
"Compile",
"and",
"load",
"the",
"reflection",
"dictionary",
"for",
"a",
"type",
"."
] | 3926935e1f2100d8ba68070c2ab44055d4800f73 | https://github.com/rootpy/rootpy/blob/3926935e1f2100d8ba68070c2ab44055d4800f73/rootpy/stl.py#L318-L406 | train |
rootpy/rootpy | rootpy/stl.py | CPPType.ensure_built | def ensure_built(self, headers=None):
"""
Make sure that a dictionary exists for this type.
"""
if not self.params:
return
else:
for child in self.params:
child.ensure_built(headers=headers)
if headers is None:
headers =... | python | def ensure_built(self, headers=None):
"""
Make sure that a dictionary exists for this type.
"""
if not self.params:
return
else:
for child in self.params:
child.ensure_built(headers=headers)
if headers is None:
headers =... | [
"def",
"ensure_built",
"(",
"self",
",",
"headers",
"=",
"None",
")",
":",
"if",
"not",
"self",
".",
"params",
":",
"return",
"else",
":",
"for",
"child",
"in",
"self",
".",
"params",
":",
"child",
".",
"ensure_built",
"(",
"headers",
"=",
"headers",
... | Make sure that a dictionary exists for this type. | [
"Make",
"sure",
"that",
"a",
"dictionary",
"exists",
"for",
"this",
"type",
"."
] | 3926935e1f2100d8ba68070c2ab44055d4800f73 | https://github.com/rootpy/rootpy/blob/3926935e1f2100d8ba68070c2ab44055d4800f73/rootpy/stl.py#L202-L214 | train |
rootpy/rootpy | rootpy/stl.py | CPPType.guess_headers | def guess_headers(self):
"""
Attempt to guess what headers may be required in order to use this
type. Returns `guess_headers` of all children recursively.
* If the typename is in the :const:`KNOWN_TYPES` dictionary, use the
header specified there
* If it's an STL typ... | python | def guess_headers(self):
"""
Attempt to guess what headers may be required in order to use this
type. Returns `guess_headers` of all children recursively.
* If the typename is in the :const:`KNOWN_TYPES` dictionary, use the
header specified there
* If it's an STL typ... | [
"def",
"guess_headers",
"(",
"self",
")",
":",
"name",
"=",
"self",
".",
"name",
".",
"replace",
"(",
"\"*\"",
",",
"\"\"",
")",
"headers",
"=",
"[",
"]",
"if",
"name",
"in",
"KNOWN_TYPES",
":",
"headers",
".",
"append",
"(",
"KNOWN_TYPES",
"[",
"nam... | Attempt to guess what headers may be required in order to use this
type. Returns `guess_headers` of all children recursively.
* If the typename is in the :const:`KNOWN_TYPES` dictionary, use the
header specified there
* If it's an STL type, include <{type}>
* If it exists in... | [
"Attempt",
"to",
"guess",
"what",
"headers",
"may",
"be",
"required",
"in",
"order",
"to",
"use",
"this",
"type",
".",
"Returns",
"guess_headers",
"of",
"all",
"children",
"recursively",
"."
] | 3926935e1f2100d8ba68070c2ab44055d4800f73 | https://github.com/rootpy/rootpy/blob/3926935e1f2100d8ba68070c2ab44055d4800f73/rootpy/stl.py#L217-L252 | train |
rootpy/rootpy | rootpy/stl.py | CPPType.cls | def cls(self):
"""
Return the class definition for this type
"""
# TODO: register the resulting type?
return SmartTemplate(self.name)(", ".join(map(str, self.params))) | python | def cls(self):
"""
Return the class definition for this type
"""
# TODO: register the resulting type?
return SmartTemplate(self.name)(", ".join(map(str, self.params))) | [
"def",
"cls",
"(",
"self",
")",
":",
"# TODO: register the resulting type?",
"return",
"SmartTemplate",
"(",
"self",
".",
"name",
")",
"(",
"\", \"",
".",
"join",
"(",
"map",
"(",
"str",
",",
"self",
".",
"params",
")",
")",
")"
] | Return the class definition for this type | [
"Return",
"the",
"class",
"definition",
"for",
"this",
"type"
] | 3926935e1f2100d8ba68070c2ab44055d4800f73 | https://github.com/rootpy/rootpy/blob/3926935e1f2100d8ba68070c2ab44055d4800f73/rootpy/stl.py#L255-L260 | train |
rootpy/rootpy | rootpy/stl.py | CPPType.from_string | def from_string(cls, string):
"""
Parse ``string`` into a CPPType instance
"""
cls.TYPE.setParseAction(cls.make)
try:
return cls.TYPE.parseString(string, parseAll=True)[0]
except ParseException:
log.error("Failed to parse '{0}'".format(string))
... | python | def from_string(cls, string):
"""
Parse ``string`` into a CPPType instance
"""
cls.TYPE.setParseAction(cls.make)
try:
return cls.TYPE.parseString(string, parseAll=True)[0]
except ParseException:
log.error("Failed to parse '{0}'".format(string))
... | [
"def",
"from_string",
"(",
"cls",
",",
"string",
")",
":",
"cls",
".",
"TYPE",
".",
"setParseAction",
"(",
"cls",
".",
"make",
")",
"try",
":",
"return",
"cls",
".",
"TYPE",
".",
"parseString",
"(",
"string",
",",
"parseAll",
"=",
"True",
")",
"[",
... | Parse ``string`` into a CPPType instance | [
"Parse",
"string",
"into",
"a",
"CPPType",
"instance"
] | 3926935e1f2100d8ba68070c2ab44055d4800f73 | https://github.com/rootpy/rootpy/blob/3926935e1f2100d8ba68070c2ab44055d4800f73/rootpy/stl.py#L275-L284 | train |
rootpy/rootpy | rootpy/utils/cinterface.py | callback | def callback(cfunc):
"""
Turn a ctypes CFUNCTYPE instance into a value which can be passed into PyROOT
"""
# Note:
# ROOT wants a c_voidp whose addressof() == the call site of the target
# function. This hackery is necessary to achieve that.
return C.c_voidp.from_address(C.cast(cfunc, C.c_vo... | python | def callback(cfunc):
"""
Turn a ctypes CFUNCTYPE instance into a value which can be passed into PyROOT
"""
# Note:
# ROOT wants a c_voidp whose addressof() == the call site of the target
# function. This hackery is necessary to achieve that.
return C.c_voidp.from_address(C.cast(cfunc, C.c_vo... | [
"def",
"callback",
"(",
"cfunc",
")",
":",
"# Note:",
"# ROOT wants a c_voidp whose addressof() == the call site of the target",
"# function. This hackery is necessary to achieve that.",
"return",
"C",
".",
"c_voidp",
".",
"from_address",
"(",
"C",
".",
"cast",
"(",
"cfunc",
... | Turn a ctypes CFUNCTYPE instance into a value which can be passed into PyROOT | [
"Turn",
"a",
"ctypes",
"CFUNCTYPE",
"instance",
"into",
"a",
"value",
"which",
"can",
"be",
"passed",
"into",
"PyROOT"
] | 3926935e1f2100d8ba68070c2ab44055d4800f73 | https://github.com/rootpy/rootpy/blob/3926935e1f2100d8ba68070c2ab44055d4800f73/rootpy/utils/cinterface.py#L21-L28 | train |
rootpy/rootpy | rootpy/utils/cinterface.py | objectproxy_realaddress | def objectproxy_realaddress(obj):
"""
Obtain a real address as an integer from an objectproxy.
"""
voidp = QROOT.TPython.ObjectProxy_AsVoidPtr(obj)
return C.addressof(C.c_char.from_buffer(voidp)) | python | def objectproxy_realaddress(obj):
"""
Obtain a real address as an integer from an objectproxy.
"""
voidp = QROOT.TPython.ObjectProxy_AsVoidPtr(obj)
return C.addressof(C.c_char.from_buffer(voidp)) | [
"def",
"objectproxy_realaddress",
"(",
"obj",
")",
":",
"voidp",
"=",
"QROOT",
".",
"TPython",
".",
"ObjectProxy_AsVoidPtr",
"(",
"obj",
")",
"return",
"C",
".",
"addressof",
"(",
"C",
".",
"c_char",
".",
"from_buffer",
"(",
"voidp",
")",
")"
] | Obtain a real address as an integer from an objectproxy. | [
"Obtain",
"a",
"real",
"address",
"as",
"an",
"integer",
"from",
"an",
"objectproxy",
"."
] | 3926935e1f2100d8ba68070c2ab44055d4800f73 | https://github.com/rootpy/rootpy/blob/3926935e1f2100d8ba68070c2ab44055d4800f73/rootpy/utils/cinterface.py#L31-L36 | train |
rootpy/rootpy | rootpy/plotting/style/__init__.py | set_style | def set_style(style, mpl=False, **kwargs):
"""
If mpl is False accept either style name or a TStyle instance.
If mpl is True accept either style name or a matplotlib.rcParams-like
dictionary
"""
if mpl:
import matplotlib as mpl
style_dictionary = {}
if isinstance(style, ... | python | def set_style(style, mpl=False, **kwargs):
"""
If mpl is False accept either style name or a TStyle instance.
If mpl is True accept either style name or a matplotlib.rcParams-like
dictionary
"""
if mpl:
import matplotlib as mpl
style_dictionary = {}
if isinstance(style, ... | [
"def",
"set_style",
"(",
"style",
",",
"mpl",
"=",
"False",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"mpl",
":",
"import",
"matplotlib",
"as",
"mpl",
"style_dictionary",
"=",
"{",
"}",
"if",
"isinstance",
"(",
"style",
",",
"string_types",
")",
":",
... | If mpl is False accept either style name or a TStyle instance.
If mpl is True accept either style name or a matplotlib.rcParams-like
dictionary | [
"If",
"mpl",
"is",
"False",
"accept",
"either",
"style",
"name",
"or",
"a",
"TStyle",
"instance",
".",
"If",
"mpl",
"is",
"True",
"accept",
"either",
"style",
"name",
"or",
"a",
"matplotlib",
".",
"rcParams",
"-",
"like",
"dictionary"
] | 3926935e1f2100d8ba68070c2ab44055d4800f73 | https://github.com/rootpy/rootpy/blob/3926935e1f2100d8ba68070c2ab44055d4800f73/rootpy/plotting/style/__init__.py#L56-L80 | train |
rootpy/rootpy | rootpy/io/file.py | _DirectoryBase.cd_previous | def cd_previous(self):
"""
cd to the gDirectory before this file was open.
"""
if self._prev_dir is None or isinstance(self._prev_dir, ROOT.TROOT):
return False
if isinstance(self._prev_dir, ROOT.TFile):
if self._prev_dir.IsOpen() and self._prev_dir.IsWrit... | python | def cd_previous(self):
"""
cd to the gDirectory before this file was open.
"""
if self._prev_dir is None or isinstance(self._prev_dir, ROOT.TROOT):
return False
if isinstance(self._prev_dir, ROOT.TFile):
if self._prev_dir.IsOpen() and self._prev_dir.IsWrit... | [
"def",
"cd_previous",
"(",
"self",
")",
":",
"if",
"self",
".",
"_prev_dir",
"is",
"None",
"or",
"isinstance",
"(",
"self",
".",
"_prev_dir",
",",
"ROOT",
".",
"TROOT",
")",
":",
"return",
"False",
"if",
"isinstance",
"(",
"self",
".",
"_prev_dir",
","... | cd to the gDirectory before this file was open. | [
"cd",
"to",
"the",
"gDirectory",
"before",
"this",
"file",
"was",
"open",
"."
] | 3926935e1f2100d8ba68070c2ab44055d4800f73 | https://github.com/rootpy/rootpy/blob/3926935e1f2100d8ba68070c2ab44055d4800f73/rootpy/io/file.py#L229-L247 | train |
rootpy/rootpy | rootpy/io/file.py | _DirectoryBase.Close | def Close(self, *args):
"""
Like ROOT's Close but reverts to the gDirectory before this file was
opened.
"""
super(_DirectoryBase, self).Close(*args)
return self.cd_previous() | python | def Close(self, *args):
"""
Like ROOT's Close but reverts to the gDirectory before this file was
opened.
"""
super(_DirectoryBase, self).Close(*args)
return self.cd_previous() | [
"def",
"Close",
"(",
"self",
",",
"*",
"args",
")",
":",
"super",
"(",
"_DirectoryBase",
",",
"self",
")",
".",
"Close",
"(",
"*",
"args",
")",
"return",
"self",
".",
"cd_previous",
"(",
")"
] | Like ROOT's Close but reverts to the gDirectory before this file was
opened. | [
"Like",
"ROOT",
"s",
"Close",
"but",
"reverts",
"to",
"the",
"gDirectory",
"before",
"this",
"file",
"was",
"opened",
"."
] | 3926935e1f2100d8ba68070c2ab44055d4800f73 | https://github.com/rootpy/rootpy/blob/3926935e1f2100d8ba68070c2ab44055d4800f73/rootpy/io/file.py#L249-L255 | train |
rootpy/rootpy | rootpy/io/file.py | _DirectoryBase.keys | def keys(self, latest=False):
"""
Return a list of the keys in this directory.
Parameters
----------
latest : bool, optional (default=False)
If True then return a list of keys with unique names where only the
key with the highest cycle number is included... | python | def keys(self, latest=False):
"""
Return a list of the keys in this directory.
Parameters
----------
latest : bool, optional (default=False)
If True then return a list of keys with unique names where only the
key with the highest cycle number is included... | [
"def",
"keys",
"(",
"self",
",",
"latest",
"=",
"False",
")",
":",
"if",
"latest",
":",
"keys",
"=",
"{",
"}",
"for",
"key",
"in",
"self",
".",
"keys",
"(",
")",
":",
"name",
"=",
"key",
".",
"GetName",
"(",
")",
"if",
"name",
"in",
"keys",
"... | Return a list of the keys in this directory.
Parameters
----------
latest : bool, optional (default=False)
If True then return a list of keys with unique names where only the
key with the highest cycle number is included where multiple keys
exist with the sa... | [
"Return",
"a",
"list",
"of",
"the",
"keys",
"in",
"this",
"directory",
"."
] | 3926935e1f2100d8ba68070c2ab44055d4800f73 | https://github.com/rootpy/rootpy/blob/3926935e1f2100d8ba68070c2ab44055d4800f73/rootpy/io/file.py#L289-L318 | train |
rootpy/rootpy | rootpy/io/file.py | _DirectoryBase.Get | def Get(self, path, rootpy=True, **kwargs):
"""
Return the requested object cast as its corresponding subclass in
rootpy if one exists and ``rootpy=True``, otherwise return the
unadulterated TObject.
"""
thing = super(_DirectoryBase, self).Get(path)
if not thing:
... | python | def Get(self, path, rootpy=True, **kwargs):
"""
Return the requested object cast as its corresponding subclass in
rootpy if one exists and ``rootpy=True``, otherwise return the
unadulterated TObject.
"""
thing = super(_DirectoryBase, self).Get(path)
if not thing:
... | [
"def",
"Get",
"(",
"self",
",",
"path",
",",
"rootpy",
"=",
"True",
",",
"*",
"*",
"kwargs",
")",
":",
"thing",
"=",
"super",
"(",
"_DirectoryBase",
",",
"self",
")",
".",
"Get",
"(",
"path",
")",
"if",
"not",
"thing",
":",
"raise",
"DoesNotExist",... | Return the requested object cast as its corresponding subclass in
rootpy if one exists and ``rootpy=True``, otherwise return the
unadulterated TObject. | [
"Return",
"the",
"requested",
"object",
"cast",
"as",
"its",
"corresponding",
"subclass",
"in",
"rootpy",
"if",
"one",
"exists",
"and",
"rootpy",
"=",
"True",
"otherwise",
"return",
"the",
"unadulterated",
"TObject",
"."
] | 3926935e1f2100d8ba68070c2ab44055d4800f73 | https://github.com/rootpy/rootpy/blob/3926935e1f2100d8ba68070c2ab44055d4800f73/rootpy/io/file.py#L321-L348 | train |
rootpy/rootpy | rootpy/io/file.py | _DirectoryBase.GetKey | def GetKey(self, path, cycle=9999, rootpy=True, **kwargs):
"""
Override TDirectory's GetKey and also handle accessing keys nested
arbitrarily deep in subdirectories.
"""
key = super(_DirectoryBase, self).GetKey(path, cycle)
if not key:
raise DoesNotExist
... | python | def GetKey(self, path, cycle=9999, rootpy=True, **kwargs):
"""
Override TDirectory's GetKey and also handle accessing keys nested
arbitrarily deep in subdirectories.
"""
key = super(_DirectoryBase, self).GetKey(path, cycle)
if not key:
raise DoesNotExist
... | [
"def",
"GetKey",
"(",
"self",
",",
"path",
",",
"cycle",
"=",
"9999",
",",
"rootpy",
"=",
"True",
",",
"*",
"*",
"kwargs",
")",
":",
"key",
"=",
"super",
"(",
"_DirectoryBase",
",",
"self",
")",
".",
"GetKey",
"(",
"path",
",",
"cycle",
")",
"if"... | Override TDirectory's GetKey and also handle accessing keys nested
arbitrarily deep in subdirectories. | [
"Override",
"TDirectory",
"s",
"GetKey",
"and",
"also",
"handle",
"accessing",
"keys",
"nested",
"arbitrarily",
"deep",
"in",
"subdirectories",
"."
] | 3926935e1f2100d8ba68070c2ab44055d4800f73 | https://github.com/rootpy/rootpy/blob/3926935e1f2100d8ba68070c2ab44055d4800f73/rootpy/io/file.py#L360-L370 | train |
rootpy/rootpy | rootpy/io/file.py | _DirectoryBase.mkdir | def mkdir(self, path, title="", recurse=False):
"""
Make a new directory. If recurse is True, create parent directories
as required. Return the newly created TDirectory.
"""
head, tail = os.path.split(os.path.normpath(path))
if tail == "":
raise ValueError("in... | python | def mkdir(self, path, title="", recurse=False):
"""
Make a new directory. If recurse is True, create parent directories
as required. Return the newly created TDirectory.
"""
head, tail = os.path.split(os.path.normpath(path))
if tail == "":
raise ValueError("in... | [
"def",
"mkdir",
"(",
"self",
",",
"path",
",",
"title",
"=",
"\"\"",
",",
"recurse",
"=",
"False",
")",
":",
"head",
",",
"tail",
"=",
"os",
".",
"path",
".",
"split",
"(",
"os",
".",
"path",
".",
"normpath",
"(",
"path",
")",
")",
"if",
"tail"... | Make a new directory. If recurse is True, create parent directories
as required. Return the newly created TDirectory. | [
"Make",
"a",
"new",
"directory",
".",
"If",
"recurse",
"is",
"True",
"create",
"parent",
"directories",
"as",
"required",
".",
"Return",
"the",
"newly",
"created",
"TDirectory",
"."
] | 3926935e1f2100d8ba68070c2ab44055d4800f73 | https://github.com/rootpy/rootpy/blob/3926935e1f2100d8ba68070c2ab44055d4800f73/rootpy/io/file.py#L385-L408 | train |
rootpy/rootpy | rootpy/io/file.py | _DirectoryBase.rm | def rm(self, path, cycle=';*'):
"""
Delete an object at `path` relative to this directory
"""
rdir = self
with preserve_current_directory():
dirname, objname = os.path.split(os.path.normpath(path))
if dirname:
rdir = rdir.Get(dirname)
... | python | def rm(self, path, cycle=';*'):
"""
Delete an object at `path` relative to this directory
"""
rdir = self
with preserve_current_directory():
dirname, objname = os.path.split(os.path.normpath(path))
if dirname:
rdir = rdir.Get(dirname)
... | [
"def",
"rm",
"(",
"self",
",",
"path",
",",
"cycle",
"=",
"';*'",
")",
":",
"rdir",
"=",
"self",
"with",
"preserve_current_directory",
"(",
")",
":",
"dirname",
",",
"objname",
"=",
"os",
".",
"path",
".",
"split",
"(",
"os",
".",
"path",
".",
"nor... | Delete an object at `path` relative to this directory | [
"Delete",
"an",
"object",
"at",
"path",
"relative",
"to",
"this",
"directory"
] | 3926935e1f2100d8ba68070c2ab44055d4800f73 | https://github.com/rootpy/rootpy/blob/3926935e1f2100d8ba68070c2ab44055d4800f73/rootpy/io/file.py#L410-L419 | train |
rootpy/rootpy | rootpy/io/file.py | _DirectoryBase.copytree | def copytree(self, dest_dir, src=None, newname=None,
exclude=None, overwrite=False):
"""
Copy this directory or just one contained object into another
directory.
Parameters
----------
dest_dir : string or Directory
The destination directory.... | python | def copytree(self, dest_dir, src=None, newname=None,
exclude=None, overwrite=False):
"""
Copy this directory or just one contained object into another
directory.
Parameters
----------
dest_dir : string or Directory
The destination directory.... | [
"def",
"copytree",
"(",
"self",
",",
"dest_dir",
",",
"src",
"=",
"None",
",",
"newname",
"=",
"None",
",",
"exclude",
"=",
"None",
",",
"overwrite",
"=",
"False",
")",
":",
"def",
"copy_object",
"(",
"obj",
",",
"dest",
",",
"name",
"=",
"None",
"... | Copy this directory or just one contained object into another
directory.
Parameters
----------
dest_dir : string or Directory
The destination directory.
src : string, optional (default=None)
If ``src`` is None then this entire directory is copied recurs... | [
"Copy",
"this",
"directory",
"or",
"just",
"one",
"contained",
"object",
"into",
"another",
"directory",
"."
] | 3926935e1f2100d8ba68070c2ab44055d4800f73 | https://github.com/rootpy/rootpy/blob/3926935e1f2100d8ba68070c2ab44055d4800f73/rootpy/io/file.py#L424-L506 | train |
rootpy/rootpy | rootpy/io/file.py | _FileBase.find | def find(self,
regexp, negate_regexp=False,
class_pattern=None,
find_fnc=re.search,
refresh_cache=False):
"""
yield the full path of the matching regular expression and the
match itself
"""
if refresh_cache or not hasattr(self, ... | python | def find(self,
regexp, negate_regexp=False,
class_pattern=None,
find_fnc=re.search,
refresh_cache=False):
"""
yield the full path of the matching regular expression and the
match itself
"""
if refresh_cache or not hasattr(self, ... | [
"def",
"find",
"(",
"self",
",",
"regexp",
",",
"negate_regexp",
"=",
"False",
",",
"class_pattern",
"=",
"None",
",",
"find_fnc",
"=",
"re",
".",
"search",
",",
"refresh_cache",
"=",
"False",
")",
":",
"if",
"refresh_cache",
"or",
"not",
"hasattr",
"(",... | yield the full path of the matching regular expression and the
match itself | [
"yield",
"the",
"full",
"path",
"of",
"the",
"matching",
"regular",
"expression",
"and",
"the",
"match",
"itself"
] | 3926935e1f2100d8ba68070c2ab44055d4800f73 | https://github.com/rootpy/rootpy/blob/3926935e1f2100d8ba68070c2ab44055d4800f73/rootpy/io/file.py#L696-L730 | train |
rootpy/rootpy | rootpy/interactive/rootwait.py | start_new_gui_thread | def start_new_gui_thread():
"""
Attempt to start a new GUI thread, if possible.
It is only possible to start one if there was one running on module import.
"""
PyGUIThread = getattr(ROOT, 'PyGUIThread', None)
if PyGUIThread is not None:
assert not PyGUIThread.isAlive(), "GUI thread alr... | python | def start_new_gui_thread():
"""
Attempt to start a new GUI thread, if possible.
It is only possible to start one if there was one running on module import.
"""
PyGUIThread = getattr(ROOT, 'PyGUIThread', None)
if PyGUIThread is not None:
assert not PyGUIThread.isAlive(), "GUI thread alr... | [
"def",
"start_new_gui_thread",
"(",
")",
":",
"PyGUIThread",
"=",
"getattr",
"(",
"ROOT",
",",
"'PyGUIThread'",
",",
"None",
")",
"if",
"PyGUIThread",
"is",
"not",
"None",
":",
"assert",
"not",
"PyGUIThread",
".",
"isAlive",
"(",
")",
",",
"\"GUI thread alre... | Attempt to start a new GUI thread, if possible.
It is only possible to start one if there was one running on module import. | [
"Attempt",
"to",
"start",
"a",
"new",
"GUI",
"thread",
"if",
"possible",
"."
] | 3926935e1f2100d8ba68070c2ab44055d4800f73 | https://github.com/rootpy/rootpy/blob/3926935e1f2100d8ba68070c2ab44055d4800f73/rootpy/interactive/rootwait.py#L85-L107 | train |
rootpy/rootpy | rootpy/interactive/rootwait.py | stop_gui_thread | def stop_gui_thread():
"""
Try to stop the GUI thread. If it was running returns True,
otherwise False.
"""
PyGUIThread = getattr(ROOT, 'PyGUIThread', None)
if PyGUIThread is None or not PyGUIThread.isAlive():
log.debug("no existing GUI thread is runnng")
return False
ROOT.... | python | def stop_gui_thread():
"""
Try to stop the GUI thread. If it was running returns True,
otherwise False.
"""
PyGUIThread = getattr(ROOT, 'PyGUIThread', None)
if PyGUIThread is None or not PyGUIThread.isAlive():
log.debug("no existing GUI thread is runnng")
return False
ROOT.... | [
"def",
"stop_gui_thread",
"(",
")",
":",
"PyGUIThread",
"=",
"getattr",
"(",
"ROOT",
",",
"'PyGUIThread'",
",",
"None",
")",
"if",
"PyGUIThread",
"is",
"None",
"or",
"not",
"PyGUIThread",
".",
"isAlive",
"(",
")",
":",
"log",
".",
"debug",
"(",
"\"no exi... | Try to stop the GUI thread. If it was running returns True,
otherwise False. | [
"Try",
"to",
"stop",
"the",
"GUI",
"thread",
".",
"If",
"it",
"was",
"running",
"returns",
"True",
"otherwise",
"False",
"."
] | 3926935e1f2100d8ba68070c2ab44055d4800f73 | https://github.com/rootpy/rootpy/blob/3926935e1f2100d8ba68070c2ab44055d4800f73/rootpy/interactive/rootwait.py#L110-L129 | train |
rootpy/rootpy | rootpy/interactive/rootwait.py | wait_for_zero_canvases | def wait_for_zero_canvases(middle_mouse_close=False):
"""
Wait for all canvases to be closed, or CTRL-c.
If `middle_mouse_close`, middle click will shut the canvas.
incpy.ignore
"""
if not __ACTIVE:
wait_failover(wait_for_zero_canvases)
return
@dispatcher
def count_can... | python | def wait_for_zero_canvases(middle_mouse_close=False):
"""
Wait for all canvases to be closed, or CTRL-c.
If `middle_mouse_close`, middle click will shut the canvas.
incpy.ignore
"""
if not __ACTIVE:
wait_failover(wait_for_zero_canvases)
return
@dispatcher
def count_can... | [
"def",
"wait_for_zero_canvases",
"(",
"middle_mouse_close",
"=",
"False",
")",
":",
"if",
"not",
"__ACTIVE",
":",
"wait_failover",
"(",
"wait_for_zero_canvases",
")",
"return",
"@",
"dispatcher",
"def",
"count_canvases",
"(",
")",
":",
"\"\"\"\n Count the numbe... | Wait for all canvases to be closed, or CTRL-c.
If `middle_mouse_close`, middle click will shut the canvas.
incpy.ignore | [
"Wait",
"for",
"all",
"canvases",
"to",
"be",
"closed",
"or",
"CTRL",
"-",
"c",
"."
] | 3926935e1f2100d8ba68070c2ab44055d4800f73 | https://github.com/rootpy/rootpy/blob/3926935e1f2100d8ba68070c2ab44055d4800f73/rootpy/interactive/rootwait.py#L161-L226 | train |
rootpy/rootpy | rootpy/interactive/rootwait.py | wait_for_frame | def wait_for_frame(frame):
"""
wait until a TGMainFrame is closed or ctrl-c
"""
if not frame:
# It's already closed or maybe we're in batch mode
return
@dispatcher
def close():
ROOT.gSystem.ExitLoop()
if not getattr(frame, "_py_close_dispatcher_attached", False):
... | python | def wait_for_frame(frame):
"""
wait until a TGMainFrame is closed or ctrl-c
"""
if not frame:
# It's already closed or maybe we're in batch mode
return
@dispatcher
def close():
ROOT.gSystem.ExitLoop()
if not getattr(frame, "_py_close_dispatcher_attached", False):
... | [
"def",
"wait_for_frame",
"(",
"frame",
")",
":",
"if",
"not",
"frame",
":",
"# It's already closed or maybe we're in batch mode",
"return",
"@",
"dispatcher",
"def",
"close",
"(",
")",
":",
"ROOT",
".",
"gSystem",
".",
"ExitLoop",
"(",
")",
"if",
"not",
"getat... | wait until a TGMainFrame is closed or ctrl-c | [
"wait",
"until",
"a",
"TGMainFrame",
"is",
"closed",
"or",
"ctrl",
"-",
"c"
] | 3926935e1f2100d8ba68070c2ab44055d4800f73 | https://github.com/rootpy/rootpy/blob/3926935e1f2100d8ba68070c2ab44055d4800f73/rootpy/interactive/rootwait.py#L231-L266 | train |
rootpy/rootpy | rootpy/interactive/rootwait.py | wait_for_browser_close | def wait_for_browser_close(b):
"""
Can be used to wait until a TBrowser is closed
"""
if b:
if not __ACTIVE:
wait_failover(wait_for_browser_close)
return
wait_for_frame(b.GetBrowserImp().GetMainFrame()) | python | def wait_for_browser_close(b):
"""
Can be used to wait until a TBrowser is closed
"""
if b:
if not __ACTIVE:
wait_failover(wait_for_browser_close)
return
wait_for_frame(b.GetBrowserImp().GetMainFrame()) | [
"def",
"wait_for_browser_close",
"(",
"b",
")",
":",
"if",
"b",
":",
"if",
"not",
"__ACTIVE",
":",
"wait_failover",
"(",
"wait_for_browser_close",
")",
"return",
"wait_for_frame",
"(",
"b",
".",
"GetBrowserImp",
"(",
")",
".",
"GetMainFrame",
"(",
")",
")"
] | Can be used to wait until a TBrowser is closed | [
"Can",
"be",
"used",
"to",
"wait",
"until",
"a",
"TBrowser",
"is",
"closed"
] | 3926935e1f2100d8ba68070c2ab44055d4800f73 | https://github.com/rootpy/rootpy/blob/3926935e1f2100d8ba68070c2ab44055d4800f73/rootpy/interactive/rootwait.py#L269-L277 | train |
rootpy/rootpy | rootpy/logger/__init__.py | log_trace | def log_trace(logger, level=logging.DEBUG, show_enter=True, show_exit=True):
"""
log a statement on function entry and exit
"""
def wrap(function):
l = logger.getChild(function.__name__).log
@wraps(function)
def thunk(*args, **kwargs):
global trace_depth
t... | python | def log_trace(logger, level=logging.DEBUG, show_enter=True, show_exit=True):
"""
log a statement on function entry and exit
"""
def wrap(function):
l = logger.getChild(function.__name__).log
@wraps(function)
def thunk(*args, **kwargs):
global trace_depth
t... | [
"def",
"log_trace",
"(",
"logger",
",",
"level",
"=",
"logging",
".",
"DEBUG",
",",
"show_enter",
"=",
"True",
",",
"show_exit",
"=",
"True",
")",
":",
"def",
"wrap",
"(",
"function",
")",
":",
"l",
"=",
"logger",
".",
"getChild",
"(",
"function",
".... | log a statement on function entry and exit | [
"log",
"a",
"statement",
"on",
"function",
"entry",
"and",
"exit"
] | 3926935e1f2100d8ba68070c2ab44055d4800f73 | https://github.com/rootpy/rootpy/blob/3926935e1f2100d8ba68070c2ab44055d4800f73/rootpy/logger/__init__.py#L140-L168 | train |
rootpy/rootpy | rootpy/logger/extended_logger.py | log_stack | def log_stack(logger, level=logging.INFO, limit=None, frame=None):
"""
Display the current stack on ``logger``.
This function is designed to be used during emission of log messages, so it
won't call itself.
"""
if showing_stack.inside:
return
showing_stack.inside = True
try:
... | python | def log_stack(logger, level=logging.INFO, limit=None, frame=None):
"""
Display the current stack on ``logger``.
This function is designed to be used during emission of log messages, so it
won't call itself.
"""
if showing_stack.inside:
return
showing_stack.inside = True
try:
... | [
"def",
"log_stack",
"(",
"logger",
",",
"level",
"=",
"logging",
".",
"INFO",
",",
"limit",
"=",
"None",
",",
"frame",
"=",
"None",
")",
":",
"if",
"showing_stack",
".",
"inside",
":",
"return",
"showing_stack",
".",
"inside",
"=",
"True",
"try",
":",
... | Display the current stack on ``logger``.
This function is designed to be used during emission of log messages, so it
won't call itself. | [
"Display",
"the",
"current",
"stack",
"on",
"logger",
"."
] | 3926935e1f2100d8ba68070c2ab44055d4800f73 | https://github.com/rootpy/rootpy/blob/3926935e1f2100d8ba68070c2ab44055d4800f73/rootpy/logger/extended_logger.py#L25-L42 | train |
rootpy/rootpy | rootpy/logger/extended_logger.py | ExtendedLogger.showdeletion | def showdeletion(self, *objects):
"""
Record a stack trace at the point when an ROOT TObject is deleted
"""
from ..memory import showdeletion as S
for o in objects:
S.monitor_object_cleanup(o) | python | def showdeletion(self, *objects):
"""
Record a stack trace at the point when an ROOT TObject is deleted
"""
from ..memory import showdeletion as S
for o in objects:
S.monitor_object_cleanup(o) | [
"def",
"showdeletion",
"(",
"self",
",",
"*",
"objects",
")",
":",
"from",
".",
".",
"memory",
"import",
"showdeletion",
"as",
"S",
"for",
"o",
"in",
"objects",
":",
"S",
".",
"monitor_object_cleanup",
"(",
"o",
")"
] | Record a stack trace at the point when an ROOT TObject is deleted | [
"Record",
"a",
"stack",
"trace",
"at",
"the",
"point",
"when",
"an",
"ROOT",
"TObject",
"is",
"deleted"
] | 3926935e1f2100d8ba68070c2ab44055d4800f73 | https://github.com/rootpy/rootpy/blob/3926935e1f2100d8ba68070c2ab44055d4800f73/rootpy/logger/extended_logger.py#L67-L73 | train |
rootpy/rootpy | rootpy/logger/extended_logger.py | ExtendedLogger.trace | def trace(self, level=logging.DEBUG, show_enter=True, show_exit=True):
"""
Functions decorated with this function show function entry and exit with
values, defaults to debug log level.
:param level: log severity to use for function tracing
:param show_enter: log function entry
... | python | def trace(self, level=logging.DEBUG, show_enter=True, show_exit=True):
"""
Functions decorated with this function show function entry and exit with
values, defaults to debug log level.
:param level: log severity to use for function tracing
:param show_enter: log function entry
... | [
"def",
"trace",
"(",
"self",
",",
"level",
"=",
"logging",
".",
"DEBUG",
",",
"show_enter",
"=",
"True",
",",
"show_exit",
"=",
"True",
")",
":",
"from",
".",
"import",
"log_trace",
"return",
"log_trace",
"(",
"self",
",",
"level",
",",
"show_enter",
"... | Functions decorated with this function show function entry and exit with
values, defaults to debug log level.
:param level: log severity to use for function tracing
:param show_enter: log function entry
:param show_enter: log function exit
Example use:
.. sourcecode:: ... | [
"Functions",
"decorated",
"with",
"this",
"function",
"show",
"function",
"entry",
"and",
"exit",
"with",
"values",
"defaults",
"to",
"debug",
"log",
"level",
"."
] | 3926935e1f2100d8ba68070c2ab44055d4800f73 | https://github.com/rootpy/rootpy/blob/3926935e1f2100d8ba68070c2ab44055d4800f73/rootpy/logger/extended_logger.py#L91-L127 | train |
rootpy/rootpy | rootpy/logger/extended_logger.py | ExtendedLogger.frame_unique | def frame_unique(f):
"""
A tuple representing a value which is unique to a given frame's line of
execution
"""
return f.f_code.co_filename, f.f_code.co_name, f.f_lineno | python | def frame_unique(f):
"""
A tuple representing a value which is unique to a given frame's line of
execution
"""
return f.f_code.co_filename, f.f_code.co_name, f.f_lineno | [
"def",
"frame_unique",
"(",
"f",
")",
":",
"return",
"f",
".",
"f_code",
".",
"co_filename",
",",
"f",
".",
"f_code",
".",
"co_name",
",",
"f",
".",
"f_lineno"
] | A tuple representing a value which is unique to a given frame's line of
execution | [
"A",
"tuple",
"representing",
"a",
"value",
"which",
"is",
"unique",
"to",
"a",
"given",
"frame",
"s",
"line",
"of",
"execution"
] | 3926935e1f2100d8ba68070c2ab44055d4800f73 | https://github.com/rootpy/rootpy/blob/3926935e1f2100d8ba68070c2ab44055d4800f73/rootpy/logger/extended_logger.py#L157-L162 | train |
rootpy/rootpy | rootpy/logger/extended_logger.py | ExtendedLogger.show_stack_depth | def show_stack_depth(self, record, frame):
"""
Compute the maximum stack depth to show requested by any hooks,
returning -1 if there are none matching, or if we've already emitted
one for the line of code referred to.
"""
logger = self
depths = [-1]
msg =... | python | def show_stack_depth(self, record, frame):
"""
Compute the maximum stack depth to show requested by any hooks,
returning -1 if there are none matching, or if we've already emitted
one for the line of code referred to.
"""
logger = self
depths = [-1]
msg =... | [
"def",
"show_stack_depth",
"(",
"self",
",",
"record",
",",
"frame",
")",
":",
"logger",
"=",
"self",
"depths",
"=",
"[",
"-",
"1",
"]",
"msg",
"=",
"record",
".",
"getMessage",
"(",
")",
"# For each logger in the hierarchy",
"while",
"logger",
":",
"to_ma... | Compute the maximum stack depth to show requested by any hooks,
returning -1 if there are none matching, or if we've already emitted
one for the line of code referred to. | [
"Compute",
"the",
"maximum",
"stack",
"depth",
"to",
"show",
"requested",
"by",
"any",
"hooks",
"returning",
"-",
"1",
"if",
"there",
"are",
"none",
"matching",
"or",
"if",
"we",
"ve",
"already",
"emitted",
"one",
"for",
"the",
"line",
"of",
"code",
"ref... | 3926935e1f2100d8ba68070c2ab44055d4800f73 | https://github.com/rootpy/rootpy/blob/3926935e1f2100d8ba68070c2ab44055d4800f73/rootpy/logger/extended_logger.py#L164-L193 | train |
rootpy/rootpy | rootpy/logger/extended_logger.py | ExtendedLogger.getChild | def getChild(self, suffix):
"""
Taken from CPython 2.7, modified to remove duplicate prefix and suffixes
"""
if suffix is None:
return self
if self.root is not self:
if suffix.startswith(self.name + "."):
# Remove duplicate prefix
... | python | def getChild(self, suffix):
"""
Taken from CPython 2.7, modified to remove duplicate prefix and suffixes
"""
if suffix is None:
return self
if self.root is not self:
if suffix.startswith(self.name + "."):
# Remove duplicate prefix
... | [
"def",
"getChild",
"(",
"self",
",",
"suffix",
")",
":",
"if",
"suffix",
"is",
"None",
":",
"return",
"self",
"if",
"self",
".",
"root",
"is",
"not",
"self",
":",
"if",
"suffix",
".",
"startswith",
"(",
"self",
".",
"name",
"+",
"\".\"",
")",
":",
... | Taken from CPython 2.7, modified to remove duplicate prefix and suffixes | [
"Taken",
"from",
"CPython",
"2",
".",
"7",
"modified",
"to",
"remove",
"duplicate",
"prefix",
"and",
"suffixes"
] | 3926935e1f2100d8ba68070c2ab44055d4800f73 | https://github.com/rootpy/rootpy/blob/3926935e1f2100d8ba68070c2ab44055d4800f73/rootpy/logger/extended_logger.py#L225-L241 | train |
rootpy/rootpy | rootpy/decorators.py | method_file_check | def method_file_check(f):
"""
A decorator to check that a TFile as been created before f is called.
This function can decorate methods.
This requires special treatment since in Python 3 unbound methods are
just functions: http://stackoverflow.com/a/3589335/1002176 but to get
consistent access t... | python | def method_file_check(f):
"""
A decorator to check that a TFile as been created before f is called.
This function can decorate methods.
This requires special treatment since in Python 3 unbound methods are
just functions: http://stackoverflow.com/a/3589335/1002176 but to get
consistent access t... | [
"def",
"method_file_check",
"(",
"f",
")",
":",
"@",
"wraps",
"(",
"f",
")",
"def",
"wrapper",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"curr_dir",
"=",
"ROOT",
".",
"gDirectory",
"if",
"isinstance",
"(",
"curr_dir",
",",
"... | A decorator to check that a TFile as been created before f is called.
This function can decorate methods.
This requires special treatment since in Python 3 unbound methods are
just functions: http://stackoverflow.com/a/3589335/1002176 but to get
consistent access to the class in both 2.x and 3.x, we ne... | [
"A",
"decorator",
"to",
"check",
"that",
"a",
"TFile",
"as",
"been",
"created",
"before",
"f",
"is",
"called",
".",
"This",
"function",
"can",
"decorate",
"methods",
"."
] | 3926935e1f2100d8ba68070c2ab44055d4800f73 | https://github.com/rootpy/rootpy/blob/3926935e1f2100d8ba68070c2ab44055d4800f73/rootpy/decorators.py#L64-L86 | train |
rootpy/rootpy | rootpy/decorators.py | chainable | def chainable(f):
"""
Decorator which causes a 'void' function to return self
Allows chaining of multiple modifier class methods.
"""
@wraps(f)
def wrapper(self, *args, **kwargs):
# perform action
f(self, *args, **kwargs)
# return reference to class.
return self
... | python | def chainable(f):
"""
Decorator which causes a 'void' function to return self
Allows chaining of multiple modifier class methods.
"""
@wraps(f)
def wrapper(self, *args, **kwargs):
# perform action
f(self, *args, **kwargs)
# return reference to class.
return self
... | [
"def",
"chainable",
"(",
"f",
")",
":",
"@",
"wraps",
"(",
"f",
")",
"def",
"wrapper",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"# perform action",
"f",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"# re... | Decorator which causes a 'void' function to return self
Allows chaining of multiple modifier class methods. | [
"Decorator",
"which",
"causes",
"a",
"void",
"function",
"to",
"return",
"self"
] | 3926935e1f2100d8ba68070c2ab44055d4800f73 | https://github.com/rootpy/rootpy/blob/3926935e1f2100d8ba68070c2ab44055d4800f73/rootpy/decorators.py#L103-L115 | train |
rootpy/rootpy | rootpy/decorators.py | snake_case_methods | def snake_case_methods(cls, debug=False):
"""
A class decorator adding snake_case methods
that alias capitalized ROOT methods. cls must subclass
a ROOT class and define the _ROOT class variable.
"""
if not CONVERT_SNAKE_CASE:
return cls
# get the ROOT base class
root_base = cls._... | python | def snake_case_methods(cls, debug=False):
"""
A class decorator adding snake_case methods
that alias capitalized ROOT methods. cls must subclass
a ROOT class and define the _ROOT class variable.
"""
if not CONVERT_SNAKE_CASE:
return cls
# get the ROOT base class
root_base = cls._... | [
"def",
"snake_case_methods",
"(",
"cls",
",",
"debug",
"=",
"False",
")",
":",
"if",
"not",
"CONVERT_SNAKE_CASE",
":",
"return",
"cls",
"# get the ROOT base class",
"root_base",
"=",
"cls",
".",
"_ROOT",
"members",
"=",
"inspect",
".",
"getmembers",
"(",
"root... | A class decorator adding snake_case methods
that alias capitalized ROOT methods. cls must subclass
a ROOT class and define the _ROOT class variable. | [
"A",
"class",
"decorator",
"adding",
"snake_case",
"methods",
"that",
"alias",
"capitalized",
"ROOT",
"methods",
".",
"cls",
"must",
"subclass",
"a",
"ROOT",
"class",
"and",
"define",
"the",
"_ROOT",
"class",
"variable",
"."
] | 3926935e1f2100d8ba68070c2ab44055d4800f73 | https://github.com/rootpy/rootpy/blob/3926935e1f2100d8ba68070c2ab44055d4800f73/rootpy/decorators.py#L131-L184 | train |
rootpy/rootpy | rootpy/decorators.py | sync | def sync(lock):
"""
A synchronization decorator
"""
def sync(f):
@wraps(f)
def new_function(*args, **kwargs):
lock.acquire()
try:
return f(*args, **kwargs)
finally:
lock.release()
return new_function
return s... | python | def sync(lock):
"""
A synchronization decorator
"""
def sync(f):
@wraps(f)
def new_function(*args, **kwargs):
lock.acquire()
try:
return f(*args, **kwargs)
finally:
lock.release()
return new_function
return s... | [
"def",
"sync",
"(",
"lock",
")",
":",
"def",
"sync",
"(",
"f",
")",
":",
"@",
"wraps",
"(",
"f",
")",
"def",
"new_function",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"lock",
".",
"acquire",
"(",
")",
"try",
":",
"return",
"f",
"("... | A synchronization decorator | [
"A",
"synchronization",
"decorator"
] | 3926935e1f2100d8ba68070c2ab44055d4800f73 | https://github.com/rootpy/rootpy/blob/3926935e1f2100d8ba68070c2ab44055d4800f73/rootpy/decorators.py#L187-L200 | train |
rootpy/rootpy | rootpy/stats/correlated_values.py | as_ufloat | def as_ufloat(roorealvar):
"""
Cast a `RooRealVar` to an `uncertainties.ufloat`
"""
if isinstance(roorealvar, (U.AffineScalarFunc, U.Variable)):
return roorealvar
return U.ufloat((roorealvar.getVal(), roorealvar.getError())) | python | def as_ufloat(roorealvar):
"""
Cast a `RooRealVar` to an `uncertainties.ufloat`
"""
if isinstance(roorealvar, (U.AffineScalarFunc, U.Variable)):
return roorealvar
return U.ufloat((roorealvar.getVal(), roorealvar.getError())) | [
"def",
"as_ufloat",
"(",
"roorealvar",
")",
":",
"if",
"isinstance",
"(",
"roorealvar",
",",
"(",
"U",
".",
"AffineScalarFunc",
",",
"U",
".",
"Variable",
")",
")",
":",
"return",
"roorealvar",
"return",
"U",
".",
"ufloat",
"(",
"(",
"roorealvar",
".",
... | Cast a `RooRealVar` to an `uncertainties.ufloat` | [
"Cast",
"a",
"RooRealVar",
"to",
"an",
"uncertainties",
".",
"ufloat"
] | 3926935e1f2100d8ba68070c2ab44055d4800f73 | https://github.com/rootpy/rootpy/blob/3926935e1f2100d8ba68070c2ab44055d4800f73/rootpy/stats/correlated_values.py#L13-L19 | train |
rootpy/rootpy | rootpy/stats/correlated_values.py | correlated_values | def correlated_values(param_names, roofitresult):
"""
Return symbolic values from a `RooFitResult` taking into account covariance
This is useful for numerically computing the uncertainties for expressions
using correlated values arising from a fit.
Parameters
----------
param_names: list ... | python | def correlated_values(param_names, roofitresult):
"""
Return symbolic values from a `RooFitResult` taking into account covariance
This is useful for numerically computing the uncertainties for expressions
using correlated values arising from a fit.
Parameters
----------
param_names: list ... | [
"def",
"correlated_values",
"(",
"param_names",
",",
"roofitresult",
")",
":",
"pars",
"=",
"roofitresult",
".",
"floatParsFinal",
"(",
")",
"#pars.Print()",
"pars",
"=",
"[",
"pars",
"[",
"i",
"]",
"for",
"i",
"in",
"range",
"(",
"pars",
".",
"getSize",
... | Return symbolic values from a `RooFitResult` taking into account covariance
This is useful for numerically computing the uncertainties for expressions
using correlated values arising from a fit.
Parameters
----------
param_names: list of strings
A list of parameters to extract from the re... | [
"Return",
"symbolic",
"values",
"from",
"a",
"RooFitResult",
"taking",
"into",
"account",
"covariance"
] | 3926935e1f2100d8ba68070c2ab44055d4800f73 | https://github.com/rootpy/rootpy/blob/3926935e1f2100d8ba68070c2ab44055d4800f73/rootpy/stats/correlated_values.py#L22-L75 | train |
rootpy/rootpy | rootpy/tree/treemodel.py | TreeModelMeta.checkattr | def checkattr(metacls, attr, value):
"""
Only allow class attributes that are instances of
rootpy.types.Column, ROOT.TObject, or ROOT.ObjectProxy
"""
if not isinstance(value, (
types.MethodType,
types.FunctionType,
classmethod,
... | python | def checkattr(metacls, attr, value):
"""
Only allow class attributes that are instances of
rootpy.types.Column, ROOT.TObject, or ROOT.ObjectProxy
"""
if not isinstance(value, (
types.MethodType,
types.FunctionType,
classmethod,
... | [
"def",
"checkattr",
"(",
"metacls",
",",
"attr",
",",
"value",
")",
":",
"if",
"not",
"isinstance",
"(",
"value",
",",
"(",
"types",
".",
"MethodType",
",",
"types",
".",
"FunctionType",
",",
"classmethod",
",",
"staticmethod",
",",
"property",
")",
")",... | Only allow class attributes that are instances of
rootpy.types.Column, ROOT.TObject, or ROOT.ObjectProxy | [
"Only",
"allow",
"class",
"attributes",
"that",
"are",
"instances",
"of",
"rootpy",
".",
"types",
".",
"Column",
"ROOT",
".",
"TObject",
"or",
"ROOT",
".",
"ObjectProxy"
] | 3926935e1f2100d8ba68070c2ab44055d4800f73 | https://github.com/rootpy/rootpy/blob/3926935e1f2100d8ba68070c2ab44055d4800f73/rootpy/tree/treemodel.py#L53-L82 | train |
rootpy/rootpy | rootpy/tree/treemodel.py | TreeModelMeta.prefix | def prefix(cls, name):
"""
Create a new TreeModel where class attribute
names are prefixed with ``name``
"""
attrs = dict([(name + attr, value) for attr, value in cls.get_attrs()])
return TreeModelMeta(
'_'.join([name, cls.__name__]),
(TreeModel,),... | python | def prefix(cls, name):
"""
Create a new TreeModel where class attribute
names are prefixed with ``name``
"""
attrs = dict([(name + attr, value) for attr, value in cls.get_attrs()])
return TreeModelMeta(
'_'.join([name, cls.__name__]),
(TreeModel,),... | [
"def",
"prefix",
"(",
"cls",
",",
"name",
")",
":",
"attrs",
"=",
"dict",
"(",
"[",
"(",
"name",
"+",
"attr",
",",
"value",
")",
"for",
"attr",
",",
"value",
"in",
"cls",
".",
"get_attrs",
"(",
")",
"]",
")",
"return",
"TreeModelMeta",
"(",
"'_'"... | Create a new TreeModel where class attribute
names are prefixed with ``name`` | [
"Create",
"a",
"new",
"TreeModel",
"where",
"class",
"attribute",
"names",
"are",
"prefixed",
"with",
"name"
] | 3926935e1f2100d8ba68070c2ab44055d4800f73 | https://github.com/rootpy/rootpy/blob/3926935e1f2100d8ba68070c2ab44055d4800f73/rootpy/tree/treemodel.py#L84-L92 | train |
rootpy/rootpy | rootpy/tree/treemodel.py | TreeModelMeta.get_attrs | def get_attrs(cls):
"""
Get all class attributes ordered by definition
"""
ignore = dir(type('dummy', (object,), {})) + ['__metaclass__']
attrs = [
item for item in inspect.getmembers(cls) if item[0] not in ignore
and not isinstance(
item[1... | python | def get_attrs(cls):
"""
Get all class attributes ordered by definition
"""
ignore = dir(type('dummy', (object,), {})) + ['__metaclass__']
attrs = [
item for item in inspect.getmembers(cls) if item[0] not in ignore
and not isinstance(
item[1... | [
"def",
"get_attrs",
"(",
"cls",
")",
":",
"ignore",
"=",
"dir",
"(",
"type",
"(",
"'dummy'",
",",
"(",
"object",
",",
")",
",",
"{",
"}",
")",
")",
"+",
"[",
"'__metaclass__'",
"]",
"attrs",
"=",
"[",
"item",
"for",
"item",
"in",
"inspect",
".",
... | Get all class attributes ordered by definition | [
"Get",
"all",
"class",
"attributes",
"ordered",
"by",
"definition"
] | 3926935e1f2100d8ba68070c2ab44055d4800f73 | https://github.com/rootpy/rootpy/blob/3926935e1f2100d8ba68070c2ab44055d4800f73/rootpy/tree/treemodel.py#L104-L120 | train |
rootpy/rootpy | rootpy/tree/treemodel.py | TreeModelMeta.to_struct | def to_struct(cls, name=None):
"""
Convert the TreeModel into a compiled C struct
"""
if name is None:
name = cls.__name__
basic_attrs = dict([(attr_name, value)
for attr_name, value in cls.get_attrs()
if isinsta... | python | def to_struct(cls, name=None):
"""
Convert the TreeModel into a compiled C struct
"""
if name is None:
name = cls.__name__
basic_attrs = dict([(attr_name, value)
for attr_name, value in cls.get_attrs()
if isinsta... | [
"def",
"to_struct",
"(",
"cls",
",",
"name",
"=",
"None",
")",
":",
"if",
"name",
"is",
"None",
":",
"name",
"=",
"cls",
".",
"__name__",
"basic_attrs",
"=",
"dict",
"(",
"[",
"(",
"attr_name",
",",
"value",
")",
"for",
"attr_name",
",",
"value",
"... | Convert the TreeModel into a compiled C struct | [
"Convert",
"the",
"TreeModel",
"into",
"a",
"compiled",
"C",
"struct"
] | 3926935e1f2100d8ba68070c2ab44055d4800f73 | https://github.com/rootpy/rootpy/blob/3926935e1f2100d8ba68070c2ab44055d4800f73/rootpy/tree/treemodel.py#L122-L139 | train |
rootpy/rootpy | rootpy/extern/hep/pdg.py | id_to_name | def id_to_name(id):
"""
Convert a PDG ID to a printable string.
"""
name = pdgid_names.get(id)
if not name:
name = repr(id)
return name | python | def id_to_name(id):
"""
Convert a PDG ID to a printable string.
"""
name = pdgid_names.get(id)
if not name:
name = repr(id)
return name | [
"def",
"id_to_name",
"(",
"id",
")",
":",
"name",
"=",
"pdgid_names",
".",
"get",
"(",
"id",
")",
"if",
"not",
"name",
":",
"name",
"=",
"repr",
"(",
"id",
")",
"return",
"name"
] | Convert a PDG ID to a printable string. | [
"Convert",
"a",
"PDG",
"ID",
"to",
"a",
"printable",
"string",
"."
] | 3926935e1f2100d8ba68070c2ab44055d4800f73 | https://github.com/rootpy/rootpy/blob/3926935e1f2100d8ba68070c2ab44055d4800f73/rootpy/extern/hep/pdg.py#L36-L43 | train |
rootpy/rootpy | rootpy/extern/hep/pdg.py | id_to_root_name | def id_to_root_name(id):
"""
Convert a PDG ID to a string with root markup.
"""
name = root_names.get(id)
if not name:
name = repr(id)
return name | python | def id_to_root_name(id):
"""
Convert a PDG ID to a string with root markup.
"""
name = root_names.get(id)
if not name:
name = repr(id)
return name | [
"def",
"id_to_root_name",
"(",
"id",
")",
":",
"name",
"=",
"root_names",
".",
"get",
"(",
"id",
")",
"if",
"not",
"name",
":",
"name",
"=",
"repr",
"(",
"id",
")",
"return",
"name"
] | Convert a PDG ID to a string with root markup. | [
"Convert",
"a",
"PDG",
"ID",
"to",
"a",
"string",
"with",
"root",
"markup",
"."
] | 3926935e1f2100d8ba68070c2ab44055d4800f73 | https://github.com/rootpy/rootpy/blob/3926935e1f2100d8ba68070c2ab44055d4800f73/rootpy/extern/hep/pdg.py#L46-L53 | train |
rootpy/rootpy | rootpy/utils/inject_closure.py | new_closure | def new_closure(vals):
"""
Build a new closure
"""
args = ','.join('x%i' % i for i in range(len(vals)))
f = eval("lambda %s:lambda:(%s)" % (args, args))
if sys.version_info[0] >= 3:
return f(*vals).__closure__
return f(*vals).func_closure | python | def new_closure(vals):
"""
Build a new closure
"""
args = ','.join('x%i' % i for i in range(len(vals)))
f = eval("lambda %s:lambda:(%s)" % (args, args))
if sys.version_info[0] >= 3:
return f(*vals).__closure__
return f(*vals).func_closure | [
"def",
"new_closure",
"(",
"vals",
")",
":",
"args",
"=",
"','",
".",
"join",
"(",
"'x%i'",
"%",
"i",
"for",
"i",
"in",
"range",
"(",
"len",
"(",
"vals",
")",
")",
")",
"f",
"=",
"eval",
"(",
"\"lambda %s:lambda:(%s)\"",
"%",
"(",
"args",
",",
"a... | Build a new closure | [
"Build",
"a",
"new",
"closure"
] | 3926935e1f2100d8ba68070c2ab44055d4800f73 | https://github.com/rootpy/rootpy/blob/3926935e1f2100d8ba68070c2ab44055d4800f73/rootpy/utils/inject_closure.py#L19-L27 | train |
rootpy/rootpy | rootpy/utils/inject_closure.py | _inject_closure_values_fix_closures | def _inject_closure_values_fix_closures(c, injected, **kwargs):
"""
Recursively fix closures
Python bytecode for a closure looks like::
LOAD_CLOSURE var1
BUILD_TUPLE <n_of_vars_closed_over>
LOAD_CONST <code_object_containing_closure>
MAKE_CLOSURE
or this in 3.6... | python | def _inject_closure_values_fix_closures(c, injected, **kwargs):
"""
Recursively fix closures
Python bytecode for a closure looks like::
LOAD_CLOSURE var1
BUILD_TUPLE <n_of_vars_closed_over>
LOAD_CONST <code_object_containing_closure>
MAKE_CLOSURE
or this in 3.6... | [
"def",
"_inject_closure_values_fix_closures",
"(",
"c",
",",
"injected",
",",
"*",
"*",
"kwargs",
")",
":",
"code",
"=",
"c",
".",
"code",
"orig_len",
"=",
"len",
"(",
"code",
")",
"for",
"iback",
",",
"(",
"opcode",
",",
"value",
")",
"in",
"enumerate... | Recursively fix closures
Python bytecode for a closure looks like::
LOAD_CLOSURE var1
BUILD_TUPLE <n_of_vars_closed_over>
LOAD_CONST <code_object_containing_closure>
MAKE_CLOSURE
or this in 3.6 (MAKE_CLOSURE is no longer an opcode)::
LOAD_CLOSURE var1
... | [
"Recursively",
"fix",
"closures"
] | 3926935e1f2100d8ba68070c2ab44055d4800f73 | https://github.com/rootpy/rootpy/blob/3926935e1f2100d8ba68070c2ab44055d4800f73/rootpy/utils/inject_closure.py#L30-L75 | train |
rootpy/rootpy | rootpy/utils/inject_closure.py | _inject_closure_values_fix_code | def _inject_closure_values_fix_code(c, injected, **kwargs):
"""
Fix code objects, recursively fixing any closures
"""
# Add more closure variables
c.freevars += injected
# Replace LOAD_GLOBAL with LOAD_DEREF (fetch from closure cells)
# for named variables
for i, (opcode, value) in enum... | python | def _inject_closure_values_fix_code(c, injected, **kwargs):
"""
Fix code objects, recursively fixing any closures
"""
# Add more closure variables
c.freevars += injected
# Replace LOAD_GLOBAL with LOAD_DEREF (fetch from closure cells)
# for named variables
for i, (opcode, value) in enum... | [
"def",
"_inject_closure_values_fix_code",
"(",
"c",
",",
"injected",
",",
"*",
"*",
"kwargs",
")",
":",
"# Add more closure variables",
"c",
".",
"freevars",
"+=",
"injected",
"# Replace LOAD_GLOBAL with LOAD_DEREF (fetch from closure cells)",
"# for named variables",
"for",
... | Fix code objects, recursively fixing any closures | [
"Fix",
"code",
"objects",
"recursively",
"fixing",
"any",
"closures"
] | 3926935e1f2100d8ba68070c2ab44055d4800f73 | https://github.com/rootpy/rootpy/blob/3926935e1f2100d8ba68070c2ab44055d4800f73/rootpy/utils/inject_closure.py#L78-L93 | train |
rootpy/rootpy | rootpy/utils/inject_closure.py | inject_closure_values | def inject_closure_values(func, **kwargs):
"""
Returns a new function identical to the previous one except that it acts as
though global variables named in `kwargs` have been closed over with the
values specified in the `kwargs` dictionary.
Works on properties, class/static methods and functions.
... | python | def inject_closure_values(func, **kwargs):
"""
Returns a new function identical to the previous one except that it acts as
though global variables named in `kwargs` have been closed over with the
values specified in the `kwargs` dictionary.
Works on properties, class/static methods and functions.
... | [
"def",
"inject_closure_values",
"(",
"func",
",",
"*",
"*",
"kwargs",
")",
":",
"wrapped_by",
"=",
"None",
"if",
"isinstance",
"(",
"func",
",",
"property",
")",
":",
"fget",
",",
"fset",
",",
"fdel",
"=",
"func",
".",
"fget",
",",
"func",
".",
"fset... | Returns a new function identical to the previous one except that it acts as
though global variables named in `kwargs` have been closed over with the
values specified in the `kwargs` dictionary.
Works on properties, class/static methods and functions.
This can be useful for mocking and other nefarious ... | [
"Returns",
"a",
"new",
"function",
"identical",
"to",
"the",
"previous",
"one",
"except",
"that",
"it",
"acts",
"as",
"though",
"global",
"variables",
"named",
"in",
"kwargs",
"have",
"been",
"closed",
"over",
"with",
"the",
"values",
"specified",
"in",
"the... | 3926935e1f2100d8ba68070c2ab44055d4800f73 | https://github.com/rootpy/rootpy/blob/3926935e1f2100d8ba68070c2ab44055d4800f73/rootpy/utils/inject_closure.py#L137-L165 | train |
rootpy/rootpy | rootpy/plotting/canvas.py | _PadBase.axes | def axes(self, ndim=1,
xlimits=None, ylimits=None, zlimits=None,
xbins=1, ybins=1, zbins=1):
"""
Create and return axes on this pad
"""
if xlimits is None:
xlimits = (0, 1)
if ylimits is None:
ylimits = (0, 1)
if zlimits i... | python | def axes(self, ndim=1,
xlimits=None, ylimits=None, zlimits=None,
xbins=1, ybins=1, zbins=1):
"""
Create and return axes on this pad
"""
if xlimits is None:
xlimits = (0, 1)
if ylimits is None:
ylimits = (0, 1)
if zlimits i... | [
"def",
"axes",
"(",
"self",
",",
"ndim",
"=",
"1",
",",
"xlimits",
"=",
"None",
",",
"ylimits",
"=",
"None",
",",
"zlimits",
"=",
"None",
",",
"xbins",
"=",
"1",
",",
"ybins",
"=",
"1",
",",
"zbins",
"=",
"1",
")",
":",
"if",
"xlimits",
"is",
... | Create and return axes on this pad | [
"Create",
"and",
"return",
"axes",
"on",
"this",
"pad"
] | 3926935e1f2100d8ba68070c2ab44055d4800f73 | https://github.com/rootpy/rootpy/blob/3926935e1f2100d8ba68070c2ab44055d4800f73/rootpy/plotting/canvas.py#L34-L93 | train |
rootpy/rootpy | rootpy/root2hdf5.py | root2hdf5 | def root2hdf5(rfile, hfile, rpath='',
entries=-1, userfunc=None,
show_progress=False,
ignore_exception=False,
**kwargs):
"""
Convert all trees in a ROOT file into tables in an HDF5 file.
Parameters
----------
rfile : string or asrootpy'd ROOT... | python | def root2hdf5(rfile, hfile, rpath='',
entries=-1, userfunc=None,
show_progress=False,
ignore_exception=False,
**kwargs):
"""
Convert all trees in a ROOT file into tables in an HDF5 file.
Parameters
----------
rfile : string or asrootpy'd ROOT... | [
"def",
"root2hdf5",
"(",
"rfile",
",",
"hfile",
",",
"rpath",
"=",
"''",
",",
"entries",
"=",
"-",
"1",
",",
"userfunc",
"=",
"None",
",",
"show_progress",
"=",
"False",
",",
"ignore_exception",
"=",
"False",
",",
"*",
"*",
"kwargs",
")",
":",
"own_r... | Convert all trees in a ROOT file into tables in an HDF5 file.
Parameters
----------
rfile : string or asrootpy'd ROOT File
A ROOT File handle or string path to an existing ROOT file.
hfile : string or PyTables HDF5 File
A PyTables HDF5 File handle or string path to an existing HDF5 fi... | [
"Convert",
"all",
"trees",
"in",
"a",
"ROOT",
"file",
"into",
"tables",
"in",
"an",
"HDF5",
"file",
"."
] | 3926935e1f2100d8ba68070c2ab44055d4800f73 | https://github.com/rootpy/rootpy/blob/3926935e1f2100d8ba68070c2ab44055d4800f73/rootpy/root2hdf5.py#L190-L310 | train |
rootpy/rootpy | rootpy/plotting/graph.py | _Graph1DBase.Reverse | def Reverse(self, copy=False):
"""
Reverse the order of the points
"""
numPoints = self.GetN()
if copy:
revGraph = self.Clone()
else:
revGraph = self
X = self.GetX()
EXlow = self.GetEXlow()
EXhigh = self.GetEXhigh()
... | python | def Reverse(self, copy=False):
"""
Reverse the order of the points
"""
numPoints = self.GetN()
if copy:
revGraph = self.Clone()
else:
revGraph = self
X = self.GetX()
EXlow = self.GetEXlow()
EXhigh = self.GetEXhigh()
... | [
"def",
"Reverse",
"(",
"self",
",",
"copy",
"=",
"False",
")",
":",
"numPoints",
"=",
"self",
".",
"GetN",
"(",
")",
"if",
"copy",
":",
"revGraph",
"=",
"self",
".",
"Clone",
"(",
")",
"else",
":",
"revGraph",
"=",
"self",
"X",
"=",
"self",
".",
... | Reverse the order of the points | [
"Reverse",
"the",
"order",
"of",
"the",
"points"
] | 3926935e1f2100d8ba68070c2ab44055d4800f73 | https://github.com/rootpy/rootpy/blob/3926935e1f2100d8ba68070c2ab44055d4800f73/rootpy/plotting/graph.py#L493-L515 | train |
rootpy/rootpy | rootpy/plotting/graph.py | _Graph1DBase.Shift | def Shift(self, value, copy=False):
"""
Shift the graph left or right by value
"""
numPoints = self.GetN()
if copy:
shiftGraph = self.Clone()
else:
shiftGraph = self
X = self.GetX()
EXlow = self.GetEXlow()
EXhigh = self.GetE... | python | def Shift(self, value, copy=False):
"""
Shift the graph left or right by value
"""
numPoints = self.GetN()
if copy:
shiftGraph = self.Clone()
else:
shiftGraph = self
X = self.GetX()
EXlow = self.GetEXlow()
EXhigh = self.GetE... | [
"def",
"Shift",
"(",
"self",
",",
"value",
",",
"copy",
"=",
"False",
")",
":",
"numPoints",
"=",
"self",
".",
"GetN",
"(",
")",
"if",
"copy",
":",
"shiftGraph",
"=",
"self",
".",
"Clone",
"(",
")",
"else",
":",
"shiftGraph",
"=",
"self",
"X",
"=... | Shift the graph left or right by value | [
"Shift",
"the",
"graph",
"left",
"or",
"right",
"by",
"value"
] | 3926935e1f2100d8ba68070c2ab44055d4800f73 | https://github.com/rootpy/rootpy/blob/3926935e1f2100d8ba68070c2ab44055d4800f73/rootpy/plotting/graph.py#L586-L607 | train |
rootpy/rootpy | rootpy/plotting/graph.py | _Graph1DBase.Integrate | def Integrate(self):
"""
Integrate using the trapazoidal method
"""
area = 0.
X = self.GetX()
Y = self.GetY()
for i in range(self.GetN() - 1):
area += (X[i + 1] - X[i]) * (Y[i] + Y[i + 1]) / 2.
return area | python | def Integrate(self):
"""
Integrate using the trapazoidal method
"""
area = 0.
X = self.GetX()
Y = self.GetY()
for i in range(self.GetN() - 1):
area += (X[i + 1] - X[i]) * (Y[i] + Y[i + 1]) / 2.
return area | [
"def",
"Integrate",
"(",
"self",
")",
":",
"area",
"=",
"0.",
"X",
"=",
"self",
".",
"GetX",
"(",
")",
"Y",
"=",
"self",
".",
"GetY",
"(",
")",
"for",
"i",
"in",
"range",
"(",
"self",
".",
"GetN",
"(",
")",
"-",
"1",
")",
":",
"area",
"+=",... | Integrate using the trapazoidal method | [
"Integrate",
"using",
"the",
"trapazoidal",
"method"
] | 3926935e1f2100d8ba68070c2ab44055d4800f73 | https://github.com/rootpy/rootpy/blob/3926935e1f2100d8ba68070c2ab44055d4800f73/rootpy/plotting/graph.py#L609-L618 | train |
rootpy/rootpy | rootpy/plotting/graph.py | _Graph1DBase.Append | def Append(self, other):
"""
Append points from another graph
"""
orig_len = len(self)
self.Set(orig_len + len(other))
ipoint = orig_len
if hasattr(self, 'SetPointError'):
for point in other:
self.SetPoint(ipoint, point.x.value, point.y... | python | def Append(self, other):
"""
Append points from another graph
"""
orig_len = len(self)
self.Set(orig_len + len(other))
ipoint = orig_len
if hasattr(self, 'SetPointError'):
for point in other:
self.SetPoint(ipoint, point.x.value, point.y... | [
"def",
"Append",
"(",
"self",
",",
"other",
")",
":",
"orig_len",
"=",
"len",
"(",
"self",
")",
"self",
".",
"Set",
"(",
"orig_len",
"+",
"len",
"(",
"other",
")",
")",
"ipoint",
"=",
"orig_len",
"if",
"hasattr",
"(",
"self",
",",
"'SetPointError'",
... | Append points from another graph | [
"Append",
"points",
"from",
"another",
"graph"
] | 3926935e1f2100d8ba68070c2ab44055d4800f73 | https://github.com/rootpy/rootpy/blob/3926935e1f2100d8ba68070c2ab44055d4800f73/rootpy/plotting/graph.py#L620-L638 | train |
rootpy/rootpy | rootpy/memory/keepalive.py | keepalive | def keepalive(nurse, *patients):
"""
Keep ``patients`` alive at least as long as ``nurse`` is around using a
``WeakKeyDictionary``.
"""
if DISABLED:
return
if hashable(nurse):
hashable_patients = []
for p in patients:
if hashable(p):
log.debug(... | python | def keepalive(nurse, *patients):
"""
Keep ``patients`` alive at least as long as ``nurse`` is around using a
``WeakKeyDictionary``.
"""
if DISABLED:
return
if hashable(nurse):
hashable_patients = []
for p in patients:
if hashable(p):
log.debug(... | [
"def",
"keepalive",
"(",
"nurse",
",",
"*",
"patients",
")",
":",
"if",
"DISABLED",
":",
"return",
"if",
"hashable",
"(",
"nurse",
")",
":",
"hashable_patients",
"=",
"[",
"]",
"for",
"p",
"in",
"patients",
":",
"if",
"hashable",
"(",
"p",
")",
":",
... | Keep ``patients`` alive at least as long as ``nurse`` is around using a
``WeakKeyDictionary``. | [
"Keep",
"patients",
"alive",
"at",
"least",
"as",
"long",
"as",
"nurse",
"is",
"around",
"using",
"a",
"WeakKeyDictionary",
"."
] | 3926935e1f2100d8ba68070c2ab44055d4800f73 | https://github.com/rootpy/rootpy/blob/3926935e1f2100d8ba68070c2ab44055d4800f73/rootpy/memory/keepalive.py#L26-L45 | train |
rootpy/rootpy | rootpy/plotting/hist.py | canonify_slice | def canonify_slice(s, n):
"""
Convert a slice object into a canonical form
to simplify treatment in histogram bin content
and edge slicing.
"""
if isinstance(s, (int, long)):
return canonify_slice(slice(s, s + 1, None), n)
start = s.start % n if s.start is not None else 0
stop = ... | python | def canonify_slice(s, n):
"""
Convert a slice object into a canonical form
to simplify treatment in histogram bin content
and edge slicing.
"""
if isinstance(s, (int, long)):
return canonify_slice(slice(s, s + 1, None), n)
start = s.start % n if s.start is not None else 0
stop = ... | [
"def",
"canonify_slice",
"(",
"s",
",",
"n",
")",
":",
"if",
"isinstance",
"(",
"s",
",",
"(",
"int",
",",
"long",
")",
")",
":",
"return",
"canonify_slice",
"(",
"slice",
"(",
"s",
",",
"s",
"+",
"1",
",",
"None",
")",
",",
"n",
")",
"start",
... | Convert a slice object into a canonical form
to simplify treatment in histogram bin content
and edge slicing. | [
"Convert",
"a",
"slice",
"object",
"into",
"a",
"canonical",
"form",
"to",
"simplify",
"treatment",
"in",
"histogram",
"bin",
"content",
"and",
"edge",
"slicing",
"."
] | 3926935e1f2100d8ba68070c2ab44055d4800f73 | https://github.com/rootpy/rootpy/blob/3926935e1f2100d8ba68070c2ab44055d4800f73/rootpy/plotting/hist.py#L37-L48 | train |
rootpy/rootpy | rootpy/plotting/hist.py | bin_to_edge_slice | def bin_to_edge_slice(s, n):
"""
Convert a bin slice into a bin edge slice.
"""
s = canonify_slice(s, n)
start = s.start
stop = s.stop
if start > stop:
_stop = start + 1
start = stop + 1
stop = _stop
start = max(start - 1, 0)
step = abs(s.step)
if stop <= ... | python | def bin_to_edge_slice(s, n):
"""
Convert a bin slice into a bin edge slice.
"""
s = canonify_slice(s, n)
start = s.start
stop = s.stop
if start > stop:
_stop = start + 1
start = stop + 1
stop = _stop
start = max(start - 1, 0)
step = abs(s.step)
if stop <= ... | [
"def",
"bin_to_edge_slice",
"(",
"s",
",",
"n",
")",
":",
"s",
"=",
"canonify_slice",
"(",
"s",
",",
"n",
")",
"start",
"=",
"s",
".",
"start",
"stop",
"=",
"s",
".",
"stop",
"if",
"start",
">",
"stop",
":",
"_stop",
"=",
"start",
"+",
"1",
"st... | Convert a bin slice into a bin edge slice. | [
"Convert",
"a",
"bin",
"slice",
"into",
"a",
"bin",
"edge",
"slice",
"."
] | 3926935e1f2100d8ba68070c2ab44055d4800f73 | https://github.com/rootpy/rootpy/blob/3926935e1f2100d8ba68070c2ab44055d4800f73/rootpy/plotting/hist.py#L51-L69 | train |
rootpy/rootpy | rootpy/plotting/hist.py | histogram | def histogram(data, *args, **kwargs):
"""
Create and fill a one-dimensional histogram.
The same arguments as the ``Hist`` class are expected.
If the number of bins and the ranges are not specified they are
automatically deduced with the ``autobinning`` function using the method
specified by the... | python | def histogram(data, *args, **kwargs):
"""
Create and fill a one-dimensional histogram.
The same arguments as the ``Hist`` class are expected.
If the number of bins and the ranges are not specified they are
automatically deduced with the ``autobinning`` function using the method
specified by the... | [
"def",
"histogram",
"(",
"data",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"from",
".",
"autobinning",
"import",
"autobinning",
"dim",
"=",
"kwargs",
".",
"pop",
"(",
"'dim'",
",",
"1",
")",
"if",
"dim",
"!=",
"1",
":",
"raise",
"NotImpl... | Create and fill a one-dimensional histogram.
The same arguments as the ``Hist`` class are expected.
If the number of bins and the ranges are not specified they are
automatically deduced with the ``autobinning`` function using the method
specified by the ``binning`` argument. Only one-dimensional histog... | [
"Create",
"and",
"fill",
"a",
"one",
"-",
"dimensional",
"histogram",
"."
] | 3926935e1f2100d8ba68070c2ab44055d4800f73 | https://github.com/rootpy/rootpy/blob/3926935e1f2100d8ba68070c2ab44055d4800f73/rootpy/plotting/hist.py#L2649-L2669 | train |
rootpy/rootpy | rootpy/plotting/hist.py | BinProxy.overflow | def overflow(self):
"""
Returns true if this BinProxy is for an overflow bin
"""
indices = self.hist.xyz(self.idx)
for i in range(self.hist.GetDimension()):
if indices[i] == 0 or indices[i] == self.hist.nbins(i) + 1:
return True
return False | python | def overflow(self):
"""
Returns true if this BinProxy is for an overflow bin
"""
indices = self.hist.xyz(self.idx)
for i in range(self.hist.GetDimension()):
if indices[i] == 0 or indices[i] == self.hist.nbins(i) + 1:
return True
return False | [
"def",
"overflow",
"(",
"self",
")",
":",
"indices",
"=",
"self",
".",
"hist",
".",
"xyz",
"(",
"self",
".",
"idx",
")",
"for",
"i",
"in",
"range",
"(",
"self",
".",
"hist",
".",
"GetDimension",
"(",
")",
")",
":",
"if",
"indices",
"[",
"i",
"]... | Returns true if this BinProxy is for an overflow bin | [
"Returns",
"true",
"if",
"this",
"BinProxy",
"is",
"for",
"an",
"overflow",
"bin"
] | 3926935e1f2100d8ba68070c2ab44055d4800f73 | https://github.com/rootpy/rootpy/blob/3926935e1f2100d8ba68070c2ab44055d4800f73/rootpy/plotting/hist.py#L217-L225 | train |
rootpy/rootpy | rootpy/plotting/hist.py | _HistBase.xyz | def xyz(self, idx):
"""
return binx, biny, binz corresponding to the global bin number
"""
# Not implemented for Python 3:
# GetBinXYZ(i, x, y, z)
nx = self.GetNbinsX() + 2
ny = self.GetNbinsY() + 2
ndim = self.GetDimension()
if ndim < 2:
... | python | def xyz(self, idx):
"""
return binx, biny, binz corresponding to the global bin number
"""
# Not implemented for Python 3:
# GetBinXYZ(i, x, y, z)
nx = self.GetNbinsX() + 2
ny = self.GetNbinsY() + 2
ndim = self.GetDimension()
if ndim < 2:
... | [
"def",
"xyz",
"(",
"self",
",",
"idx",
")",
":",
"# Not implemented for Python 3:",
"# GetBinXYZ(i, x, y, z)",
"nx",
"=",
"self",
".",
"GetNbinsX",
"(",
")",
"+",
"2",
"ny",
"=",
"self",
".",
"GetNbinsY",
"(",
")",
"+",
"2",
"ndim",
"=",
"self",
".",
"... | return binx, biny, binz corresponding to the global bin number | [
"return",
"binx",
"biny",
"binz",
"corresponding",
"to",
"the",
"global",
"bin",
"number"
] | 3926935e1f2100d8ba68070c2ab44055d4800f73 | https://github.com/rootpy/rootpy/blob/3926935e1f2100d8ba68070c2ab44055d4800f73/rootpy/plotting/hist.py#L377-L400 | train |
rootpy/rootpy | rootpy/plotting/hist.py | _HistBase.nbins | def nbins(self, axis=0, overflow=False):
"""
Get the number of bins along an axis
"""
if axis == 0:
nbins = self.GetNbinsX()
elif axis == 1:
nbins = self.GetNbinsY()
elif axis == 2:
nbins = self.GetNbinsZ()
else:
rai... | python | def nbins(self, axis=0, overflow=False):
"""
Get the number of bins along an axis
"""
if axis == 0:
nbins = self.GetNbinsX()
elif axis == 1:
nbins = self.GetNbinsY()
elif axis == 2:
nbins = self.GetNbinsZ()
else:
rai... | [
"def",
"nbins",
"(",
"self",
",",
"axis",
"=",
"0",
",",
"overflow",
"=",
"False",
")",
":",
"if",
"axis",
"==",
"0",
":",
"nbins",
"=",
"self",
".",
"GetNbinsX",
"(",
")",
"elif",
"axis",
"==",
"1",
":",
"nbins",
"=",
"self",
".",
"GetNbinsY",
... | Get the number of bins along an axis | [
"Get",
"the",
"number",
"of",
"bins",
"along",
"an",
"axis"
] | 3926935e1f2100d8ba68070c2ab44055d4800f73 | https://github.com/rootpy/rootpy/blob/3926935e1f2100d8ba68070c2ab44055d4800f73/rootpy/plotting/hist.py#L463-L477 | train |
rootpy/rootpy | rootpy/plotting/hist.py | _HistBase.bins_range | def bins_range(self, axis=0, overflow=False):
"""
Return a range of bin indices for iterating along an axis
Parameters
----------
axis : int, optional (default=1)
The axis (0, 1 or 2).
overflow : bool, optional (default=False)
If True then inclu... | python | def bins_range(self, axis=0, overflow=False):
"""
Return a range of bin indices for iterating along an axis
Parameters
----------
axis : int, optional (default=1)
The axis (0, 1 or 2).
overflow : bool, optional (default=False)
If True then inclu... | [
"def",
"bins_range",
"(",
"self",
",",
"axis",
"=",
"0",
",",
"overflow",
"=",
"False",
")",
":",
"nbins",
"=",
"self",
".",
"nbins",
"(",
"axis",
"=",
"axis",
",",
"overflow",
"=",
"False",
")",
"if",
"overflow",
":",
"start",
"=",
"0",
"end_offse... | Return a range of bin indices for iterating along an axis
Parameters
----------
axis : int, optional (default=1)
The axis (0, 1 or 2).
overflow : bool, optional (default=False)
If True then include the underflow and overflow bins
otherwise only incl... | [
"Return",
"a",
"range",
"of",
"bin",
"indices",
"for",
"iterating",
"along",
"an",
"axis"
] | 3926935e1f2100d8ba68070c2ab44055d4800f73 | https://github.com/rootpy/rootpy/blob/3926935e1f2100d8ba68070c2ab44055d4800f73/rootpy/plotting/hist.py#L479-L506 | train |
rootpy/rootpy | rootpy/plotting/hist.py | _HistBase.uniform_binned | def uniform_binned(self, name=None):
"""
Return a new histogram with constant width bins along all axes by
using the bin indices as the bin edges of the new histogram.
"""
if self.GetDimension() == 1:
new_hist = Hist(
self.GetNbinsX(), 0, self.GetNbins... | python | def uniform_binned(self, name=None):
"""
Return a new histogram with constant width bins along all axes by
using the bin indices as the bin edges of the new histogram.
"""
if self.GetDimension() == 1:
new_hist = Hist(
self.GetNbinsX(), 0, self.GetNbins... | [
"def",
"uniform_binned",
"(",
"self",
",",
"name",
"=",
"None",
")",
":",
"if",
"self",
".",
"GetDimension",
"(",
")",
"==",
"1",
":",
"new_hist",
"=",
"Hist",
"(",
"self",
".",
"GetNbinsX",
"(",
")",
",",
"0",
",",
"self",
".",
"GetNbinsX",
"(",
... | Return a new histogram with constant width bins along all axes by
using the bin indices as the bin edges of the new histogram. | [
"Return",
"a",
"new",
"histogram",
"with",
"constant",
"width",
"bins",
"along",
"all",
"axes",
"by",
"using",
"the",
"bin",
"indices",
"as",
"the",
"bin",
"edges",
"of",
"the",
"new",
"histogram",
"."
] | 3926935e1f2100d8ba68070c2ab44055d4800f73 | https://github.com/rootpy/rootpy/blob/3926935e1f2100d8ba68070c2ab44055d4800f73/rootpy/plotting/hist.py#L749-L775 | train |
rootpy/rootpy | rootpy/plotting/hist.py | _HistBase.underflow | def underflow(self, axis=0):
"""
Return the underflow for the given axis.
Depending on the dimension of the histogram, may return an array.
"""
if axis not in range(3):
raise ValueError("axis must be 0, 1, or 2")
if self.DIM == 1:
return self.GetB... | python | def underflow(self, axis=0):
"""
Return the underflow for the given axis.
Depending on the dimension of the histogram, may return an array.
"""
if axis not in range(3):
raise ValueError("axis must be 0, 1, or 2")
if self.DIM == 1:
return self.GetB... | [
"def",
"underflow",
"(",
"self",
",",
"axis",
"=",
"0",
")",
":",
"if",
"axis",
"not",
"in",
"range",
"(",
"3",
")",
":",
"raise",
"ValueError",
"(",
"\"axis must be 0, 1, or 2\"",
")",
"if",
"self",
".",
"DIM",
"==",
"1",
":",
"return",
"self",
".",... | Return the underflow for the given axis.
Depending on the dimension of the histogram, may return an array. | [
"Return",
"the",
"underflow",
"for",
"the",
"given",
"axis",
"."
] | 3926935e1f2100d8ba68070c2ab44055d4800f73 | https://github.com/rootpy/rootpy/blob/3926935e1f2100d8ba68070c2ab44055d4800f73/rootpy/plotting/hist.py#L777-L806 | train |
rootpy/rootpy | rootpy/plotting/hist.py | _HistBase.lowerbound | def lowerbound(self, axis=0):
"""
Get the lower bound of the binning along an axis
"""
if not 0 <= axis < self.GetDimension():
raise ValueError(
"axis must be a non-negative integer less than "
"the dimensionality of the histogram")
if ... | python | def lowerbound(self, axis=0):
"""
Get the lower bound of the binning along an axis
"""
if not 0 <= axis < self.GetDimension():
raise ValueError(
"axis must be a non-negative integer less than "
"the dimensionality of the histogram")
if ... | [
"def",
"lowerbound",
"(",
"self",
",",
"axis",
"=",
"0",
")",
":",
"if",
"not",
"0",
"<=",
"axis",
"<",
"self",
".",
"GetDimension",
"(",
")",
":",
"raise",
"ValueError",
"(",
"\"axis must be a non-negative integer less than \"",
"\"the dimensionality of the histo... | Get the lower bound of the binning along an axis | [
"Get",
"the",
"lower",
"bound",
"of",
"the",
"binning",
"along",
"an",
"axis"
] | 3926935e1f2100d8ba68070c2ab44055d4800f73 | https://github.com/rootpy/rootpy/blob/3926935e1f2100d8ba68070c2ab44055d4800f73/rootpy/plotting/hist.py#L844-L858 | train |
rootpy/rootpy | rootpy/plotting/hist.py | _HistBase.bounds | def bounds(self, axis=0):
"""
Get the lower and upper bounds of the binning along an axis
"""
if not 0 <= axis < self.GetDimension():
raise ValueError(
"axis must be a non-negative integer less than "
"the dimensionality of the histogram")
... | python | def bounds(self, axis=0):
"""
Get the lower and upper bounds of the binning along an axis
"""
if not 0 <= axis < self.GetDimension():
raise ValueError(
"axis must be a non-negative integer less than "
"the dimensionality of the histogram")
... | [
"def",
"bounds",
"(",
"self",
",",
"axis",
"=",
"0",
")",
":",
"if",
"not",
"0",
"<=",
"axis",
"<",
"self",
".",
"GetDimension",
"(",
")",
":",
"raise",
"ValueError",
"(",
"\"axis must be a non-negative integer less than \"",
"\"the dimensionality of the histogram... | Get the lower and upper bounds of the binning along an axis | [
"Get",
"the",
"lower",
"and",
"upper",
"bounds",
"of",
"the",
"binning",
"along",
"an",
"axis"
] | 3926935e1f2100d8ba68070c2ab44055d4800f73 | https://github.com/rootpy/rootpy/blob/3926935e1f2100d8ba68070c2ab44055d4800f73/rootpy/plotting/hist.py#L876-L890 | train |
rootpy/rootpy | rootpy/plotting/hist.py | _HistBase.check_compatibility | def check_compatibility(self, other, check_edges=False, precision=1E-7):
"""
Test whether two histograms are considered compatible by the number of
dimensions, number of bins along each axis, and optionally the bin
edges.
Parameters
----------
other : histogram
... | python | def check_compatibility(self, other, check_edges=False, precision=1E-7):
"""
Test whether two histograms are considered compatible by the number of
dimensions, number of bins along each axis, and optionally the bin
edges.
Parameters
----------
other : histogram
... | [
"def",
"check_compatibility",
"(",
"self",
",",
"other",
",",
"check_edges",
"=",
"False",
",",
"precision",
"=",
"1E-7",
")",
":",
"if",
"self",
".",
"GetDimension",
"(",
")",
"!=",
"other",
".",
"GetDimension",
"(",
")",
":",
"raise",
"TypeError",
"(",... | Test whether two histograms are considered compatible by the number of
dimensions, number of bins along each axis, and optionally the bin
edges.
Parameters
----------
other : histogram
A rootpy histogram
check_edges : bool, optional (default=False)
... | [
"Test",
"whether",
"two",
"histograms",
"are",
"considered",
"compatible",
"by",
"the",
"number",
"of",
"dimensions",
"number",
"of",
"bins",
"along",
"each",
"axis",
"and",
"optionally",
"the",
"bin",
"edges",
"."
] | 3926935e1f2100d8ba68070c2ab44055d4800f73 | https://github.com/rootpy/rootpy/blob/3926935e1f2100d8ba68070c2ab44055d4800f73/rootpy/plotting/hist.py#L1018-L1063 | train |
rootpy/rootpy | rootpy/plotting/hist.py | _HistBase.fill_array | def fill_array(self, array, weights=None):
"""
Fill this histogram with a NumPy array
"""
try:
try:
from root_numpy import fill_hist as fill_func
except ImportError:
from root_numpy import fill_array as fill_func
except Impo... | python | def fill_array(self, array, weights=None):
"""
Fill this histogram with a NumPy array
"""
try:
try:
from root_numpy import fill_hist as fill_func
except ImportError:
from root_numpy import fill_array as fill_func
except Impo... | [
"def",
"fill_array",
"(",
"self",
",",
"array",
",",
"weights",
"=",
"None",
")",
":",
"try",
":",
"try",
":",
"from",
"root_numpy",
"import",
"fill_hist",
"as",
"fill_func",
"except",
"ImportError",
":",
"from",
"root_numpy",
"import",
"fill_array",
"as",
... | Fill this histogram with a NumPy array | [
"Fill",
"this",
"histogram",
"with",
"a",
"NumPy",
"array"
] | 3926935e1f2100d8ba68070c2ab44055d4800f73 | https://github.com/rootpy/rootpy/blob/3926935e1f2100d8ba68070c2ab44055d4800f73/rootpy/plotting/hist.py#L1192-L1206 | train |
rootpy/rootpy | rootpy/plotting/hist.py | _HistBase.fill_view | def fill_view(self, view):
"""
Fill this histogram from a view of another histogram
"""
other = view.hist
_other_x_center = other.axis(0).GetBinCenter
_other_y_center = other.axis(1).GetBinCenter
_other_z_center = other.axis(2).GetBinCenter
_other_get = ot... | python | def fill_view(self, view):
"""
Fill this histogram from a view of another histogram
"""
other = view.hist
_other_x_center = other.axis(0).GetBinCenter
_other_y_center = other.axis(1).GetBinCenter
_other_z_center = other.axis(2).GetBinCenter
_other_get = ot... | [
"def",
"fill_view",
"(",
"self",
",",
"view",
")",
":",
"other",
"=",
"view",
".",
"hist",
"_other_x_center",
"=",
"other",
".",
"axis",
"(",
"0",
")",
".",
"GetBinCenter",
"_other_y_center",
"=",
"other",
".",
"axis",
"(",
"1",
")",
".",
"GetBinCenter... | Fill this histogram from a view of another histogram | [
"Fill",
"this",
"histogram",
"from",
"a",
"view",
"of",
"another",
"histogram"
] | 3926935e1f2100d8ba68070c2ab44055d4800f73 | https://github.com/rootpy/rootpy/blob/3926935e1f2100d8ba68070c2ab44055d4800f73/rootpy/plotting/hist.py#L1208-L1237 | train |
rootpy/rootpy | rootpy/plotting/hist.py | _HistBase.get_sum_w2 | def get_sum_w2(self, ix, iy=0, iz=0):
"""
Obtain the true number of entries in the bin weighted by w^2
"""
if self.GetSumw2N() == 0:
raise RuntimeError(
"Attempting to access Sumw2 in histogram "
"where weights were not stored")
xl = se... | python | def get_sum_w2(self, ix, iy=0, iz=0):
"""
Obtain the true number of entries in the bin weighted by w^2
"""
if self.GetSumw2N() == 0:
raise RuntimeError(
"Attempting to access Sumw2 in histogram "
"where weights were not stored")
xl = se... | [
"def",
"get_sum_w2",
"(",
"self",
",",
"ix",
",",
"iy",
"=",
"0",
",",
"iz",
"=",
"0",
")",
":",
"if",
"self",
".",
"GetSumw2N",
"(",
")",
"==",
"0",
":",
"raise",
"RuntimeError",
"(",
"\"Attempting to access Sumw2 in histogram \"",
"\"where weights were not... | Obtain the true number of entries in the bin weighted by w^2 | [
"Obtain",
"the",
"true",
"number",
"of",
"entries",
"in",
"the",
"bin",
"weighted",
"by",
"w^2"
] | 3926935e1f2100d8ba68070c2ab44055d4800f73 | https://github.com/rootpy/rootpy/blob/3926935e1f2100d8ba68070c2ab44055d4800f73/rootpy/plotting/hist.py#L1245-L1258 | train |
rootpy/rootpy | rootpy/plotting/hist.py | _HistBase.set_sum_w2 | def set_sum_w2(self, w, ix, iy=0, iz=0):
"""
Sets the true number of entries in the bin weighted by w^2
"""
if self.GetSumw2N() == 0:
raise RuntimeError(
"Attempting to access Sumw2 in histogram "
"where weights were not stored")
xl = s... | python | def set_sum_w2(self, w, ix, iy=0, iz=0):
"""
Sets the true number of entries in the bin weighted by w^2
"""
if self.GetSumw2N() == 0:
raise RuntimeError(
"Attempting to access Sumw2 in histogram "
"where weights were not stored")
xl = s... | [
"def",
"set_sum_w2",
"(",
"self",
",",
"w",
",",
"ix",
",",
"iy",
"=",
"0",
",",
"iz",
"=",
"0",
")",
":",
"if",
"self",
".",
"GetSumw2N",
"(",
")",
"==",
"0",
":",
"raise",
"RuntimeError",
"(",
"\"Attempting to access Sumw2 in histogram \"",
"\"where we... | Sets the true number of entries in the bin weighted by w^2 | [
"Sets",
"the",
"true",
"number",
"of",
"entries",
"in",
"the",
"bin",
"weighted",
"by",
"w^2"
] | 3926935e1f2100d8ba68070c2ab44055d4800f73 | https://github.com/rootpy/rootpy/blob/3926935e1f2100d8ba68070c2ab44055d4800f73/rootpy/plotting/hist.py#L1260-L1273 | train |
rootpy/rootpy | rootpy/plotting/hist.py | _HistBase.rebinned | def rebinned(self, bins, axis=0):
"""
Return a new rebinned histogram
Parameters
----------
bins : int, tuple, or iterable
If ``bins`` is an int, then return a histogram that is rebinned by
grouping N=``bins`` bins together along the axis ``axis``.
... | python | def rebinned(self, bins, axis=0):
"""
Return a new rebinned histogram
Parameters
----------
bins : int, tuple, or iterable
If ``bins`` is an int, then return a histogram that is rebinned by
grouping N=``bins`` bins together along the axis ``axis``.
... | [
"def",
"rebinned",
"(",
"self",
",",
"bins",
",",
"axis",
"=",
"0",
")",
":",
"ndim",
"=",
"self",
".",
"GetDimension",
"(",
")",
"if",
"axis",
">=",
"ndim",
":",
"raise",
"ValueError",
"(",
"\"axis must be less than the dimensionality of the histogram\"",
")"... | Return a new rebinned histogram
Parameters
----------
bins : int, tuple, or iterable
If ``bins`` is an int, then return a histogram that is rebinned by
grouping N=``bins`` bins together along the axis ``axis``.
If ``bins`` is a tuple, then it must contain th... | [
"Return",
"a",
"new",
"rebinned",
"histogram"
] | 3926935e1f2100d8ba68070c2ab44055d4800f73 | https://github.com/rootpy/rootpy/blob/3926935e1f2100d8ba68070c2ab44055d4800f73/rootpy/plotting/hist.py#L1405-L1491 | train |
rootpy/rootpy | rootpy/plotting/hist.py | _HistBase.smoothed | def smoothed(self, iterations=1):
"""
Return a smoothed copy of this histogram
Parameters
----------
iterations : int, optional (default=1)
The number of smoothing iterations
Returns
-------
hist : asrootpy'd histogram
The smoot... | python | def smoothed(self, iterations=1):
"""
Return a smoothed copy of this histogram
Parameters
----------
iterations : int, optional (default=1)
The number of smoothing iterations
Returns
-------
hist : asrootpy'd histogram
The smoot... | [
"def",
"smoothed",
"(",
"self",
",",
"iterations",
"=",
"1",
")",
":",
"copy",
"=",
"self",
".",
"Clone",
"(",
"shallow",
"=",
"True",
")",
"copy",
".",
"Smooth",
"(",
"iterations",
")",
"return",
"copy"
] | Return a smoothed copy of this histogram
Parameters
----------
iterations : int, optional (default=1)
The number of smoothing iterations
Returns
-------
hist : asrootpy'd histogram
The smoothed histogram | [
"Return",
"a",
"smoothed",
"copy",
"of",
"this",
"histogram"
] | 3926935e1f2100d8ba68070c2ab44055d4800f73 | https://github.com/rootpy/rootpy/blob/3926935e1f2100d8ba68070c2ab44055d4800f73/rootpy/plotting/hist.py#L1493-L1512 | train |
rootpy/rootpy | rootpy/plotting/hist.py | _HistBase.empty_clone | def empty_clone(self, binning=None, axis=0, type=None, **kwargs):
"""
Return a new empty histogram. The binning may be modified
along one axis by specifying the binning and axis arguments.
If binning is False, then the corresponding axis is dropped
from the returned histogram.
... | python | def empty_clone(self, binning=None, axis=0, type=None, **kwargs):
"""
Return a new empty histogram. The binning may be modified
along one axis by specifying the binning and axis arguments.
If binning is False, then the corresponding axis is dropped
from the returned histogram.
... | [
"def",
"empty_clone",
"(",
"self",
",",
"binning",
"=",
"None",
",",
"axis",
"=",
"0",
",",
"type",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"ndim",
"=",
"self",
".",
"GetDimension",
"(",
")",
"if",
"binning",
"is",
"False",
"and",
"ndim",
... | Return a new empty histogram. The binning may be modified
along one axis by specifying the binning and axis arguments.
If binning is False, then the corresponding axis is dropped
from the returned histogram. | [
"Return",
"a",
"new",
"empty",
"histogram",
".",
"The",
"binning",
"may",
"be",
"modified",
"along",
"one",
"axis",
"by",
"specifying",
"the",
"binning",
"and",
"axis",
"arguments",
".",
"If",
"binning",
"is",
"False",
"then",
"the",
"corresponding",
"axis",... | 3926935e1f2100d8ba68070c2ab44055d4800f73 | https://github.com/rootpy/rootpy/blob/3926935e1f2100d8ba68070c2ab44055d4800f73/rootpy/plotting/hist.py#L1514-L1542 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.