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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
symengine/symengine.py | symengine/compatibility.py | as_int | def as_int(n):
"""
Convert the argument to a builtin integer.
The return value is guaranteed to be equal to the input. ValueError is
raised if the input has a non-integral value.
Examples
========
>>> from sympy.core.compatibility import as_int
>>> from sympy import sqrt
>>> 3.0
... | python | def as_int(n):
"""
Convert the argument to a builtin integer.
The return value is guaranteed to be equal to the input. ValueError is
raised if the input has a non-integral value.
Examples
========
>>> from sympy.core.compatibility import as_int
>>> from sympy import sqrt
>>> 3.0
... | [
"def",
"as_int",
"(",
"n",
")",
":",
"try",
":",
"result",
"=",
"int",
"(",
"n",
")",
"if",
"result",
"!=",
"n",
":",
"raise",
"TypeError",
"except",
"TypeError",
":",
"raise",
"ValueError",
"(",
"'%s is not an integer'",
"%",
"n",
")",
"return",
"resu... | Convert the argument to a builtin integer.
The return value is guaranteed to be equal to the input. ValueError is
raised if the input has a non-integral value.
Examples
========
>>> from sympy.core.compatibility import as_int
>>> from sympy import sqrt
>>> 3.0
3.0
>>> as_int(3.0) ... | [
"Convert",
"the",
"argument",
"to",
"a",
"builtin",
"integer",
"."
] | 1366cf98ceaade339c5dd24ae3381a0e63ea9dad | https://github.com/symengine/symengine.py/blob/1366cf98ceaade339c5dd24ae3381a0e63ea9dad/symengine/compatibility.py#L359-L389 | train |
symengine/symengine.py | symengine/compatibility.py | default_sort_key | def default_sort_key(item, order=None):
"""Return a key that can be used for sorting.
The key has the structure:
(class_key, (len(args), args), exponent.sort_key(), coefficient)
This key is supplied by the sort_key routine of Basic objects when
``item`` is a Basic object or an object (other than ... | python | def default_sort_key(item, order=None):
"""Return a key that can be used for sorting.
The key has the structure:
(class_key, (len(args), args), exponent.sort_key(), coefficient)
This key is supplied by the sort_key routine of Basic objects when
``item`` is a Basic object or an object (other than ... | [
"def",
"default_sort_key",
"(",
"item",
",",
"order",
"=",
"None",
")",
":",
"from",
"sympy",
".",
"core",
"import",
"S",
",",
"Basic",
"from",
"sympy",
".",
"core",
".",
"sympify",
"import",
"sympify",
",",
"SympifyError",
"from",
"sympy",
".",
"core",
... | Return a key that can be used for sorting.
The key has the structure:
(class_key, (len(args), args), exponent.sort_key(), coefficient)
This key is supplied by the sort_key routine of Basic objects when
``item`` is a Basic object or an object (other than a string) that
sympifies to a Basic object.... | [
"Return",
"a",
"key",
"that",
"can",
"be",
"used",
"for",
"sorting",
"."
] | 1366cf98ceaade339c5dd24ae3381a0e63ea9dad | https://github.com/symengine/symengine.py/blob/1366cf98ceaade339c5dd24ae3381a0e63ea9dad/symengine/compatibility.py#L392-L541 | train |
symengine/symengine.py | symengine/utilities.py | var | def var(names, **args):
"""
Create symbols and inject them into the global namespace.
INPUT:
- s -- a string, either a single variable name, or
- a space separated list of variable names, or
- a list of variable names.
This calls :func:`symbols` with the same... | python | def var(names, **args):
"""
Create symbols and inject them into the global namespace.
INPUT:
- s -- a string, either a single variable name, or
- a space separated list of variable names, or
- a list of variable names.
This calls :func:`symbols` with the same... | [
"def",
"var",
"(",
"names",
",",
"*",
"*",
"args",
")",
":",
"def",
"traverse",
"(",
"symbols",
",",
"frame",
")",
":",
"\"\"\"Recursively inject symbols to the global namespace. \"\"\"",
"for",
"symbol",
"in",
"symbols",
":",
"if",
"isinstance",
"(",
"symbol",
... | Create symbols and inject them into the global namespace.
INPUT:
- s -- a string, either a single variable name, or
- a space separated list of variable names, or
- a list of variable names.
This calls :func:`symbols` with the same arguments and puts the results
... | [
"Create",
"symbols",
"and",
"inject",
"them",
"into",
"the",
"global",
"namespace",
"."
] | 1366cf98ceaade339c5dd24ae3381a0e63ea9dad | https://github.com/symengine/symengine.py/blob/1366cf98ceaade339c5dd24ae3381a0e63ea9dad/symengine/utilities.py#L184-L242 | train |
Murali-group/halp | halp/undirected_hypergraph.py | UndirectedHypergraph._combine_attribute_arguments | def _combine_attribute_arguments(self, attr_dict, attr):
# Note: Code & comments unchanged from DirectedHypergraph
"""Combines attr_dict and attr dictionaries, by updating attr_dict
with attr.
:param attr_dict: dictionary of attributes of the node.
:param attr: keyword argum... | python | def _combine_attribute_arguments(self, attr_dict, attr):
# Note: Code & comments unchanged from DirectedHypergraph
"""Combines attr_dict and attr dictionaries, by updating attr_dict
with attr.
:param attr_dict: dictionary of attributes of the node.
:param attr: keyword argum... | [
"def",
"_combine_attribute_arguments",
"(",
"self",
",",
"attr_dict",
",",
"attr",
")",
":",
"# Note: Code & comments unchanged from DirectedHypergraph",
"# If no attribute dict was passed, treat the keyword",
"# arguments as the dict",
"if",
"attr_dict",
"is",
"None",
":",
"attr... | Combines attr_dict and attr dictionaries, by updating attr_dict
with attr.
:param attr_dict: dictionary of attributes of the node.
:param attr: keyword arguments of attributes of the node;
attr's values will override attr_dict's values
if both are pro... | [
"Combines",
"attr_dict",
"and",
"attr",
"dictionaries",
"by",
"updating",
"attr_dict",
"with",
"attr",
"."
] | 6eb27466ba84e2281e18f93b62aae5efb21ef8b3 | https://github.com/Murali-group/halp/blob/6eb27466ba84e2281e18f93b62aae5efb21ef8b3/halp/undirected_hypergraph.py#L137-L162 | train |
Murali-group/halp | halp/undirected_hypergraph.py | UndirectedHypergraph.remove_node | def remove_node(self, node):
"""Removes a node and its attributes from the hypergraph. Removes
every hyperedge that contains this node.
:param node: reference to the node being added.
:raises: ValueError -- No such node exists.
Examples:
::
>>> H = Undirect... | python | def remove_node(self, node):
"""Removes a node and its attributes from the hypergraph. Removes
every hyperedge that contains this node.
:param node: reference to the node being added.
:raises: ValueError -- No such node exists.
Examples:
::
>>> H = Undirect... | [
"def",
"remove_node",
"(",
"self",
",",
"node",
")",
":",
"if",
"not",
"self",
".",
"has_node",
"(",
"node",
")",
":",
"raise",
"ValueError",
"(",
"\"No such node exists.\"",
")",
"# Loop over every hyperedge in the star of the node;",
"# i.e., over every hyperedge that... | Removes a node and its attributes from the hypergraph. Removes
every hyperedge that contains this node.
:param node: reference to the node being added.
:raises: ValueError -- No such node exists.
Examples:
::
>>> H = UndirectedHypergraph()
>>> H.add_nod... | [
"Removes",
"a",
"node",
"and",
"its",
"attributes",
"from",
"the",
"hypergraph",
".",
"Removes",
"every",
"hyperedge",
"that",
"contains",
"this",
"node",
"."
] | 6eb27466ba84e2281e18f93b62aae5efb21ef8b3 | https://github.com/Murali-group/halp/blob/6eb27466ba84e2281e18f93b62aae5efb21ef8b3/halp/undirected_hypergraph.py#L256-L288 | train |
Murali-group/halp | halp/undirected_hypergraph.py | UndirectedHypergraph.add_hyperedge | def add_hyperedge(self, nodes, attr_dict=None, **attr):
"""Adds a hyperedge to the hypergraph, along with any related
attributes of the hyperedge.
This method will automatically add any node from the node set
that was not in the hypergraph.
A hyperedge without a "... | python | def add_hyperedge(self, nodes, attr_dict=None, **attr):
"""Adds a hyperedge to the hypergraph, along with any related
attributes of the hyperedge.
This method will automatically add any node from the node set
that was not in the hypergraph.
A hyperedge without a "... | [
"def",
"add_hyperedge",
"(",
"self",
",",
"nodes",
",",
"attr_dict",
"=",
"None",
",",
"*",
"*",
"attr",
")",
":",
"attr_dict",
"=",
"self",
".",
"_combine_attribute_arguments",
"(",
"attr_dict",
",",
"attr",
")",
"# Don't allow empty node set (invalid hyperedge)"... | Adds a hyperedge to the hypergraph, along with any related
attributes of the hyperedge.
This method will automatically add any node from the node set
that was not in the hypergraph.
A hyperedge without a "weight" attribute specified will be
assigned the defaul... | [
"Adds",
"a",
"hyperedge",
"to",
"the",
"hypergraph",
"along",
"with",
"any",
"related",
"attributes",
"of",
"the",
"hyperedge",
".",
"This",
"method",
"will",
"automatically",
"add",
"any",
"node",
"from",
"the",
"node",
"set",
"that",
"was",
"not",
"in",
... | 6eb27466ba84e2281e18f93b62aae5efb21ef8b3 | https://github.com/Murali-group/halp/blob/6eb27466ba84e2281e18f93b62aae5efb21ef8b3/halp/undirected_hypergraph.py#L384-L447 | train |
Murali-group/halp | halp/undirected_hypergraph.py | UndirectedHypergraph.add_hyperedges | def add_hyperedges(self, hyperedges, attr_dict=None, **attr):
"""Adds multiple hyperedges to the graph, along with any related
attributes of the hyperedges.
If any node of a hyperedge has not previously been added to the
hypergraph, it will automatically be added here.
... | python | def add_hyperedges(self, hyperedges, attr_dict=None, **attr):
"""Adds multiple hyperedges to the graph, along with any related
attributes of the hyperedges.
If any node of a hyperedge has not previously been added to the
hypergraph, it will automatically be added here.
... | [
"def",
"add_hyperedges",
"(",
"self",
",",
"hyperedges",
",",
"attr_dict",
"=",
"None",
",",
"*",
"*",
"attr",
")",
":",
"attr_dict",
"=",
"self",
".",
"_combine_attribute_arguments",
"(",
"attr_dict",
",",
"attr",
")",
"hyperedge_ids",
"=",
"[",
"]",
"for... | Adds multiple hyperedges to the graph, along with any related
attributes of the hyperedges.
If any node of a hyperedge has not previously been added to the
hypergraph, it will automatically be added here.
Hyperedges without a "weight" attribute specified will be
... | [
"Adds",
"multiple",
"hyperedges",
"to",
"the",
"graph",
"along",
"with",
"any",
"related",
"attributes",
"of",
"the",
"hyperedges",
".",
"If",
"any",
"node",
"of",
"a",
"hyperedge",
"has",
"not",
"previously",
"been",
"added",
"to",
"the",
"hypergraph",
"it"... | 6eb27466ba84e2281e18f93b62aae5efb21ef8b3 | https://github.com/Murali-group/halp/blob/6eb27466ba84e2281e18f93b62aae5efb21ef8b3/halp/undirected_hypergraph.py#L449-L487 | train |
Murali-group/halp | halp/undirected_hypergraph.py | UndirectedHypergraph.get_hyperedge_id | def get_hyperedge_id(self, nodes):
"""From a set of nodes, returns the ID of the hyperedge that this
set comprises.
:param nodes: iterable container of references to nodes in the
the hyperedge to be added
:returns: str -- ID of the hyperedge that has that the specifi... | python | def get_hyperedge_id(self, nodes):
"""From a set of nodes, returns the ID of the hyperedge that this
set comprises.
:param nodes: iterable container of references to nodes in the
the hyperedge to be added
:returns: str -- ID of the hyperedge that has that the specifi... | [
"def",
"get_hyperedge_id",
"(",
"self",
",",
"nodes",
")",
":",
"frozen_nodes",
"=",
"frozenset",
"(",
"nodes",
")",
"if",
"not",
"self",
".",
"has_hyperedge",
"(",
"frozen_nodes",
")",
":",
"raise",
"ValueError",
"(",
"\"No such hyperedge exists.\"",
")",
"re... | From a set of nodes, returns the ID of the hyperedge that this
set comprises.
:param nodes: iterable container of references to nodes in the
the hyperedge to be added
:returns: str -- ID of the hyperedge that has that the specified
node set comprises.
... | [
"From",
"a",
"set",
"of",
"nodes",
"returns",
"the",
"ID",
"of",
"the",
"hyperedge",
"that",
"this",
"set",
"comprises",
"."
] | 6eb27466ba84e2281e18f93b62aae5efb21ef8b3 | https://github.com/Murali-group/halp/blob/6eb27466ba84e2281e18f93b62aae5efb21ef8b3/halp/undirected_hypergraph.py#L592-L618 | train |
Murali-group/halp | halp/undirected_hypergraph.py | UndirectedHypergraph.get_hyperedge_attribute | def get_hyperedge_attribute(self, hyperedge_id, attribute_name):
# Note: Code unchanged from DirectedHypergraph
"""Given a hyperedge ID and the name of an attribute, get a copy
of that hyperedge's attribute.
:param hyperedge_id: ID of the hyperedge to retrieve the attribute of.
... | python | def get_hyperedge_attribute(self, hyperedge_id, attribute_name):
# Note: Code unchanged from DirectedHypergraph
"""Given a hyperedge ID and the name of an attribute, get a copy
of that hyperedge's attribute.
:param hyperedge_id: ID of the hyperedge to retrieve the attribute of.
... | [
"def",
"get_hyperedge_attribute",
"(",
"self",
",",
"hyperedge_id",
",",
"attribute_name",
")",
":",
"# Note: Code unchanged from DirectedHypergraph",
"if",
"not",
"self",
".",
"has_hyperedge_id",
"(",
"hyperedge_id",
")",
":",
"raise",
"ValueError",
"(",
"\"No such hyp... | Given a hyperedge ID and the name of an attribute, get a copy
of that hyperedge's attribute.
:param hyperedge_id: ID of the hyperedge to retrieve the attribute of.
:param attribute_name: name of the attribute to retrieve.
:returns: attribute value of the attribute_name key for the
... | [
"Given",
"a",
"hyperedge",
"ID",
"and",
"the",
"name",
"of",
"an",
"attribute",
"get",
"a",
"copy",
"of",
"that",
"hyperedge",
"s",
"attribute",
"."
] | 6eb27466ba84e2281e18f93b62aae5efb21ef8b3 | https://github.com/Murali-group/halp/blob/6eb27466ba84e2281e18f93b62aae5efb21ef8b3/halp/undirected_hypergraph.py#L620-L649 | train |
Murali-group/halp | halp/undirected_hypergraph.py | UndirectedHypergraph.get_hyperedge_attributes | def get_hyperedge_attributes(self, hyperedge_id):
"""Given a hyperedge ID, get a dictionary of copies of that hyperedge's
attributes.
:param hyperedge_id: ID of the hyperedge to retrieve the attributes of.
:returns: dict -- copy of each attribute of the specified hyperedge_id
... | python | def get_hyperedge_attributes(self, hyperedge_id):
"""Given a hyperedge ID, get a dictionary of copies of that hyperedge's
attributes.
:param hyperedge_id: ID of the hyperedge to retrieve the attributes of.
:returns: dict -- copy of each attribute of the specified hyperedge_id
... | [
"def",
"get_hyperedge_attributes",
"(",
"self",
",",
"hyperedge_id",
")",
":",
"if",
"not",
"self",
".",
"has_hyperedge_id",
"(",
"hyperedge_id",
")",
":",
"raise",
"ValueError",
"(",
"\"No such hyperedge exists.\"",
")",
"dict_to_copy",
"=",
"self",
".",
"_hypere... | Given a hyperedge ID, get a dictionary of copies of that hyperedge's
attributes.
:param hyperedge_id: ID of the hyperedge to retrieve the attributes of.
:returns: dict -- copy of each attribute of the specified hyperedge_id
(except the private __frozen_nodes entry).
:rai... | [
"Given",
"a",
"hyperedge",
"ID",
"get",
"a",
"dictionary",
"of",
"copies",
"of",
"that",
"hyperedge",
"s",
"attributes",
"."
] | 6eb27466ba84e2281e18f93b62aae5efb21ef8b3 | https://github.com/Murali-group/halp/blob/6eb27466ba84e2281e18f93b62aae5efb21ef8b3/halp/undirected_hypergraph.py#L651-L668 | train |
Murali-group/halp | halp/undirected_hypergraph.py | UndirectedHypergraph.get_star | def get_star(self, node):
"""Given a node, get a copy of that node's star, that is, the set of
hyperedges that the node belongs to.
:param node: node to retrieve the star of.
:returns: set -- set of hyperedge_ids for the hyperedges
in the node's star.
:ra... | python | def get_star(self, node):
"""Given a node, get a copy of that node's star, that is, the set of
hyperedges that the node belongs to.
:param node: node to retrieve the star of.
:returns: set -- set of hyperedge_ids for the hyperedges
in the node's star.
:ra... | [
"def",
"get_star",
"(",
"self",
",",
"node",
")",
":",
"if",
"node",
"not",
"in",
"self",
".",
"_node_attributes",
":",
"raise",
"ValueError",
"(",
"\"No such node exists.\"",
")",
"return",
"self",
".",
"_star",
"[",
"node",
"]",
".",
"copy",
"(",
")"
] | Given a node, get a copy of that node's star, that is, the set of
hyperedges that the node belongs to.
:param node: node to retrieve the star of.
:returns: set -- set of hyperedge_ids for the hyperedges
in the node's star.
:raises: ValueError -- No such node exis... | [
"Given",
"a",
"node",
"get",
"a",
"copy",
"of",
"that",
"node",
"s",
"star",
"that",
"is",
"the",
"set",
"of",
"hyperedges",
"that",
"the",
"node",
"belongs",
"to",
"."
] | 6eb27466ba84e2281e18f93b62aae5efb21ef8b3 | https://github.com/Murali-group/halp/blob/6eb27466ba84e2281e18f93b62aae5efb21ef8b3/halp/undirected_hypergraph.py#L691-L703 | train |
Murali-group/halp | halp/utilities/directed_statistics.py | _F_outdegree | def _F_outdegree(H, F):
"""Returns the result of a function F applied to the set of outdegrees in
in the hypergraph.
:param H: the hypergraph whose outdegrees will be operated on.
:param F: function to execute on the list of outdegrees in the hypergraph.
:returns: result of the given function F.
... | python | def _F_outdegree(H, F):
"""Returns the result of a function F applied to the set of outdegrees in
in the hypergraph.
:param H: the hypergraph whose outdegrees will be operated on.
:param F: function to execute on the list of outdegrees in the hypergraph.
:returns: result of the given function F.
... | [
"def",
"_F_outdegree",
"(",
"H",
",",
"F",
")",
":",
"if",
"not",
"isinstance",
"(",
"H",
",",
"DirectedHypergraph",
")",
":",
"raise",
"TypeError",
"(",
"\"Algorithm only applicable to directed hypergraphs\"",
")",
"return",
"F",
"(",
"[",
"len",
"(",
"H",
... | Returns the result of a function F applied to the set of outdegrees in
in the hypergraph.
:param H: the hypergraph whose outdegrees will be operated on.
:param F: function to execute on the list of outdegrees in the hypergraph.
:returns: result of the given function F.
:raises: TypeError -- Algorit... | [
"Returns",
"the",
"result",
"of",
"a",
"function",
"F",
"applied",
"to",
"the",
"set",
"of",
"outdegrees",
"in",
"in",
"the",
"hypergraph",
"."
] | 6eb27466ba84e2281e18f93b62aae5efb21ef8b3 | https://github.com/Murali-group/halp/blob/6eb27466ba84e2281e18f93b62aae5efb21ef8b3/halp/utilities/directed_statistics.py#L40-L54 | train |
Murali-group/halp | halp/utilities/directed_statistics.py | _F_indegree | def _F_indegree(H, F):
"""Returns the result of a function F applied to the list of indegrees in
in the hypergraph.
:param H: the hypergraph whose indegrees will be operated on.
:param F: function to execute on the list of indegrees in the hypergraph.
:returns: result of the given function F.
:... | python | def _F_indegree(H, F):
"""Returns the result of a function F applied to the list of indegrees in
in the hypergraph.
:param H: the hypergraph whose indegrees will be operated on.
:param F: function to execute on the list of indegrees in the hypergraph.
:returns: result of the given function F.
:... | [
"def",
"_F_indegree",
"(",
"H",
",",
"F",
")",
":",
"if",
"not",
"isinstance",
"(",
"H",
",",
"DirectedHypergraph",
")",
":",
"raise",
"TypeError",
"(",
"\"Algorithm only applicable to directed hypergraphs\"",
")",
"return",
"F",
"(",
"[",
"len",
"(",
"H",
"... | Returns the result of a function F applied to the list of indegrees in
in the hypergraph.
:param H: the hypergraph whose indegrees will be operated on.
:param F: function to execute on the list of indegrees in the hypergraph.
:returns: result of the given function F.
:raises: TypeError -- Algorithm... | [
"Returns",
"the",
"result",
"of",
"a",
"function",
"F",
"applied",
"to",
"the",
"list",
"of",
"indegrees",
"in",
"in",
"the",
"hypergraph",
"."
] | 6eb27466ba84e2281e18f93b62aae5efb21ef8b3 | https://github.com/Murali-group/halp/blob/6eb27466ba84e2281e18f93b62aae5efb21ef8b3/halp/utilities/directed_statistics.py#L105-L119 | train |
Murali-group/halp | halp/utilities/directed_statistics.py | _F_hyperedge_tail_cardinality | def _F_hyperedge_tail_cardinality(H, F):
"""Returns the result of a function F applied to the set of cardinalities
of hyperedge tails in the hypergraph.
:param H: the hypergraph whose tail cardinalities will be
operated on.
:param F: function to execute on the set of cardinalities i... | python | def _F_hyperedge_tail_cardinality(H, F):
"""Returns the result of a function F applied to the set of cardinalities
of hyperedge tails in the hypergraph.
:param H: the hypergraph whose tail cardinalities will be
operated on.
:param F: function to execute on the set of cardinalities i... | [
"def",
"_F_hyperedge_tail_cardinality",
"(",
"H",
",",
"F",
")",
":",
"if",
"not",
"isinstance",
"(",
"H",
",",
"DirectedHypergraph",
")",
":",
"raise",
"TypeError",
"(",
"\"Algorithm only applicable to directed hypergraphs\"",
")",
"return",
"F",
"(",
"[",
"len",... | Returns the result of a function F applied to the set of cardinalities
of hyperedge tails in the hypergraph.
:param H: the hypergraph whose tail cardinalities will be
operated on.
:param F: function to execute on the set of cardinalities in the
hypergraph.
:returns: resu... | [
"Returns",
"the",
"result",
"of",
"a",
"function",
"F",
"applied",
"to",
"the",
"set",
"of",
"cardinalities",
"of",
"hyperedge",
"tails",
"in",
"the",
"hypergraph",
"."
] | 6eb27466ba84e2281e18f93b62aae5efb21ef8b3 | https://github.com/Murali-group/halp/blob/6eb27466ba84e2281e18f93b62aae5efb21ef8b3/halp/utilities/directed_statistics.py#L170-L186 | train |
Murali-group/halp | halp/utilities/directed_statistics.py | _F_hyperedge_head_cardinality | def _F_hyperedge_head_cardinality(H, F):
"""Returns the result of a function F applied to the set of cardinalities
of hyperedge heads in the hypergraph.
:param H: the hypergraph whose head cardinalities will be
operated on.
:param F: function to execute on the set of cardinalities i... | python | def _F_hyperedge_head_cardinality(H, F):
"""Returns the result of a function F applied to the set of cardinalities
of hyperedge heads in the hypergraph.
:param H: the hypergraph whose head cardinalities will be
operated on.
:param F: function to execute on the set of cardinalities i... | [
"def",
"_F_hyperedge_head_cardinality",
"(",
"H",
",",
"F",
")",
":",
"if",
"not",
"isinstance",
"(",
"H",
",",
"DirectedHypergraph",
")",
":",
"raise",
"TypeError",
"(",
"\"Algorithm only applicable to directed hypergraphs\"",
")",
"return",
"F",
"(",
"[",
"len",... | Returns the result of a function F applied to the set of cardinalities
of hyperedge heads in the hypergraph.
:param H: the hypergraph whose head cardinalities will be
operated on.
:param F: function to execute on the set of cardinalities in the
hypergraph.
:returns: resu... | [
"Returns",
"the",
"result",
"of",
"a",
"function",
"F",
"applied",
"to",
"the",
"set",
"of",
"cardinalities",
"of",
"hyperedge",
"heads",
"in",
"the",
"hypergraph",
"."
] | 6eb27466ba84e2281e18f93b62aae5efb21ef8b3 | https://github.com/Murali-group/halp/blob/6eb27466ba84e2281e18f93b62aae5efb21ef8b3/halp/utilities/directed_statistics.py#L240-L256 | train |
Murali-group/halp | halp/utilities/undirected_matrices.py | get_hyperedge_weight_matrix | def get_hyperedge_weight_matrix(H, hyperedge_ids_to_indices):
"""Creates the diagonal matrix W of hyperedge weights as a sparse matrix.
:param H: the hypergraph to find the weights.
:param hyperedge_weights: the mapping from the indices of hyperedge IDs to
the corresponding hype... | python | def get_hyperedge_weight_matrix(H, hyperedge_ids_to_indices):
"""Creates the diagonal matrix W of hyperedge weights as a sparse matrix.
:param H: the hypergraph to find the weights.
:param hyperedge_weights: the mapping from the indices of hyperedge IDs to
the corresponding hype... | [
"def",
"get_hyperedge_weight_matrix",
"(",
"H",
",",
"hyperedge_ids_to_indices",
")",
":",
"# Combined 2 methods into 1; this could be written better",
"hyperedge_weights",
"=",
"{",
"}",
"for",
"hyperedge_id",
"in",
"H",
".",
"hyperedge_id_iterator",
"(",
")",
":",
"hype... | Creates the diagonal matrix W of hyperedge weights as a sparse matrix.
:param H: the hypergraph to find the weights.
:param hyperedge_weights: the mapping from the indices of hyperedge IDs to
the corresponding hyperedge weights.
:returns: sparse.csc_matrix -- the diagonal edge w... | [
"Creates",
"the",
"diagonal",
"matrix",
"W",
"of",
"hyperedge",
"weights",
"as",
"a",
"sparse",
"matrix",
"."
] | 6eb27466ba84e2281e18f93b62aae5efb21ef8b3 | https://github.com/Murali-group/halp/blob/6eb27466ba84e2281e18f93b62aae5efb21ef8b3/halp/utilities/undirected_matrices.py#L103-L123 | train |
Murali-group/halp | halp/utilities/undirected_matrices.py | get_hyperedge_degree_matrix | def get_hyperedge_degree_matrix(M):
"""Creates the diagonal matrix of hyperedge degrees D_e as a sparse matrix,
where a hyperedge degree is the cardinality of the hyperedge.
:param M: the incidence matrix of the hypergraph to find the D_e matrix on.
:returns: sparse.csc_matrix -- the diagonal hyperedge... | python | def get_hyperedge_degree_matrix(M):
"""Creates the diagonal matrix of hyperedge degrees D_e as a sparse matrix,
where a hyperedge degree is the cardinality of the hyperedge.
:param M: the incidence matrix of the hypergraph to find the D_e matrix on.
:returns: sparse.csc_matrix -- the diagonal hyperedge... | [
"def",
"get_hyperedge_degree_matrix",
"(",
"M",
")",
":",
"degrees",
"=",
"M",
".",
"sum",
"(",
"0",
")",
".",
"transpose",
"(",
")",
"new_degree",
"=",
"[",
"]",
"for",
"degree",
"in",
"degrees",
":",
"new_degree",
".",
"append",
"(",
"int",
"(",
"d... | Creates the diagonal matrix of hyperedge degrees D_e as a sparse matrix,
where a hyperedge degree is the cardinality of the hyperedge.
:param M: the incidence matrix of the hypergraph to find the D_e matrix on.
:returns: sparse.csc_matrix -- the diagonal hyperedge degree matrix as a
sparse matr... | [
"Creates",
"the",
"diagonal",
"matrix",
"of",
"hyperedge",
"degrees",
"D_e",
"as",
"a",
"sparse",
"matrix",
"where",
"a",
"hyperedge",
"degree",
"is",
"the",
"cardinality",
"of",
"the",
"hyperedge",
"."
] | 6eb27466ba84e2281e18f93b62aae5efb21ef8b3 | https://github.com/Murali-group/halp/blob/6eb27466ba84e2281e18f93b62aae5efb21ef8b3/halp/utilities/undirected_matrices.py#L126-L140 | train |
Murali-group/halp | halp/utilities/undirected_matrices.py | fast_inverse | def fast_inverse(M):
"""Computes the inverse of a diagonal matrix.
:param H: the diagonal matrix to find the inverse of.
:returns: sparse.csc_matrix -- the inverse of the input matrix as a
sparse matrix.
"""
diags = M.diagonal()
new_diag = []
for value in diags:
new_dia... | python | def fast_inverse(M):
"""Computes the inverse of a diagonal matrix.
:param H: the diagonal matrix to find the inverse of.
:returns: sparse.csc_matrix -- the inverse of the input matrix as a
sparse matrix.
"""
diags = M.diagonal()
new_diag = []
for value in diags:
new_dia... | [
"def",
"fast_inverse",
"(",
"M",
")",
":",
"diags",
"=",
"M",
".",
"diagonal",
"(",
")",
"new_diag",
"=",
"[",
"]",
"for",
"value",
"in",
"diags",
":",
"new_diag",
".",
"append",
"(",
"1.0",
"/",
"value",
")",
"return",
"sparse",
".",
"diags",
"(",... | Computes the inverse of a diagonal matrix.
:param H: the diagonal matrix to find the inverse of.
:returns: sparse.csc_matrix -- the inverse of the input matrix as a
sparse matrix. | [
"Computes",
"the",
"inverse",
"of",
"a",
"diagonal",
"matrix",
"."
] | 6eb27466ba84e2281e18f93b62aae5efb21ef8b3 | https://github.com/Murali-group/halp/blob/6eb27466ba84e2281e18f93b62aae5efb21ef8b3/halp/utilities/undirected_matrices.py#L143-L156 | train |
Murali-group/halp | halp/signaling_hypergraph.py | node_iterator | def node_iterator(self):
"""Provides an iterator over the nodes.
"""
return iter(self._node_attributes)
def has_hypernode(self, hypernode):
"""Determines if a specific hypernode is present in the hypergraph.
:param node: reference to hypernode whose presence is being checked.... | python | def node_iterator(self):
"""Provides an iterator over the nodes.
"""
return iter(self._node_attributes)
def has_hypernode(self, hypernode):
"""Determines if a specific hypernode is present in the hypergraph.
:param node: reference to hypernode whose presence is being checked.... | [
"def",
"node_iterator",
"(",
"self",
")",
":",
"return",
"iter",
"(",
"self",
".",
"_node_attributes",
")",
"def",
"has_hypernode",
"(",
"self",
",",
"hypernode",
")",
":",
"\"\"\"Determines if a specific hypernode is present in the hypergraph.\n\n :param node: refer... | Provides an iterator over the nodes. | [
"Provides",
"an",
"iterator",
"over",
"the",
"nodes",
"."
] | 6eb27466ba84e2281e18f93b62aae5efb21ef8b3 | https://github.com/Murali-group/halp/blob/6eb27466ba84e2281e18f93b62aae5efb21ef8b3/halp/signaling_hypergraph.py#L243-L256 | train |
Murali-group/halp | halp/signaling_hypergraph.py | add_hypernode | def add_hypernode(self, hypernode, composing_nodes=set(), attr_dict=None, **attr):
"""Adds a hypernode to the graph, along with any related attributes
of the hypernode.
:param hypernode: reference to the hypernode being added.
:param nodes: reference to the set of nodes that compose
... | python | def add_hypernode(self, hypernode, composing_nodes=set(), attr_dict=None, **attr):
"""Adds a hypernode to the graph, along with any related attributes
of the hypernode.
:param hypernode: reference to the hypernode being added.
:param nodes: reference to the set of nodes that compose
... | [
"def",
"add_hypernode",
"(",
"self",
",",
"hypernode",
",",
"composing_nodes",
"=",
"set",
"(",
")",
",",
"attr_dict",
"=",
"None",
",",
"*",
"*",
"attr",
")",
":",
"attr_dict",
"=",
"self",
".",
"_combine_attribute_arguments",
"(",
"attr_dict",
",",
"attr... | Adds a hypernode to the graph, along with any related attributes
of the hypernode.
:param hypernode: reference to the hypernode being added.
:param nodes: reference to the set of nodes that compose
the hypernode.
:param in_hypernodes: set of references to the hypernodes th... | [
"Adds",
"a",
"hypernode",
"to",
"the",
"graph",
"along",
"with",
"any",
"related",
"attributes",
"of",
"the",
"hypernode",
"."
] | 6eb27466ba84e2281e18f93b62aae5efb21ef8b3 | https://github.com/Murali-group/halp/blob/6eb27466ba84e2281e18f93b62aae5efb21ef8b3/halp/signaling_hypergraph.py#L305-L344 | train |
Murali-group/halp | halp/algorithms/undirected_partitioning.py | _create_random_starter | def _create_random_starter(node_count):
"""Creates the random starter for the random walk.
:param node_count: number of nodes to create the random vector.
:returns: list -- list of starting probabilities for each node.
"""
pi = np.zeros(node_count, dtype=float)
for i in range(node_count):
... | python | def _create_random_starter(node_count):
"""Creates the random starter for the random walk.
:param node_count: number of nodes to create the random vector.
:returns: list -- list of starting probabilities for each node.
"""
pi = np.zeros(node_count, dtype=float)
for i in range(node_count):
... | [
"def",
"_create_random_starter",
"(",
"node_count",
")",
":",
"pi",
"=",
"np",
".",
"zeros",
"(",
"node_count",
",",
"dtype",
"=",
"float",
")",
"for",
"i",
"in",
"range",
"(",
"node_count",
")",
":",
"pi",
"[",
"i",
"]",
"=",
"random",
".",
"random"... | Creates the random starter for the random walk.
:param node_count: number of nodes to create the random vector.
:returns: list -- list of starting probabilities for each node. | [
"Creates",
"the",
"random",
"starter",
"for",
"the",
"random",
"walk",
"."
] | 6eb27466ba84e2281e18f93b62aae5efb21ef8b3 | https://github.com/Murali-group/halp/blob/6eb27466ba84e2281e18f93b62aae5efb21ef8b3/halp/algorithms/undirected_partitioning.py#L188-L202 | train |
Murali-group/halp | halp/algorithms/undirected_partitioning.py | _has_converged | def _has_converged(pi_star, pi):
"""Checks if the random walk has converged.
:param pi_star: the new vector
:param pi: the old vector
:returns: bool-- True iff pi has converged.
"""
node_count = pi.shape[0]
EPS = 10e-6
for i in range(node_count):
if pi[i] - pi_star[i] > EPS:
... | python | def _has_converged(pi_star, pi):
"""Checks if the random walk has converged.
:param pi_star: the new vector
:param pi: the old vector
:returns: bool-- True iff pi has converged.
"""
node_count = pi.shape[0]
EPS = 10e-6
for i in range(node_count):
if pi[i] - pi_star[i] > EPS:
... | [
"def",
"_has_converged",
"(",
"pi_star",
",",
"pi",
")",
":",
"node_count",
"=",
"pi",
".",
"shape",
"[",
"0",
"]",
"EPS",
"=",
"10e-6",
"for",
"i",
"in",
"range",
"(",
"node_count",
")",
":",
"if",
"pi",
"[",
"i",
"]",
"-",
"pi_star",
"[",
"i",
... | Checks if the random walk has converged.
:param pi_star: the new vector
:param pi: the old vector
:returns: bool-- True iff pi has converged. | [
"Checks",
"if",
"the",
"random",
"walk",
"has",
"converged",
"."
] | 6eb27466ba84e2281e18f93b62aae5efb21ef8b3 | https://github.com/Murali-group/halp/blob/6eb27466ba84e2281e18f93b62aae5efb21ef8b3/halp/algorithms/undirected_partitioning.py#L205-L219 | train |
Murali-group/halp | halp/utilities/priority_queue.py | PriorityQueue.add_element | def add_element(self, priority, element, count=None):
"""Adds an element with a specific priority.
:param priority: priority of the element.
:param element: element to add.
"""
if count is None:
count = next(self.counter)
entry = [priority, count, element]
... | python | def add_element(self, priority, element, count=None):
"""Adds an element with a specific priority.
:param priority: priority of the element.
:param element: element to add.
"""
if count is None:
count = next(self.counter)
entry = [priority, count, element]
... | [
"def",
"add_element",
"(",
"self",
",",
"priority",
",",
"element",
",",
"count",
"=",
"None",
")",
":",
"if",
"count",
"is",
"None",
":",
"count",
"=",
"next",
"(",
"self",
".",
"counter",
")",
"entry",
"=",
"[",
"priority",
",",
"count",
",",
"el... | Adds an element with a specific priority.
:param priority: priority of the element.
:param element: element to add. | [
"Adds",
"an",
"element",
"with",
"a",
"specific",
"priority",
"."
] | 6eb27466ba84e2281e18f93b62aae5efb21ef8b3 | https://github.com/Murali-group/halp/blob/6eb27466ba84e2281e18f93b62aae5efb21ef8b3/halp/utilities/priority_queue.py#L41-L52 | train |
Murali-group/halp | halp/utilities/priority_queue.py | PriorityQueue.reprioritize | def reprioritize(self, priority, element):
"""Updates the priority of an element.
:raises: ValueError -- No such element in the priority queue.
"""
if element not in self.element_finder:
raise ValueError("No such element in the priority queue.")
entry = self.element... | python | def reprioritize(self, priority, element):
"""Updates the priority of an element.
:raises: ValueError -- No such element in the priority queue.
"""
if element not in self.element_finder:
raise ValueError("No such element in the priority queue.")
entry = self.element... | [
"def",
"reprioritize",
"(",
"self",
",",
"priority",
",",
"element",
")",
":",
"if",
"element",
"not",
"in",
"self",
".",
"element_finder",
":",
"raise",
"ValueError",
"(",
"\"No such element in the priority queue.\"",
")",
"entry",
"=",
"self",
".",
"element_fi... | Updates the priority of an element.
:raises: ValueError -- No such element in the priority queue. | [
"Updates",
"the",
"priority",
"of",
"an",
"element",
"."
] | 6eb27466ba84e2281e18f93b62aae5efb21ef8b3 | https://github.com/Murali-group/halp/blob/6eb27466ba84e2281e18f93b62aae5efb21ef8b3/halp/utilities/priority_queue.py#L79-L89 | train |
Murali-group/halp | halp/utilities/priority_queue.py | PriorityQueue.contains_element | def contains_element(self, element):
"""Determines if an element is contained in the priority queue."
:returns: bool -- true iff element is in the priority queue.
"""
return (element in self.element_finder) and \
(self.element_finder[element][1] != self.INVALID) | python | def contains_element(self, element):
"""Determines if an element is contained in the priority queue."
:returns: bool -- true iff element is in the priority queue.
"""
return (element in self.element_finder) and \
(self.element_finder[element][1] != self.INVALID) | [
"def",
"contains_element",
"(",
"self",
",",
"element",
")",
":",
"return",
"(",
"element",
"in",
"self",
".",
"element_finder",
")",
"and",
"(",
"self",
".",
"element_finder",
"[",
"element",
"]",
"[",
"1",
"]",
"!=",
"self",
".",
"INVALID",
")"
] | Determines if an element is contained in the priority queue."
:returns: bool -- true iff element is in the priority queue. | [
"Determines",
"if",
"an",
"element",
"is",
"contained",
"in",
"the",
"priority",
"queue",
"."
] | 6eb27466ba84e2281e18f93b62aae5efb21ef8b3 | https://github.com/Murali-group/halp/blob/6eb27466ba84e2281e18f93b62aae5efb21ef8b3/halp/utilities/priority_queue.py#L102-L109 | train |
Murali-group/halp | halp/utilities/priority_queue.py | PriorityQueue.is_empty | def is_empty(self):
"""Determines if the priority queue has any elements.
Performs removal of any elements that were "marked-as-invalid".
:returns: true iff the priority queue has no elements.
"""
while self.pq:
if self.pq[0][1] != self.INVALID:
retu... | python | def is_empty(self):
"""Determines if the priority queue has any elements.
Performs removal of any elements that were "marked-as-invalid".
:returns: true iff the priority queue has no elements.
"""
while self.pq:
if self.pq[0][1] != self.INVALID:
retu... | [
"def",
"is_empty",
"(",
"self",
")",
":",
"while",
"self",
".",
"pq",
":",
"if",
"self",
".",
"pq",
"[",
"0",
"]",
"[",
"1",
"]",
"!=",
"self",
".",
"INVALID",
":",
"return",
"False",
"else",
":",
"_",
",",
"_",
",",
"element",
"=",
"heapq",
... | Determines if the priority queue has any elements.
Performs removal of any elements that were "marked-as-invalid".
:returns: true iff the priority queue has no elements. | [
"Determines",
"if",
"the",
"priority",
"queue",
"has",
"any",
"elements",
".",
"Performs",
"removal",
"of",
"any",
"elements",
"that",
"were",
"marked",
"-",
"as",
"-",
"invalid",
"."
] | 6eb27466ba84e2281e18f93b62aae5efb21ef8b3 | https://github.com/Murali-group/halp/blob/6eb27466ba84e2281e18f93b62aae5efb21ef8b3/halp/utilities/priority_queue.py#L111-L125 | train |
Murali-group/halp | halp/algorithms/directed_paths.py | is_connected | def is_connected(H, source_node, target_node):
"""Checks if a target node is connected to a source node. That is,
this method determines if a target node can be visited from the source
node in the sense of the 'Visit' algorithm.
Refer to 'visit's documentation for more details.
:param H: the hyper... | python | def is_connected(H, source_node, target_node):
"""Checks if a target node is connected to a source node. That is,
this method determines if a target node can be visited from the source
node in the sense of the 'Visit' algorithm.
Refer to 'visit's documentation for more details.
:param H: the hyper... | [
"def",
"is_connected",
"(",
"H",
",",
"source_node",
",",
"target_node",
")",
":",
"visited_nodes",
",",
"Pv",
",",
"Pe",
"=",
"visit",
"(",
"H",
",",
"source_node",
")",
"return",
"target_node",
"in",
"visited_nodes"
] | Checks if a target node is connected to a source node. That is,
this method determines if a target node can be visited from the source
node in the sense of the 'Visit' algorithm.
Refer to 'visit's documentation for more details.
:param H: the hypergraph to check connectedness on.
:param source_nod... | [
"Checks",
"if",
"a",
"target",
"node",
"is",
"connected",
"to",
"a",
"source",
"node",
".",
"That",
"is",
"this",
"method",
"determines",
"if",
"a",
"target",
"node",
"can",
"be",
"visited",
"from",
"the",
"source",
"node",
"in",
"the",
"sense",
"of",
... | 6eb27466ba84e2281e18f93b62aae5efb21ef8b3 | https://github.com/Murali-group/halp/blob/6eb27466ba84e2281e18f93b62aae5efb21ef8b3/halp/algorithms/directed_paths.py#L84-L98 | train |
Murali-group/halp | halp/algorithms/directed_paths.py | is_b_connected | def is_b_connected(H, source_node, target_node):
"""Checks if a target node is B-connected to a source node.
A node t is B-connected to a node s iff:
- t is s, or
- there exists an edge in the backward star of t such that all nodes in
the tail of that edge are B-connected to s
... | python | def is_b_connected(H, source_node, target_node):
"""Checks if a target node is B-connected to a source node.
A node t is B-connected to a node s iff:
- t is s, or
- there exists an edge in the backward star of t such that all nodes in
the tail of that edge are B-connected to s
... | [
"def",
"is_b_connected",
"(",
"H",
",",
"source_node",
",",
"target_node",
")",
":",
"b_visited_nodes",
",",
"Pv",
",",
"Pe",
",",
"v",
"=",
"b_visit",
"(",
"H",
",",
"source_node",
")",
"return",
"target_node",
"in",
"b_visited_nodes"
] | Checks if a target node is B-connected to a source node.
A node t is B-connected to a node s iff:
- t is s, or
- there exists an edge in the backward star of t such that all nodes in
the tail of that edge are B-connected to s
In other words, this method determines if a target node ... | [
"Checks",
"if",
"a",
"target",
"node",
"is",
"B",
"-",
"connected",
"to",
"a",
"source",
"node",
"."
] | 6eb27466ba84e2281e18f93b62aae5efb21ef8b3 | https://github.com/Murali-group/halp/blob/6eb27466ba84e2281e18f93b62aae5efb21ef8b3/halp/algorithms/directed_paths.py#L215-L234 | train |
Murali-group/halp | halp/algorithms/directed_paths.py | is_f_connected | def is_f_connected(H, source_node, target_node):
"""Checks if a target node is F-connected to a source node.
A node t is F-connected to a node s iff s if B-connected to t.
Refer to 'f_visit's or 'is_b_connected's documentation for more details.
:param H: the hypergraph to check F-connectedness on.
... | python | def is_f_connected(H, source_node, target_node):
"""Checks if a target node is F-connected to a source node.
A node t is F-connected to a node s iff s if B-connected to t.
Refer to 'f_visit's or 'is_b_connected's documentation for more details.
:param H: the hypergraph to check F-connectedness on.
... | [
"def",
"is_f_connected",
"(",
"H",
",",
"source_node",
",",
"target_node",
")",
":",
"f_visited_nodes",
",",
"Pv",
",",
"Pe",
",",
"v",
"=",
"f_visit",
"(",
"H",
",",
"source_node",
")",
"return",
"target_node",
"in",
"f_visited_nodes"
] | Checks if a target node is F-connected to a source node.
A node t is F-connected to a node s iff s if B-connected to t.
Refer to 'f_visit's or 'is_b_connected's documentation for more details.
:param H: the hypergraph to check F-connectedness on.
:param source_node: the node to check F-connectedness t... | [
"Checks",
"if",
"a",
"target",
"node",
"is",
"F",
"-",
"connected",
"to",
"a",
"source",
"node",
"."
] | 6eb27466ba84e2281e18f93b62aae5efb21ef8b3 | https://github.com/Murali-group/halp/blob/6eb27466ba84e2281e18f93b62aae5efb21ef8b3/halp/algorithms/directed_paths.py#L263-L276 | train |
Murali-group/halp | halp/utilities/undirected_graph_transformations.py | from_networkx_graph | def from_networkx_graph(nx_graph):
"""Returns an UndirectedHypergraph object that is the graph equivalent of
the given NetworkX Graph object.
:param nx_graph: the NetworkX undirected graph object to transform.
:returns: UndirectedHypergraph -- H object equivalent to the
NetworkX undirected ... | python | def from_networkx_graph(nx_graph):
"""Returns an UndirectedHypergraph object that is the graph equivalent of
the given NetworkX Graph object.
:param nx_graph: the NetworkX undirected graph object to transform.
:returns: UndirectedHypergraph -- H object equivalent to the
NetworkX undirected ... | [
"def",
"from_networkx_graph",
"(",
"nx_graph",
")",
":",
"import",
"networkx",
"as",
"nx",
"if",
"not",
"isinstance",
"(",
"nx_graph",
",",
"nx",
".",
"Graph",
")",
":",
"raise",
"TypeError",
"(",
"\"Transformation only applicable to undirected \\\n ... | Returns an UndirectedHypergraph object that is the graph equivalent of
the given NetworkX Graph object.
:param nx_graph: the NetworkX undirected graph object to transform.
:returns: UndirectedHypergraph -- H object equivalent to the
NetworkX undirected graph.
:raises: TypeError -- Transform... | [
"Returns",
"an",
"UndirectedHypergraph",
"object",
"that",
"is",
"the",
"graph",
"equivalent",
"of",
"the",
"given",
"NetworkX",
"Graph",
"object",
"."
] | 6eb27466ba84e2281e18f93b62aae5efb21ef8b3 | https://github.com/Murali-group/halp/blob/6eb27466ba84e2281e18f93b62aae5efb21ef8b3/halp/utilities/undirected_graph_transformations.py#L81-L107 | train |
Murali-group/halp | halp/utilities/directed_graph_transformations.py | from_networkx_digraph | def from_networkx_digraph(nx_digraph):
"""Returns a DirectedHypergraph object that is the graph equivalent of the
given NetworkX DiGraph object.
:param nx_digraph: the NetworkX directed graph object to transform.
:returns: DirectedHypergraph -- hypergraph object equivalent to the
NetworkX d... | python | def from_networkx_digraph(nx_digraph):
"""Returns a DirectedHypergraph object that is the graph equivalent of the
given NetworkX DiGraph object.
:param nx_digraph: the NetworkX directed graph object to transform.
:returns: DirectedHypergraph -- hypergraph object equivalent to the
NetworkX d... | [
"def",
"from_networkx_digraph",
"(",
"nx_digraph",
")",
":",
"import",
"networkx",
"as",
"nx",
"if",
"not",
"isinstance",
"(",
"nx_digraph",
",",
"nx",
".",
"DiGraph",
")",
":",
"raise",
"TypeError",
"(",
"\"Transformation only applicable to directed \\\n ... | Returns a DirectedHypergraph object that is the graph equivalent of the
given NetworkX DiGraph object.
:param nx_digraph: the NetworkX directed graph object to transform.
:returns: DirectedHypergraph -- hypergraph object equivalent to the
NetworkX directed graph.
:raises: TypeError -- Trans... | [
"Returns",
"a",
"DirectedHypergraph",
"object",
"that",
"is",
"the",
"graph",
"equivalent",
"of",
"the",
"given",
"NetworkX",
"DiGraph",
"object",
"."
] | 6eb27466ba84e2281e18f93b62aae5efb21ef8b3 | https://github.com/Murali-group/halp/blob/6eb27466ba84e2281e18f93b62aae5efb21ef8b3/halp/utilities/directed_graph_transformations.py#L81-L110 | train |
Murali-group/halp | halp/utilities/directed_matrices.py | get_tail_incidence_matrix | def get_tail_incidence_matrix(H, nodes_to_indices, hyperedge_ids_to_indices):
"""Creates the incidence matrix of the tail nodes of the given
hypergraph as a sparse matrix.
:param H: the hypergraph for which to create the incidence matrix of.
:param nodes_to_indices: for each node, maps the node to its
... | python | def get_tail_incidence_matrix(H, nodes_to_indices, hyperedge_ids_to_indices):
"""Creates the incidence matrix of the tail nodes of the given
hypergraph as a sparse matrix.
:param H: the hypergraph for which to create the incidence matrix of.
:param nodes_to_indices: for each node, maps the node to its
... | [
"def",
"get_tail_incidence_matrix",
"(",
"H",
",",
"nodes_to_indices",
",",
"hyperedge_ids_to_indices",
")",
":",
"if",
"not",
"isinstance",
"(",
"H",
",",
"DirectedHypergraph",
")",
":",
"raise",
"TypeError",
"(",
"\"Algorithm only applicable to directed hypergraphs\"",
... | Creates the incidence matrix of the tail nodes of the given
hypergraph as a sparse matrix.
:param H: the hypergraph for which to create the incidence matrix of.
:param nodes_to_indices: for each node, maps the node to its
corresponding integer index.
:param hyperedge_ids_to_... | [
"Creates",
"the",
"incidence",
"matrix",
"of",
"the",
"tail",
"nodes",
"of",
"the",
"given",
"hypergraph",
"as",
"a",
"sparse",
"matrix",
"."
] | 6eb27466ba84e2281e18f93b62aae5efb21ef8b3 | https://github.com/Murali-group/halp/blob/6eb27466ba84e2281e18f93b62aae5efb21ef8b3/halp/utilities/directed_matrices.py#L59-L87 | train |
Murali-group/halp | halp/directed_hypergraph.py | DirectedHypergraph.add_node | def add_node(self, node, attr_dict=None, **attr):
"""Adds a node to the graph, along with any related attributes
of the node.
:param node: reference to the node being added.
:param attr_dict: dictionary of attributes of the node.
:param attr: keyword arguments of attributes o... | python | def add_node(self, node, attr_dict=None, **attr):
"""Adds a node to the graph, along with any related attributes
of the node.
:param node: reference to the node being added.
:param attr_dict: dictionary of attributes of the node.
:param attr: keyword arguments of attributes o... | [
"def",
"add_node",
"(",
"self",
",",
"node",
",",
"attr_dict",
"=",
"None",
",",
"*",
"*",
"attr",
")",
":",
"attr_dict",
"=",
"self",
".",
"_combine_attribute_arguments",
"(",
"attr_dict",
",",
"attr",
")",
"# If the node hasn't previously been added, add it alon... | Adds a node to the graph, along with any related attributes
of the node.
:param node: reference to the node being added.
:param attr_dict: dictionary of attributes of the node.
:param attr: keyword arguments of attributes of the node;
attr's values will override a... | [
"Adds",
"a",
"node",
"to",
"the",
"graph",
"along",
"with",
"any",
"related",
"attributes",
"of",
"the",
"node",
"."
] | 6eb27466ba84e2281e18f93b62aae5efb21ef8b3 | https://github.com/Murali-group/halp/blob/6eb27466ba84e2281e18f93b62aae5efb21ef8b3/halp/directed_hypergraph.py#L204-L234 | train |
Murali-group/halp | halp/directed_hypergraph.py | DirectedHypergraph.add_nodes | def add_nodes(self, nodes, attr_dict=None, **attr):
"""Adds multiple nodes to the graph, along with any related attributes
of the nodes.
:param nodes: iterable container to either references of the nodes
OR tuples of (node reference, attribute dictionary);
... | python | def add_nodes(self, nodes, attr_dict=None, **attr):
"""Adds multiple nodes to the graph, along with any related attributes
of the nodes.
:param nodes: iterable container to either references of the nodes
OR tuples of (node reference, attribute dictionary);
... | [
"def",
"add_nodes",
"(",
"self",
",",
"nodes",
",",
"attr_dict",
"=",
"None",
",",
"*",
"*",
"attr",
")",
":",
"attr_dict",
"=",
"self",
".",
"_combine_attribute_arguments",
"(",
"attr_dict",
",",
"attr",
")",
"for",
"node",
"in",
"nodes",
":",
"# Note: ... | Adds multiple nodes to the graph, along with any related attributes
of the nodes.
:param nodes: iterable container to either references of the nodes
OR tuples of (node reference, attribute dictionary);
if an attribute dictionary is provided in the tuple,
... | [
"Adds",
"multiple",
"nodes",
"to",
"the",
"graph",
"along",
"with",
"any",
"related",
"attributes",
"of",
"the",
"nodes",
"."
] | 6eb27466ba84e2281e18f93b62aae5efb21ef8b3 | https://github.com/Murali-group/halp/blob/6eb27466ba84e2281e18f93b62aae5efb21ef8b3/halp/directed_hypergraph.py#L236-L278 | train |
Murali-group/halp | halp/directed_hypergraph.py | DirectedHypergraph.remove_node | def remove_node(self, node):
"""Removes a node and its attributes from the hypergraph. Removes
every hyperedge that contains this node in either the head or the tail.
:param node: reference to the node being added.
:raises: ValueError -- No such node exists.
Examples:
:... | python | def remove_node(self, node):
"""Removes a node and its attributes from the hypergraph. Removes
every hyperedge that contains this node in either the head or the tail.
:param node: reference to the node being added.
:raises: ValueError -- No such node exists.
Examples:
:... | [
"def",
"remove_node",
"(",
"self",
",",
"node",
")",
":",
"if",
"not",
"self",
".",
"has_node",
"(",
"node",
")",
":",
"raise",
"ValueError",
"(",
"\"No such node exists.\"",
")",
"# Remove every hyperedge which is in the forward star of the node",
"forward_star",
"="... | Removes a node and its attributes from the hypergraph. Removes
every hyperedge that contains this node in either the head or the tail.
:param node: reference to the node being added.
:raises: ValueError -- No such node exists.
Examples:
::
>>> H = DirectedHypergrap... | [
"Removes",
"a",
"node",
"and",
"its",
"attributes",
"from",
"the",
"hypergraph",
".",
"Removes",
"every",
"hyperedge",
"that",
"contains",
"this",
"node",
"in",
"either",
"the",
"head",
"or",
"the",
"tail",
"."
] | 6eb27466ba84e2281e18f93b62aae5efb21ef8b3 | https://github.com/Murali-group/halp/blob/6eb27466ba84e2281e18f93b62aae5efb21ef8b3/halp/directed_hypergraph.py#L280-L315 | train |
Murali-group/halp | halp/directed_hypergraph.py | DirectedHypergraph.get_node_attribute | def get_node_attribute(self, node, attribute_name):
"""Given a node and the name of an attribute, get a copy
of that node's attribute.
:param node: reference to the node to retrieve the attribute of.
:param attribute_name: name of the attribute to retrieve.
:returns: attribute v... | python | def get_node_attribute(self, node, attribute_name):
"""Given a node and the name of an attribute, get a copy
of that node's attribute.
:param node: reference to the node to retrieve the attribute of.
:param attribute_name: name of the attribute to retrieve.
:returns: attribute v... | [
"def",
"get_node_attribute",
"(",
"self",
",",
"node",
",",
"attribute_name",
")",
":",
"if",
"not",
"self",
".",
"has_node",
"(",
"node",
")",
":",
"raise",
"ValueError",
"(",
"\"No such node exists.\"",
")",
"elif",
"attribute_name",
"not",
"in",
"self",
"... | Given a node and the name of an attribute, get a copy
of that node's attribute.
:param node: reference to the node to retrieve the attribute of.
:param attribute_name: name of the attribute to retrieve.
:returns: attribute value of the attribute_name key for the
specifie... | [
"Given",
"a",
"node",
"and",
"the",
"name",
"of",
"an",
"attribute",
"get",
"a",
"copy",
"of",
"that",
"node",
"s",
"attribute",
"."
] | 6eb27466ba84e2281e18f93b62aae5efb21ef8b3 | https://github.com/Murali-group/halp/blob/6eb27466ba84e2281e18f93b62aae5efb21ef8b3/halp/directed_hypergraph.py#L420-L438 | train |
Murali-group/halp | halp/directed_hypergraph.py | DirectedHypergraph.get_node_attributes | def get_node_attributes(self, node):
"""Given a node, get a dictionary with copies of that node's
attributes.
:param node: reference to the node to retrieve the attributes of.
:returns: dict -- copy of each attribute of the specified node.
:raises: ValueError -- No such node exi... | python | def get_node_attributes(self, node):
"""Given a node, get a dictionary with copies of that node's
attributes.
:param node: reference to the node to retrieve the attributes of.
:returns: dict -- copy of each attribute of the specified node.
:raises: ValueError -- No such node exi... | [
"def",
"get_node_attributes",
"(",
"self",
",",
"node",
")",
":",
"if",
"not",
"self",
".",
"has_node",
"(",
"node",
")",
":",
"raise",
"ValueError",
"(",
"\"No such node exists.\"",
")",
"attributes",
"=",
"{",
"}",
"for",
"attr_name",
",",
"attr_value",
... | Given a node, get a dictionary with copies of that node's
attributes.
:param node: reference to the node to retrieve the attributes of.
:returns: dict -- copy of each attribute of the specified node.
:raises: ValueError -- No such node exists. | [
"Given",
"a",
"node",
"get",
"a",
"dictionary",
"with",
"copies",
"of",
"that",
"node",
"s",
"attributes",
"."
] | 6eb27466ba84e2281e18f93b62aae5efb21ef8b3 | https://github.com/Murali-group/halp/blob/6eb27466ba84e2281e18f93b62aae5efb21ef8b3/halp/directed_hypergraph.py#L440-L454 | train |
Murali-group/halp | halp/directed_hypergraph.py | DirectedHypergraph.add_hyperedge | def add_hyperedge(self, tail, head, attr_dict=None, **attr):
"""Adds a hyperedge to the hypergraph, along with any related
attributes of the hyperedge.
This method will automatically add any node from the tail and
head that was not in the hypergraph.
A hyperedge without a "weight... | python | def add_hyperedge(self, tail, head, attr_dict=None, **attr):
"""Adds a hyperedge to the hypergraph, along with any related
attributes of the hyperedge.
This method will automatically add any node from the tail and
head that was not in the hypergraph.
A hyperedge without a "weight... | [
"def",
"add_hyperedge",
"(",
"self",
",",
"tail",
",",
"head",
",",
"attr_dict",
"=",
"None",
",",
"*",
"*",
"attr",
")",
":",
"attr_dict",
"=",
"self",
".",
"_combine_attribute_arguments",
"(",
"attr_dict",
",",
"attr",
")",
"# Don't allow both empty tail and... | Adds a hyperedge to the hypergraph, along with any related
attributes of the hyperedge.
This method will automatically add any node from the tail and
head that was not in the hypergraph.
A hyperedge without a "weight" attribute specified will be
assigned the default value of 1.
... | [
"Adds",
"a",
"hyperedge",
"to",
"the",
"hypergraph",
"along",
"with",
"any",
"related",
"attributes",
"of",
"the",
"hyperedge",
".",
"This",
"method",
"will",
"automatically",
"add",
"any",
"node",
"from",
"the",
"tail",
"and",
"head",
"that",
"was",
"not",
... | 6eb27466ba84e2281e18f93b62aae5efb21ef8b3 | https://github.com/Murali-group/halp/blob/6eb27466ba84e2281e18f93b62aae5efb21ef8b3/halp/directed_hypergraph.py#L465-L548 | train |
Murali-group/halp | halp/directed_hypergraph.py | DirectedHypergraph.add_hyperedges | def add_hyperedges(self, hyperedges, attr_dict=None, **attr):
"""Adds multiple hyperedges to the graph, along with any related
attributes of the hyperedges.
If any node in the tail or head of any hyperedge has not
previously been added to the hypergraph, it will automatically... | python | def add_hyperedges(self, hyperedges, attr_dict=None, **attr):
"""Adds multiple hyperedges to the graph, along with any related
attributes of the hyperedges.
If any node in the tail or head of any hyperedge has not
previously been added to the hypergraph, it will automatically... | [
"def",
"add_hyperedges",
"(",
"self",
",",
"hyperedges",
",",
"attr_dict",
"=",
"None",
",",
"*",
"*",
"attr",
")",
":",
"attr_dict",
"=",
"self",
".",
"_combine_attribute_arguments",
"(",
"attr_dict",
",",
"attr",
")",
"hyperedge_ids",
"=",
"[",
"]",
"for... | Adds multiple hyperedges to the graph, along with any related
attributes of the hyperedges.
If any node in the tail or head of any hyperedge has not
previously been added to the hypergraph, it will automatically
be added here. Hyperedges without a "weight" attribute speci... | [
"Adds",
"multiple",
"hyperedges",
"to",
"the",
"graph",
"along",
"with",
"any",
"related",
"attributes",
"of",
"the",
"hyperedges",
".",
"If",
"any",
"node",
"in",
"the",
"tail",
"or",
"head",
"of",
"any",
"hyperedge",
"has",
"not",
"previously",
"been",
"... | 6eb27466ba84e2281e18f93b62aae5efb21ef8b3 | https://github.com/Murali-group/halp/blob/6eb27466ba84e2281e18f93b62aae5efb21ef8b3/halp/directed_hypergraph.py#L550-L606 | train |
Murali-group/halp | halp/directed_hypergraph.py | DirectedHypergraph.get_hyperedge_id | def get_hyperedge_id(self, tail, head):
"""From a tail and head set of nodes, returns the ID of the hyperedge
that these sets comprise.
:param tail: iterable container of references to nodes in the
tail of the hyperedge to be added
:param head: iterable container of ... | python | def get_hyperedge_id(self, tail, head):
"""From a tail and head set of nodes, returns the ID of the hyperedge
that these sets comprise.
:param tail: iterable container of references to nodes in the
tail of the hyperedge to be added
:param head: iterable container of ... | [
"def",
"get_hyperedge_id",
"(",
"self",
",",
"tail",
",",
"head",
")",
":",
"frozen_tail",
"=",
"frozenset",
"(",
"tail",
")",
"frozen_head",
"=",
"frozenset",
"(",
"head",
")",
"if",
"not",
"self",
".",
"has_hyperedge",
"(",
"frozen_tail",
",",
"frozen_he... | From a tail and head set of nodes, returns the ID of the hyperedge
that these sets comprise.
:param tail: iterable container of references to nodes in the
tail of the hyperedge to be added
:param head: iterable container of references to nodes in the
head... | [
"From",
"a",
"tail",
"and",
"head",
"set",
"of",
"nodes",
"returns",
"the",
"ID",
"of",
"the",
"hyperedge",
"that",
"these",
"sets",
"comprise",
"."
] | 6eb27466ba84e2281e18f93b62aae5efb21ef8b3 | https://github.com/Murali-group/halp/blob/6eb27466ba84e2281e18f93b62aae5efb21ef8b3/halp/directed_hypergraph.py#L724-L753 | train |
Murali-group/halp | halp/directed_hypergraph.py | DirectedHypergraph.get_forward_star | def get_forward_star(self, node):
"""Given a node, get a copy of that node's forward star.
:param node: node to retrieve the forward-star of.
:returns: set -- set of hyperedge_ids for the hyperedges
in the node's forward star.
:raises: ValueError -- No such node ... | python | def get_forward_star(self, node):
"""Given a node, get a copy of that node's forward star.
:param node: node to retrieve the forward-star of.
:returns: set -- set of hyperedge_ids for the hyperedges
in the node's forward star.
:raises: ValueError -- No such node ... | [
"def",
"get_forward_star",
"(",
"self",
",",
"node",
")",
":",
"if",
"node",
"not",
"in",
"self",
".",
"_node_attributes",
":",
"raise",
"ValueError",
"(",
"\"No such node exists.\"",
")",
"return",
"self",
".",
"_forward_star",
"[",
"node",
"]",
".",
"copy"... | Given a node, get a copy of that node's forward star.
:param node: node to retrieve the forward-star of.
:returns: set -- set of hyperedge_ids for the hyperedges
in the node's forward star.
:raises: ValueError -- No such node exists. | [
"Given",
"a",
"node",
"get",
"a",
"copy",
"of",
"that",
"node",
"s",
"forward",
"star",
"."
] | 6eb27466ba84e2281e18f93b62aae5efb21ef8b3 | https://github.com/Murali-group/halp/blob/6eb27466ba84e2281e18f93b62aae5efb21ef8b3/halp/directed_hypergraph.py#L833-L844 | train |
Murali-group/halp | halp/directed_hypergraph.py | DirectedHypergraph.get_backward_star | def get_backward_star(self, node):
"""Given a node, get a copy of that node's backward star.
:param node: node to retrieve the backward-star of.
:returns: set -- set of hyperedge_ids for the hyperedges
in the node's backward star.
:raises: ValueError -- No such node exis... | python | def get_backward_star(self, node):
"""Given a node, get a copy of that node's backward star.
:param node: node to retrieve the backward-star of.
:returns: set -- set of hyperedge_ids for the hyperedges
in the node's backward star.
:raises: ValueError -- No such node exis... | [
"def",
"get_backward_star",
"(",
"self",
",",
"node",
")",
":",
"if",
"node",
"not",
"in",
"self",
".",
"_node_attributes",
":",
"raise",
"ValueError",
"(",
"\"No such node exists.\"",
")",
"return",
"self",
".",
"_backward_star",
"[",
"node",
"]",
".",
"cop... | Given a node, get a copy of that node's backward star.
:param node: node to retrieve the backward-star of.
:returns: set -- set of hyperedge_ids for the hyperedges
in the node's backward star.
:raises: ValueError -- No such node exists. | [
"Given",
"a",
"node",
"get",
"a",
"copy",
"of",
"that",
"node",
"s",
"backward",
"star",
"."
] | 6eb27466ba84e2281e18f93b62aae5efb21ef8b3 | https://github.com/Murali-group/halp/blob/6eb27466ba84e2281e18f93b62aae5efb21ef8b3/halp/directed_hypergraph.py#L846-L857 | train |
Murali-group/halp | halp/directed_hypergraph.py | DirectedHypergraph.get_successors | def get_successors(self, tail):
"""Given a tail set of nodes, get a list of edges of which the node
set is the tail of each edge.
:param tail: set of nodes that correspond to the tails of some
(possibly empty) set of edges.
:returns: set -- hyperedge_ids of the h... | python | def get_successors(self, tail):
"""Given a tail set of nodes, get a list of edges of which the node
set is the tail of each edge.
:param tail: set of nodes that correspond to the tails of some
(possibly empty) set of edges.
:returns: set -- hyperedge_ids of the h... | [
"def",
"get_successors",
"(",
"self",
",",
"tail",
")",
":",
"frozen_tail",
"=",
"frozenset",
"(",
"tail",
")",
"# If this node set isn't any tail in the hypergraph, then it has",
"# no successors; thus, return an empty list",
"if",
"frozen_tail",
"not",
"in",
"self",
".",
... | Given a tail set of nodes, get a list of edges of which the node
set is the tail of each edge.
:param tail: set of nodes that correspond to the tails of some
(possibly empty) set of edges.
:returns: set -- hyperedge_ids of the hyperedges that have tail
in... | [
"Given",
"a",
"tail",
"set",
"of",
"nodes",
"get",
"a",
"list",
"of",
"edges",
"of",
"which",
"the",
"node",
"set",
"is",
"the",
"tail",
"of",
"each",
"edge",
"."
] | 6eb27466ba84e2281e18f93b62aae5efb21ef8b3 | https://github.com/Murali-group/halp/blob/6eb27466ba84e2281e18f93b62aae5efb21ef8b3/halp/directed_hypergraph.py#L859-L875 | train |
Murali-group/halp | halp/directed_hypergraph.py | DirectedHypergraph.get_predecessors | def get_predecessors(self, head):
"""Given a head set of nodes, get a list of edges of which the node set
is the head of each edge.
:param head: set of nodes that correspond to the heads of some
(possibly empty) set of edges.
:returns: set -- hyperedge_ids of the... | python | def get_predecessors(self, head):
"""Given a head set of nodes, get a list of edges of which the node set
is the head of each edge.
:param head: set of nodes that correspond to the heads of some
(possibly empty) set of edges.
:returns: set -- hyperedge_ids of the... | [
"def",
"get_predecessors",
"(",
"self",
",",
"head",
")",
":",
"frozen_head",
"=",
"frozenset",
"(",
"head",
")",
"# If this node set isn't any head in the hypergraph, then it has",
"# no predecessors; thus, return an empty list",
"if",
"frozen_head",
"not",
"in",
"self",
"... | Given a head set of nodes, get a list of edges of which the node set
is the head of each edge.
:param head: set of nodes that correspond to the heads of some
(possibly empty) set of edges.
:returns: set -- hyperedge_ids of the hyperedges that have head
in... | [
"Given",
"a",
"head",
"set",
"of",
"nodes",
"get",
"a",
"list",
"of",
"edges",
"of",
"which",
"the",
"node",
"set",
"is",
"the",
"head",
"of",
"each",
"edge",
"."
] | 6eb27466ba84e2281e18f93b62aae5efb21ef8b3 | https://github.com/Murali-group/halp/blob/6eb27466ba84e2281e18f93b62aae5efb21ef8b3/halp/directed_hypergraph.py#L877-L892 | train |
Murali-group/halp | halp/directed_hypergraph.py | DirectedHypergraph.is_BF_hypergraph | def is_BF_hypergraph(self):
"""Indicates whether the hypergraph is a BF-hypergraph.
A BF-hypergraph consists of only B-hyperedges and F-hyperedges.
See "is_B_hypergraph" or "is_F_hypergraph" for more details.
:returns: bool -- True iff the hypergraph is an F-hypergraph.
"""
... | python | def is_BF_hypergraph(self):
"""Indicates whether the hypergraph is a BF-hypergraph.
A BF-hypergraph consists of only B-hyperedges and F-hyperedges.
See "is_B_hypergraph" or "is_F_hypergraph" for more details.
:returns: bool -- True iff the hypergraph is an F-hypergraph.
"""
... | [
"def",
"is_BF_hypergraph",
"(",
"self",
")",
":",
"for",
"hyperedge_id",
"in",
"self",
".",
"_hyperedge_attributes",
":",
"tail",
"=",
"self",
".",
"get_hyperedge_tail",
"(",
"hyperedge_id",
")",
"head",
"=",
"self",
".",
"get_hyperedge_head",
"(",
"hyperedge_id... | Indicates whether the hypergraph is a BF-hypergraph.
A BF-hypergraph consists of only B-hyperedges and F-hyperedges.
See "is_B_hypergraph" or "is_F_hypergraph" for more details.
:returns: bool -- True iff the hypergraph is an F-hypergraph. | [
"Indicates",
"whether",
"the",
"hypergraph",
"is",
"a",
"BF",
"-",
"hypergraph",
".",
"A",
"BF",
"-",
"hypergraph",
"consists",
"of",
"only",
"B",
"-",
"hyperedges",
"and",
"F",
"-",
"hyperedges",
".",
"See",
"is_B_hypergraph",
"or",
"is_F_hypergraph",
"for"... | 6eb27466ba84e2281e18f93b62aae5efb21ef8b3 | https://github.com/Murali-group/halp/blob/6eb27466ba84e2281e18f93b62aae5efb21ef8b3/halp/directed_hypergraph.py#L928-L941 | train |
Murali-group/halp | halp/directed_hypergraph.py | DirectedHypergraph.get_induced_subhypergraph | def get_induced_subhypergraph(self, nodes):
"""Gives a new hypergraph that is the subhypergraph of the current
hypergraph induced by the provided set of nodes. That is, the induced
subhypergraph's node set corresponds precisely to the nodes provided,
and the coressponding hyperedges in t... | python | def get_induced_subhypergraph(self, nodes):
"""Gives a new hypergraph that is the subhypergraph of the current
hypergraph induced by the provided set of nodes. That is, the induced
subhypergraph's node set corresponds precisely to the nodes provided,
and the coressponding hyperedges in t... | [
"def",
"get_induced_subhypergraph",
"(",
"self",
",",
"nodes",
")",
":",
"sub_H",
"=",
"self",
".",
"copy",
"(",
")",
"sub_H",
".",
"remove_nodes",
"(",
"sub_H",
".",
"get_node_set",
"(",
")",
"-",
"set",
"(",
"nodes",
")",
")",
"return",
"sub_H"
] | Gives a new hypergraph that is the subhypergraph of the current
hypergraph induced by the provided set of nodes. That is, the induced
subhypergraph's node set corresponds precisely to the nodes provided,
and the coressponding hyperedges in the subhypergraph are only those
from the origin... | [
"Gives",
"a",
"new",
"hypergraph",
"that",
"is",
"the",
"subhypergraph",
"of",
"the",
"current",
"hypergraph",
"induced",
"by",
"the",
"provided",
"set",
"of",
"nodes",
".",
"That",
"is",
"the",
"induced",
"subhypergraph",
"s",
"node",
"set",
"corresponds",
... | 6eb27466ba84e2281e18f93b62aae5efb21ef8b3 | https://github.com/Murali-group/halp/blob/6eb27466ba84e2281e18f93b62aae5efb21ef8b3/halp/directed_hypergraph.py#L1046-L1061 | train |
aio-libs/multidict | multidict/_multidict_py.py | _Base.getall | def getall(self, key, default=_marker):
"""Return a list of all values matching the key."""
identity = self._title(key)
res = [v for i, k, v in self._impl._items if i == identity]
if res:
return res
if not res and default is not _marker:
return default
... | python | def getall(self, key, default=_marker):
"""Return a list of all values matching the key."""
identity = self._title(key)
res = [v for i, k, v in self._impl._items if i == identity]
if res:
return res
if not res and default is not _marker:
return default
... | [
"def",
"getall",
"(",
"self",
",",
"key",
",",
"default",
"=",
"_marker",
")",
":",
"identity",
"=",
"self",
".",
"_title",
"(",
"key",
")",
"res",
"=",
"[",
"v",
"for",
"i",
",",
"k",
",",
"v",
"in",
"self",
".",
"_impl",
".",
"_items",
"if",
... | Return a list of all values matching the key. | [
"Return",
"a",
"list",
"of",
"all",
"values",
"matching",
"the",
"key",
"."
] | 1ecfa942cf6ae79727711a109e1f46ed24fae07f | https://github.com/aio-libs/multidict/blob/1ecfa942cf6ae79727711a109e1f46ed24fae07f/multidict/_multidict_py.py#L64-L72 | train |
aio-libs/multidict | multidict/_multidict_py.py | MultiDict.extend | def extend(self, *args, **kwargs):
"""Extend current MultiDict with more values.
This method must be used instead of update.
"""
self._extend(args, kwargs, 'extend', self._extend_items) | python | def extend(self, *args, **kwargs):
"""Extend current MultiDict with more values.
This method must be used instead of update.
"""
self._extend(args, kwargs, 'extend', self._extend_items) | [
"def",
"extend",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"_extend",
"(",
"args",
",",
"kwargs",
",",
"'extend'",
",",
"self",
".",
"_extend_items",
")"
] | Extend current MultiDict with more values.
This method must be used instead of update. | [
"Extend",
"current",
"MultiDict",
"with",
"more",
"values",
"."
] | 1ecfa942cf6ae79727711a109e1f46ed24fae07f | https://github.com/aio-libs/multidict/blob/1ecfa942cf6ae79727711a109e1f46ed24fae07f/multidict/_multidict_py.py#L218-L223 | train |
aio-libs/multidict | multidict/_multidict_py.py | MultiDict.setdefault | def setdefault(self, key, default=None):
"""Return value for key, set value to default if key is not present."""
identity = self._title(key)
for i, k, v in self._impl._items:
if i == identity:
return v
self.add(key, default)
return default | python | def setdefault(self, key, default=None):
"""Return value for key, set value to default if key is not present."""
identity = self._title(key)
for i, k, v in self._impl._items:
if i == identity:
return v
self.add(key, default)
return default | [
"def",
"setdefault",
"(",
"self",
",",
"key",
",",
"default",
"=",
"None",
")",
":",
"identity",
"=",
"self",
".",
"_title",
"(",
"key",
")",
"for",
"i",
",",
"k",
",",
"v",
"in",
"self",
".",
"_impl",
".",
"_items",
":",
"if",
"i",
"==",
"iden... | Return value for key, set value to default if key is not present. | [
"Return",
"value",
"for",
"key",
"set",
"value",
"to",
"default",
"if",
"key",
"is",
"not",
"present",
"."
] | 1ecfa942cf6ae79727711a109e1f46ed24fae07f | https://github.com/aio-libs/multidict/blob/1ecfa942cf6ae79727711a109e1f46ed24fae07f/multidict/_multidict_py.py#L281-L288 | train |
aio-libs/multidict | multidict/_multidict_py.py | MultiDict.popall | def popall(self, key, default=_marker):
"""Remove all occurrences of key and return the list of corresponding
values.
If key is not found, default is returned if given, otherwise
KeyError is raised.
"""
found = False
identity = self._title(key)
ret = []
... | python | def popall(self, key, default=_marker):
"""Remove all occurrences of key and return the list of corresponding
values.
If key is not found, default is returned if given, otherwise
KeyError is raised.
"""
found = False
identity = self._title(key)
ret = []
... | [
"def",
"popall",
"(",
"self",
",",
"key",
",",
"default",
"=",
"_marker",
")",
":",
"found",
"=",
"False",
"identity",
"=",
"self",
".",
"_title",
"(",
"key",
")",
"ret",
"=",
"[",
"]",
"for",
"i",
"in",
"range",
"(",
"len",
"(",
"self",
".",
"... | Remove all occurrences of key and return the list of corresponding
values.
If key is not found, default is returned if given, otherwise
KeyError is raised. | [
"Remove",
"all",
"occurrences",
"of",
"key",
"and",
"return",
"the",
"list",
"of",
"corresponding",
"values",
"."
] | 1ecfa942cf6ae79727711a109e1f46ed24fae07f | https://github.com/aio-libs/multidict/blob/1ecfa942cf6ae79727711a109e1f46ed24fae07f/multidict/_multidict_py.py#L311-L336 | train |
rootpy/rootpy | rootpy/stats/histfactory/histfactory.py | Data.total | def total(self, xbin1=1, xbin2=-2):
"""
Return the total yield and its associated statistical uncertainty.
"""
return self.hist.integral(xbin1=xbin1, xbin2=xbin2, error=True) | python | def total(self, xbin1=1, xbin2=-2):
"""
Return the total yield and its associated statistical uncertainty.
"""
return self.hist.integral(xbin1=xbin1, xbin2=xbin2, error=True) | [
"def",
"total",
"(",
"self",
",",
"xbin1",
"=",
"1",
",",
"xbin2",
"=",
"-",
"2",
")",
":",
"return",
"self",
".",
"hist",
".",
"integral",
"(",
"xbin1",
"=",
"xbin1",
",",
"xbin2",
"=",
"xbin2",
",",
"error",
"=",
"True",
")"
] | Return the total yield and its associated statistical uncertainty. | [
"Return",
"the",
"total",
"yield",
"and",
"its",
"associated",
"statistical",
"uncertainty",
"."
] | 3926935e1f2100d8ba68070c2ab44055d4800f73 | https://github.com/rootpy/rootpy/blob/3926935e1f2100d8ba68070c2ab44055d4800f73/rootpy/stats/histfactory/histfactory.py#L133-L137 | train |
rootpy/rootpy | rootpy/stats/histfactory/histfactory.py | Sample.iter_sys | def iter_sys(self):
"""
Iterate over sys_name, overall_sys, histo_sys.
overall_sys or histo_sys may be None for any given sys_name.
"""
names = self.sys_names()
for name in names:
osys = self.GetOverallSys(name)
hsys = self.GetHistoSys(name)
... | python | def iter_sys(self):
"""
Iterate over sys_name, overall_sys, histo_sys.
overall_sys or histo_sys may be None for any given sys_name.
"""
names = self.sys_names()
for name in names:
osys = self.GetOverallSys(name)
hsys = self.GetHistoSys(name)
... | [
"def",
"iter_sys",
"(",
"self",
")",
":",
"names",
"=",
"self",
".",
"sys_names",
"(",
")",
"for",
"name",
"in",
"names",
":",
"osys",
"=",
"self",
".",
"GetOverallSys",
"(",
"name",
")",
"hsys",
"=",
"self",
".",
"GetHistoSys",
"(",
"name",
")",
"... | Iterate over sys_name, overall_sys, histo_sys.
overall_sys or histo_sys may be None for any given sys_name. | [
"Iterate",
"over",
"sys_name",
"overall_sys",
"histo_sys",
".",
"overall_sys",
"or",
"histo_sys",
"may",
"be",
"None",
"for",
"any",
"given",
"sys_name",
"."
] | 3926935e1f2100d8ba68070c2ab44055d4800f73 | https://github.com/rootpy/rootpy/blob/3926935e1f2100d8ba68070c2ab44055d4800f73/rootpy/stats/histfactory/histfactory.py#L260-L269 | train |
rootpy/rootpy | rootpy/stats/histfactory/histfactory.py | Sample.sys_hist | def sys_hist(self, name=None):
"""
Return the effective low and high histogram for a given systematic.
If this sample does not contain the named systematic then return
the nominal histogram for both low and high variations.
"""
if name is None:
low = self.hist... | python | def sys_hist(self, name=None):
"""
Return the effective low and high histogram for a given systematic.
If this sample does not contain the named systematic then return
the nominal histogram for both low and high variations.
"""
if name is None:
low = self.hist... | [
"def",
"sys_hist",
"(",
"self",
",",
"name",
"=",
"None",
")",
":",
"if",
"name",
"is",
"None",
":",
"low",
"=",
"self",
".",
"hist",
".",
"Clone",
"(",
"shallow",
"=",
"True",
")",
"high",
"=",
"self",
".",
"hist",
".",
"Clone",
"(",
"shallow",
... | Return the effective low and high histogram for a given systematic.
If this sample does not contain the named systematic then return
the nominal histogram for both low and high variations. | [
"Return",
"the",
"effective",
"low",
"and",
"high",
"histogram",
"for",
"a",
"given",
"systematic",
".",
"If",
"this",
"sample",
"does",
"not",
"contain",
"the",
"named",
"systematic",
"then",
"return",
"the",
"nominal",
"histogram",
"for",
"both",
"low",
"a... | 3926935e1f2100d8ba68070c2ab44055d4800f73 | https://github.com/rootpy/rootpy/blob/3926935e1f2100d8ba68070c2ab44055d4800f73/rootpy/stats/histfactory/histfactory.py#L271-L293 | train |
rootpy/rootpy | rootpy/stats/histfactory/histfactory.py | Channel.sys_hist | def sys_hist(self, name=None, where=None):
"""
Return the effective total low and high histogram for a given
systematic over samples in this channel.
If a sample does not contain the named systematic then its nominal
histogram is used for both low and high variations.
Pa... | python | def sys_hist(self, name=None, where=None):
"""
Return the effective total low and high histogram for a given
systematic over samples in this channel.
If a sample does not contain the named systematic then its nominal
histogram is used for both low and high variations.
Pa... | [
"def",
"sys_hist",
"(",
"self",
",",
"name",
"=",
"None",
",",
"where",
"=",
"None",
")",
":",
"total_low",
",",
"total_high",
"=",
"None",
",",
"None",
"for",
"sample",
"in",
"self",
".",
"samples",
":",
"if",
"where",
"is",
"not",
"None",
"and",
... | Return the effective total low and high histogram for a given
systematic over samples in this channel.
If a sample does not contain the named systematic then its nominal
histogram is used for both low and high variations.
Parameters
----------
name : string, optional (d... | [
"Return",
"the",
"effective",
"total",
"low",
"and",
"high",
"histogram",
"for",
"a",
"given",
"systematic",
"over",
"samples",
"in",
"this",
"channel",
".",
"If",
"a",
"sample",
"does",
"not",
"contain",
"the",
"named",
"systematic",
"then",
"its",
"nominal... | 3926935e1f2100d8ba68070c2ab44055d4800f73 | https://github.com/rootpy/rootpy/blob/3926935e1f2100d8ba68070c2ab44055d4800f73/rootpy/stats/histfactory/histfactory.py#L894-L931 | train |
rootpy/rootpy | rootpy/stats/histfactory/histfactory.py | Channel.apply_snapshot | def apply_snapshot(self, argset):
"""
Create a clone of this Channel where histograms are modified according
to the values of the nuisance parameters in the snapshot. This is
useful when creating post-fit distribution plots.
Parameters
----------
argset : RooArt... | python | def apply_snapshot(self, argset):
"""
Create a clone of this Channel where histograms are modified according
to the values of the nuisance parameters in the snapshot. This is
useful when creating post-fit distribution plots.
Parameters
----------
argset : RooArt... | [
"def",
"apply_snapshot",
"(",
"self",
",",
"argset",
")",
":",
"clone",
"=",
"self",
".",
"Clone",
"(",
")",
"args",
"=",
"[",
"var",
"for",
"var",
"in",
"argset",
"if",
"not",
"(",
"var",
".",
"name",
".",
"startswith",
"(",
"'binWidth_obs_x_'",
")"... | Create a clone of this Channel where histograms are modified according
to the values of the nuisance parameters in the snapshot. This is
useful when creating post-fit distribution plots.
Parameters
----------
argset : RooArtSet
A RooArgSet of RooRealVar nuisance par... | [
"Create",
"a",
"clone",
"of",
"this",
"Channel",
"where",
"histograms",
"are",
"modified",
"according",
"to",
"the",
"values",
"of",
"the",
"nuisance",
"parameters",
"in",
"the",
"snapshot",
".",
"This",
"is",
"useful",
"when",
"creating",
"post",
"-",
"fit"... | 3926935e1f2100d8ba68070c2ab44055d4800f73 | https://github.com/rootpy/rootpy/blob/3926935e1f2100d8ba68070c2ab44055d4800f73/rootpy/stats/histfactory/histfactory.py#L1040-L1109 | train |
rootpy/rootpy | rootpy/extern/byteplay2/__init__.py | printcodelist | def printcodelist(codelist, to=sys.stdout):
"""Get a code list. Print it nicely."""
labeldict = {}
pendinglabels = []
for i, (op, arg) in enumerate(codelist):
if isinstance(op, Label):
pendinglabels.append(op)
elif op is SetLineno:
pass
else:
... | python | def printcodelist(codelist, to=sys.stdout):
"""Get a code list. Print it nicely."""
labeldict = {}
pendinglabels = []
for i, (op, arg) in enumerate(codelist):
if isinstance(op, Label):
pendinglabels.append(op)
elif op is SetLineno:
pass
else:
... | [
"def",
"printcodelist",
"(",
"codelist",
",",
"to",
"=",
"sys",
".",
"stdout",
")",
":",
"labeldict",
"=",
"{",
"}",
"pendinglabels",
"=",
"[",
"]",
"for",
"i",
",",
"(",
"op",
",",
"arg",
")",
"in",
"enumerate",
"(",
"codelist",
")",
":",
"if",
... | Get a code list. Print it nicely. | [
"Get",
"a",
"code",
"list",
".",
"Print",
"it",
"nicely",
"."
] | 3926935e1f2100d8ba68070c2ab44055d4800f73 | https://github.com/rootpy/rootpy/blob/3926935e1f2100d8ba68070c2ab44055d4800f73/rootpy/extern/byteplay2/__init__.py#L785-L840 | train |
rootpy/rootpy | rootpy/extern/byteplay2/__init__.py | recompile | def recompile(filename):
"""Create a .pyc by disassembling the file and assembling it again, printing
a message that the reassembled file was loaded."""
# Most of the code here based on the compile.py module.
import os
import imp
import marshal
import struct
f = open(filename, 'U')
... | python | def recompile(filename):
"""Create a .pyc by disassembling the file and assembling it again, printing
a message that the reassembled file was loaded."""
# Most of the code here based on the compile.py module.
import os
import imp
import marshal
import struct
f = open(filename, 'U')
... | [
"def",
"recompile",
"(",
"filename",
")",
":",
"# Most of the code here based on the compile.py module.",
"import",
"os",
"import",
"imp",
"import",
"marshal",
"import",
"struct",
"f",
"=",
"open",
"(",
"filename",
",",
"'U'",
")",
"try",
":",
"timestamp",
"=",
... | Create a .pyc by disassembling the file and assembling it again, printing
a message that the reassembled file was loaded. | [
"Create",
"a",
".",
"pyc",
"by",
"disassembling",
"the",
"file",
"and",
"assembling",
"it",
"again",
"printing",
"a",
"message",
"that",
"the",
"reassembled",
"file",
"was",
"loaded",
"."
] | 3926935e1f2100d8ba68070c2ab44055d4800f73 | https://github.com/rootpy/rootpy/blob/3926935e1f2100d8ba68070c2ab44055d4800f73/rootpy/extern/byteplay2/__init__.py#L842-L885 | train |
rootpy/rootpy | rootpy/extern/byteplay2/__init__.py | recompile_all | def recompile_all(path):
"""recursively recompile all .py files in the directory"""
import os
if os.path.isdir(path):
for root, dirs, files in os.walk(path):
for name in files:
if name.endswith('.py'):
filename = os.path.abspath(os.path.join(root, name... | python | def recompile_all(path):
"""recursively recompile all .py files in the directory"""
import os
if os.path.isdir(path):
for root, dirs, files in os.walk(path):
for name in files:
if name.endswith('.py'):
filename = os.path.abspath(os.path.join(root, name... | [
"def",
"recompile_all",
"(",
"path",
")",
":",
"import",
"os",
"if",
"os",
".",
"path",
".",
"isdir",
"(",
"path",
")",
":",
"for",
"root",
",",
"dirs",
",",
"files",
"in",
"os",
".",
"walk",
"(",
"path",
")",
":",
"for",
"name",
"in",
"files",
... | recursively recompile all .py files in the directory | [
"recursively",
"recompile",
"all",
".",
"py",
"files",
"in",
"the",
"directory"
] | 3926935e1f2100d8ba68070c2ab44055d4800f73 | https://github.com/rootpy/rootpy/blob/3926935e1f2100d8ba68070c2ab44055d4800f73/rootpy/extern/byteplay2/__init__.py#L887-L899 | train |
rootpy/rootpy | rootpy/extern/byteplay2/__init__.py | Code.from_code | def from_code(cls, co):
"""Disassemble a Python code object into a Code object."""
co_code = co.co_code
labels = dict((addr, Label()) for addr in findlabels(co_code))
linestarts = dict(cls._findlinestarts(co))
cellfree = co.co_cellvars + co.co_freevars
code = CodeList()
... | python | def from_code(cls, co):
"""Disassemble a Python code object into a Code object."""
co_code = co.co_code
labels = dict((addr, Label()) for addr in findlabels(co_code))
linestarts = dict(cls._findlinestarts(co))
cellfree = co.co_cellvars + co.co_freevars
code = CodeList()
... | [
"def",
"from_code",
"(",
"cls",
",",
"co",
")",
":",
"co_code",
"=",
"co",
".",
"co_code",
"labels",
"=",
"dict",
"(",
"(",
"addr",
",",
"Label",
"(",
")",
")",
"for",
"addr",
"in",
"findlabels",
"(",
"co_code",
")",
")",
"linestarts",
"=",
"dict",... | Disassemble a Python code object into a Code object. | [
"Disassemble",
"a",
"Python",
"code",
"object",
"into",
"a",
"Code",
"object",
"."
] | 3926935e1f2100d8ba68070c2ab44055d4800f73 | https://github.com/rootpy/rootpy/blob/3926935e1f2100d8ba68070c2ab44055d4800f73/rootpy/extern/byteplay2/__init__.py#L320-L387 | train |
rootpy/rootpy | rootpy/plotting/contrib/quantiles.py | effective_sample_size | def effective_sample_size(h):
"""
Calculate the effective sample size for a histogram
the same way as ROOT does.
"""
sum = 0
ew = 0
w = 0
for bin in h.bins(overflow=False):
sum += bin.value
ew = bin.error
w += ew * ew
esum = sum * sum / w
return esum | python | def effective_sample_size(h):
"""
Calculate the effective sample size for a histogram
the same way as ROOT does.
"""
sum = 0
ew = 0
w = 0
for bin in h.bins(overflow=False):
sum += bin.value
ew = bin.error
w += ew * ew
esum = sum * sum / w
return esum | [
"def",
"effective_sample_size",
"(",
"h",
")",
":",
"sum",
"=",
"0",
"ew",
"=",
"0",
"w",
"=",
"0",
"for",
"bin",
"in",
"h",
".",
"bins",
"(",
"overflow",
"=",
"False",
")",
":",
"sum",
"+=",
"bin",
".",
"value",
"ew",
"=",
"bin",
".",
"error",... | Calculate the effective sample size for a histogram
the same way as ROOT does. | [
"Calculate",
"the",
"effective",
"sample",
"size",
"for",
"a",
"histogram",
"the",
"same",
"way",
"as",
"ROOT",
"does",
"."
] | 3926935e1f2100d8ba68070c2ab44055d4800f73 | https://github.com/rootpy/rootpy/blob/3926935e1f2100d8ba68070c2ab44055d4800f73/rootpy/plotting/contrib/quantiles.py#L107-L120 | train |
rootpy/rootpy | rootpy/plotting/contrib/quantiles.py | critical_value | def critical_value(n, p):
"""
This function calculates the critical value given
n and p, and confidence level = 1 - p.
"""
dn = 1
delta = 0.5
res = ROOT.TMath.KolmogorovProb(dn * sqrt(n))
while res > 1.0001 * p or res < 0.9999 * p:
if (res > 1.0001 * p):
dn = dn + del... | python | def critical_value(n, p):
"""
This function calculates the critical value given
n and p, and confidence level = 1 - p.
"""
dn = 1
delta = 0.5
res = ROOT.TMath.KolmogorovProb(dn * sqrt(n))
while res > 1.0001 * p or res < 0.9999 * p:
if (res > 1.0001 * p):
dn = dn + del... | [
"def",
"critical_value",
"(",
"n",
",",
"p",
")",
":",
"dn",
"=",
"1",
"delta",
"=",
"0.5",
"res",
"=",
"ROOT",
".",
"TMath",
".",
"KolmogorovProb",
"(",
"dn",
"*",
"sqrt",
"(",
"n",
")",
")",
"while",
"res",
">",
"1.0001",
"*",
"p",
"or",
"res... | This function calculates the critical value given
n and p, and confidence level = 1 - p. | [
"This",
"function",
"calculates",
"the",
"critical",
"value",
"given",
"n",
"and",
"p",
"and",
"confidence",
"level",
"=",
"1",
"-",
"p",
"."
] | 3926935e1f2100d8ba68070c2ab44055d4800f73 | https://github.com/rootpy/rootpy/blob/3926935e1f2100d8ba68070c2ab44055d4800f73/rootpy/plotting/contrib/quantiles.py#L123-L138 | train |
rootpy/rootpy | rootpy/io/pickler.py | dump | def dump(obj, root_file, proto=0, key=None):
"""Dump an object into a ROOT TFile.
`root_file` may be an open ROOT file or directory, or a string path to an
existing ROOT file.
"""
if isinstance(root_file, string_types):
root_file = root_open(root_file, 'recreate')
own_file = True
... | python | def dump(obj, root_file, proto=0, key=None):
"""Dump an object into a ROOT TFile.
`root_file` may be an open ROOT file or directory, or a string path to an
existing ROOT file.
"""
if isinstance(root_file, string_types):
root_file = root_open(root_file, 'recreate')
own_file = True
... | [
"def",
"dump",
"(",
"obj",
",",
"root_file",
",",
"proto",
"=",
"0",
",",
"key",
"=",
"None",
")",
":",
"if",
"isinstance",
"(",
"root_file",
",",
"string_types",
")",
":",
"root_file",
"=",
"root_open",
"(",
"root_file",
",",
"'recreate'",
")",
"own_f... | Dump an object into a ROOT TFile.
`root_file` may be an open ROOT file or directory, or a string path to an
existing ROOT file. | [
"Dump",
"an",
"object",
"into",
"a",
"ROOT",
"TFile",
"."
] | 3926935e1f2100d8ba68070c2ab44055d4800f73 | https://github.com/rootpy/rootpy/blob/3926935e1f2100d8ba68070c2ab44055d4800f73/rootpy/io/pickler.py#L344-L358 | train |
rootpy/rootpy | rootpy/io/pickler.py | load | def load(root_file, use_proxy=True, key=None):
"""Load an object from a ROOT TFile.
`root_file` may be an open ROOT file or directory, or a string path to an
existing ROOT file.
"""
if isinstance(root_file, string_types):
root_file = root_open(root_file)
own_file = True
else:
... | python | def load(root_file, use_proxy=True, key=None):
"""Load an object from a ROOT TFile.
`root_file` may be an open ROOT file or directory, or a string path to an
existing ROOT file.
"""
if isinstance(root_file, string_types):
root_file = root_open(root_file)
own_file = True
else:
... | [
"def",
"load",
"(",
"root_file",
",",
"use_proxy",
"=",
"True",
",",
"key",
"=",
"None",
")",
":",
"if",
"isinstance",
"(",
"root_file",
",",
"string_types",
")",
":",
"root_file",
"=",
"root_open",
"(",
"root_file",
")",
"own_file",
"=",
"True",
"else",... | Load an object from a ROOT TFile.
`root_file` may be an open ROOT file or directory, or a string path to an
existing ROOT file. | [
"Load",
"an",
"object",
"from",
"a",
"ROOT",
"TFile",
"."
] | 3926935e1f2100d8ba68070c2ab44055d4800f73 | https://github.com/rootpy/rootpy/blob/3926935e1f2100d8ba68070c2ab44055d4800f73/rootpy/io/pickler.py#L361-L375 | train |
rootpy/rootpy | rootpy/io/pickler.py | Pickler.dump | def dump(self, obj, key=None):
"""Write a pickled representation of obj to the open TFile."""
if key is None:
key = '_pickle'
with preserve_current_directory():
self.__file.cd()
if sys.version_info[0] < 3:
pickle.Pickler.dump(self, obj)
... | python | def dump(self, obj, key=None):
"""Write a pickled representation of obj to the open TFile."""
if key is None:
key = '_pickle'
with preserve_current_directory():
self.__file.cd()
if sys.version_info[0] < 3:
pickle.Pickler.dump(self, obj)
... | [
"def",
"dump",
"(",
"self",
",",
"obj",
",",
"key",
"=",
"None",
")",
":",
"if",
"key",
"is",
"None",
":",
"key",
"=",
"'_pickle'",
"with",
"preserve_current_directory",
"(",
")",
":",
"self",
".",
"__file",
".",
"cd",
"(",
")",
"if",
"sys",
".",
... | Write a pickled representation of obj to the open TFile. | [
"Write",
"a",
"pickled",
"representation",
"of",
"obj",
"to",
"the",
"open",
"TFile",
"."
] | 3926935e1f2100d8ba68070c2ab44055d4800f73 | https://github.com/rootpy/rootpy/blob/3926935e1f2100d8ba68070c2ab44055d4800f73/rootpy/io/pickler.py#L162-L176 | train |
rootpy/rootpy | rootpy/io/pickler.py | Unpickler.load | def load(self, key=None):
"""Read a pickled object representation from the open file."""
if key is None:
key = '_pickle'
obj = None
if _compat_hooks:
save = _compat_hooks[0]()
try:
self.__n += 1
s = self.__file.Get(key + ';{0:d}'.fo... | python | def load(self, key=None):
"""Read a pickled object representation from the open file."""
if key is None:
key = '_pickle'
obj = None
if _compat_hooks:
save = _compat_hooks[0]()
try:
self.__n += 1
s = self.__file.Get(key + ';{0:d}'.fo... | [
"def",
"load",
"(",
"self",
",",
"key",
"=",
"None",
")",
":",
"if",
"key",
"is",
"None",
":",
"key",
"=",
"'_pickle'",
"obj",
"=",
"None",
"if",
"_compat_hooks",
":",
"save",
"=",
"_compat_hooks",
"[",
"0",
"]",
"(",
")",
"try",
":",
"self",
"."... | Read a pickled object representation from the open file. | [
"Read",
"a",
"pickled",
"object",
"representation",
"from",
"the",
"open",
"file",
"."
] | 3926935e1f2100d8ba68070c2ab44055d4800f73 | https://github.com/rootpy/rootpy/blob/3926935e1f2100d8ba68070c2ab44055d4800f73/rootpy/io/pickler.py#L272-L291 | train |
rootpy/rootpy | rootpy/utils/extras.py | iter_ROOT_classes | def iter_ROOT_classes():
"""
Iterator over all available ROOT classes
"""
class_index = "http://root.cern.ch/root/html/ClassIndex.html"
for s in minidom.parse(urlopen(class_index)).getElementsByTagName("span"):
if ("class", "typename") in s.attributes.items():
class_name = s.chil... | python | def iter_ROOT_classes():
"""
Iterator over all available ROOT classes
"""
class_index = "http://root.cern.ch/root/html/ClassIndex.html"
for s in minidom.parse(urlopen(class_index)).getElementsByTagName("span"):
if ("class", "typename") in s.attributes.items():
class_name = s.chil... | [
"def",
"iter_ROOT_classes",
"(",
")",
":",
"class_index",
"=",
"\"http://root.cern.ch/root/html/ClassIndex.html\"",
"for",
"s",
"in",
"minidom",
".",
"parse",
"(",
"urlopen",
"(",
"class_index",
")",
")",
".",
"getElementsByTagName",
"(",
"\"span\"",
")",
":",
"if... | Iterator over all available ROOT classes | [
"Iterator",
"over",
"all",
"available",
"ROOT",
"classes"
] | 3926935e1f2100d8ba68070c2ab44055d4800f73 | https://github.com/rootpy/rootpy/blob/3926935e1f2100d8ba68070c2ab44055d4800f73/rootpy/utils/extras.py#L27-L38 | train |
rootpy/rootpy | rootpy/plotting/style/cmstdr/labels.py | CMS_label | def CMS_label(text="Preliminary 2012", sqrts=8, pad=None):
""" Add a 'CMS Preliminary' style label to the current Pad.
The blurbs are drawn in the top margin. The label "CMS " + text is drawn
in the upper left. If sqrts is None, it will be omitted. Otherwise, it
will be drawn in the upper right.
... | python | def CMS_label(text="Preliminary 2012", sqrts=8, pad=None):
""" Add a 'CMS Preliminary' style label to the current Pad.
The blurbs are drawn in the top margin. The label "CMS " + text is drawn
in the upper left. If sqrts is None, it will be omitted. Otherwise, it
will be drawn in the upper right.
... | [
"def",
"CMS_label",
"(",
"text",
"=",
"\"Preliminary 2012\"",
",",
"sqrts",
"=",
"8",
",",
"pad",
"=",
"None",
")",
":",
"if",
"pad",
"is",
"None",
":",
"pad",
"=",
"ROOT",
".",
"gPad",
"with",
"preserve_current_canvas",
"(",
")",
":",
"pad",
".",
"c... | Add a 'CMS Preliminary' style label to the current Pad.
The blurbs are drawn in the top margin. The label "CMS " + text is drawn
in the upper left. If sqrts is None, it will be omitted. Otherwise, it
will be drawn in the upper right. | [
"Add",
"a",
"CMS",
"Preliminary",
"style",
"label",
"to",
"the",
"current",
"Pad",
"."
] | 3926935e1f2100d8ba68070c2ab44055d4800f73 | https://github.com/rootpy/rootpy/blob/3926935e1f2100d8ba68070c2ab44055d4800f73/rootpy/plotting/style/cmstdr/labels.py#L15-L50 | train |
rootpy/rootpy | rootpy/stats/histfactory/utils.py | make_channel | def make_channel(name, samples, data=None, verbose=False):
"""
Create a Channel from a list of Samples
"""
if verbose:
llog = log['make_channel']
llog.info("creating channel {0}".format(name))
# avoid segfault if name begins with a digit by using "channel_" prefix
chan = Channel(... | python | def make_channel(name, samples, data=None, verbose=False):
"""
Create a Channel from a list of Samples
"""
if verbose:
llog = log['make_channel']
llog.info("creating channel {0}".format(name))
# avoid segfault if name begins with a digit by using "channel_" prefix
chan = Channel(... | [
"def",
"make_channel",
"(",
"name",
",",
"samples",
",",
"data",
"=",
"None",
",",
"verbose",
"=",
"False",
")",
":",
"if",
"verbose",
":",
"llog",
"=",
"log",
"[",
"'make_channel'",
"]",
"llog",
".",
"info",
"(",
"\"creating channel {0}\"",
".",
"format... | Create a Channel from a list of Samples | [
"Create",
"a",
"Channel",
"from",
"a",
"list",
"of",
"Samples"
] | 3926935e1f2100d8ba68070c2ab44055d4800f73 | https://github.com/rootpy/rootpy/blob/3926935e1f2100d8ba68070c2ab44055d4800f73/rootpy/stats/histfactory/utils.py#L32-L53 | train |
rootpy/rootpy | rootpy/stats/histfactory/utils.py | make_measurement | def make_measurement(name,
channels,
lumi=1.0, lumi_rel_error=0.1,
output_prefix='./histfactory',
POI=None,
const_params=None,
verbose=False):
"""
Create a Measurement from a list of Cha... | python | def make_measurement(name,
channels,
lumi=1.0, lumi_rel_error=0.1,
output_prefix='./histfactory',
POI=None,
const_params=None,
verbose=False):
"""
Create a Measurement from a list of Cha... | [
"def",
"make_measurement",
"(",
"name",
",",
"channels",
",",
"lumi",
"=",
"1.0",
",",
"lumi_rel_error",
"=",
"0.1",
",",
"output_prefix",
"=",
"'./histfactory'",
",",
"POI",
"=",
"None",
",",
"const_params",
"=",
"None",
",",
"verbose",
"=",
"False",
")",... | Create a Measurement from a list of Channels | [
"Create",
"a",
"Measurement",
"from",
"a",
"list",
"of",
"Channels"
] | 3926935e1f2100d8ba68070c2ab44055d4800f73 | https://github.com/rootpy/rootpy/blob/3926935e1f2100d8ba68070c2ab44055d4800f73/rootpy/stats/histfactory/utils.py#L56-L104 | train |
rootpy/rootpy | rootpy/stats/histfactory/utils.py | make_workspace | def make_workspace(measurement, channel=None, name=None, silence=False):
"""
Create a workspace containing the model for a measurement
If `channel` is None then include all channels in the model
If `silence` is True, then silence HistFactory's output on
stdout and stderr.
"""
context = sil... | python | def make_workspace(measurement, channel=None, name=None, silence=False):
"""
Create a workspace containing the model for a measurement
If `channel` is None then include all channels in the model
If `silence` is True, then silence HistFactory's output on
stdout and stderr.
"""
context = sil... | [
"def",
"make_workspace",
"(",
"measurement",
",",
"channel",
"=",
"None",
",",
"name",
"=",
"None",
",",
"silence",
"=",
"False",
")",
":",
"context",
"=",
"silence_sout_serr",
"if",
"silence",
"else",
"do_nothing",
"with",
"context",
"(",
")",
":",
"hist2... | Create a workspace containing the model for a measurement
If `channel` is None then include all channels in the model
If `silence` is True, then silence HistFactory's output on
stdout and stderr. | [
"Create",
"a",
"workspace",
"containing",
"the",
"model",
"for",
"a",
"measurement"
] | 3926935e1f2100d8ba68070c2ab44055d4800f73 | https://github.com/rootpy/rootpy/blob/3926935e1f2100d8ba68070c2ab44055d4800f73/rootpy/stats/histfactory/utils.py#L107-L129 | train |
rootpy/rootpy | rootpy/stats/histfactory/utils.py | measurements_from_xml | def measurements_from_xml(filename,
collect_histograms=True,
cd_parent=False,
silence=False):
"""
Read in a list of Measurements from XML
"""
if not os.path.isfile(filename):
raise OSError("the file {0} does not exist"... | python | def measurements_from_xml(filename,
collect_histograms=True,
cd_parent=False,
silence=False):
"""
Read in a list of Measurements from XML
"""
if not os.path.isfile(filename):
raise OSError("the file {0} does not exist"... | [
"def",
"measurements_from_xml",
"(",
"filename",
",",
"collect_histograms",
"=",
"True",
",",
"cd_parent",
"=",
"False",
",",
"silence",
"=",
"False",
")",
":",
"if",
"not",
"os",
".",
"path",
".",
"isfile",
"(",
"filename",
")",
":",
"raise",
"OSError",
... | Read in a list of Measurements from XML | [
"Read",
"in",
"a",
"list",
"of",
"Measurements",
"from",
"XML"
] | 3926935e1f2100d8ba68070c2ab44055d4800f73 | https://github.com/rootpy/rootpy/blob/3926935e1f2100d8ba68070c2ab44055d4800f73/rootpy/stats/histfactory/utils.py#L132-L166 | train |
rootpy/rootpy | rootpy/stats/histfactory/utils.py | write_measurement | def write_measurement(measurement,
root_file=None,
xml_path=None,
output_path=None,
output_suffix=None,
write_workspaces=False,
apply_xml_patches=True,
silence=False)... | python | def write_measurement(measurement,
root_file=None,
xml_path=None,
output_path=None,
output_suffix=None,
write_workspaces=False,
apply_xml_patches=True,
silence=False)... | [
"def",
"write_measurement",
"(",
"measurement",
",",
"root_file",
"=",
"None",
",",
"xml_path",
"=",
"None",
",",
"output_path",
"=",
"None",
",",
"output_suffix",
"=",
"None",
",",
"write_workspaces",
"=",
"False",
",",
"apply_xml_patches",
"=",
"True",
",",
... | Write a measurement and RooWorkspaces for all contained channels
into a ROOT file and write the XML files into a directory.
Parameters
----------
measurement : HistFactory::Measurement
An asrootpy'd ``HistFactory::Measurement`` object
root_file : ROOT TFile or string, optional (default=No... | [
"Write",
"a",
"measurement",
"and",
"RooWorkspaces",
"for",
"all",
"contained",
"channels",
"into",
"a",
"ROOT",
"file",
"and",
"write",
"the",
"XML",
"files",
"into",
"a",
"directory",
"."
] | 3926935e1f2100d8ba68070c2ab44055d4800f73 | https://github.com/rootpy/rootpy/blob/3926935e1f2100d8ba68070c2ab44055d4800f73/rootpy/stats/histfactory/utils.py#L169-L282 | train |
rootpy/rootpy | rootpy/stats/histfactory/utils.py | patch_xml | def patch_xml(files, root_file=None, float_precision=3):
"""
Apply patches to HistFactory XML output from PrintXML
"""
if float_precision < 0:
raise ValueError("precision must be greater than 0")
def fix_path(match):
path = match.group(1)
if path:
head, tail = os... | python | def patch_xml(files, root_file=None, float_precision=3):
"""
Apply patches to HistFactory XML output from PrintXML
"""
if float_precision < 0:
raise ValueError("precision must be greater than 0")
def fix_path(match):
path = match.group(1)
if path:
head, tail = os... | [
"def",
"patch_xml",
"(",
"files",
",",
"root_file",
"=",
"None",
",",
"float_precision",
"=",
"3",
")",
":",
"if",
"float_precision",
"<",
"0",
":",
"raise",
"ValueError",
"(",
"\"precision must be greater than 0\"",
")",
"def",
"fix_path",
"(",
"match",
")",
... | Apply patches to HistFactory XML output from PrintXML | [
"Apply",
"patches",
"to",
"HistFactory",
"XML",
"output",
"from",
"PrintXML"
] | 3926935e1f2100d8ba68070c2ab44055d4800f73 | https://github.com/rootpy/rootpy/blob/3926935e1f2100d8ba68070c2ab44055d4800f73/rootpy/stats/histfactory/utils.py#L285-L354 | train |
rootpy/rootpy | rootpy/plotting/views.py | _FolderView.path | def path(self):
''' Get the path of the wrapped folder '''
if isinstance(self.dir, Directory):
return self.dir._path
elif isinstance(self.dir, ROOT.TDirectory):
return self.dir.GetPath()
elif isinstance(self.dir, _FolderView):
return self.dir.path()
... | python | def path(self):
''' Get the path of the wrapped folder '''
if isinstance(self.dir, Directory):
return self.dir._path
elif isinstance(self.dir, ROOT.TDirectory):
return self.dir.GetPath()
elif isinstance(self.dir, _FolderView):
return self.dir.path()
... | [
"def",
"path",
"(",
"self",
")",
":",
"if",
"isinstance",
"(",
"self",
".",
"dir",
",",
"Directory",
")",
":",
"return",
"self",
".",
"dir",
".",
"_path",
"elif",
"isinstance",
"(",
"self",
".",
"dir",
",",
"ROOT",
".",
"TDirectory",
")",
":",
"ret... | Get the path of the wrapped folder | [
"Get",
"the",
"path",
"of",
"the",
"wrapped",
"folder"
] | 3926935e1f2100d8ba68070c2ab44055d4800f73 | https://github.com/rootpy/rootpy/blob/3926935e1f2100d8ba68070c2ab44055d4800f73/rootpy/plotting/views.py#L293-L302 | train |
rootpy/rootpy | rootpy/plotting/views.py | _MultiFolderView.Get | def Get(self, path):
''' Merge the objects at path in all subdirectories '''
return self.merge_views(x.Get(path) for x in self.dirs) | python | def Get(self, path):
''' Merge the objects at path in all subdirectories '''
return self.merge_views(x.Get(path) for x in self.dirs) | [
"def",
"Get",
"(",
"self",
",",
"path",
")",
":",
"return",
"self",
".",
"merge_views",
"(",
"x",
".",
"Get",
"(",
"path",
")",
"for",
"x",
"in",
"self",
".",
"dirs",
")"
] | Merge the objects at path in all subdirectories | [
"Merge",
"the",
"objects",
"at",
"path",
"in",
"all",
"subdirectories"
] | 3926935e1f2100d8ba68070c2ab44055d4800f73 | https://github.com/rootpy/rootpy/blob/3926935e1f2100d8ba68070c2ab44055d4800f73/rootpy/plotting/views.py#L341-L343 | train |
rootpy/rootpy | rootpy/logger/roothandler.py | python_logging_error_handler | def python_logging_error_handler(level, root_says_abort, location, msg):
"""
A python error handler for ROOT which maps ROOT's errors and warnings on
to python's.
"""
from ..utils import quickroot as QROOT
if not Initialized.value:
try:
QROOT.kTRUE
except AttributeEr... | python | def python_logging_error_handler(level, root_says_abort, location, msg):
"""
A python error handler for ROOT which maps ROOT's errors and warnings on
to python's.
"""
from ..utils import quickroot as QROOT
if not Initialized.value:
try:
QROOT.kTRUE
except AttributeEr... | [
"def",
"python_logging_error_handler",
"(",
"level",
",",
"root_says_abort",
",",
"location",
",",
"msg",
")",
":",
"from",
".",
".",
"utils",
"import",
"quickroot",
"as",
"QROOT",
"if",
"not",
"Initialized",
".",
"value",
":",
"try",
":",
"QROOT",
".",
"k... | A python error handler for ROOT which maps ROOT's errors and warnings on
to python's. | [
"A",
"python",
"error",
"handler",
"for",
"ROOT",
"which",
"maps",
"ROOT",
"s",
"errors",
"and",
"warnings",
"on",
"to",
"python",
"s",
"."
] | 3926935e1f2100d8ba68070c2ab44055d4800f73 | https://github.com/rootpy/rootpy/blob/3926935e1f2100d8ba68070c2ab44055d4800f73/rootpy/logger/roothandler.py#L42-L124 | train |
rootpy/rootpy | rootpy/context.py | preserve_current_canvas | def preserve_current_canvas():
"""
Context manager which ensures that the current canvas remains the current
canvas when the context is left.
"""
old = ROOT.gPad
try:
yield
finally:
if old:
old.cd()
elif ROOT.gPad:
# Put things back how they we... | python | def preserve_current_canvas():
"""
Context manager which ensures that the current canvas remains the current
canvas when the context is left.
"""
old = ROOT.gPad
try:
yield
finally:
if old:
old.cd()
elif ROOT.gPad:
# Put things back how they we... | [
"def",
"preserve_current_canvas",
"(",
")",
":",
"old",
"=",
"ROOT",
".",
"gPad",
"try",
":",
"yield",
"finally",
":",
"if",
"old",
":",
"old",
".",
"cd",
"(",
")",
"elif",
"ROOT",
".",
"gPad",
":",
"# Put things back how they were before.",
"with",
"invis... | Context manager which ensures that the current canvas remains the current
canvas when the context is left. | [
"Context",
"manager",
"which",
"ensures",
"that",
"the",
"current",
"canvas",
"remains",
"the",
"current",
"canvas",
"when",
"the",
"context",
"is",
"left",
"."
] | 3926935e1f2100d8ba68070c2ab44055d4800f73 | https://github.com/rootpy/rootpy/blob/3926935e1f2100d8ba68070c2ab44055d4800f73/rootpy/context.py#L46-L62 | train |
rootpy/rootpy | rootpy/context.py | preserve_batch_state | def preserve_batch_state():
"""
Context manager which ensures the batch state is the same on exit as it was
on entry.
"""
with LOCK:
old = ROOT.gROOT.IsBatch()
try:
yield
finally:
ROOT.gROOT.SetBatch(old) | python | def preserve_batch_state():
"""
Context manager which ensures the batch state is the same on exit as it was
on entry.
"""
with LOCK:
old = ROOT.gROOT.IsBatch()
try:
yield
finally:
ROOT.gROOT.SetBatch(old) | [
"def",
"preserve_batch_state",
"(",
")",
":",
"with",
"LOCK",
":",
"old",
"=",
"ROOT",
".",
"gROOT",
".",
"IsBatch",
"(",
")",
"try",
":",
"yield",
"finally",
":",
"ROOT",
".",
"gROOT",
".",
"SetBatch",
"(",
"old",
")"
] | Context manager which ensures the batch state is the same on exit as it was
on entry. | [
"Context",
"manager",
"which",
"ensures",
"the",
"batch",
"state",
"is",
"the",
"same",
"on",
"exit",
"as",
"it",
"was",
"on",
"entry",
"."
] | 3926935e1f2100d8ba68070c2ab44055d4800f73 | https://github.com/rootpy/rootpy/blob/3926935e1f2100d8ba68070c2ab44055d4800f73/rootpy/context.py#L81-L91 | train |
rootpy/rootpy | rootpy/context.py | invisible_canvas | def invisible_canvas():
"""
Context manager yielding a temporary canvas drawn in batch mode, invisible
to the user. Original state is restored on exit.
Example use; obtain X axis object without interfering with anything::
with invisible_canvas() as c:
efficiency.Draw()
... | python | def invisible_canvas():
"""
Context manager yielding a temporary canvas drawn in batch mode, invisible
to the user. Original state is restored on exit.
Example use; obtain X axis object without interfering with anything::
with invisible_canvas() as c:
efficiency.Draw()
... | [
"def",
"invisible_canvas",
"(",
")",
":",
"with",
"preserve_current_canvas",
"(",
")",
":",
"with",
"preserve_batch_state",
"(",
")",
":",
"ROOT",
".",
"gROOT",
".",
"SetBatch",
"(",
")",
"c",
"=",
"ROOT",
".",
"TCanvas",
"(",
")",
"try",
":",
"c",
"."... | Context manager yielding a temporary canvas drawn in batch mode, invisible
to the user. Original state is restored on exit.
Example use; obtain X axis object without interfering with anything::
with invisible_canvas() as c:
efficiency.Draw()
g = efficiency.GetPaintedGraph()
... | [
"Context",
"manager",
"yielding",
"a",
"temporary",
"canvas",
"drawn",
"in",
"batch",
"mode",
"invisible",
"to",
"the",
"user",
".",
"Original",
"state",
"is",
"restored",
"on",
"exit",
"."
] | 3926935e1f2100d8ba68070c2ab44055d4800f73 | https://github.com/rootpy/rootpy/blob/3926935e1f2100d8ba68070c2ab44055d4800f73/rootpy/context.py#L95-L116 | train |
rootpy/rootpy | rootpy/context.py | thread_specific_tmprootdir | def thread_specific_tmprootdir():
"""
Context manager which makes a thread specific gDirectory to avoid
interfering with the current file.
Use cases:
A TTree Draw function which doesn't want to interfere with whatever
gDirectory happens to be.
Multi-threading where there are t... | python | def thread_specific_tmprootdir():
"""
Context manager which makes a thread specific gDirectory to avoid
interfering with the current file.
Use cases:
A TTree Draw function which doesn't want to interfere with whatever
gDirectory happens to be.
Multi-threading where there are t... | [
"def",
"thread_specific_tmprootdir",
"(",
")",
":",
"with",
"preserve_current_directory",
"(",
")",
":",
"dname",
"=",
"\"rootpy-tmp/thread/{0}\"",
".",
"format",
"(",
"threading",
".",
"current_thread",
"(",
")",
".",
"ident",
")",
"d",
"=",
"ROOT",
".",
"gRO... | Context manager which makes a thread specific gDirectory to avoid
interfering with the current file.
Use cases:
A TTree Draw function which doesn't want to interfere with whatever
gDirectory happens to be.
Multi-threading where there are two threads creating objects with the
s... | [
"Context",
"manager",
"which",
"makes",
"a",
"thread",
"specific",
"gDirectory",
"to",
"avoid",
"interfering",
"with",
"the",
"current",
"file",
"."
] | 3926935e1f2100d8ba68070c2ab44055d4800f73 | https://github.com/rootpy/rootpy/blob/3926935e1f2100d8ba68070c2ab44055d4800f73/rootpy/context.py#L120-L142 | train |
rootpy/rootpy | rootpy/context.py | working_directory | def working_directory(path):
"""
A context manager that changes the working directory to the given
path, and then changes it back to its previous value on exit.
"""
prev_cwd = os.getcwd()
os.chdir(path)
try:
yield
finally:
os.chdir(prev_cwd) | python | def working_directory(path):
"""
A context manager that changes the working directory to the given
path, and then changes it back to its previous value on exit.
"""
prev_cwd = os.getcwd()
os.chdir(path)
try:
yield
finally:
os.chdir(prev_cwd) | [
"def",
"working_directory",
"(",
"path",
")",
":",
"prev_cwd",
"=",
"os",
".",
"getcwd",
"(",
")",
"os",
".",
"chdir",
"(",
"path",
")",
"try",
":",
"yield",
"finally",
":",
"os",
".",
"chdir",
"(",
"prev_cwd",
")"
] | A context manager that changes the working directory to the given
path, and then changes it back to its previous value on exit. | [
"A",
"context",
"manager",
"that",
"changes",
"the",
"working",
"directory",
"to",
"the",
"given",
"path",
"and",
"then",
"changes",
"it",
"back",
"to",
"its",
"previous",
"value",
"on",
"exit",
"."
] | 3926935e1f2100d8ba68070c2ab44055d4800f73 | https://github.com/rootpy/rootpy/blob/3926935e1f2100d8ba68070c2ab44055d4800f73/rootpy/context.py#L181-L191 | train |
rootpy/rootpy | rootpy/plotting/autobinning.py | autobinning | def autobinning(data, method="freedman_diaconis"):
"""
This method determines the optimal binning for histogramming.
Parameters
----------
data: 1D array-like
Input data.
method: string, one of the following:
- sturges
- sturges-doane
- scott
- ... | python | def autobinning(data, method="freedman_diaconis"):
"""
This method determines the optimal binning for histogramming.
Parameters
----------
data: 1D array-like
Input data.
method: string, one of the following:
- sturges
- sturges-doane
- scott
- ... | [
"def",
"autobinning",
"(",
"data",
",",
"method",
"=",
"\"freedman_diaconis\"",
")",
":",
"name",
"=",
"method",
".",
"replace",
"(",
"\"-\"",
",",
"\"_\"",
")",
"try",
":",
"method",
"=",
"getattr",
"(",
"BinningMethods",
",",
"name",
")",
"if",
"not",
... | This method determines the optimal binning for histogramming.
Parameters
----------
data: 1D array-like
Input data.
method: string, one of the following:
- sturges
- sturges-doane
- scott
- sqrt
- doane
- freedman-diaconis
... | [
"This",
"method",
"determines",
"the",
"optimal",
"binning",
"for",
"histogramming",
"."
] | 3926935e1f2100d8ba68070c2ab44055d4800f73 | https://github.com/rootpy/rootpy/blob/3926935e1f2100d8ba68070c2ab44055d4800f73/rootpy/plotting/autobinning.py#L12-L50 | train |
rootpy/rootpy | rootpy/plotting/autobinning.py | BinningMethods.all_methods | def all_methods(cls):
"""
Return the names of all available binning methods
"""
def name(fn):
return fn.__get__(cls).__name__.replace("_", "-")
return sorted(name(f) for f in cls.__dict__.values()
if isinstance(f, staticmethod)) | python | def all_methods(cls):
"""
Return the names of all available binning methods
"""
def name(fn):
return fn.__get__(cls).__name__.replace("_", "-")
return sorted(name(f) for f in cls.__dict__.values()
if isinstance(f, staticmethod)) | [
"def",
"all_methods",
"(",
"cls",
")",
":",
"def",
"name",
"(",
"fn",
")",
":",
"return",
"fn",
".",
"__get__",
"(",
"cls",
")",
".",
"__name__",
".",
"replace",
"(",
"\"_\"",
",",
"\"-\"",
")",
"return",
"sorted",
"(",
"name",
"(",
"f",
")",
"fo... | Return the names of all available binning methods | [
"Return",
"the",
"names",
"of",
"all",
"available",
"binning",
"methods"
] | 3926935e1f2100d8ba68070c2ab44055d4800f73 | https://github.com/rootpy/rootpy/blob/3926935e1f2100d8ba68070c2ab44055d4800f73/rootpy/plotting/autobinning.py#L58-L65 | train |
rootpy/rootpy | rootpy/plotting/autobinning.py | BinningMethods.doane | def doane(data):
"""
Modified Doane modified
"""
from scipy.stats import skew
n = len(data)
sigma = np.sqrt(6. * (n - 2.) / (n + 1.) / (n + 3.))
return 1 + np.log2(n) + \
np.log2(1 + np.abs(skew(data)) / sigma) | python | def doane(data):
"""
Modified Doane modified
"""
from scipy.stats import skew
n = len(data)
sigma = np.sqrt(6. * (n - 2.) / (n + 1.) / (n + 3.))
return 1 + np.log2(n) + \
np.log2(1 + np.abs(skew(data)) / sigma) | [
"def",
"doane",
"(",
"data",
")",
":",
"from",
"scipy",
".",
"stats",
"import",
"skew",
"n",
"=",
"len",
"(",
"data",
")",
"sigma",
"=",
"np",
".",
"sqrt",
"(",
"6.",
"*",
"(",
"n",
"-",
"2.",
")",
"/",
"(",
"n",
"+",
"1.",
")",
"/",
"(",
... | Modified Doane modified | [
"Modified",
"Doane",
"modified"
] | 3926935e1f2100d8ba68070c2ab44055d4800f73 | https://github.com/rootpy/rootpy/blob/3926935e1f2100d8ba68070c2ab44055d4800f73/rootpy/plotting/autobinning.py#L84-L92 | train |
rootpy/rootpy | rootpy/utils/lock.py | lock | def lock(path, poll_interval=5, max_age=60):
"""
Aquire a file lock in a thread-safe manner that also reaps stale locks
possibly left behind by processes that crashed hard.
"""
if max_age < 30:
raise ValueError("`max_age` must be at least 30 seconds")
if poll_interval < 1:
raise ... | python | def lock(path, poll_interval=5, max_age=60):
"""
Aquire a file lock in a thread-safe manner that also reaps stale locks
possibly left behind by processes that crashed hard.
"""
if max_age < 30:
raise ValueError("`max_age` must be at least 30 seconds")
if poll_interval < 1:
raise ... | [
"def",
"lock",
"(",
"path",
",",
"poll_interval",
"=",
"5",
",",
"max_age",
"=",
"60",
")",
":",
"if",
"max_age",
"<",
"30",
":",
"raise",
"ValueError",
"(",
"\"`max_age` must be at least 30 seconds\"",
")",
"if",
"poll_interval",
"<",
"1",
":",
"raise",
"... | Aquire a file lock in a thread-safe manner that also reaps stale locks
possibly left behind by processes that crashed hard. | [
"Aquire",
"a",
"file",
"lock",
"in",
"a",
"thread",
"-",
"safe",
"manner",
"that",
"also",
"reaps",
"stale",
"locks",
"possibly",
"left",
"behind",
"by",
"processes",
"that",
"crashed",
"hard",
"."
] | 3926935e1f2100d8ba68070c2ab44055d4800f73 | https://github.com/rootpy/rootpy/blob/3926935e1f2100d8ba68070c2ab44055d4800f73/rootpy/utils/lock.py#L18-L71 | train |
rootpy/rootpy | rootpy/ROOT.py | proxy_global | def proxy_global(name, no_expand_macro=False, fname='func', args=()):
"""
Used to automatically asrootpy ROOT's thread local variables
"""
if no_expand_macro: # pragma: no cover
# handle older ROOT versions without _ExpandMacroFunction wrapping
@property
def gSomething_no_func(s... | python | def proxy_global(name, no_expand_macro=False, fname='func', args=()):
"""
Used to automatically asrootpy ROOT's thread local variables
"""
if no_expand_macro: # pragma: no cover
# handle older ROOT versions without _ExpandMacroFunction wrapping
@property
def gSomething_no_func(s... | [
"def",
"proxy_global",
"(",
"name",
",",
"no_expand_macro",
"=",
"False",
",",
"fname",
"=",
"'func'",
",",
"args",
"=",
"(",
")",
")",
":",
"if",
"no_expand_macro",
":",
"# pragma: no cover",
"# handle older ROOT versions without _ExpandMacroFunction wrapping",
"@",
... | Used to automatically asrootpy ROOT's thread local variables | [
"Used",
"to",
"automatically",
"asrootpy",
"ROOT",
"s",
"thread",
"local",
"variables"
] | 3926935e1f2100d8ba68070c2ab44055d4800f73 | https://github.com/rootpy/rootpy/blob/3926935e1f2100d8ba68070c2ab44055d4800f73/rootpy/ROOT.py#L61-L87 | train |
rootpy/rootpy | rootpy/plotting/legend.py | Legend.AddEntry | def AddEntry(self, thing, label=None, style=None):
"""
Add an entry to the legend.
If `label` is None, `thing.GetTitle()` will be used as the label.
If `style` is None, `thing.legendstyle` is used if present,
otherwise `P`.
"""
if isinstance(thing, HistStack):
... | python | def AddEntry(self, thing, label=None, style=None):
"""
Add an entry to the legend.
If `label` is None, `thing.GetTitle()` will be used as the label.
If `style` is None, `thing.legendstyle` is used if present,
otherwise `P`.
"""
if isinstance(thing, HistStack):
... | [
"def",
"AddEntry",
"(",
"self",
",",
"thing",
",",
"label",
"=",
"None",
",",
"style",
"=",
"None",
")",
":",
"if",
"isinstance",
"(",
"thing",
",",
"HistStack",
")",
":",
"things",
"=",
"thing",
"else",
":",
"things",
"=",
"[",
"thing",
"]",
"for"... | Add an entry to the legend.
If `label` is None, `thing.GetTitle()` will be used as the label.
If `style` is None, `thing.legendstyle` is used if present,
otherwise `P`. | [
"Add",
"an",
"entry",
"to",
"the",
"legend",
"."
] | 3926935e1f2100d8ba68070c2ab44055d4800f73 | https://github.com/rootpy/rootpy/blob/3926935e1f2100d8ba68070c2ab44055d4800f73/rootpy/plotting/legend.py#L87-L105 | train |
rootpy/rootpy | rootpy/logger/magic.py | get_seh | def get_seh():
"""
Makes a function which can be used to set the ROOT error handler with a
python function and returns the existing error handler.
"""
if ON_RTD:
return lambda x: x
ErrorHandlerFunc_t = ctypes.CFUNCTYPE(
None, ctypes.c_int, ctypes.c_bool,
ctypes.c_char_p,... | python | def get_seh():
"""
Makes a function which can be used to set the ROOT error handler with a
python function and returns the existing error handler.
"""
if ON_RTD:
return lambda x: x
ErrorHandlerFunc_t = ctypes.CFUNCTYPE(
None, ctypes.c_int, ctypes.c_bool,
ctypes.c_char_p,... | [
"def",
"get_seh",
"(",
")",
":",
"if",
"ON_RTD",
":",
"return",
"lambda",
"x",
":",
"x",
"ErrorHandlerFunc_t",
"=",
"ctypes",
".",
"CFUNCTYPE",
"(",
"None",
",",
"ctypes",
".",
"c_int",
",",
"ctypes",
".",
"c_bool",
",",
"ctypes",
".",
"c_char_p",
",",... | Makes a function which can be used to set the ROOT error handler with a
python function and returns the existing error handler. | [
"Makes",
"a",
"function",
"which",
"can",
"be",
"used",
"to",
"set",
"the",
"ROOT",
"error",
"handler",
"with",
"a",
"python",
"function",
"and",
"returns",
"the",
"existing",
"error",
"handler",
"."
] | 3926935e1f2100d8ba68070c2ab44055d4800f73 | https://github.com/rootpy/rootpy/blob/3926935e1f2100d8ba68070c2ab44055d4800f73/rootpy/logger/magic.py#L85-L129 | train |
rootpy/rootpy | rootpy/logger/magic.py | get_f_code_idx | def get_f_code_idx():
"""
How many pointers into PyFrame is the ``f_code`` variable?
"""
frame = sys._getframe()
frame_ptr = id(frame)
LARGE_ENOUGH = 20
# Look through the frame object until we find the f_tstate variable, whose
# value we know from above.
ptrs = [ctypes.c_voidp.fro... | python | def get_f_code_idx():
"""
How many pointers into PyFrame is the ``f_code`` variable?
"""
frame = sys._getframe()
frame_ptr = id(frame)
LARGE_ENOUGH = 20
# Look through the frame object until we find the f_tstate variable, whose
# value we know from above.
ptrs = [ctypes.c_voidp.fro... | [
"def",
"get_f_code_idx",
"(",
")",
":",
"frame",
"=",
"sys",
".",
"_getframe",
"(",
")",
"frame_ptr",
"=",
"id",
"(",
"frame",
")",
"LARGE_ENOUGH",
"=",
"20",
"# Look through the frame object until we find the f_tstate variable, whose",
"# value we know from above.",
"p... | How many pointers into PyFrame is the ``f_code`` variable? | [
"How",
"many",
"pointers",
"into",
"PyFrame",
"is",
"the",
"f_code",
"variable?"
] | 3926935e1f2100d8ba68070c2ab44055d4800f73 | https://github.com/rootpy/rootpy/blob/3926935e1f2100d8ba68070c2ab44055d4800f73/rootpy/logger/magic.py#L138-L161 | train |
rootpy/rootpy | rootpy/logger/magic.py | get_frame_pointers | def get_frame_pointers(frame=None):
"""
Obtain writable pointers to ``frame.f_trace`` and ``frame.f_lineno``.
Very dangerous. Unlikely to be portable between python implementations.
This is hard in general because the ``PyFrameObject`` can have a variable size
depending on the build configuration.... | python | def get_frame_pointers(frame=None):
"""
Obtain writable pointers to ``frame.f_trace`` and ``frame.f_lineno``.
Very dangerous. Unlikely to be portable between python implementations.
This is hard in general because the ``PyFrameObject`` can have a variable size
depending on the build configuration.... | [
"def",
"get_frame_pointers",
"(",
"frame",
"=",
"None",
")",
":",
"if",
"frame",
"is",
"None",
":",
"frame",
"=",
"sys",
".",
"_getframe",
"(",
"2",
")",
"frame",
"=",
"id",
"(",
"frame",
")",
"# http://hg.python.org/cpython/file/3aa530c2db06/Include/frameobject... | Obtain writable pointers to ``frame.f_trace`` and ``frame.f_lineno``.
Very dangerous. Unlikely to be portable between python implementations.
This is hard in general because the ``PyFrameObject`` can have a variable size
depending on the build configuration. We can get it reliably because we can
deter... | [
"Obtain",
"writable",
"pointers",
"to",
"frame",
".",
"f_trace",
"and",
"frame",
".",
"f_lineno",
"."
] | 3926935e1f2100d8ba68070c2ab44055d4800f73 | https://github.com/rootpy/rootpy/blob/3926935e1f2100d8ba68070c2ab44055d4800f73/rootpy/logger/magic.py#L166-L193 | train |
rootpy/rootpy | rootpy/logger/magic.py | set_linetrace_on_frame | def set_linetrace_on_frame(f, localtrace=None):
"""
Non-portable function to modify linetracing.
Remember to enable global tracing with :py:func:`sys.settrace`, otherwise no
effect!
"""
traceptr, _, _ = get_frame_pointers(f)
if localtrace is not None:
# Need to incref to avoid the f... | python | def set_linetrace_on_frame(f, localtrace=None):
"""
Non-portable function to modify linetracing.
Remember to enable global tracing with :py:func:`sys.settrace`, otherwise no
effect!
"""
traceptr, _, _ = get_frame_pointers(f)
if localtrace is not None:
# Need to incref to avoid the f... | [
"def",
"set_linetrace_on_frame",
"(",
"f",
",",
"localtrace",
"=",
"None",
")",
":",
"traceptr",
",",
"_",
",",
"_",
"=",
"get_frame_pointers",
"(",
"f",
")",
"if",
"localtrace",
"is",
"not",
"None",
":",
"# Need to incref to avoid the frame causing a double-delet... | Non-portable function to modify linetracing.
Remember to enable global tracing with :py:func:`sys.settrace`, otherwise no
effect! | [
"Non",
"-",
"portable",
"function",
"to",
"modify",
"linetracing",
"."
] | 3926935e1f2100d8ba68070c2ab44055d4800f73 | https://github.com/rootpy/rootpy/blob/3926935e1f2100d8ba68070c2ab44055d4800f73/rootpy/logger/magic.py#L196-L212 | train |
rootpy/rootpy | rootpy/logger/magic.py | re_execute_with_exception | def re_execute_with_exception(frame, exception, traceback):
"""
Dark magic. Causes ``frame`` to raise an exception at the current location
with ``traceback`` appended to it.
Note that since the line tracer is raising an exception, the interpreter
disables the global trace, so it's not possible to r... | python | def re_execute_with_exception(frame, exception, traceback):
"""
Dark magic. Causes ``frame`` to raise an exception at the current location
with ``traceback`` appended to it.
Note that since the line tracer is raising an exception, the interpreter
disables the global trace, so it's not possible to r... | [
"def",
"re_execute_with_exception",
"(",
"frame",
",",
"exception",
",",
"traceback",
")",
":",
"if",
"sys",
".",
"gettrace",
"(",
")",
"==",
"globaltrace",
":",
"# If our trace handler is already installed, that means that this",
"# function has been called twice before the ... | Dark magic. Causes ``frame`` to raise an exception at the current location
with ``traceback`` appended to it.
Note that since the line tracer is raising an exception, the interpreter
disables the global trace, so it's not possible to restore the previous
tracing conditions. | [
"Dark",
"magic",
".",
"Causes",
"frame",
"to",
"raise",
"an",
"exception",
"at",
"the",
"current",
"location",
"with",
"traceback",
"appended",
"to",
"it",
"."
] | 3926935e1f2100d8ba68070c2ab44055d4800f73 | https://github.com/rootpy/rootpy/blob/3926935e1f2100d8ba68070c2ab44055d4800f73/rootpy/logger/magic.py#L219-L269 | train |
rootpy/rootpy | rootpy/logger/magic.py | _inject_jump | def _inject_jump(self, where, dest):
"""
Monkeypatch bytecode at ``where`` to force it to jump to ``dest``.
Returns function which puts things back to how they were.
"""
# We're about to do dangerous things to a function's code content.
# We can't make a lock to prevent the interpreter from usi... | python | def _inject_jump(self, where, dest):
"""
Monkeypatch bytecode at ``where`` to force it to jump to ``dest``.
Returns function which puts things back to how they were.
"""
# We're about to do dangerous things to a function's code content.
# We can't make a lock to prevent the interpreter from usi... | [
"def",
"_inject_jump",
"(",
"self",
",",
"where",
",",
"dest",
")",
":",
"# We're about to do dangerous things to a function's code content.",
"# We can't make a lock to prevent the interpreter from using those",
"# bytes, so the best we can do is to set the check interval to be high",
"# ... | Monkeypatch bytecode at ``where`` to force it to jump to ``dest``.
Returns function which puts things back to how they were. | [
"Monkeypatch",
"bytecode",
"at",
"where",
"to",
"force",
"it",
"to",
"jump",
"to",
"dest",
"."
] | 3926935e1f2100d8ba68070c2ab44055d4800f73 | https://github.com/rootpy/rootpy/blob/3926935e1f2100d8ba68070c2ab44055d4800f73/rootpy/logger/magic.py#L272-L313 | train |
rootpy/rootpy | rootpy/tree/chain.py | BaseTreeChain.Draw | def Draw(self, *args, **kwargs):
"""
Loop over subfiles, draw each, and sum the output into a single
histogram.
"""
self.reset()
output = None
while self._rollover():
if output is None:
# Make our own copy of the drawn histogram
... | python | def Draw(self, *args, **kwargs):
"""
Loop over subfiles, draw each, and sum the output into a single
histogram.
"""
self.reset()
output = None
while self._rollover():
if output is None:
# Make our own copy of the drawn histogram
... | [
"def",
"Draw",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"reset",
"(",
")",
"output",
"=",
"None",
"while",
"self",
".",
"_rollover",
"(",
")",
":",
"if",
"output",
"is",
"None",
":",
"# Make our own copy of the d... | Loop over subfiles, draw each, and sum the output into a single
histogram. | [
"Loop",
"over",
"subfiles",
"draw",
"each",
"and",
"sum",
"the",
"output",
"into",
"a",
"single",
"histogram",
"."
] | 3926935e1f2100d8ba68070c2ab44055d4800f73 | https://github.com/rootpy/rootpy/blob/3926935e1f2100d8ba68070c2ab44055d4800f73/rootpy/tree/chain.py#L105-L128 | train |
rootpy/rootpy | rootpy/interactive/console.py | interact_plain | def interact_plain(header=UP_LINE, local_ns=None,
module=None, dummy=None,
stack_depth=1, global_ns=None):
"""
Create an interactive python console
"""
frame = sys._getframe(stack_depth)
variables = {}
if local_ns is not None:
variables.update(loca... | python | def interact_plain(header=UP_LINE, local_ns=None,
module=None, dummy=None,
stack_depth=1, global_ns=None):
"""
Create an interactive python console
"""
frame = sys._getframe(stack_depth)
variables = {}
if local_ns is not None:
variables.update(loca... | [
"def",
"interact_plain",
"(",
"header",
"=",
"UP_LINE",
",",
"local_ns",
"=",
"None",
",",
"module",
"=",
"None",
",",
"dummy",
"=",
"None",
",",
"stack_depth",
"=",
"1",
",",
"global_ns",
"=",
"None",
")",
":",
"frame",
"=",
"sys",
".",
"_getframe",
... | Create an interactive python console | [
"Create",
"an",
"interactive",
"python",
"console"
] | 3926935e1f2100d8ba68070c2ab44055d4800f73 | https://github.com/rootpy/rootpy/blob/3926935e1f2100d8ba68070c2ab44055d4800f73/rootpy/interactive/console.py#L33-L54 | train |
rootpy/rootpy | rootpy/plotting/root2matplotlib.py | hist | def hist(hists,
stacked=True,
reverse=False,
xpadding=0, ypadding=.1,
yerror_in_padding=True,
logy=None,
snap=True,
axes=None,
**kwargs):
"""
Make a matplotlib hist plot from a ROOT histogram, stack or
list of histograms.
Parameter... | python | def hist(hists,
stacked=True,
reverse=False,
xpadding=0, ypadding=.1,
yerror_in_padding=True,
logy=None,
snap=True,
axes=None,
**kwargs):
"""
Make a matplotlib hist plot from a ROOT histogram, stack or
list of histograms.
Parameter... | [
"def",
"hist",
"(",
"hists",
",",
"stacked",
"=",
"True",
",",
"reverse",
"=",
"False",
",",
"xpadding",
"=",
"0",
",",
"ypadding",
"=",
".1",
",",
"yerror_in_padding",
"=",
"True",
",",
"logy",
"=",
"None",
",",
"snap",
"=",
"True",
",",
"axes",
"... | Make a matplotlib hist plot from a ROOT histogram, stack or
list of histograms.
Parameters
----------
hists : Hist, list of Hist, HistStack
The histogram(s) to be plotted
stacked : bool, optional (default=True)
If True then stack the histograms with the first histogram on the
... | [
"Make",
"a",
"matplotlib",
"hist",
"plot",
"from",
"a",
"ROOT",
"histogram",
"stack",
"or",
"list",
"of",
"histograms",
"."
] | 3926935e1f2100d8ba68070c2ab44055d4800f73 | https://github.com/rootpy/rootpy/blob/3926935e1f2100d8ba68070c2ab44055d4800f73/rootpy/plotting/root2matplotlib.py#L141-L265 | train |
rootpy/rootpy | rootpy/plotting/root2matplotlib.py | errorbar | def errorbar(hists,
xerr=True, yerr=True,
xpadding=0, ypadding=.1,
xerror_in_padding=True,
yerror_in_padding=True,
emptybins=True,
snap=True,
axes=None,
**kwargs):
"""
Make a matplotlib errorbar plot from a R... | python | def errorbar(hists,
xerr=True, yerr=True,
xpadding=0, ypadding=.1,
xerror_in_padding=True,
yerror_in_padding=True,
emptybins=True,
snap=True,
axes=None,
**kwargs):
"""
Make a matplotlib errorbar plot from a R... | [
"def",
"errorbar",
"(",
"hists",
",",
"xerr",
"=",
"True",
",",
"yerr",
"=",
"True",
",",
"xpadding",
"=",
"0",
",",
"ypadding",
"=",
".1",
",",
"xerror_in_padding",
"=",
"True",
",",
"yerror_in_padding",
"=",
"True",
",",
"emptybins",
"=",
"True",
","... | Make a matplotlib errorbar plot from a ROOT histogram or graph
or list of histograms and graphs.
Parameters
----------
hists : Hist, Graph or list of Hist and Graph
The histogram(s) and/or Graph(s) to be plotted
xerr : bool, optional (default=True)
If True, x error bars will be di... | [
"Make",
"a",
"matplotlib",
"errorbar",
"plot",
"from",
"a",
"ROOT",
"histogram",
"or",
"graph",
"or",
"list",
"of",
"histograms",
"and",
"graphs",
"."
] | 3926935e1f2100d8ba68070c2ab44055d4800f73 | https://github.com/rootpy/rootpy/blob/3926935e1f2100d8ba68070c2ab44055d4800f73/rootpy/plotting/root2matplotlib.py#L481-L577 | train |
rootpy/rootpy | rootpy/plotting/root2matplotlib.py | step | def step(h, logy=None, axes=None, **kwargs):
"""
Make a matplotlib step plot from a ROOT histogram.
Parameters
----------
h : Hist
A rootpy Hist
logy : bool, optional (default=None)
If True then clip the y range between 1E-300 and 1E300.
If None (the default) then auto... | python | def step(h, logy=None, axes=None, **kwargs):
"""
Make a matplotlib step plot from a ROOT histogram.
Parameters
----------
h : Hist
A rootpy Hist
logy : bool, optional (default=None)
If True then clip the y range between 1E-300 and 1E300.
If None (the default) then auto... | [
"def",
"step",
"(",
"h",
",",
"logy",
"=",
"None",
",",
"axes",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"axes",
"is",
"None",
":",
"axes",
"=",
"plt",
".",
"gca",
"(",
")",
"if",
"logy",
"is",
"None",
":",
"logy",
"=",
"axes",
... | Make a matplotlib step plot from a ROOT histogram.
Parameters
----------
h : Hist
A rootpy Hist
logy : bool, optional (default=None)
If True then clip the y range between 1E-300 and 1E300.
If None (the default) then automatically determine if the axes are
log-scale and... | [
"Make",
"a",
"matplotlib",
"step",
"plot",
"from",
"a",
"ROOT",
"histogram",
"."
] | 3926935e1f2100d8ba68070c2ab44055d4800f73 | https://github.com/rootpy/rootpy/blob/3926935e1f2100d8ba68070c2ab44055d4800f73/rootpy/plotting/root2matplotlib.py#L603-L641 | train |
rootpy/rootpy | rootpy/plotting/root2matplotlib.py | fill_between | def fill_between(a, b, logy=None, axes=None, **kwargs):
"""
Fill the region between two histograms or graphs.
Parameters
----------
a : Hist
A rootpy Hist
b : Hist
A rootpy Hist
logy : bool, optional (default=None)
If True then clip the region between 1E-300 and 1... | python | def fill_between(a, b, logy=None, axes=None, **kwargs):
"""
Fill the region between two histograms or graphs.
Parameters
----------
a : Hist
A rootpy Hist
b : Hist
A rootpy Hist
logy : bool, optional (default=None)
If True then clip the region between 1E-300 and 1... | [
"def",
"fill_between",
"(",
"a",
",",
"b",
",",
"logy",
"=",
"None",
",",
"axes",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"axes",
"is",
"None",
":",
"axes",
"=",
"plt",
".",
"gca",
"(",
")",
"if",
"logy",
"is",
"None",
":",
"log... | Fill the region between two histograms or graphs.
Parameters
----------
a : Hist
A rootpy Hist
b : Hist
A rootpy Hist
logy : bool, optional (default=None)
If True then clip the region between 1E-300 and 1E300.
If None (the default) then automatically determine if ... | [
"Fill",
"the",
"region",
"between",
"two",
"histograms",
"or",
"graphs",
"."
] | 3926935e1f2100d8ba68070c2ab44055d4800f73 | https://github.com/rootpy/rootpy/blob/3926935e1f2100d8ba68070c2ab44055d4800f73/rootpy/plotting/root2matplotlib.py#L644-L698 | train |
rootpy/rootpy | rootpy/plotting/root2matplotlib.py | hist2d | def hist2d(h, axes=None, colorbar=False, **kwargs):
"""
Draw a 2D matplotlib histogram 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 curr... | python | def hist2d(h, axes=None, colorbar=False, **kwargs):
"""
Draw a 2D matplotlib histogram 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 curr... | [
"def",
"hist2d",
"(",
"h",
",",
"axes",
"=",
"None",
",",
"colorbar",
"=",
"False",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"axes",
"is",
"None",
":",
"axes",
"=",
"plt",
".",
"gca",
"(",
")",
"X",
",",
"Y",
"=",
"np",
".",
"meshgrid",
"(",
... | Draw a 2D matplotlib histogram 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)
... | [
"Draw",
"a",
"2D",
"matplotlib",
"histogram",
"plot",
"from",
"a",
"2D",
"ROOT",
"histogram",
"."
] | 3926935e1f2100d8ba68070c2ab44055d4800f73 | https://github.com/rootpy/rootpy/blob/3926935e1f2100d8ba68070c2ab44055d4800f73/rootpy/plotting/root2matplotlib.py#L701-L740 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.