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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
wmayner/pyphi | pyphi/macro.py | Blackbox.hidden_indices | def hidden_indices(self):
"""All elements hidden inside the blackboxes."""
return tuple(sorted(set(self.micro_indices) -
set(self.output_indices))) | python | def hidden_indices(self):
"""All elements hidden inside the blackboxes."""
return tuple(sorted(set(self.micro_indices) -
set(self.output_indices))) | [
"def",
"hidden_indices",
"(",
"self",
")",
":",
"return",
"tuple",
"(",
"sorted",
"(",
"set",
"(",
"self",
".",
"micro_indices",
")",
"-",
"set",
"(",
"self",
".",
"output_indices",
")",
")",
")"
] | All elements hidden inside the blackboxes. | [
"All",
"elements",
"hidden",
"inside",
"the",
"blackboxes",
"."
] | deeca69a084d782a6fde7bf26f59e93b593c5d77 | https://github.com/wmayner/pyphi/blob/deeca69a084d782a6fde7bf26f59e93b593c5d77/pyphi/macro.py#L582-L585 | train |
wmayner/pyphi | pyphi/macro.py | Blackbox.outputs_of | def outputs_of(self, partition_index):
"""The outputs of the partition at ``partition_index``.
Note that this returns a tuple of element indices, since coarse-
grained blackboxes may have multiple outputs.
"""
partition = self.partition[partition_index]
outputs = set(par... | python | def outputs_of(self, partition_index):
"""The outputs of the partition at ``partition_index``.
Note that this returns a tuple of element indices, since coarse-
grained blackboxes may have multiple outputs.
"""
partition = self.partition[partition_index]
outputs = set(par... | [
"def",
"outputs_of",
"(",
"self",
",",
"partition_index",
")",
":",
"partition",
"=",
"self",
".",
"partition",
"[",
"partition_index",
"]",
"outputs",
"=",
"set",
"(",
"partition",
")",
".",
"intersection",
"(",
"self",
".",
"output_indices",
")",
"return",... | The outputs of the partition at ``partition_index``.
Note that this returns a tuple of element indices, since coarse-
grained blackboxes may have multiple outputs. | [
"The",
"outputs",
"of",
"the",
"partition",
"at",
"partition_index",
"."
] | deeca69a084d782a6fde7bf26f59e93b593c5d77 | https://github.com/wmayner/pyphi/blob/deeca69a084d782a6fde7bf26f59e93b593c5d77/pyphi/macro.py#L600-L608 | train |
wmayner/pyphi | pyphi/macro.py | Blackbox.reindex | def reindex(self):
"""Squeeze the indices of this blackboxing to ``0..n``.
Returns:
Blackbox: a new, reindexed |Blackbox|.
Example:
>>> partition = ((3,), (2, 4))
>>> output_indices = (2, 3)
>>> blackbox = Blackbox(partition, output_indices)
... | python | def reindex(self):
"""Squeeze the indices of this blackboxing to ``0..n``.
Returns:
Blackbox: a new, reindexed |Blackbox|.
Example:
>>> partition = ((3,), (2, 4))
>>> output_indices = (2, 3)
>>> blackbox = Blackbox(partition, output_indices)
... | [
"def",
"reindex",
"(",
"self",
")",
":",
"_map",
"=",
"dict",
"(",
"zip",
"(",
"self",
".",
"micro_indices",
",",
"reindex",
"(",
"self",
".",
"micro_indices",
")",
")",
")",
"partition",
"=",
"tuple",
"(",
"tuple",
"(",
"_map",
"[",
"index",
"]",
... | Squeeze the indices of this blackboxing to ``0..n``.
Returns:
Blackbox: a new, reindexed |Blackbox|.
Example:
>>> partition = ((3,), (2, 4))
>>> output_indices = (2, 3)
>>> blackbox = Blackbox(partition, output_indices)
>>> blackbox.reindex()... | [
"Squeeze",
"the",
"indices",
"of",
"this",
"blackboxing",
"to",
"0",
"..",
"n",
"."
] | deeca69a084d782a6fde7bf26f59e93b593c5d77 | https://github.com/wmayner/pyphi/blob/deeca69a084d782a6fde7bf26f59e93b593c5d77/pyphi/macro.py#L610-L630 | train |
wmayner/pyphi | pyphi/macro.py | Blackbox.macro_state | def macro_state(self, micro_state):
"""Compute the macro-state of this blackbox.
This is just the state of the blackbox's output indices.
Args:
micro_state (tuple[int]): The state of the micro-elements in the
blackbox.
Returns:
tuple[int]: The s... | python | def macro_state(self, micro_state):
"""Compute the macro-state of this blackbox.
This is just the state of the blackbox's output indices.
Args:
micro_state (tuple[int]): The state of the micro-elements in the
blackbox.
Returns:
tuple[int]: The s... | [
"def",
"macro_state",
"(",
"self",
",",
"micro_state",
")",
":",
"assert",
"len",
"(",
"micro_state",
")",
"==",
"len",
"(",
"self",
".",
"micro_indices",
")",
"reindexed",
"=",
"self",
".",
"reindex",
"(",
")",
"return",
"utils",
".",
"state_of",
"(",
... | Compute the macro-state of this blackbox.
This is just the state of the blackbox's output indices.
Args:
micro_state (tuple[int]): The state of the micro-elements in the
blackbox.
Returns:
tuple[int]: The state of the output indices. | [
"Compute",
"the",
"macro",
"-",
"state",
"of",
"this",
"blackbox",
"."
] | deeca69a084d782a6fde7bf26f59e93b593c5d77 | https://github.com/wmayner/pyphi/blob/deeca69a084d782a6fde7bf26f59e93b593c5d77/pyphi/macro.py#L632-L647 | train |
wmayner/pyphi | pyphi/macro.py | Blackbox.in_same_box | def in_same_box(self, a, b):
"""Return ``True`` if nodes ``a`` and ``b``` are in the same box."""
assert a in self.micro_indices
assert b in self.micro_indices
for part in self.partition:
if a in part and b in part:
return True
return False | python | def in_same_box(self, a, b):
"""Return ``True`` if nodes ``a`` and ``b``` are in the same box."""
assert a in self.micro_indices
assert b in self.micro_indices
for part in self.partition:
if a in part and b in part:
return True
return False | [
"def",
"in_same_box",
"(",
"self",
",",
"a",
",",
"b",
")",
":",
"assert",
"a",
"in",
"self",
".",
"micro_indices",
"assert",
"b",
"in",
"self",
".",
"micro_indices",
"for",
"part",
"in",
"self",
".",
"partition",
":",
"if",
"a",
"in",
"part",
"and",... | Return ``True`` if nodes ``a`` and ``b``` are in the same box. | [
"Return",
"True",
"if",
"nodes",
"a",
"and",
"b",
"are",
"in",
"the",
"same",
"box",
"."
] | deeca69a084d782a6fde7bf26f59e93b593c5d77 | https://github.com/wmayner/pyphi/blob/deeca69a084d782a6fde7bf26f59e93b593c5d77/pyphi/macro.py#L649-L658 | train |
wmayner/pyphi | pyphi/macro.py | Blackbox.hidden_from | def hidden_from(self, a, b):
"""Return True if ``a`` is hidden in a different box than ``b``."""
return a in self.hidden_indices and not self.in_same_box(a, b) | python | def hidden_from(self, a, b):
"""Return True if ``a`` is hidden in a different box than ``b``."""
return a in self.hidden_indices and not self.in_same_box(a, b) | [
"def",
"hidden_from",
"(",
"self",
",",
"a",
",",
"b",
")",
":",
"return",
"a",
"in",
"self",
".",
"hidden_indices",
"and",
"not",
"self",
".",
"in_same_box",
"(",
"a",
",",
"b",
")"
] | Return True if ``a`` is hidden in a different box than ``b``. | [
"Return",
"True",
"if",
"a",
"is",
"hidden",
"in",
"a",
"different",
"box",
"than",
"b",
"."
] | deeca69a084d782a6fde7bf26f59e93b593c5d77 | https://github.com/wmayner/pyphi/blob/deeca69a084d782a6fde7bf26f59e93b593c5d77/pyphi/macro.py#L660-L662 | train |
wmayner/pyphi | pyphi/network.py | irreducible_purviews | def irreducible_purviews(cm, direction, mechanism, purviews):
"""Return all purviews which are irreducible for the mechanism.
Args:
cm (np.ndarray): An |N x N| connectivity matrix.
direction (Direction): |CAUSE| or |EFFECT|.
purviews (list[tuple[int]]): The purviews to check.
me... | python | def irreducible_purviews(cm, direction, mechanism, purviews):
"""Return all purviews which are irreducible for the mechanism.
Args:
cm (np.ndarray): An |N x N| connectivity matrix.
direction (Direction): |CAUSE| or |EFFECT|.
purviews (list[tuple[int]]): The purviews to check.
me... | [
"def",
"irreducible_purviews",
"(",
"cm",
",",
"direction",
",",
"mechanism",
",",
"purviews",
")",
":",
"def",
"reducible",
"(",
"purview",
")",
":",
"_from",
",",
"to",
"=",
"direction",
".",
"order",
"(",
"mechanism",
",",
"purview",
")",
"return",
"c... | Return all purviews which are irreducible for the mechanism.
Args:
cm (np.ndarray): An |N x N| connectivity matrix.
direction (Direction): |CAUSE| or |EFFECT|.
purviews (list[tuple[int]]): The purviews to check.
mechanism (tuple[int]): The mechanism in question.
Returns:
... | [
"Return",
"all",
"purviews",
"which",
"are",
"irreducible",
"for",
"the",
"mechanism",
"."
] | deeca69a084d782a6fde7bf26f59e93b593c5d77 | https://github.com/wmayner/pyphi/blob/deeca69a084d782a6fde7bf26f59e93b593c5d77/pyphi/network.py#L214-L235 | train |
wmayner/pyphi | pyphi/network.py | Network._build_tpm | def _build_tpm(tpm):
"""Validate the TPM passed by the user and convert to multidimensional
form.
"""
tpm = np.array(tpm)
validate.tpm(tpm)
# Convert to multidimensional state-by-node form
if is_state_by_state(tpm):
tpm = convert.state_by_state2state... | python | def _build_tpm(tpm):
"""Validate the TPM passed by the user and convert to multidimensional
form.
"""
tpm = np.array(tpm)
validate.tpm(tpm)
# Convert to multidimensional state-by-node form
if is_state_by_state(tpm):
tpm = convert.state_by_state2state... | [
"def",
"_build_tpm",
"(",
"tpm",
")",
":",
"tpm",
"=",
"np",
".",
"array",
"(",
"tpm",
")",
"validate",
".",
"tpm",
"(",
"tpm",
")",
"if",
"is_state_by_state",
"(",
"tpm",
")",
":",
"tpm",
"=",
"convert",
".",
"state_by_state2state_by_node",
"(",
"tpm"... | Validate the TPM passed by the user and convert to multidimensional
form. | [
"Validate",
"the",
"TPM",
"passed",
"by",
"the",
"user",
"and",
"convert",
"to",
"multidimensional",
"form",
"."
] | deeca69a084d782a6fde7bf26f59e93b593c5d77 | https://github.com/wmayner/pyphi/blob/deeca69a084d782a6fde7bf26f59e93b593c5d77/pyphi/network.py#L77-L93 | train |
wmayner/pyphi | pyphi/network.py | Network._build_cm | def _build_cm(self, cm):
"""Convert the passed CM to the proper format, or construct the
unitary CM if none was provided.
"""
if cm is None:
# Assume all are connected.
cm = np.ones((self.size, self.size))
else:
cm = np.array(cm)
utils... | python | def _build_cm(self, cm):
"""Convert the passed CM to the proper format, or construct the
unitary CM if none was provided.
"""
if cm is None:
# Assume all are connected.
cm = np.ones((self.size, self.size))
else:
cm = np.array(cm)
utils... | [
"def",
"_build_cm",
"(",
"self",
",",
"cm",
")",
":",
"if",
"cm",
"is",
"None",
":",
"cm",
"=",
"np",
".",
"ones",
"(",
"(",
"self",
".",
"size",
",",
"self",
".",
"size",
")",
")",
"else",
":",
"cm",
"=",
"np",
".",
"array",
"(",
"cm",
")"... | Convert the passed CM to the proper format, or construct the
unitary CM if none was provided. | [
"Convert",
"the",
"passed",
"CM",
"to",
"the",
"proper",
"format",
"or",
"construct",
"the",
"unitary",
"CM",
"if",
"none",
"was",
"provided",
"."
] | deeca69a084d782a6fde7bf26f59e93b593c5d77 | https://github.com/wmayner/pyphi/blob/deeca69a084d782a6fde7bf26f59e93b593c5d77/pyphi/network.py#L104-L116 | train |
wmayner/pyphi | pyphi/network.py | Network.potential_purviews | def potential_purviews(self, direction, mechanism):
"""All purviews which are not clearly reducible for mechanism.
Args:
direction (Direction): |CAUSE| or |EFFECT|.
mechanism (tuple[int]): The mechanism which all purviews are
checked for reducibility over.
... | python | def potential_purviews(self, direction, mechanism):
"""All purviews which are not clearly reducible for mechanism.
Args:
direction (Direction): |CAUSE| or |EFFECT|.
mechanism (tuple[int]): The mechanism which all purviews are
checked for reducibility over.
... | [
"def",
"potential_purviews",
"(",
"self",
",",
"direction",
",",
"mechanism",
")",
":",
"all_purviews",
"=",
"utils",
".",
"powerset",
"(",
"self",
".",
"_node_indices",
")",
"return",
"irreducible_purviews",
"(",
"self",
".",
"cm",
",",
"direction",
",",
"m... | All purviews which are not clearly reducible for mechanism.
Args:
direction (Direction): |CAUSE| or |EFFECT|.
mechanism (tuple[int]): The mechanism which all purviews are
checked for reducibility over.
Returns:
list[tuple[int]]: All purviews which ar... | [
"All",
"purviews",
"which",
"are",
"not",
"clearly",
"reducible",
"for",
"mechanism",
"."
] | deeca69a084d782a6fde7bf26f59e93b593c5d77 | https://github.com/wmayner/pyphi/blob/deeca69a084d782a6fde7bf26f59e93b593c5d77/pyphi/network.py#L155-L169 | train |
wmayner/pyphi | pyphi/jsonify.py | _loadable_models | def _loadable_models():
"""A dictionary of loadable PyPhi models.
These are stored in this function (instead of module scope) to resolve
circular import issues.
"""
classes = [
pyphi.Direction,
pyphi.Network,
pyphi.Subsystem,
pyphi.Transition,
pyphi.labels.No... | python | def _loadable_models():
"""A dictionary of loadable PyPhi models.
These are stored in this function (instead of module scope) to resolve
circular import issues.
"""
classes = [
pyphi.Direction,
pyphi.Network,
pyphi.Subsystem,
pyphi.Transition,
pyphi.labels.No... | [
"def",
"_loadable_models",
"(",
")",
":",
"classes",
"=",
"[",
"pyphi",
".",
"Direction",
",",
"pyphi",
".",
"Network",
",",
"pyphi",
".",
"Subsystem",
",",
"pyphi",
".",
"Transition",
",",
"pyphi",
".",
"labels",
".",
"NodeLabels",
",",
"pyphi",
".",
... | A dictionary of loadable PyPhi models.
These are stored in this function (instead of module scope) to resolve
circular import issues. | [
"A",
"dictionary",
"of",
"loadable",
"PyPhi",
"models",
"."
] | deeca69a084d782a6fde7bf26f59e93b593c5d77 | https://github.com/wmayner/pyphi/blob/deeca69a084d782a6fde7bf26f59e93b593c5d77/pyphi/jsonify.py#L51-L83 | train |
wmayner/pyphi | pyphi/jsonify.py | jsonify | def jsonify(obj): # pylint: disable=too-many-return-statements
"""Return a JSON-encodable representation of an object, recursively using
any available ``to_json`` methods, converting NumPy arrays and datatypes to
native lists and types along the way.
"""
# Call the `to_json` method if available and... | python | def jsonify(obj): # pylint: disable=too-many-return-statements
"""Return a JSON-encodable representation of an object, recursively using
any available ``to_json`` methods, converting NumPy arrays and datatypes to
native lists and types along the way.
"""
# Call the `to_json` method if available and... | [
"def",
"jsonify",
"(",
"obj",
")",
":",
"if",
"hasattr",
"(",
"obj",
",",
"'to_json'",
")",
":",
"d",
"=",
"obj",
".",
"to_json",
"(",
")",
"_push_metadata",
"(",
"d",
",",
"obj",
")",
"return",
"jsonify",
"(",
"d",
")",
"if",
"isinstance",
"(",
... | Return a JSON-encodable representation of an object, recursively using
any available ``to_json`` methods, converting NumPy arrays and datatypes to
native lists and types along the way. | [
"Return",
"a",
"JSON",
"-",
"encodable",
"representation",
"of",
"an",
"object",
"recursively",
"using",
"any",
"available",
"to_json",
"methods",
"converting",
"NumPy",
"arrays",
"and",
"datatypes",
"to",
"native",
"lists",
"and",
"types",
"along",
"the",
"way"... | deeca69a084d782a6fde7bf26f59e93b593c5d77 | https://github.com/wmayner/pyphi/blob/deeca69a084d782a6fde7bf26f59e93b593c5d77/pyphi/jsonify.py#L107-L141 | train |
wmayner/pyphi | pyphi/jsonify.py | _check_version | def _check_version(version):
"""Check whether the JSON version matches the PyPhi version."""
if version != pyphi.__version__:
raise pyphi.exceptions.JSONVersionError(
'Cannot load JSON from a different version of PyPhi. '
'JSON version = {0}, current version = {1}.'.format(
... | python | def _check_version(version):
"""Check whether the JSON version matches the PyPhi version."""
if version != pyphi.__version__:
raise pyphi.exceptions.JSONVersionError(
'Cannot load JSON from a different version of PyPhi. '
'JSON version = {0}, current version = {1}.'.format(
... | [
"def",
"_check_version",
"(",
"version",
")",
":",
"if",
"version",
"!=",
"pyphi",
".",
"__version__",
":",
"raise",
"pyphi",
".",
"exceptions",
".",
"JSONVersionError",
"(",
"'Cannot load JSON from a different version of PyPhi. '",
"'JSON version = {0}, current version = {... | Check whether the JSON version matches the PyPhi version. | [
"Check",
"whether",
"the",
"JSON",
"version",
"matches",
"the",
"PyPhi",
"version",
"."
] | deeca69a084d782a6fde7bf26f59e93b593c5d77 | https://github.com/wmayner/pyphi/blob/deeca69a084d782a6fde7bf26f59e93b593c5d77/pyphi/jsonify.py#L176-L182 | train |
wmayner/pyphi | pyphi/jsonify.py | PyPhiJSONDecoder._load_object | def _load_object(self, obj):
"""Recursively load a PyPhi object.
PyPhi models are recursively loaded, using the model metadata to
recreate the original object relations. Lists are cast to tuples
because most objects in PyPhi which are serialized to lists (eg.
mechanisms and purv... | python | def _load_object(self, obj):
"""Recursively load a PyPhi object.
PyPhi models are recursively loaded, using the model metadata to
recreate the original object relations. Lists are cast to tuples
because most objects in PyPhi which are serialized to lists (eg.
mechanisms and purv... | [
"def",
"_load_object",
"(",
"self",
",",
"obj",
")",
":",
"if",
"isinstance",
"(",
"obj",
",",
"dict",
")",
":",
"obj",
"=",
"{",
"k",
":",
"self",
".",
"_load_object",
"(",
"v",
")",
"for",
"k",
",",
"v",
"in",
"obj",
".",
"items",
"(",
")",
... | Recursively load a PyPhi object.
PyPhi models are recursively loaded, using the model metadata to
recreate the original object relations. Lists are cast to tuples
because most objects in PyPhi which are serialized to lists (eg.
mechanisms and purviews) are ultimately tuples. Other lists... | [
"Recursively",
"load",
"a",
"PyPhi",
"object",
"."
] | deeca69a084d782a6fde7bf26f59e93b593c5d77 | https://github.com/wmayner/pyphi/blob/deeca69a084d782a6fde7bf26f59e93b593c5d77/pyphi/jsonify.py#L212-L230 | train |
wmayner/pyphi | pyphi/jsonify.py | PyPhiJSONDecoder._load_model | def _load_model(self, dct):
"""Load a serialized PyPhi model.
The object is memoized for reuse elsewhere in the object graph.
"""
classname, version, _ = _pop_metadata(dct)
_check_version(version)
cls = self._models[classname]
# Use `from_json` if available
... | python | def _load_model(self, dct):
"""Load a serialized PyPhi model.
The object is memoized for reuse elsewhere in the object graph.
"""
classname, version, _ = _pop_metadata(dct)
_check_version(version)
cls = self._models[classname]
# Use `from_json` if available
... | [
"def",
"_load_model",
"(",
"self",
",",
"dct",
")",
":",
"classname",
",",
"version",
",",
"_",
"=",
"_pop_metadata",
"(",
"dct",
")",
"_check_version",
"(",
"version",
")",
"cls",
"=",
"self",
".",
"_models",
"[",
"classname",
"]",
"if",
"hasattr",
"(... | Load a serialized PyPhi model.
The object is memoized for reuse elsewhere in the object graph. | [
"Load",
"a",
"serialized",
"PyPhi",
"model",
"."
] | deeca69a084d782a6fde7bf26f59e93b593c5d77 | https://github.com/wmayner/pyphi/blob/deeca69a084d782a6fde7bf26f59e93b593c5d77/pyphi/jsonify.py#L233-L248 | train |
wmayner/pyphi | pyphi/distance.py | _compute_hamming_matrix | def _compute_hamming_matrix(N):
"""Compute and store a Hamming matrix for |N| nodes.
Hamming matrices have the following sizes::
N MBs
== ===
9 2
10 8
11 32
12 128
13 512
Given these sizes and the fact that large matrices are needed infrequ... | python | def _compute_hamming_matrix(N):
"""Compute and store a Hamming matrix for |N| nodes.
Hamming matrices have the following sizes::
N MBs
== ===
9 2
10 8
11 32
12 128
13 512
Given these sizes and the fact that large matrices are needed infrequ... | [
"def",
"_compute_hamming_matrix",
"(",
"N",
")",
":",
"possible_states",
"=",
"np",
".",
"array",
"(",
"list",
"(",
"utils",
".",
"all_states",
"(",
"(",
"N",
")",
")",
")",
")",
"return",
"cdist",
"(",
"possible_states",
",",
"possible_states",
",",
"'h... | Compute and store a Hamming matrix for |N| nodes.
Hamming matrices have the following sizes::
N MBs
== ===
9 2
10 8
11 32
12 128
13 512
Given these sizes and the fact that large matrices are needed infrequently,
we store computed matrices u... | [
"Compute",
"and",
"store",
"a",
"Hamming",
"matrix",
"for",
"|N|",
"nodes",
"."
] | deeca69a084d782a6fde7bf26f59e93b593c5d77 | https://github.com/wmayner/pyphi/blob/deeca69a084d782a6fde7bf26f59e93b593c5d77/pyphi/distance.py#L107-L130 | train |
wmayner/pyphi | pyphi/distance.py | effect_emd | def effect_emd(d1, d2):
"""Compute the EMD between two effect repertoires.
Because the nodes are independent, the EMD between effect repertoires is
equal to the sum of the EMDs between the marginal distributions of each
node, and the EMD between marginal distribution for a node is the absolute
diff... | python | def effect_emd(d1, d2):
"""Compute the EMD between two effect repertoires.
Because the nodes are independent, the EMD between effect repertoires is
equal to the sum of the EMDs between the marginal distributions of each
node, and the EMD between marginal distribution for a node is the absolute
diff... | [
"def",
"effect_emd",
"(",
"d1",
",",
"d2",
")",
":",
"return",
"sum",
"(",
"abs",
"(",
"marginal_zero",
"(",
"d1",
",",
"i",
")",
"-",
"marginal_zero",
"(",
"d2",
",",
"i",
")",
")",
"for",
"i",
"in",
"range",
"(",
"d1",
".",
"ndim",
")",
")"
] | Compute the EMD between two effect repertoires.
Because the nodes are independent, the EMD between effect repertoires is
equal to the sum of the EMDs between the marginal distributions of each
node, and the EMD between marginal distribution for a node is the absolute
difference in the probabilities tha... | [
"Compute",
"the",
"EMD",
"between",
"two",
"effect",
"repertoires",
"."
] | deeca69a084d782a6fde7bf26f59e93b593c5d77 | https://github.com/wmayner/pyphi/blob/deeca69a084d782a6fde7bf26f59e93b593c5d77/pyphi/distance.py#L147-L163 | train |
wmayner/pyphi | pyphi/distance.py | entropy_difference | def entropy_difference(d1, d2):
"""Return the difference in entropy between two distributions."""
d1, d2 = flatten(d1), flatten(d2)
return abs(entropy(d1, base=2.0) - entropy(d2, base=2.0)) | python | def entropy_difference(d1, d2):
"""Return the difference in entropy between two distributions."""
d1, d2 = flatten(d1), flatten(d2)
return abs(entropy(d1, base=2.0) - entropy(d2, base=2.0)) | [
"def",
"entropy_difference",
"(",
"d1",
",",
"d2",
")",
":",
"d1",
",",
"d2",
"=",
"flatten",
"(",
"d1",
")",
",",
"flatten",
"(",
"d2",
")",
"return",
"abs",
"(",
"entropy",
"(",
"d1",
",",
"base",
"=",
"2.0",
")",
"-",
"entropy",
"(",
"d2",
"... | Return the difference in entropy between two distributions. | [
"Return",
"the",
"difference",
"in",
"entropy",
"between",
"two",
"distributions",
"."
] | deeca69a084d782a6fde7bf26f59e93b593c5d77 | https://github.com/wmayner/pyphi/blob/deeca69a084d782a6fde7bf26f59e93b593c5d77/pyphi/distance.py#L196-L199 | train |
wmayner/pyphi | pyphi/distance.py | psq2 | def psq2(d1, d2):
"""Compute the PSQ2 measure.
Args:
d1 (np.ndarray): The first distribution.
d2 (np.ndarray): The second distribution.
"""
d1, d2 = flatten(d1), flatten(d2)
def f(p):
return sum((p ** 2) * np.nan_to_num(np.log(p * len(p))))
return abs(f(d1) - f(d2)) | python | def psq2(d1, d2):
"""Compute the PSQ2 measure.
Args:
d1 (np.ndarray): The first distribution.
d2 (np.ndarray): The second distribution.
"""
d1, d2 = flatten(d1), flatten(d2)
def f(p):
return sum((p ** 2) * np.nan_to_num(np.log(p * len(p))))
return abs(f(d1) - f(d2)) | [
"def",
"psq2",
"(",
"d1",
",",
"d2",
")",
":",
"d1",
",",
"d2",
"=",
"flatten",
"(",
"d1",
")",
",",
"flatten",
"(",
"d2",
")",
"def",
"f",
"(",
"p",
")",
":",
"return",
"sum",
"(",
"(",
"p",
"**",
"2",
")",
"*",
"np",
".",
"nan_to_num",
... | Compute the PSQ2 measure.
Args:
d1 (np.ndarray): The first distribution.
d2 (np.ndarray): The second distribution. | [
"Compute",
"the",
"PSQ2",
"measure",
"."
] | deeca69a084d782a6fde7bf26f59e93b593c5d77 | https://github.com/wmayner/pyphi/blob/deeca69a084d782a6fde7bf26f59e93b593c5d77/pyphi/distance.py#L204-L216 | train |
wmayner/pyphi | pyphi/distance.py | mp2q | def mp2q(p, q):
"""Compute the MP2Q measure.
Args:
p (np.ndarray): The unpartitioned repertoire
q (np.ndarray): The partitioned repertoire
"""
p, q = flatten(p), flatten(q)
entropy_dist = 1 / len(p)
return sum(entropy_dist * np.nan_to_num((p ** 2) / q * np.log(p / q))) | python | def mp2q(p, q):
"""Compute the MP2Q measure.
Args:
p (np.ndarray): The unpartitioned repertoire
q (np.ndarray): The partitioned repertoire
"""
p, q = flatten(p), flatten(q)
entropy_dist = 1 / len(p)
return sum(entropy_dist * np.nan_to_num((p ** 2) / q * np.log(p / q))) | [
"def",
"mp2q",
"(",
"p",
",",
"q",
")",
":",
"p",
",",
"q",
"=",
"flatten",
"(",
"p",
")",
",",
"flatten",
"(",
"q",
")",
"entropy_dist",
"=",
"1",
"/",
"len",
"(",
"p",
")",
"return",
"sum",
"(",
"entropy_dist",
"*",
"np",
".",
"nan_to_num",
... | Compute the MP2Q measure.
Args:
p (np.ndarray): The unpartitioned repertoire
q (np.ndarray): The partitioned repertoire | [
"Compute",
"the",
"MP2Q",
"measure",
"."
] | deeca69a084d782a6fde7bf26f59e93b593c5d77 | https://github.com/wmayner/pyphi/blob/deeca69a084d782a6fde7bf26f59e93b593c5d77/pyphi/distance.py#L221-L230 | train |
wmayner/pyphi | pyphi/distance.py | klm | def klm(p, q):
"""Compute the KLM divergence."""
p, q = flatten(p), flatten(q)
return max(abs(p * np.nan_to_num(np.log(p / q)))) | python | def klm(p, q):
"""Compute the KLM divergence."""
p, q = flatten(p), flatten(q)
return max(abs(p * np.nan_to_num(np.log(p / q)))) | [
"def",
"klm",
"(",
"p",
",",
"q",
")",
":",
"p",
",",
"q",
"=",
"flatten",
"(",
"p",
")",
",",
"flatten",
"(",
"q",
")",
"return",
"max",
"(",
"abs",
"(",
"p",
"*",
"np",
".",
"nan_to_num",
"(",
"np",
".",
"log",
"(",
"p",
"/",
"q",
")",
... | Compute the KLM divergence. | [
"Compute",
"the",
"KLM",
"divergence",
"."
] | deeca69a084d782a6fde7bf26f59e93b593c5d77 | https://github.com/wmayner/pyphi/blob/deeca69a084d782a6fde7bf26f59e93b593c5d77/pyphi/distance.py#L236-L239 | train |
wmayner/pyphi | pyphi/distance.py | directional_emd | def directional_emd(direction, d1, d2):
"""Compute the EMD between two repertoires for a given direction.
The full EMD computation is used for cause repertoires. A fast analytic
solution is used for effect repertoires.
Args:
direction (Direction): |CAUSE| or |EFFECT|.
d1 (np.ndarray): ... | python | def directional_emd(direction, d1, d2):
"""Compute the EMD between two repertoires for a given direction.
The full EMD computation is used for cause repertoires. A fast analytic
solution is used for effect repertoires.
Args:
direction (Direction): |CAUSE| or |EFFECT|.
d1 (np.ndarray): ... | [
"def",
"directional_emd",
"(",
"direction",
",",
"d1",
",",
"d2",
")",
":",
"if",
"direction",
"==",
"Direction",
".",
"CAUSE",
":",
"func",
"=",
"hamming_emd",
"elif",
"direction",
"==",
"Direction",
".",
"EFFECT",
":",
"func",
"=",
"effect_emd",
"else",
... | Compute the EMD between two repertoires for a given direction.
The full EMD computation is used for cause repertoires. A fast analytic
solution is used for effect repertoires.
Args:
direction (Direction): |CAUSE| or |EFFECT|.
d1 (np.ndarray): The first repertoire.
d2 (np.ndarray): ... | [
"Compute",
"the",
"EMD",
"between",
"two",
"repertoires",
"for",
"a",
"given",
"direction",
"."
] | deeca69a084d782a6fde7bf26f59e93b593c5d77 | https://github.com/wmayner/pyphi/blob/deeca69a084d782a6fde7bf26f59e93b593c5d77/pyphi/distance.py#L242-L267 | train |
wmayner/pyphi | pyphi/distance.py | repertoire_distance | def repertoire_distance(direction, r1, r2):
"""Compute the distance between two repertoires for the given direction.
Args:
direction (Direction): |CAUSE| or |EFFECT|.
r1 (np.ndarray): The first repertoire.
r2 (np.ndarray): The second repertoire.
Returns:
float: The distance... | python | def repertoire_distance(direction, r1, r2):
"""Compute the distance between two repertoires for the given direction.
Args:
direction (Direction): |CAUSE| or |EFFECT|.
r1 (np.ndarray): The first repertoire.
r2 (np.ndarray): The second repertoire.
Returns:
float: The distance... | [
"def",
"repertoire_distance",
"(",
"direction",
",",
"r1",
",",
"r2",
")",
":",
"if",
"config",
".",
"MEASURE",
"==",
"'EMD'",
":",
"dist",
"=",
"directional_emd",
"(",
"direction",
",",
"r1",
",",
"r2",
")",
"else",
":",
"dist",
"=",
"measures",
"[",
... | Compute the distance between two repertoires for the given direction.
Args:
direction (Direction): |CAUSE| or |EFFECT|.
r1 (np.ndarray): The first repertoire.
r2 (np.ndarray): The second repertoire.
Returns:
float: The distance between ``d1`` and ``d2``, rounded to |PRECISION|. | [
"Compute",
"the",
"distance",
"between",
"two",
"repertoires",
"for",
"the",
"given",
"direction",
"."
] | deeca69a084d782a6fde7bf26f59e93b593c5d77 | https://github.com/wmayner/pyphi/blob/deeca69a084d782a6fde7bf26f59e93b593c5d77/pyphi/distance.py#L270-L286 | train |
wmayner/pyphi | pyphi/distance.py | system_repertoire_distance | def system_repertoire_distance(r1, r2):
"""Compute the distance between two repertoires of a system.
Args:
r1 (np.ndarray): The first repertoire.
r2 (np.ndarray): The second repertoire.
Returns:
float: The distance between ``r1`` and ``r2``.
"""
if config.MEASURE in measure... | python | def system_repertoire_distance(r1, r2):
"""Compute the distance between two repertoires of a system.
Args:
r1 (np.ndarray): The first repertoire.
r2 (np.ndarray): The second repertoire.
Returns:
float: The distance between ``r1`` and ``r2``.
"""
if config.MEASURE in measure... | [
"def",
"system_repertoire_distance",
"(",
"r1",
",",
"r2",
")",
":",
"if",
"config",
".",
"MEASURE",
"in",
"measures",
".",
"asymmetric",
"(",
")",
":",
"raise",
"ValueError",
"(",
"'{} is asymmetric and cannot be used as a system-level '",
"'irreducibility measure.'",
... | Compute the distance between two repertoires of a system.
Args:
r1 (np.ndarray): The first repertoire.
r2 (np.ndarray): The second repertoire.
Returns:
float: The distance between ``r1`` and ``r2``. | [
"Compute",
"the",
"distance",
"between",
"two",
"repertoires",
"of",
"a",
"system",
"."
] | deeca69a084d782a6fde7bf26f59e93b593c5d77 | https://github.com/wmayner/pyphi/blob/deeca69a084d782a6fde7bf26f59e93b593c5d77/pyphi/distance.py#L289-L304 | train |
wmayner/pyphi | pyphi/distance.py | MeasureRegistry.register | def register(self, name, asymmetric=False):
"""Decorator for registering a measure with PyPhi.
Args:
name (string): The name of the measure.
Keyword Args:
asymmetric (boolean): ``True`` if the measure is asymmetric.
"""
def register_func(func):
... | python | def register(self, name, asymmetric=False):
"""Decorator for registering a measure with PyPhi.
Args:
name (string): The name of the measure.
Keyword Args:
asymmetric (boolean): ``True`` if the measure is asymmetric.
"""
def register_func(func):
... | [
"def",
"register",
"(",
"self",
",",
"name",
",",
"asymmetric",
"=",
"False",
")",
":",
"def",
"register_func",
"(",
"func",
")",
":",
"if",
"asymmetric",
":",
"self",
".",
"_asymmetric",
".",
"append",
"(",
"name",
")",
"self",
".",
"store",
"[",
"n... | Decorator for registering a measure with PyPhi.
Args:
name (string): The name of the measure.
Keyword Args:
asymmetric (boolean): ``True`` if the measure is asymmetric. | [
"Decorator",
"for",
"registering",
"a",
"measure",
"with",
"PyPhi",
"."
] | deeca69a084d782a6fde7bf26f59e93b593c5d77 | https://github.com/wmayner/pyphi/blob/deeca69a084d782a6fde7bf26f59e93b593c5d77/pyphi/distance.py#L46-L60 | train |
wmayner/pyphi | pyphi/partition.py | partitions | def partitions(collection):
"""Generate all set partitions of a collection.
Example:
>>> list(partitions(range(3))) # doctest: +NORMALIZE_WHITESPACE
[[[0, 1, 2]],
[[0], [1, 2]],
[[0, 1], [2]],
[[1], [0, 2]],
[[0], [1], [2]]]
"""
collection = list(col... | python | def partitions(collection):
"""Generate all set partitions of a collection.
Example:
>>> list(partitions(range(3))) # doctest: +NORMALIZE_WHITESPACE
[[[0, 1, 2]],
[[0], [1, 2]],
[[0, 1], [2]],
[[1], [0, 2]],
[[0], [1], [2]]]
"""
collection = list(col... | [
"def",
"partitions",
"(",
"collection",
")",
":",
"collection",
"=",
"list",
"(",
"collection",
")",
"if",
"not",
"collection",
":",
"return",
"if",
"len",
"(",
"collection",
")",
"==",
"1",
":",
"yield",
"[",
"collection",
"]",
"return",
"first",
"=",
... | Generate all set partitions of a collection.
Example:
>>> list(partitions(range(3))) # doctest: +NORMALIZE_WHITESPACE
[[[0, 1, 2]],
[[0], [1, 2]],
[[0, 1], [2]],
[[1], [0, 2]],
[[0], [1], [2]]] | [
"Generate",
"all",
"set",
"partitions",
"of",
"a",
"collection",
"."
] | deeca69a084d782a6fde7bf26f59e93b593c5d77 | https://github.com/wmayner/pyphi/blob/deeca69a084d782a6fde7bf26f59e93b593c5d77/pyphi/partition.py#L18-L43 | train |
wmayner/pyphi | pyphi/partition.py | bipartition_indices | def bipartition_indices(N):
"""Return indices for undirected bipartitions of a sequence.
Args:
N (int): The length of the sequence.
Returns:
list: A list of tuples containing the indices for each of the two
parts.
Example:
>>> N = 3
>>> bipartition_indices(N)
... | python | def bipartition_indices(N):
"""Return indices for undirected bipartitions of a sequence.
Args:
N (int): The length of the sequence.
Returns:
list: A list of tuples containing the indices for each of the two
parts.
Example:
>>> N = 3
>>> bipartition_indices(N)
... | [
"def",
"bipartition_indices",
"(",
"N",
")",
":",
"result",
"=",
"[",
"]",
"if",
"N",
"<=",
"0",
":",
"return",
"result",
"for",
"i",
"in",
"range",
"(",
"2",
"**",
"(",
"N",
"-",
"1",
")",
")",
":",
"part",
"=",
"[",
"[",
"]",
",",
"[",
"]... | Return indices for undirected bipartitions of a sequence.
Args:
N (int): The length of the sequence.
Returns:
list: A list of tuples containing the indices for each of the two
parts.
Example:
>>> N = 3
>>> bipartition_indices(N)
[((), (0, 1, 2)), ((0,), (1,... | [
"Return",
"indices",
"for",
"undirected",
"bipartitions",
"of",
"a",
"sequence",
"."
] | deeca69a084d782a6fde7bf26f59e93b593c5d77 | https://github.com/wmayner/pyphi/blob/deeca69a084d782a6fde7bf26f59e93b593c5d77/pyphi/partition.py#L47-L72 | train |
wmayner/pyphi | pyphi/partition.py | bipartition | def bipartition(seq):
"""Return a list of bipartitions for a sequence.
Args:
a (Iterable): The sequence to partition.
Returns:
list[tuple[tuple]]: A list of tuples containing each of the two
partitions.
Example:
>>> bipartition((1,2,3))
[((), (1, 2, 3)), ((1,),... | python | def bipartition(seq):
"""Return a list of bipartitions for a sequence.
Args:
a (Iterable): The sequence to partition.
Returns:
list[tuple[tuple]]: A list of tuples containing each of the two
partitions.
Example:
>>> bipartition((1,2,3))
[((), (1, 2, 3)), ((1,),... | [
"def",
"bipartition",
"(",
"seq",
")",
":",
"return",
"[",
"(",
"tuple",
"(",
"seq",
"[",
"i",
"]",
"for",
"i",
"in",
"part0_idx",
")",
",",
"tuple",
"(",
"seq",
"[",
"j",
"]",
"for",
"j",
"in",
"part1_idx",
")",
")",
"for",
"part0_idx",
",",
"... | Return a list of bipartitions for a sequence.
Args:
a (Iterable): The sequence to partition.
Returns:
list[tuple[tuple]]: A list of tuples containing each of the two
partitions.
Example:
>>> bipartition((1,2,3))
[((), (1, 2, 3)), ((1,), (2, 3)), ((2,), (1, 3)), ((1... | [
"Return",
"a",
"list",
"of",
"bipartitions",
"for",
"a",
"sequence",
"."
] | deeca69a084d782a6fde7bf26f59e93b593c5d77 | https://github.com/wmayner/pyphi/blob/deeca69a084d782a6fde7bf26f59e93b593c5d77/pyphi/partition.py#L76-L92 | train |
wmayner/pyphi | pyphi/partition.py | directed_bipartition | def directed_bipartition(seq, nontrivial=False):
"""Return a list of directed bipartitions for a sequence.
Args:
seq (Iterable): The sequence to partition.
Returns:
list[tuple[tuple]]: A list of tuples containing each of the two
parts.
Example:
>>> directed_bipartition... | python | def directed_bipartition(seq, nontrivial=False):
"""Return a list of directed bipartitions for a sequence.
Args:
seq (Iterable): The sequence to partition.
Returns:
list[tuple[tuple]]: A list of tuples containing each of the two
parts.
Example:
>>> directed_bipartition... | [
"def",
"directed_bipartition",
"(",
"seq",
",",
"nontrivial",
"=",
"False",
")",
":",
"bipartitions",
"=",
"[",
"(",
"tuple",
"(",
"seq",
"[",
"i",
"]",
"for",
"i",
"in",
"part0_idx",
")",
",",
"tuple",
"(",
"seq",
"[",
"j",
"]",
"for",
"j",
"in",
... | Return a list of directed bipartitions for a sequence.
Args:
seq (Iterable): The sequence to partition.
Returns:
list[tuple[tuple]]: A list of tuples containing each of the two
parts.
Example:
>>> directed_bipartition((1, 2, 3)) # doctest: +NORMALIZE_WHITESPACE
[(... | [
"Return",
"a",
"list",
"of",
"directed",
"bipartitions",
"for",
"a",
"sequence",
"."
] | deeca69a084d782a6fde7bf26f59e93b593c5d77 | https://github.com/wmayner/pyphi/blob/deeca69a084d782a6fde7bf26f59e93b593c5d77/pyphi/partition.py#L123-L153 | train |
wmayner/pyphi | pyphi/partition.py | bipartition_of_one | def bipartition_of_one(seq):
"""Generate bipartitions where one part is of length 1."""
seq = list(seq)
for i, elt in enumerate(seq):
yield ((elt,), tuple(seq[:i] + seq[(i + 1):])) | python | def bipartition_of_one(seq):
"""Generate bipartitions where one part is of length 1."""
seq = list(seq)
for i, elt in enumerate(seq):
yield ((elt,), tuple(seq[:i] + seq[(i + 1):])) | [
"def",
"bipartition_of_one",
"(",
"seq",
")",
":",
"seq",
"=",
"list",
"(",
"seq",
")",
"for",
"i",
",",
"elt",
"in",
"enumerate",
"(",
"seq",
")",
":",
"yield",
"(",
"(",
"elt",
",",
")",
",",
"tuple",
"(",
"seq",
"[",
":",
"i",
"]",
"+",
"s... | Generate bipartitions where one part is of length 1. | [
"Generate",
"bipartitions",
"where",
"one",
"part",
"is",
"of",
"length",
"1",
"."
] | deeca69a084d782a6fde7bf26f59e93b593c5d77 | https://github.com/wmayner/pyphi/blob/deeca69a084d782a6fde7bf26f59e93b593c5d77/pyphi/partition.py#L156-L160 | train |
wmayner/pyphi | pyphi/partition.py | directed_bipartition_of_one | def directed_bipartition_of_one(seq):
"""Generate directed bipartitions where one part is of length 1.
Args:
seq (Iterable): The sequence to partition.
Returns:
list[tuple[tuple]]: A list of tuples containing each of the two
partitions.
Example:
>>> partitions = direct... | python | def directed_bipartition_of_one(seq):
"""Generate directed bipartitions where one part is of length 1.
Args:
seq (Iterable): The sequence to partition.
Returns:
list[tuple[tuple]]: A list of tuples containing each of the two
partitions.
Example:
>>> partitions = direct... | [
"def",
"directed_bipartition_of_one",
"(",
"seq",
")",
":",
"bipartitions",
"=",
"list",
"(",
"bipartition_of_one",
"(",
"seq",
")",
")",
"return",
"chain",
"(",
"bipartitions",
",",
"reverse_elements",
"(",
"bipartitions",
")",
")"
] | Generate directed bipartitions where one part is of length 1.
Args:
seq (Iterable): The sequence to partition.
Returns:
list[tuple[tuple]]: A list of tuples containing each of the two
partitions.
Example:
>>> partitions = directed_bipartition_of_one((1, 2, 3))
>>> ... | [
"Generate",
"directed",
"bipartitions",
"where",
"one",
"part",
"is",
"of",
"length",
"1",
"."
] | deeca69a084d782a6fde7bf26f59e93b593c5d77 | https://github.com/wmayner/pyphi/blob/deeca69a084d782a6fde7bf26f59e93b593c5d77/pyphi/partition.py#L169-L190 | train |
wmayner/pyphi | pyphi/partition.py | directed_tripartition_indices | def directed_tripartition_indices(N):
"""Return indices for directed tripartitions of a sequence.
Args:
N (int): The length of the sequence.
Returns:
list[tuple]: A list of tuples containing the indices for each
partition.
Example:
>>> N = 1
>>> directed_tripar... | python | def directed_tripartition_indices(N):
"""Return indices for directed tripartitions of a sequence.
Args:
N (int): The length of the sequence.
Returns:
list[tuple]: A list of tuples containing the indices for each
partition.
Example:
>>> N = 1
>>> directed_tripar... | [
"def",
"directed_tripartition_indices",
"(",
"N",
")",
":",
"result",
"=",
"[",
"]",
"if",
"N",
"<=",
"0",
":",
"return",
"result",
"base",
"=",
"[",
"0",
",",
"1",
",",
"2",
"]",
"for",
"key",
"in",
"product",
"(",
"base",
",",
"repeat",
"=",
"N... | Return indices for directed tripartitions of a sequence.
Args:
N (int): The length of the sequence.
Returns:
list[tuple]: A list of tuples containing the indices for each
partition.
Example:
>>> N = 1
>>> directed_tripartition_indices(N)
[((0,), (), ()), ((... | [
"Return",
"indices",
"for",
"directed",
"tripartitions",
"of",
"a",
"sequence",
"."
] | deeca69a084d782a6fde7bf26f59e93b593c5d77 | https://github.com/wmayner/pyphi/blob/deeca69a084d782a6fde7bf26f59e93b593c5d77/pyphi/partition.py#L194-L221 | train |
wmayner/pyphi | pyphi/partition.py | directed_tripartition | def directed_tripartition(seq):
"""Generator over all directed tripartitions of a sequence.
Args:
seq (Iterable): a sequence.
Yields:
tuple[tuple]: A tripartition of ``seq``.
Example:
>>> seq = (2, 5)
>>> list(directed_tripartition(seq)) # doctest: +NORMALIZE_WHITESPA... | python | def directed_tripartition(seq):
"""Generator over all directed tripartitions of a sequence.
Args:
seq (Iterable): a sequence.
Yields:
tuple[tuple]: A tripartition of ``seq``.
Example:
>>> seq = (2, 5)
>>> list(directed_tripartition(seq)) # doctest: +NORMALIZE_WHITESPA... | [
"def",
"directed_tripartition",
"(",
"seq",
")",
":",
"for",
"a",
",",
"b",
",",
"c",
"in",
"directed_tripartition_indices",
"(",
"len",
"(",
"seq",
")",
")",
":",
"yield",
"(",
"tuple",
"(",
"seq",
"[",
"i",
"]",
"for",
"i",
"in",
"a",
")",
",",
... | Generator over all directed tripartitions of a sequence.
Args:
seq (Iterable): a sequence.
Yields:
tuple[tuple]: A tripartition of ``seq``.
Example:
>>> seq = (2, 5)
>>> list(directed_tripartition(seq)) # doctest: +NORMALIZE_WHITESPACE
[((2, 5), (), ()),
... | [
"Generator",
"over",
"all",
"directed",
"tripartitions",
"of",
"a",
"sequence",
"."
] | deeca69a084d782a6fde7bf26f59e93b593c5d77 | https://github.com/wmayner/pyphi/blob/deeca69a084d782a6fde7bf26f59e93b593c5d77/pyphi/partition.py#L224-L249 | train |
wmayner/pyphi | pyphi/partition.py | k_partitions | def k_partitions(collection, k):
"""Generate all ``k``-partitions of a collection.
Example:
>>> list(k_partitions(range(3), 2))
[[[0, 1], [2]], [[0], [1, 2]], [[0, 2], [1]]]
"""
collection = list(collection)
n = len(collection)
# Special cases
if n == 0 or k < 1:
re... | python | def k_partitions(collection, k):
"""Generate all ``k``-partitions of a collection.
Example:
>>> list(k_partitions(range(3), 2))
[[[0, 1], [2]], [[0], [1, 2]], [[0, 2], [1]]]
"""
collection = list(collection)
n = len(collection)
# Special cases
if n == 0 or k < 1:
re... | [
"def",
"k_partitions",
"(",
"collection",
",",
"k",
")",
":",
"collection",
"=",
"list",
"(",
"collection",
")",
"n",
"=",
"len",
"(",
"collection",
")",
"if",
"n",
"==",
"0",
"or",
"k",
"<",
"1",
":",
"return",
"[",
"]",
"if",
"k",
"==",
"1",
... | Generate all ``k``-partitions of a collection.
Example:
>>> list(k_partitions(range(3), 2))
[[[0, 1], [2]], [[0], [1, 2]], [[0, 2], [1]]] | [
"Generate",
"all",
"k",
"-",
"partitions",
"of",
"a",
"collection",
"."
] | deeca69a084d782a6fde7bf26f59e93b593c5d77 | https://github.com/wmayner/pyphi/blob/deeca69a084d782a6fde7bf26f59e93b593c5d77/pyphi/partition.py#L335-L354 | train |
wmayner/pyphi | pyphi/partition.py | mip_partitions | def mip_partitions(mechanism, purview, node_labels=None):
"""Return a generator over all mechanism-purview partitions, based on the
current configuration.
"""
func = partition_types[config.PARTITION_TYPE]
return func(mechanism, purview, node_labels) | python | def mip_partitions(mechanism, purview, node_labels=None):
"""Return a generator over all mechanism-purview partitions, based on the
current configuration.
"""
func = partition_types[config.PARTITION_TYPE]
return func(mechanism, purview, node_labels) | [
"def",
"mip_partitions",
"(",
"mechanism",
",",
"purview",
",",
"node_labels",
"=",
"None",
")",
":",
"func",
"=",
"partition_types",
"[",
"config",
".",
"PARTITION_TYPE",
"]",
"return",
"func",
"(",
"mechanism",
",",
"purview",
",",
"node_labels",
")"
] | Return a generator over all mechanism-purview partitions, based on the
current configuration. | [
"Return",
"a",
"generator",
"over",
"all",
"mechanism",
"-",
"purview",
"partitions",
"based",
"on",
"the",
"current",
"configuration",
"."
] | deeca69a084d782a6fde7bf26f59e93b593c5d77 | https://github.com/wmayner/pyphi/blob/deeca69a084d782a6fde7bf26f59e93b593c5d77/pyphi/partition.py#L378-L383 | train |
wmayner/pyphi | pyphi/partition.py | mip_bipartitions | def mip_bipartitions(mechanism, purview, node_labels=None):
r"""Return an generator of all |small_phi| bipartitions of a mechanism over
a purview.
Excludes all bipartitions where one half is entirely empty, *e.g*::
A ∅
─── ✕ ───
B ∅
is not valid, but ::
A ... | python | def mip_bipartitions(mechanism, purview, node_labels=None):
r"""Return an generator of all |small_phi| bipartitions of a mechanism over
a purview.
Excludes all bipartitions where one half is entirely empty, *e.g*::
A ∅
─── ✕ ───
B ∅
is not valid, but ::
A ... | [
"def",
"mip_bipartitions",
"(",
"mechanism",
",",
"purview",
",",
"node_labels",
"=",
"None",
")",
":",
"r",
"numerators",
"=",
"bipartition",
"(",
"mechanism",
")",
"denominators",
"=",
"directed_bipartition",
"(",
"purview",
")",
"for",
"n",
",",
"d",
"in"... | r"""Return an generator of all |small_phi| bipartitions of a mechanism over
a purview.
Excludes all bipartitions where one half is entirely empty, *e.g*::
A ∅
─── ✕ ───
B ∅
is not valid, but ::
A ∅
─── ✕ ───
∅ B
is.
Args:
... | [
"r",
"Return",
"an",
"generator",
"of",
"all",
"|small_phi|",
"bipartitions",
"of",
"a",
"mechanism",
"over",
"a",
"purview",
"."
] | deeca69a084d782a6fde7bf26f59e93b593c5d77 | https://github.com/wmayner/pyphi/blob/deeca69a084d782a6fde7bf26f59e93b593c5d77/pyphi/partition.py#L387-L439 | train |
wmayner/pyphi | pyphi/partition.py | wedge_partitions | def wedge_partitions(mechanism, purview, node_labels=None):
"""Return an iterator over all wedge partitions.
These are partitions which strictly split the mechanism and allow a subset
of the purview to be split into a third partition, e.g.::
A B ∅
─── ✕ ─── ✕ ───
B C ... | python | def wedge_partitions(mechanism, purview, node_labels=None):
"""Return an iterator over all wedge partitions.
These are partitions which strictly split the mechanism and allow a subset
of the purview to be split into a third partition, e.g.::
A B ∅
─── ✕ ─── ✕ ───
B C ... | [
"def",
"wedge_partitions",
"(",
"mechanism",
",",
"purview",
",",
"node_labels",
"=",
"None",
")",
":",
"numerators",
"=",
"bipartition",
"(",
"mechanism",
")",
"denominators",
"=",
"directed_tripartition",
"(",
"purview",
")",
"yielded",
"=",
"set",
"(",
")",... | Return an iterator over all wedge partitions.
These are partitions which strictly split the mechanism and allow a subset
of the purview to be split into a third partition, e.g.::
A B ∅
─── ✕ ─── ✕ ───
B C D
See |PARTITION_TYPE| in |config| for more information.
... | [
"Return",
"an",
"iterator",
"over",
"all",
"wedge",
"partitions",
"."
] | deeca69a084d782a6fde7bf26f59e93b593c5d77 | https://github.com/wmayner/pyphi/blob/deeca69a084d782a6fde7bf26f59e93b593c5d77/pyphi/partition.py#L443-L511 | train |
wmayner/pyphi | pyphi/partition.py | all_partitions | def all_partitions(mechanism, purview, node_labels=None):
"""Return all possible partitions of a mechanism and purview.
Partitions can consist of any number of parts.
Args:
mechanism (tuple[int]): A mechanism.
purview (tuple[int]): A purview.
Yields:
KPartition: A partition of... | python | def all_partitions(mechanism, purview, node_labels=None):
"""Return all possible partitions of a mechanism and purview.
Partitions can consist of any number of parts.
Args:
mechanism (tuple[int]): A mechanism.
purview (tuple[int]): A purview.
Yields:
KPartition: A partition of... | [
"def",
"all_partitions",
"(",
"mechanism",
",",
"purview",
",",
"node_labels",
"=",
"None",
")",
":",
"for",
"mechanism_partition",
"in",
"partitions",
"(",
"mechanism",
")",
":",
"mechanism_partition",
".",
"append",
"(",
"[",
"]",
")",
"n_mechanism_parts",
"... | Return all possible partitions of a mechanism and purview.
Partitions can consist of any number of parts.
Args:
mechanism (tuple[int]): A mechanism.
purview (tuple[int]): A purview.
Yields:
KPartition: A partition of this mechanism and purview into ``k`` parts. | [
"Return",
"all",
"possible",
"partitions",
"of",
"a",
"mechanism",
"and",
"purview",
"."
] | deeca69a084d782a6fde7bf26f59e93b593c5d77 | https://github.com/wmayner/pyphi/blob/deeca69a084d782a6fde7bf26f59e93b593c5d77/pyphi/partition.py#L515-L555 | train |
openstack/pyghmi | pyghmi/ipmi/oem/lenovo/imm.py | naturalize_string | def naturalize_string(key):
"""Analyzes string in a human way to enable natural sort
:param nodename: The node name to analyze
:returns: A structure that can be consumed by 'sorted'
"""
return [int(text) if text.isdigit() else text.lower()
for text in re.split(numregex, key)] | python | def naturalize_string(key):
"""Analyzes string in a human way to enable natural sort
:param nodename: The node name to analyze
:returns: A structure that can be consumed by 'sorted'
"""
return [int(text) if text.isdigit() else text.lower()
for text in re.split(numregex, key)] | [
"def",
"naturalize_string",
"(",
"key",
")",
":",
"return",
"[",
"int",
"(",
"text",
")",
"if",
"text",
".",
"isdigit",
"(",
")",
"else",
"text",
".",
"lower",
"(",
")",
"for",
"text",
"in",
"re",
".",
"split",
"(",
"numregex",
",",
"key",
")",
"... | Analyzes string in a human way to enable natural sort
:param nodename: The node name to analyze
:returns: A structure that can be consumed by 'sorted' | [
"Analyzes",
"string",
"in",
"a",
"human",
"way",
"to",
"enable",
"natural",
"sort"
] | f710b1d30a8eed19a9e86f01f9351c737666f3e5 | https://github.com/openstack/pyghmi/blob/f710b1d30a8eed19a9e86f01f9351c737666f3e5/pyghmi/ipmi/oem/lenovo/imm.py#L52-L59 | train |
openstack/pyghmi | pyghmi/ipmi/events.py | EventHandler.fetch_sel | def fetch_sel(self, ipmicmd, clear=False):
"""Fetch SEL entries
Return an iterable of SEL entries. If clearing is requested,
the fetch and clear will be done as an atomic operation, assuring
no entries are dropped.
:param ipmicmd: The Command object to use to interrogate
:param clear:... | python | def fetch_sel(self, ipmicmd, clear=False):
"""Fetch SEL entries
Return an iterable of SEL entries. If clearing is requested,
the fetch and clear will be done as an atomic operation, assuring
no entries are dropped.
:param ipmicmd: The Command object to use to interrogate
:param clear:... | [
"def",
"fetch_sel",
"(",
"self",
",",
"ipmicmd",
",",
"clear",
"=",
"False",
")",
":",
"records",
"=",
"[",
"]",
"endat",
"=",
"self",
".",
"_fetch_entries",
"(",
"ipmicmd",
",",
"0",
",",
"records",
")",
"if",
"clear",
"and",
"records",
":",
"rsp",
... | Fetch SEL entries
Return an iterable of SEL entries. If clearing is requested,
the fetch and clear will be done as an atomic operation, assuring
no entries are dropped.
:param ipmicmd: The Command object to use to interrogate
:param clear: Whether to clear the entries upon retrieval. | [
"Fetch",
"SEL",
"entries"
] | f710b1d30a8eed19a9e86f01f9351c737666f3e5 | https://github.com/openstack/pyghmi/blob/f710b1d30a8eed19a9e86f01f9351c737666f3e5/pyghmi/ipmi/events.py#L553-L581 | train |
openstack/pyghmi | pyghmi/ipmi/command.py | Command.oem_init | def oem_init(self):
"""Initialize the command object for OEM capabilities
A number of capabilities are either totally OEM defined or
else augmented somehow by knowledge of the OEM. This
method does an interrogation to identify the OEM.
"""
if self._oemknown:
... | python | def oem_init(self):
"""Initialize the command object for OEM capabilities
A number of capabilities are either totally OEM defined or
else augmented somehow by knowledge of the OEM. This
method does an interrogation to identify the OEM.
"""
if self._oemknown:
... | [
"def",
"oem_init",
"(",
"self",
")",
":",
"if",
"self",
".",
"_oemknown",
":",
"return",
"self",
".",
"_oem",
",",
"self",
".",
"_oemknown",
"=",
"get_oem_handler",
"(",
"self",
".",
"_get_device_id",
"(",
")",
",",
"self",
")"
] | Initialize the command object for OEM capabilities
A number of capabilities are either totally OEM defined or
else augmented somehow by knowledge of the OEM. This
method does an interrogation to identify the OEM. | [
"Initialize",
"the",
"command",
"object",
"for",
"OEM",
"capabilities"
] | f710b1d30a8eed19a9e86f01f9351c737666f3e5 | https://github.com/openstack/pyghmi/blob/f710b1d30a8eed19a9e86f01f9351c737666f3e5/pyghmi/ipmi/command.py#L228-L239 | train |
openstack/pyghmi | pyghmi/ipmi/command.py | Command.reset_bmc | def reset_bmc(self):
"""Do a cold reset in BMC
"""
response = self.raw_command(netfn=6, command=2)
if 'error' in response:
raise exc.IpmiException(response['error']) | python | def reset_bmc(self):
"""Do a cold reset in BMC
"""
response = self.raw_command(netfn=6, command=2)
if 'error' in response:
raise exc.IpmiException(response['error']) | [
"def",
"reset_bmc",
"(",
"self",
")",
":",
"response",
"=",
"self",
".",
"raw_command",
"(",
"netfn",
"=",
"6",
",",
"command",
"=",
"2",
")",
"if",
"'error'",
"in",
"response",
":",
"raise",
"exc",
".",
"IpmiException",
"(",
"response",
"[",
"'error'"... | Do a cold reset in BMC | [
"Do",
"a",
"cold",
"reset",
"in",
"BMC"
] | f710b1d30a8eed19a9e86f01f9351c737666f3e5 | https://github.com/openstack/pyghmi/blob/f710b1d30a8eed19a9e86f01f9351c737666f3e5/pyghmi/ipmi/command.py#L364-L369 | train |
openstack/pyghmi | pyghmi/ipmi/command.py | Command.xraw_command | def xraw_command(self, netfn, command, bridge_request=(), data=(),
delay_xmit=None, retry=True, timeout=None):
"""Send raw ipmi command to BMC, raising exception on error
This is identical to raw_command, except it raises exceptions
on IPMI errors and returns data as a buff... | python | def xraw_command(self, netfn, command, bridge_request=(), data=(),
delay_xmit=None, retry=True, timeout=None):
"""Send raw ipmi command to BMC, raising exception on error
This is identical to raw_command, except it raises exceptions
on IPMI errors and returns data as a buff... | [
"def",
"xraw_command",
"(",
"self",
",",
"netfn",
",",
"command",
",",
"bridge_request",
"=",
"(",
")",
",",
"data",
"=",
"(",
")",
",",
"delay_xmit",
"=",
"None",
",",
"retry",
"=",
"True",
",",
"timeout",
"=",
"None",
")",
":",
"rsp",
"=",
"self"... | Send raw ipmi command to BMC, raising exception on error
This is identical to raw_command, except it raises exceptions
on IPMI errors and returns data as a buffer. This is the recommend
function to use. The response['data'] being a buffer allows
traditional indexed access as well as w... | [
"Send",
"raw",
"ipmi",
"command",
"to",
"BMC",
"raising",
"exception",
"on",
"error"
] | f710b1d30a8eed19a9e86f01f9351c737666f3e5 | https://github.com/openstack/pyghmi/blob/f710b1d30a8eed19a9e86f01f9351c737666f3e5/pyghmi/ipmi/command.py#L418-L446 | train |
openstack/pyghmi | pyghmi/ipmi/command.py | Command.raw_command | def raw_command(self, netfn, command, bridge_request=(), data=(),
delay_xmit=None, retry=True, timeout=None):
"""Send raw ipmi command to BMC
This allows arbitrary IPMI bytes to be issued. This is commonly used
for certain vendor specific commands.
Example: ipmicmd... | python | def raw_command(self, netfn, command, bridge_request=(), data=(),
delay_xmit=None, retry=True, timeout=None):
"""Send raw ipmi command to BMC
This allows arbitrary IPMI bytes to be issued. This is commonly used
for certain vendor specific commands.
Example: ipmicmd... | [
"def",
"raw_command",
"(",
"self",
",",
"netfn",
",",
"command",
",",
"bridge_request",
"=",
"(",
")",
",",
"data",
"=",
"(",
")",
",",
"delay_xmit",
"=",
"None",
",",
"retry",
"=",
"True",
",",
"timeout",
"=",
"None",
")",
":",
"rsp",
"=",
"self",... | Send raw ipmi command to BMC
This allows arbitrary IPMI bytes to be issued. This is commonly used
for certain vendor specific commands.
Example: ipmicmd.raw_command(netfn=0,command=4,data=(5))
:param netfn: Net function number
:param command: Command value
:param brid... | [
"Send",
"raw",
"ipmi",
"command",
"to",
"BMC"
] | f710b1d30a8eed19a9e86f01f9351c737666f3e5 | https://github.com/openstack/pyghmi/blob/f710b1d30a8eed19a9e86f01f9351c737666f3e5/pyghmi/ipmi/command.py#L462-L487 | train |
openstack/pyghmi | pyghmi/ipmi/command.py | Command.get_power | def get_power(self):
"""Get current power state of the managed system
The response, if successful, should contain 'powerstate' key and
either 'on' or 'off' to indicate current state.
:returns: dict -- {'powerstate': value}
"""
response = self.raw_command(netfn=0, comman... | python | def get_power(self):
"""Get current power state of the managed system
The response, if successful, should contain 'powerstate' key and
either 'on' or 'off' to indicate current state.
:returns: dict -- {'powerstate': value}
"""
response = self.raw_command(netfn=0, comman... | [
"def",
"get_power",
"(",
"self",
")",
":",
"response",
"=",
"self",
".",
"raw_command",
"(",
"netfn",
"=",
"0",
",",
"command",
"=",
"1",
")",
"if",
"'error'",
"in",
"response",
":",
"raise",
"exc",
".",
"IpmiException",
"(",
"response",
"[",
"'error'"... | Get current power state of the managed system
The response, if successful, should contain 'powerstate' key and
either 'on' or 'off' to indicate current state.
:returns: dict -- {'powerstate': value} | [
"Get",
"current",
"power",
"state",
"of",
"the",
"managed",
"system"
] | f710b1d30a8eed19a9e86f01f9351c737666f3e5 | https://github.com/openstack/pyghmi/blob/f710b1d30a8eed19a9e86f01f9351c737666f3e5/pyghmi/ipmi/command.py#L489-L502 | train |
openstack/pyghmi | pyghmi/ipmi/command.py | Command.get_event_log | def get_event_log(self, clear=False):
"""Retrieve the log of events, optionally clearing
The contents of the SEL are returned as an iterable. Timestamps
are given as local time, ISO 8601 (whether the target has an accurate
clock or not). Timestamps may be omitted for events that canno... | python | def get_event_log(self, clear=False):
"""Retrieve the log of events, optionally clearing
The contents of the SEL are returned as an iterable. Timestamps
are given as local time, ISO 8601 (whether the target has an accurate
clock or not). Timestamps may be omitted for events that canno... | [
"def",
"get_event_log",
"(",
"self",
",",
"clear",
"=",
"False",
")",
":",
"self",
".",
"oem_init",
"(",
")",
"return",
"sel",
".",
"EventHandler",
"(",
"self",
".",
"init_sdr",
"(",
")",
",",
"self",
")",
".",
"fetch_sel",
"(",
"self",
",",
"clear",... | Retrieve the log of events, optionally clearing
The contents of the SEL are returned as an iterable. Timestamps
are given as local time, ISO 8601 (whether the target has an accurate
clock or not). Timestamps may be omitted for events that cannot be
given a timestamp, leaving only the ... | [
"Retrieve",
"the",
"log",
"of",
"events",
"optionally",
"clearing"
] | f710b1d30a8eed19a9e86f01f9351c737666f3e5 | https://github.com/openstack/pyghmi/blob/f710b1d30a8eed19a9e86f01f9351c737666f3e5/pyghmi/ipmi/command.py#L559-L575 | train |
openstack/pyghmi | pyghmi/ipmi/command.py | Command.decode_pet | def decode_pet(self, specifictrap, petdata):
"""Decode PET to an event
In IPMI, the alert format are PET alerts. It is a particular set of
data put into an SNMPv1 trap and sent. It bears no small resemblence
to the SEL entries. This function takes data that would have been
rec... | python | def decode_pet(self, specifictrap, petdata):
"""Decode PET to an event
In IPMI, the alert format are PET alerts. It is a particular set of
data put into an SNMPv1 trap and sent. It bears no small resemblence
to the SEL entries. This function takes data that would have been
rec... | [
"def",
"decode_pet",
"(",
"self",
",",
"specifictrap",
",",
"petdata",
")",
":",
"self",
".",
"oem_init",
"(",
")",
"return",
"sel",
".",
"EventHandler",
"(",
"self",
".",
"init_sdr",
"(",
")",
",",
"self",
")",
".",
"decode_pet",
"(",
"specifictrap",
... | Decode PET to an event
In IPMI, the alert format are PET alerts. It is a particular set of
data put into an SNMPv1 trap and sent. It bears no small resemblence
to the SEL entries. This function takes data that would have been
received by an SNMP trap handler, and provides an event dec... | [
"Decode",
"PET",
"to",
"an",
"event"
] | f710b1d30a8eed19a9e86f01f9351c737666f3e5 | https://github.com/openstack/pyghmi/blob/f710b1d30a8eed19a9e86f01f9351c737666f3e5/pyghmi/ipmi/command.py#L577-L593 | train |
openstack/pyghmi | pyghmi/ipmi/command.py | Command.get_inventory_descriptions | def get_inventory_descriptions(self):
"""Retrieve list of things that could be inventoried
This permits a caller to examine the available items
without actually causing the inventory data to be gathered. It
returns an iterable of string descriptions
"""
yield "System"
... | python | def get_inventory_descriptions(self):
"""Retrieve list of things that could be inventoried
This permits a caller to examine the available items
without actually causing the inventory data to be gathered. It
returns an iterable of string descriptions
"""
yield "System"
... | [
"def",
"get_inventory_descriptions",
"(",
"self",
")",
":",
"yield",
"\"System\"",
"self",
".",
"init_sdr",
"(",
")",
"for",
"fruid",
"in",
"sorted",
"(",
"self",
".",
"_sdr",
".",
"fru",
")",
":",
"yield",
"self",
".",
"_sdr",
".",
"fru",
"[",
"fruid"... | Retrieve list of things that could be inventoried
This permits a caller to examine the available items
without actually causing the inventory data to be gathered. It
returns an iterable of string descriptions | [
"Retrieve",
"list",
"of",
"things",
"that",
"could",
"be",
"inventoried"
] | f710b1d30a8eed19a9e86f01f9351c737666f3e5 | https://github.com/openstack/pyghmi/blob/f710b1d30a8eed19a9e86f01f9351c737666f3e5/pyghmi/ipmi/command.py#L595-L608 | train |
openstack/pyghmi | pyghmi/ipmi/command.py | Command.get_inventory_of_component | def get_inventory_of_component(self, component):
"""Retrieve inventory of a component
Retrieve detailed inventory information for only the requested
component.
"""
self.oem_init()
if component == 'System':
return self._get_zero_fru()
self.init_sdr()
... | python | def get_inventory_of_component(self, component):
"""Retrieve inventory of a component
Retrieve detailed inventory information for only the requested
component.
"""
self.oem_init()
if component == 'System':
return self._get_zero_fru()
self.init_sdr()
... | [
"def",
"get_inventory_of_component",
"(",
"self",
",",
"component",
")",
":",
"self",
".",
"oem_init",
"(",
")",
"if",
"component",
"==",
"'System'",
":",
"return",
"self",
".",
"_get_zero_fru",
"(",
")",
"self",
".",
"init_sdr",
"(",
")",
"for",
"fruid",
... | Retrieve inventory of a component
Retrieve detailed inventory information for only the requested
component. | [
"Retrieve",
"inventory",
"of",
"a",
"component"
] | f710b1d30a8eed19a9e86f01f9351c737666f3e5 | https://github.com/openstack/pyghmi/blob/f710b1d30a8eed19a9e86f01f9351c737666f3e5/pyghmi/ipmi/command.py#L610-L625 | train |
openstack/pyghmi | pyghmi/ipmi/command.py | Command.get_inventory | def get_inventory(self):
"""Retrieve inventory of system
Retrieve inventory of the targeted system. This frequently includes
serial numbers, sometimes hardware addresses, sometimes memory modules
This function will retrieve whatever the underlying platform provides
and apply so... | python | def get_inventory(self):
"""Retrieve inventory of system
Retrieve inventory of the targeted system. This frequently includes
serial numbers, sometimes hardware addresses, sometimes memory modules
This function will retrieve whatever the underlying platform provides
and apply so... | [
"def",
"get_inventory",
"(",
"self",
")",
":",
"self",
".",
"oem_init",
"(",
")",
"yield",
"(",
"\"System\"",
",",
"self",
".",
"_get_zero_fru",
"(",
")",
")",
"self",
".",
"init_sdr",
"(",
")",
"for",
"fruid",
"in",
"sorted",
"(",
"self",
".",
"_sdr... | Retrieve inventory of system
Retrieve inventory of the targeted system. This frequently includes
serial numbers, sometimes hardware addresses, sometimes memory modules
This function will retrieve whatever the underlying platform provides
and apply some structure. Iterating over the re... | [
"Retrieve",
"inventory",
"of",
"system"
] | f710b1d30a8eed19a9e86f01f9351c737666f3e5 | https://github.com/openstack/pyghmi/blob/f710b1d30a8eed19a9e86f01f9351c737666f3e5/pyghmi/ipmi/command.py#L651-L672 | train |
openstack/pyghmi | pyghmi/ipmi/command.py | Command.get_health | def get_health(self):
"""Summarize health of managed system
This provides a summary of the health of the managed system.
It additionally provides an iterable list of reasons for
warning, critical, or failed assessments.
"""
summary = {'badreadings': [], 'health': const.H... | python | def get_health(self):
"""Summarize health of managed system
This provides a summary of the health of the managed system.
It additionally provides an iterable list of reasons for
warning, critical, or failed assessments.
"""
summary = {'badreadings': [], 'health': const.H... | [
"def",
"get_health",
"(",
"self",
")",
":",
"summary",
"=",
"{",
"'badreadings'",
":",
"[",
"]",
",",
"'health'",
":",
"const",
".",
"Health",
".",
"Ok",
"}",
"fallbackreadings",
"=",
"[",
"]",
"try",
":",
"self",
".",
"oem_init",
"(",
")",
"fallback... | Summarize health of managed system
This provides a summary of the health of the managed system.
It additionally provides an iterable list of reasons for
warning, critical, or failed assessments. | [
"Summarize",
"health",
"of",
"managed",
"system"
] | f710b1d30a8eed19a9e86f01f9351c737666f3e5 | https://github.com/openstack/pyghmi/blob/f710b1d30a8eed19a9e86f01f9351c737666f3e5/pyghmi/ipmi/command.py#L698-L718 | train |
openstack/pyghmi | pyghmi/ipmi/command.py | Command.get_sensor_reading | def get_sensor_reading(self, sensorname):
"""Get a sensor reading by name
Returns a single decoded sensor reading per the name
passed in
:param sensorname: Name of the desired sensor
:returns: sdr.SensorReading object
"""
self.init_sdr()
for sensor in s... | python | def get_sensor_reading(self, sensorname):
"""Get a sensor reading by name
Returns a single decoded sensor reading per the name
passed in
:param sensorname: Name of the desired sensor
:returns: sdr.SensorReading object
"""
self.init_sdr()
for sensor in s... | [
"def",
"get_sensor_reading",
"(",
"self",
",",
"sensorname",
")",
":",
"self",
".",
"init_sdr",
"(",
")",
"for",
"sensor",
"in",
"self",
".",
"_sdr",
".",
"get_sensor_numbers",
"(",
")",
":",
"if",
"self",
".",
"_sdr",
".",
"sensors",
"[",
"sensor",
"]... | Get a sensor reading by name
Returns a single decoded sensor reading per the name
passed in
:param sensorname: Name of the desired sensor
:returns: sdr.SensorReading object | [
"Get",
"a",
"sensor",
"reading",
"by",
"name"
] | f710b1d30a8eed19a9e86f01f9351c737666f3e5 | https://github.com/openstack/pyghmi/blob/f710b1d30a8eed19a9e86f01f9351c737666f3e5/pyghmi/ipmi/command.py#L720-L738 | train |
openstack/pyghmi | pyghmi/ipmi/command.py | Command._fetch_lancfg_param | def _fetch_lancfg_param(self, channel, param, prefixlen=False):
"""Internal helper for fetching lan cfg parameters
If the parameter revison != 0x11, bail. Further, if 4 bytes, return
string with ipv4. If 6 bytes, colon delimited hex (mac address). If
one byte, return the int value
... | python | def _fetch_lancfg_param(self, channel, param, prefixlen=False):
"""Internal helper for fetching lan cfg parameters
If the parameter revison != 0x11, bail. Further, if 4 bytes, return
string with ipv4. If 6 bytes, colon delimited hex (mac address). If
one byte, return the int value
... | [
"def",
"_fetch_lancfg_param",
"(",
"self",
",",
"channel",
",",
"param",
",",
"prefixlen",
"=",
"False",
")",
":",
"fetchcmd",
"=",
"bytearray",
"(",
"(",
"channel",
",",
"param",
",",
"0",
",",
"0",
")",
")",
"fetched",
"=",
"self",
".",
"xraw_command... | Internal helper for fetching lan cfg parameters
If the parameter revison != 0x11, bail. Further, if 4 bytes, return
string with ipv4. If 6 bytes, colon delimited hex (mac address). If
one byte, return the int value | [
"Internal",
"helper",
"for",
"fetching",
"lan",
"cfg",
"parameters"
] | f710b1d30a8eed19a9e86f01f9351c737666f3e5 | https://github.com/openstack/pyghmi/blob/f710b1d30a8eed19a9e86f01f9351c737666f3e5/pyghmi/ipmi/command.py#L740-L769 | train |
openstack/pyghmi | pyghmi/ipmi/command.py | Command.set_net_configuration | def set_net_configuration(self, ipv4_address=None, ipv4_configuration=None,
ipv4_gateway=None, channel=None):
"""Set network configuration data.
Apply desired network configuration data, leaving unspecified
parameters alone.
:param ipv4_address: CIDR nota... | python | def set_net_configuration(self, ipv4_address=None, ipv4_configuration=None,
ipv4_gateway=None, channel=None):
"""Set network configuration data.
Apply desired network configuration data, leaving unspecified
parameters alone.
:param ipv4_address: CIDR nota... | [
"def",
"set_net_configuration",
"(",
"self",
",",
"ipv4_address",
"=",
"None",
",",
"ipv4_configuration",
"=",
"None",
",",
"ipv4_gateway",
"=",
"None",
",",
"channel",
"=",
"None",
")",
":",
"if",
"channel",
"is",
"None",
":",
"channel",
"=",
"self",
".",... | Set network configuration data.
Apply desired network configuration data, leaving unspecified
parameters alone.
:param ipv4_address: CIDR notation for IP address and netmask
Example: '192.168.0.10/16'
:param ipv4_configuration: Method to use to configure the ... | [
"Set",
"network",
"configuration",
"data",
"."
] | f710b1d30a8eed19a9e86f01f9351c737666f3e5 | https://github.com/openstack/pyghmi/blob/f710b1d30a8eed19a9e86f01f9351c737666f3e5/pyghmi/ipmi/command.py#L787-L825 | train |
openstack/pyghmi | pyghmi/ipmi/command.py | Command.get_net_configuration | def get_net_configuration(self, channel=None, gateway_macs=True):
"""Get network configuration data
Retrieve network configuration from the target
:param channel: Channel to configure, defaults to None for 'autodetect'
:param gateway_macs: Whether to retrieve mac addresses for gateways... | python | def get_net_configuration(self, channel=None, gateway_macs=True):
"""Get network configuration data
Retrieve network configuration from the target
:param channel: Channel to configure, defaults to None for 'autodetect'
:param gateway_macs: Whether to retrieve mac addresses for gateways... | [
"def",
"get_net_configuration",
"(",
"self",
",",
"channel",
"=",
"None",
",",
"gateway_macs",
"=",
"True",
")",
":",
"if",
"channel",
"is",
"None",
":",
"channel",
"=",
"self",
".",
"get_network_channel",
"(",
")",
"retdata",
"=",
"{",
"}",
"v4addr",
"=... | Get network configuration data
Retrieve network configuration from the target
:param channel: Channel to configure, defaults to None for 'autodetect'
:param gateway_macs: Whether to retrieve mac addresses for gateways
:returns: A dictionary of network configuration data | [
"Get",
"network",
"configuration",
"data"
] | f710b1d30a8eed19a9e86f01f9351c737666f3e5 | https://github.com/openstack/pyghmi/blob/f710b1d30a8eed19a9e86f01f9351c737666f3e5/pyghmi/ipmi/command.py#L880-L916 | train |
openstack/pyghmi | pyghmi/ipmi/command.py | Command.get_sensor_data | def get_sensor_data(self):
"""Get sensor reading objects
Iterates sensor reading objects pertaining to the currently
managed BMC.
:returns: Iterator of sdr.SensorReading objects
"""
self.init_sdr()
for sensor in self._sdr.get_sensor_numbers():
rsp = ... | python | def get_sensor_data(self):
"""Get sensor reading objects
Iterates sensor reading objects pertaining to the currently
managed BMC.
:returns: Iterator of sdr.SensorReading objects
"""
self.init_sdr()
for sensor in self._sdr.get_sensor_numbers():
rsp = ... | [
"def",
"get_sensor_data",
"(",
"self",
")",
":",
"self",
".",
"init_sdr",
"(",
")",
"for",
"sensor",
"in",
"self",
".",
"_sdr",
".",
"get_sensor_numbers",
"(",
")",
":",
"rsp",
"=",
"self",
".",
"raw_command",
"(",
"command",
"=",
"0x2d",
",",
"netfn",... | Get sensor reading objects
Iterates sensor reading objects pertaining to the currently
managed BMC.
:returns: Iterator of sdr.SensorReading objects | [
"Get",
"sensor",
"reading",
"objects"
] | f710b1d30a8eed19a9e86f01f9351c737666f3e5 | https://github.com/openstack/pyghmi/blob/f710b1d30a8eed19a9e86f01f9351c737666f3e5/pyghmi/ipmi/command.py#L918-L936 | train |
openstack/pyghmi | pyghmi/ipmi/command.py | Command.get_sensor_descriptions | def get_sensor_descriptions(self):
"""Get available sensor names
Iterates over the available sensor descriptions
:returns: Iterator of dicts describing each sensor
"""
self.init_sdr()
for sensor in self._sdr.get_sensor_numbers():
yield {'name': self._sdr.sen... | python | def get_sensor_descriptions(self):
"""Get available sensor names
Iterates over the available sensor descriptions
:returns: Iterator of dicts describing each sensor
"""
self.init_sdr()
for sensor in self._sdr.get_sensor_numbers():
yield {'name': self._sdr.sen... | [
"def",
"get_sensor_descriptions",
"(",
"self",
")",
":",
"self",
".",
"init_sdr",
"(",
")",
"for",
"sensor",
"in",
"self",
".",
"_sdr",
".",
"get_sensor_numbers",
"(",
")",
":",
"yield",
"{",
"'name'",
":",
"self",
".",
"_sdr",
".",
"sensors",
"[",
"se... | Get available sensor names
Iterates over the available sensor descriptions
:returns: Iterator of dicts describing each sensor | [
"Get",
"available",
"sensor",
"names"
] | f710b1d30a8eed19a9e86f01f9351c737666f3e5 | https://github.com/openstack/pyghmi/blob/f710b1d30a8eed19a9e86f01f9351c737666f3e5/pyghmi/ipmi/command.py#L938-L951 | train |
openstack/pyghmi | pyghmi/ipmi/command.py | Command.get_network_channel | def get_network_channel(self):
"""Get a reasonable 'default' network channel.
When configuring/examining network configuration, it's desirable to
find the correct channel. Here we run with the 'real' number of the
current channel if it is a LAN channel, otherwise it evaluates
a... | python | def get_network_channel(self):
"""Get a reasonable 'default' network channel.
When configuring/examining network configuration, it's desirable to
find the correct channel. Here we run with the 'real' number of the
current channel if it is a LAN channel, otherwise it evaluates
a... | [
"def",
"get_network_channel",
"(",
"self",
")",
":",
"if",
"self",
".",
"_netchannel",
"is",
"None",
":",
"for",
"channel",
"in",
"chain",
"(",
"(",
"0xe",
",",
")",
",",
"range",
"(",
"1",
",",
"0xc",
")",
")",
":",
"try",
":",
"rsp",
"=",
"self... | Get a reasonable 'default' network channel.
When configuring/examining network configuration, it's desirable to
find the correct channel. Here we run with the 'real' number of the
current channel if it is a LAN channel, otherwise it evaluates
all of the channels to find the first worka... | [
"Get",
"a",
"reasonable",
"default",
"network",
"channel",
"."
] | f710b1d30a8eed19a9e86f01f9351c737666f3e5 | https://github.com/openstack/pyghmi/blob/f710b1d30a8eed19a9e86f01f9351c737666f3e5/pyghmi/ipmi/command.py#L953-L994 | train |
openstack/pyghmi | pyghmi/ipmi/command.py | Command.get_alert_destination_count | def get_alert_destination_count(self, channel=None):
"""Get the number of supported alert destinations
:param channel: Channel for alerts to be examined, defaults to current
"""
if channel is None:
channel = self.get_network_channel()
rqdata = (channel, 0x11, 0, 0)
... | python | def get_alert_destination_count(self, channel=None):
"""Get the number of supported alert destinations
:param channel: Channel for alerts to be examined, defaults to current
"""
if channel is None:
channel = self.get_network_channel()
rqdata = (channel, 0x11, 0, 0)
... | [
"def",
"get_alert_destination_count",
"(",
"self",
",",
"channel",
"=",
"None",
")",
":",
"if",
"channel",
"is",
"None",
":",
"channel",
"=",
"self",
".",
"get_network_channel",
"(",
")",
"rqdata",
"=",
"(",
"channel",
",",
"0x11",
",",
"0",
",",
"0",
... | Get the number of supported alert destinations
:param channel: Channel for alerts to be examined, defaults to current | [
"Get",
"the",
"number",
"of",
"supported",
"alert",
"destinations"
] | f710b1d30a8eed19a9e86f01f9351c737666f3e5 | https://github.com/openstack/pyghmi/blob/f710b1d30a8eed19a9e86f01f9351c737666f3e5/pyghmi/ipmi/command.py#L996-L1005 | train |
openstack/pyghmi | pyghmi/ipmi/command.py | Command.get_alert_destination | def get_alert_destination(self, destination=0, channel=None):
"""Get alert destination
Get a specified alert destination. Returns a dictionary of relevant
configuration. The following keys may be present:
acknowledge_required - Indicates whether the target expects an
... | python | def get_alert_destination(self, destination=0, channel=None):
"""Get alert destination
Get a specified alert destination. Returns a dictionary of relevant
configuration. The following keys may be present:
acknowledge_required - Indicates whether the target expects an
... | [
"def",
"get_alert_destination",
"(",
"self",
",",
"destination",
"=",
"0",
",",
"channel",
"=",
"None",
")",
":",
"destinfo",
"=",
"{",
"}",
"if",
"channel",
"is",
"None",
":",
"channel",
"=",
"self",
".",
"get_network_channel",
"(",
")",
"rqdata",
"=",
... | Get alert destination
Get a specified alert destination. Returns a dictionary of relevant
configuration. The following keys may be present:
acknowledge_required - Indicates whether the target expects an
acknowledgement
acknowledge_timeout - How long it w... | [
"Get",
"alert",
"destination"
] | f710b1d30a8eed19a9e86f01f9351c737666f3e5 | https://github.com/openstack/pyghmi/blob/f710b1d30a8eed19a9e86f01f9351c737666f3e5/pyghmi/ipmi/command.py#L1007-L1044 | train |
openstack/pyghmi | pyghmi/ipmi/command.py | Command.clear_alert_destination | def clear_alert_destination(self, destination=0, channel=None):
"""Clear an alert destination
Remove the specified alert destination configuration.
:param destination: The destination to clear (defaults to 0)
"""
if channel is None:
channel = self.get_network_chann... | python | def clear_alert_destination(self, destination=0, channel=None):
"""Clear an alert destination
Remove the specified alert destination configuration.
:param destination: The destination to clear (defaults to 0)
"""
if channel is None:
channel = self.get_network_chann... | [
"def",
"clear_alert_destination",
"(",
"self",
",",
"destination",
"=",
"0",
",",
"channel",
"=",
"None",
")",
":",
"if",
"channel",
"is",
"None",
":",
"channel",
"=",
"self",
".",
"get_network_channel",
"(",
")",
"self",
".",
"set_alert_destination",
"(",
... | Clear an alert destination
Remove the specified alert destination configuration.
:param destination: The destination to clear (defaults to 0) | [
"Clear",
"an",
"alert",
"destination"
] | f710b1d30a8eed19a9e86f01f9351c737666f3e5 | https://github.com/openstack/pyghmi/blob/f710b1d30a8eed19a9e86f01f9351c737666f3e5/pyghmi/ipmi/command.py#L1046-L1056 | train |
openstack/pyghmi | pyghmi/ipmi/command.py | Command.set_alert_community | def set_alert_community(self, community, channel=None):
"""Set the community string for alerts
This configures the string the BMC will use as the community string
for PET alerts/traps.
:param community: The community string
:param channel: The LAN channel (defaults to auto dete... | python | def set_alert_community(self, community, channel=None):
"""Set the community string for alerts
This configures the string the BMC will use as the community string
for PET alerts/traps.
:param community: The community string
:param channel: The LAN channel (defaults to auto dete... | [
"def",
"set_alert_community",
"(",
"self",
",",
"community",
",",
"channel",
"=",
"None",
")",
":",
"if",
"channel",
"is",
"None",
":",
"channel",
"=",
"self",
".",
"get_network_channel",
"(",
")",
"community",
"=",
"community",
".",
"encode",
"(",
"'utf-8... | Set the community string for alerts
This configures the string the BMC will use as the community string
for PET alerts/traps.
:param community: The community string
:param channel: The LAN channel (defaults to auto detect) | [
"Set",
"the",
"community",
"string",
"for",
"alerts"
] | f710b1d30a8eed19a9e86f01f9351c737666f3e5 | https://github.com/openstack/pyghmi/blob/f710b1d30a8eed19a9e86f01f9351c737666f3e5/pyghmi/ipmi/command.py#L1058-L1073 | train |
openstack/pyghmi | pyghmi/ipmi/command.py | Command._assure_alert_policy | def _assure_alert_policy(self, channel, destination):
"""Make sure an alert policy exists
Each policy will be a dict with the following keys:
-'index' - The policy index number
:returns: An iterable of currently configured alert policies
"""
# First we do a get PEF confi... | python | def _assure_alert_policy(self, channel, destination):
"""Make sure an alert policy exists
Each policy will be a dict with the following keys:
-'index' - The policy index number
:returns: An iterable of currently configured alert policies
"""
# First we do a get PEF confi... | [
"def",
"_assure_alert_policy",
"(",
"self",
",",
"channel",
",",
"destination",
")",
":",
"rsp",
"=",
"self",
".",
"xraw_command",
"(",
"netfn",
"=",
"4",
",",
"command",
"=",
"0x13",
",",
"data",
"=",
"(",
"8",
",",
"0",
",",
"0",
")",
")",
"numpo... | Make sure an alert policy exists
Each policy will be a dict with the following keys:
-'index' - The policy index number
:returns: An iterable of currently configured alert policies | [
"Make",
"sure",
"an",
"alert",
"policy",
"exists"
] | f710b1d30a8eed19a9e86f01f9351c737666f3e5 | https://github.com/openstack/pyghmi/blob/f710b1d30a8eed19a9e86f01f9351c737666f3e5/pyghmi/ipmi/command.py#L1075-L1108 | train |
openstack/pyghmi | pyghmi/ipmi/command.py | Command.get_alert_community | def get_alert_community(self, channel=None):
"""Get the current community string for alerts
Returns the community string that will be in SNMP traps from this
BMC
:param channel: The channel to get configuration for, autodetect by
default
:returns: The co... | python | def get_alert_community(self, channel=None):
"""Get the current community string for alerts
Returns the community string that will be in SNMP traps from this
BMC
:param channel: The channel to get configuration for, autodetect by
default
:returns: The co... | [
"def",
"get_alert_community",
"(",
"self",
",",
"channel",
"=",
"None",
")",
":",
"if",
"channel",
"is",
"None",
":",
"channel",
"=",
"self",
".",
"get_network_channel",
"(",
")",
"rsp",
"=",
"self",
".",
"xraw_command",
"(",
"netfn",
"=",
"0xc",
",",
... | Get the current community string for alerts
Returns the community string that will be in SNMP traps from this
BMC
:param channel: The channel to get configuration for, autodetect by
default
:returns: The community string | [
"Get",
"the",
"current",
"community",
"string",
"for",
"alerts"
] | f710b1d30a8eed19a9e86f01f9351c737666f3e5 | https://github.com/openstack/pyghmi/blob/f710b1d30a8eed19a9e86f01f9351c737666f3e5/pyghmi/ipmi/command.py#L1110-L1123 | train |
openstack/pyghmi | pyghmi/ipmi/command.py | Command.set_alert_destination | def set_alert_destination(self, ip=None, acknowledge_required=None,
acknowledge_timeout=None, retries=None,
destination=0, channel=None):
"""Configure one or more parameters of an alert destination
If any parameter is 'None' (default), that pa... | python | def set_alert_destination(self, ip=None, acknowledge_required=None,
acknowledge_timeout=None, retries=None,
destination=0, channel=None):
"""Configure one or more parameters of an alert destination
If any parameter is 'None' (default), that pa... | [
"def",
"set_alert_destination",
"(",
"self",
",",
"ip",
"=",
"None",
",",
"acknowledge_required",
"=",
"None",
",",
"acknowledge_timeout",
"=",
"None",
",",
"retries",
"=",
"None",
",",
"destination",
"=",
"0",
",",
"channel",
"=",
"None",
")",
":",
"if",
... | Configure one or more parameters of an alert destination
If any parameter is 'None' (default), that parameter is left unchanged.
Otherwise, all given parameters are set by this command.
:param ip: IP address of the destination. It is currently expected
that the calling code... | [
"Configure",
"one",
"or",
"more",
"parameters",
"of",
"an",
"alert",
"destination"
] | f710b1d30a8eed19a9e86f01f9351c737666f3e5 | https://github.com/openstack/pyghmi/blob/f710b1d30a8eed19a9e86f01f9351c737666f3e5/pyghmi/ipmi/command.py#L1137-L1197 | train |
openstack/pyghmi | pyghmi/ipmi/command.py | Command.get_hostname | def get_hostname(self):
"""Get the hostname used by the BMC in various contexts
This can vary somewhat in interpretation, but generally speaking
this should be the name that shows up on UIs and in DHCP requests and
DNS registration requests, as applicable.
:return: current host... | python | def get_hostname(self):
"""Get the hostname used by the BMC in various contexts
This can vary somewhat in interpretation, but generally speaking
this should be the name that shows up on UIs and in DHCP requests and
DNS registration requests, as applicable.
:return: current host... | [
"def",
"get_hostname",
"(",
"self",
")",
":",
"self",
".",
"oem_init",
"(",
")",
"try",
":",
"return",
"self",
".",
"_oem",
".",
"get_hostname",
"(",
")",
"except",
"exc",
".",
"UnsupportedFunctionality",
":",
"return",
"self",
".",
"get_mci",
"(",
")"
] | Get the hostname used by the BMC in various contexts
This can vary somewhat in interpretation, but generally speaking
this should be the name that shows up on UIs and in DHCP requests and
DNS registration requests, as applicable.
:return: current hostname | [
"Get",
"the",
"hostname",
"used",
"by",
"the",
"BMC",
"in",
"various",
"contexts"
] | f710b1d30a8eed19a9e86f01f9351c737666f3e5 | https://github.com/openstack/pyghmi/blob/f710b1d30a8eed19a9e86f01f9351c737666f3e5/pyghmi/ipmi/command.py#L1199-L1214 | train |
openstack/pyghmi | pyghmi/ipmi/command.py | Command.set_hostname | def set_hostname(self, hostname):
"""Set the hostname to be used by the BMC in various contexts.
See get_hostname for details
:param hostname: The hostname to set
:return: Nothing
"""
self.oem_init()
try:
return self._oem.set_hostname(hostname)
... | python | def set_hostname(self, hostname):
"""Set the hostname to be used by the BMC in various contexts.
See get_hostname for details
:param hostname: The hostname to set
:return: Nothing
"""
self.oem_init()
try:
return self._oem.set_hostname(hostname)
... | [
"def",
"set_hostname",
"(",
"self",
",",
"hostname",
")",
":",
"self",
".",
"oem_init",
"(",
")",
"try",
":",
"return",
"self",
".",
"_oem",
".",
"set_hostname",
"(",
"hostname",
")",
"except",
"exc",
".",
"UnsupportedFunctionality",
":",
"return",
"self",... | Set the hostname to be used by the BMC in various contexts.
See get_hostname for details
:param hostname: The hostname to set
:return: Nothing | [
"Set",
"the",
"hostname",
"to",
"be",
"used",
"by",
"the",
"BMC",
"in",
"various",
"contexts",
"."
] | f710b1d30a8eed19a9e86f01f9351c737666f3e5 | https://github.com/openstack/pyghmi/blob/f710b1d30a8eed19a9e86f01f9351c737666f3e5/pyghmi/ipmi/command.py#L1223-L1235 | train |
openstack/pyghmi | pyghmi/ipmi/command.py | Command.get_channel_access | def get_channel_access(self, channel=None, read_mode='volatile'):
"""Get channel access
:param channel: number [1:7]
:param read_mode:
non_volatile = get non-volatile Channel Access
volatile = get present volatile (active) setting of Channel Access
:return: A Pyth... | python | def get_channel_access(self, channel=None, read_mode='volatile'):
"""Get channel access
:param channel: number [1:7]
:param read_mode:
non_volatile = get non-volatile Channel Access
volatile = get present volatile (active) setting of Channel Access
:return: A Pyth... | [
"def",
"get_channel_access",
"(",
"self",
",",
"channel",
"=",
"None",
",",
"read_mode",
"=",
"'volatile'",
")",
":",
"if",
"channel",
"is",
"None",
":",
"channel",
"=",
"self",
".",
"get_network_channel",
"(",
")",
"data",
"=",
"[",
"]",
"data",
".",
... | Get channel access
:param channel: number [1:7]
:param read_mode:
non_volatile = get non-volatile Channel Access
volatile = get present volatile (active) setting of Channel Access
:return: A Python dict with the following keys/values:
{
- alerting:
... | [
"Get",
"channel",
"access"
] | f710b1d30a8eed19a9e86f01f9351c737666f3e5 | https://github.com/openstack/pyghmi/blob/f710b1d30a8eed19a9e86f01f9351c737666f3e5/pyghmi/ipmi/command.py#L1394-L1463 | train |
openstack/pyghmi | pyghmi/ipmi/command.py | Command.get_channel_info | def get_channel_info(self, channel=None):
"""Get channel info
:param channel: number [1:7]
:return:
session_support:
no_session: channel is session-less
single: channel is single-session
multi: channel is multi-session
auto: channel is se... | python | def get_channel_info(self, channel=None):
"""Get channel info
:param channel: number [1:7]
:return:
session_support:
no_session: channel is session-less
single: channel is single-session
multi: channel is multi-session
auto: channel is se... | [
"def",
"get_channel_info",
"(",
"self",
",",
"channel",
"=",
"None",
")",
":",
"if",
"channel",
"is",
"None",
":",
"channel",
"=",
"self",
".",
"get_network_channel",
"(",
")",
"data",
"=",
"[",
"]",
"data",
".",
"append",
"(",
"channel",
"&",
"0b00001... | Get channel info
:param channel: number [1:7]
:return:
session_support:
no_session: channel is session-less
single: channel is single-session
multi: channel is multi-session
auto: channel is session-based (channel could alternate between
... | [
"Get",
"channel",
"info"
] | f710b1d30a8eed19a9e86f01f9351c737666f3e5 | https://github.com/openstack/pyghmi/blob/f710b1d30a8eed19a9e86f01f9351c737666f3e5/pyghmi/ipmi/command.py#L1465-L1524 | train |
openstack/pyghmi | pyghmi/ipmi/command.py | Command.get_firmware | def get_firmware(self, components=()):
"""Retrieve OEM Firmware information
"""
self.oem_init()
mcinfo = self.xraw_command(netfn=6, command=1)
bmcver = '{0}.{1}'.format(
ord(mcinfo['data'][2]), hex(ord(mcinfo['data'][3]))[2:])
return self._oem.get_oem_firmware... | python | def get_firmware(self, components=()):
"""Retrieve OEM Firmware information
"""
self.oem_init()
mcinfo = self.xraw_command(netfn=6, command=1)
bmcver = '{0}.{1}'.format(
ord(mcinfo['data'][2]), hex(ord(mcinfo['data'][3]))[2:])
return self._oem.get_oem_firmware... | [
"def",
"get_firmware",
"(",
"self",
",",
"components",
"=",
"(",
")",
")",
":",
"self",
".",
"oem_init",
"(",
")",
"mcinfo",
"=",
"self",
".",
"xraw_command",
"(",
"netfn",
"=",
"6",
",",
"command",
"=",
"1",
")",
"bmcver",
"=",
"'{0}.{1}'",
".",
"... | Retrieve OEM Firmware information | [
"Retrieve",
"OEM",
"Firmware",
"information"
] | f710b1d30a8eed19a9e86f01f9351c737666f3e5 | https://github.com/openstack/pyghmi/blob/f710b1d30a8eed19a9e86f01f9351c737666f3e5/pyghmi/ipmi/command.py#L1886-L1893 | train |
openstack/pyghmi | pyghmi/ipmi/command.py | Command.update_firmware | def update_firmware(self, file, data=None, progress=None, bank=None):
"""Send file to BMC to perform firmware update
:param filename: The filename to upload to the target BMC
:param data: The payload of the firmware. Default is to read from
specified filename.
... | python | def update_firmware(self, file, data=None, progress=None, bank=None):
"""Send file to BMC to perform firmware update
:param filename: The filename to upload to the target BMC
:param data: The payload of the firmware. Default is to read from
specified filename.
... | [
"def",
"update_firmware",
"(",
"self",
",",
"file",
",",
"data",
"=",
"None",
",",
"progress",
"=",
"None",
",",
"bank",
"=",
"None",
")",
":",
"self",
".",
"oem_init",
"(",
")",
"if",
"progress",
"is",
"None",
":",
"progress",
"=",
"lambda",
"x",
... | Send file to BMC to perform firmware update
:param filename: The filename to upload to the target BMC
:param data: The payload of the firmware. Default is to read from
specified filename.
:param progress: A callback that will be given a dict describing
... | [
"Send",
"file",
"to",
"BMC",
"to",
"perform",
"firmware",
"update"
] | f710b1d30a8eed19a9e86f01f9351c737666f3e5 | https://github.com/openstack/pyghmi/blob/f710b1d30a8eed19a9e86f01f9351c737666f3e5/pyghmi/ipmi/command.py#L1936-L1949 | train |
openstack/pyghmi | pyghmi/ipmi/command.py | Command.attach_remote_media | def attach_remote_media(self, url, username=None, password=None):
"""Attach remote media by url
Given a url, attach remote media (cd/usb image) to the target system.
:param url: URL to indicate where to find image (protocol support
varies by BMC)
:param username: ... | python | def attach_remote_media(self, url, username=None, password=None):
"""Attach remote media by url
Given a url, attach remote media (cd/usb image) to the target system.
:param url: URL to indicate where to find image (protocol support
varies by BMC)
:param username: ... | [
"def",
"attach_remote_media",
"(",
"self",
",",
"url",
",",
"username",
"=",
"None",
",",
"password",
"=",
"None",
")",
":",
"self",
".",
"oem_init",
"(",
")",
"return",
"self",
".",
"_oem",
".",
"attach_remote_media",
"(",
"url",
",",
"username",
",",
... | Attach remote media by url
Given a url, attach remote media (cd/usb image) to the target system.
:param url: URL to indicate where to find image (protocol support
varies by BMC)
:param username: Username for endpoint to use when accessing the URL.
... | [
"Attach",
"remote",
"media",
"by",
"url"
] | f710b1d30a8eed19a9e86f01f9351c737666f3e5 | https://github.com/openstack/pyghmi/blob/f710b1d30a8eed19a9e86f01f9351c737666f3e5/pyghmi/ipmi/command.py#L1951-L1964 | train |
openstack/pyghmi | pyghmi/ipmi/command.py | Command.upload_media | def upload_media(self, filename, progress=None):
"""Upload a file to be hosted on the target BMC
This will upload the specified data to
the BMC so that it will make it available to the system as an emulated
USB device.
:param filename: The filename to use, the basename of the p... | python | def upload_media(self, filename, progress=None):
"""Upload a file to be hosted on the target BMC
This will upload the specified data to
the BMC so that it will make it available to the system as an emulated
USB device.
:param filename: The filename to use, the basename of the p... | [
"def",
"upload_media",
"(",
"self",
",",
"filename",
",",
"progress",
"=",
"None",
")",
":",
"self",
".",
"oem_init",
"(",
")",
"return",
"self",
".",
"_oem",
".",
"upload_media",
"(",
"filename",
",",
"progress",
")"
] | Upload a file to be hosted on the target BMC
This will upload the specified data to
the BMC so that it will make it available to the system as an emulated
USB device.
:param filename: The filename to use, the basename of the parameter
will be given to the bmc.
... | [
"Upload",
"a",
"file",
"to",
"be",
"hosted",
"on",
"the",
"target",
"BMC"
] | f710b1d30a8eed19a9e86f01f9351c737666f3e5 | https://github.com/openstack/pyghmi/blob/f710b1d30a8eed19a9e86f01f9351c737666f3e5/pyghmi/ipmi/command.py#L1970-L1982 | train |
openstack/pyghmi | pyghmi/ipmi/oem/generic.py | OEMHandler.process_event | def process_event(self, event, ipmicmd, seldata):
"""Modify an event according with OEM understanding.
Given an event, allow an OEM module to augment it. For example,
event data fields can have OEM bytes. Other times an OEM may wish
to apply some transform to some field to suit their ... | python | def process_event(self, event, ipmicmd, seldata):
"""Modify an event according with OEM understanding.
Given an event, allow an OEM module to augment it. For example,
event data fields can have OEM bytes. Other times an OEM may wish
to apply some transform to some field to suit their ... | [
"def",
"process_event",
"(",
"self",
",",
"event",
",",
"ipmicmd",
",",
"seldata",
")",
":",
"event",
"[",
"'oem_handler'",
"]",
"=",
"None",
"evdata",
"=",
"event",
"[",
"'event_data_bytes'",
"]",
"if",
"evdata",
"[",
"0",
"]",
"&",
"0b11000000",
"==",
... | Modify an event according with OEM understanding.
Given an event, allow an OEM module to augment it. For example,
event data fields can have OEM bytes. Other times an OEM may wish
to apply some transform to some field to suit their conventions. | [
"Modify",
"an",
"event",
"according",
"with",
"OEM",
"understanding",
"."
] | f710b1d30a8eed19a9e86f01f9351c737666f3e5 | https://github.com/openstack/pyghmi/blob/f710b1d30a8eed19a9e86f01f9351c737666f3e5/pyghmi/ipmi/oem/generic.py#L45-L57 | train |
openstack/pyghmi | pyghmi/ipmi/console.py | Console._got_session | def _got_session(self, response):
"""Private function to navigate SOL payload activation
"""
if 'error' in response:
self._print_error(response['error'])
return
if not self.ipmi_session:
self.callgotsession = response
return
# Send ... | python | def _got_session(self, response):
"""Private function to navigate SOL payload activation
"""
if 'error' in response:
self._print_error(response['error'])
return
if not self.ipmi_session:
self.callgotsession = response
return
# Send ... | [
"def",
"_got_session",
"(",
"self",
",",
"response",
")",
":",
"if",
"'error'",
"in",
"response",
":",
"self",
".",
"_print_error",
"(",
"response",
"[",
"'error'",
"]",
")",
"return",
"if",
"not",
"self",
".",
"ipmi_session",
":",
"self",
".",
"callgots... | Private function to navigate SOL payload activation | [
"Private",
"function",
"to",
"navigate",
"SOL",
"payload",
"activation"
] | f710b1d30a8eed19a9e86f01f9351c737666f3e5 | https://github.com/openstack/pyghmi/blob/f710b1d30a8eed19a9e86f01f9351c737666f3e5/pyghmi/ipmi/console.py#L77-L160 | train |
openstack/pyghmi | pyghmi/ipmi/console.py | Console._got_cons_input | def _got_cons_input(self, handle):
"""Callback for handle events detected by ipmi session
"""
self._addpendingdata(handle.read())
if not self.awaitingack:
self._sendpendingoutput() | python | def _got_cons_input(self, handle):
"""Callback for handle events detected by ipmi session
"""
self._addpendingdata(handle.read())
if not self.awaitingack:
self._sendpendingoutput() | [
"def",
"_got_cons_input",
"(",
"self",
",",
"handle",
")",
":",
"self",
".",
"_addpendingdata",
"(",
"handle",
".",
"read",
"(",
")",
")",
"if",
"not",
"self",
".",
"awaitingack",
":",
"self",
".",
"_sendpendingoutput",
"(",
")"
] | Callback for handle events detected by ipmi session | [
"Callback",
"for",
"handle",
"events",
"detected",
"by",
"ipmi",
"session"
] | f710b1d30a8eed19a9e86f01f9351c737666f3e5 | https://github.com/openstack/pyghmi/blob/f710b1d30a8eed19a9e86f01f9351c737666f3e5/pyghmi/ipmi/console.py#L192-L197 | train |
openstack/pyghmi | pyghmi/ipmi/console.py | Console.close | def close(self):
"""Shut down an SOL session,
"""
if self.ipmi_session:
self.ipmi_session.unregister_keepalive(self.keepaliveid)
if self.activated:
try:
self.ipmi_session.raw_command(netfn=6, command=0x49,
... | python | def close(self):
"""Shut down an SOL session,
"""
if self.ipmi_session:
self.ipmi_session.unregister_keepalive(self.keepaliveid)
if self.activated:
try:
self.ipmi_session.raw_command(netfn=6, command=0x49,
... | [
"def",
"close",
"(",
"self",
")",
":",
"if",
"self",
".",
"ipmi_session",
":",
"self",
".",
"ipmi_session",
".",
"unregister_keepalive",
"(",
"self",
".",
"keepaliveid",
")",
"if",
"self",
".",
"activated",
":",
"try",
":",
"self",
".",
"ipmi_session",
"... | Shut down an SOL session, | [
"Shut",
"down",
"an",
"SOL",
"session"
] | f710b1d30a8eed19a9e86f01f9351c737666f3e5 | https://github.com/openstack/pyghmi/blob/f710b1d30a8eed19a9e86f01f9351c737666f3e5/pyghmi/ipmi/console.py#L199-L211 | train |
openstack/pyghmi | pyghmi/ipmi/console.py | ServerConsole._got_sol_payload | def _got_sol_payload(self, payload):
"""SOL payload callback
"""
# TODO(jbjohnso) test cases to throw some likely scenarios at functions
# for example, retry with new data, retry with no new data
# retry with unexpected sequence number
if type(payload) == dict: # we rece... | python | def _got_sol_payload(self, payload):
"""SOL payload callback
"""
# TODO(jbjohnso) test cases to throw some likely scenarios at functions
# for example, retry with new data, retry with no new data
# retry with unexpected sequence number
if type(payload) == dict: # we rece... | [
"def",
"_got_sol_payload",
"(",
"self",
",",
"payload",
")",
":",
"if",
"type",
"(",
"payload",
")",
"==",
"dict",
":",
"self",
".",
"activated",
"=",
"False",
"self",
".",
"_print_error",
"(",
"payload",
")",
"return",
"newseq",
"=",
"payload",
"[",
"... | SOL payload callback | [
"SOL",
"payload",
"callback"
] | f710b1d30a8eed19a9e86f01f9351c737666f3e5 | https://github.com/openstack/pyghmi/blob/f710b1d30a8eed19a9e86f01f9351c737666f3e5/pyghmi/ipmi/console.py#L459-L531 | train |
openstack/pyghmi | pyghmi/ipmi/oem/lenovo/handler.py | OEMHandler.is_fpc | def is_fpc(self):
"""True if the target is a Lenovo nextscale fan power controller
"""
if self.has_imm or self.has_xcc:
return None
if self._fpc_variant is not None:
return self._fpc_variant
fpc_ids = ((19046, 32, 1063), (20301, 32, 462))
smm_id = ... | python | def is_fpc(self):
"""True if the target is a Lenovo nextscale fan power controller
"""
if self.has_imm or self.has_xcc:
return None
if self._fpc_variant is not None:
return self._fpc_variant
fpc_ids = ((19046, 32, 1063), (20301, 32, 462))
smm_id = ... | [
"def",
"is_fpc",
"(",
"self",
")",
":",
"if",
"self",
".",
"has_imm",
"or",
"self",
".",
"has_xcc",
":",
"return",
"None",
"if",
"self",
".",
"_fpc_variant",
"is",
"not",
"None",
":",
"return",
"self",
".",
"_fpc_variant",
"fpc_ids",
"=",
"(",
"(",
"... | True if the target is a Lenovo nextscale fan power controller | [
"True",
"if",
"the",
"target",
"is",
"a",
"Lenovo",
"nextscale",
"fan",
"power",
"controller"
] | f710b1d30a8eed19a9e86f01f9351c737666f3e5 | https://github.com/openstack/pyghmi/blob/f710b1d30a8eed19a9e86f01f9351c737666f3e5/pyghmi/ipmi/oem/lenovo/handler.py#L335-L350 | train |
openstack/pyghmi | pyghmi/ipmi/oem/lenovo/handler.py | OEMHandler.has_tsm | def has_tsm(self):
"""True if this particular server have a TSM based service processor
"""
if (self.oemid['manufacturer_id'] == 19046 and
self.oemid['device_id'] == 32):
try:
self.ipmicmd.xraw_command(netfn=0x3a, command=0xf)
except pygexc... | python | def has_tsm(self):
"""True if this particular server have a TSM based service processor
"""
if (self.oemid['manufacturer_id'] == 19046 and
self.oemid['device_id'] == 32):
try:
self.ipmicmd.xraw_command(netfn=0x3a, command=0xf)
except pygexc... | [
"def",
"has_tsm",
"(",
"self",
")",
":",
"if",
"(",
"self",
".",
"oemid",
"[",
"'manufacturer_id'",
"]",
"==",
"19046",
"and",
"self",
".",
"oemid",
"[",
"'device_id'",
"]",
"==",
"32",
")",
":",
"try",
":",
"self",
".",
"ipmicmd",
".",
"xraw_command... | True if this particular server have a TSM based service processor | [
"True",
"if",
"this",
"particular",
"server",
"have",
"a",
"TSM",
"based",
"service",
"processor"
] | f710b1d30a8eed19a9e86f01f9351c737666f3e5 | https://github.com/openstack/pyghmi/blob/f710b1d30a8eed19a9e86f01f9351c737666f3e5/pyghmi/ipmi/oem/lenovo/handler.py#L359-L371 | train |
openstack/pyghmi | pyghmi/ipmi/oem/lenovo/handler.py | OEMHandler.set_oem_capping_enabled | def set_oem_capping_enabled(self, enable):
"""Set PSU based power capping
:param enable: True for enable and False for disable
"""
# 1 - Enable power capping(default)
if enable:
statecode = 1
# 0 - Disable power capping
else:
statecode = 0... | python | def set_oem_capping_enabled(self, enable):
"""Set PSU based power capping
:param enable: True for enable and False for disable
"""
# 1 - Enable power capping(default)
if enable:
statecode = 1
# 0 - Disable power capping
else:
statecode = 0... | [
"def",
"set_oem_capping_enabled",
"(",
"self",
",",
"enable",
")",
":",
"if",
"enable",
":",
"statecode",
"=",
"1",
"else",
":",
"statecode",
"=",
"0",
"if",
"self",
".",
"has_tsm",
":",
"self",
".",
"ipmicmd",
".",
"xraw_command",
"(",
"netfn",
"=",
"... | Set PSU based power capping
:param enable: True for enable and False for disable | [
"Set",
"PSU",
"based",
"power",
"capping"
] | f710b1d30a8eed19a9e86f01f9351c737666f3e5 | https://github.com/openstack/pyghmi/blob/f710b1d30a8eed19a9e86f01f9351c737666f3e5/pyghmi/ipmi/oem/lenovo/handler.py#L636-L650 | train |
openstack/pyghmi | pyghmi/ipmi/private/util.py | decode_wireformat_uuid | def decode_wireformat_uuid(rawguid):
"""Decode a wire format UUID
It handles the rather particular scheme where half is little endian
and half is big endian. It returns a string like dmidecode would output.
"""
if isinstance(rawguid, list):
rawguid = bytearray(rawguid)
lebytes = struct... | python | def decode_wireformat_uuid(rawguid):
"""Decode a wire format UUID
It handles the rather particular scheme where half is little endian
and half is big endian. It returns a string like dmidecode would output.
"""
if isinstance(rawguid, list):
rawguid = bytearray(rawguid)
lebytes = struct... | [
"def",
"decode_wireformat_uuid",
"(",
"rawguid",
")",
":",
"if",
"isinstance",
"(",
"rawguid",
",",
"list",
")",
":",
"rawguid",
"=",
"bytearray",
"(",
"rawguid",
")",
"lebytes",
"=",
"struct",
".",
"unpack_from",
"(",
"'<IHH'",
",",
"buffer",
"(",
"rawgui... | Decode a wire format UUID
It handles the rather particular scheme where half is little endian
and half is big endian. It returns a string like dmidecode would output. | [
"Decode",
"a",
"wire",
"format",
"UUID"
] | f710b1d30a8eed19a9e86f01f9351c737666f3e5 | https://github.com/openstack/pyghmi/blob/f710b1d30a8eed19a9e86f01f9351c737666f3e5/pyghmi/ipmi/private/util.py#L41-L52 | train |
openstack/pyghmi | pyghmi/ipmi/private/util.py | urlsplit | def urlsplit(url):
"""Split an arbitrary url into protocol, host, rest
The standard urlsplit does not want to provide 'netloc' for arbitrary
protocols, this works around that.
:param url: The url to split into component parts
"""
proto, rest = url.split(':', 1)
host = ''
if rest[:2] ==... | python | def urlsplit(url):
"""Split an arbitrary url into protocol, host, rest
The standard urlsplit does not want to provide 'netloc' for arbitrary
protocols, this works around that.
:param url: The url to split into component parts
"""
proto, rest = url.split(':', 1)
host = ''
if rest[:2] ==... | [
"def",
"urlsplit",
"(",
"url",
")",
":",
"proto",
",",
"rest",
"=",
"url",
".",
"split",
"(",
"':'",
",",
"1",
")",
"host",
"=",
"''",
"if",
"rest",
"[",
":",
"2",
"]",
"==",
"'//'",
":",
"host",
",",
"rest",
"=",
"rest",
"[",
"2",
":",
"]"... | Split an arbitrary url into protocol, host, rest
The standard urlsplit does not want to provide 'netloc' for arbitrary
protocols, this works around that.
:param url: The url to split into component parts | [
"Split",
"an",
"arbitrary",
"url",
"into",
"protocol",
"host",
"rest"
] | f710b1d30a8eed19a9e86f01f9351c737666f3e5 | https://github.com/openstack/pyghmi/blob/f710b1d30a8eed19a9e86f01f9351c737666f3e5/pyghmi/ipmi/private/util.py#L55-L68 | train |
openstack/pyghmi | pyghmi/ipmi/private/util.py | get_ipv4 | def get_ipv4(hostname):
"""Get list of ipv4 addresses for hostname
"""
addrinfo = socket.getaddrinfo(hostname, None, socket.AF_INET,
socket.SOCK_STREAM)
return [addrinfo[x][4][0] for x in range(len(addrinfo))] | python | def get_ipv4(hostname):
"""Get list of ipv4 addresses for hostname
"""
addrinfo = socket.getaddrinfo(hostname, None, socket.AF_INET,
socket.SOCK_STREAM)
return [addrinfo[x][4][0] for x in range(len(addrinfo))] | [
"def",
"get_ipv4",
"(",
"hostname",
")",
":",
"addrinfo",
"=",
"socket",
".",
"getaddrinfo",
"(",
"hostname",
",",
"None",
",",
"socket",
".",
"AF_INET",
",",
"socket",
".",
"SOCK_STREAM",
")",
"return",
"[",
"addrinfo",
"[",
"x",
"]",
"[",
"4",
"]",
... | Get list of ipv4 addresses for hostname | [
"Get",
"list",
"of",
"ipv4",
"addresses",
"for",
"hostname"
] | f710b1d30a8eed19a9e86f01f9351c737666f3e5 | https://github.com/openstack/pyghmi/blob/f710b1d30a8eed19a9e86f01f9351c737666f3e5/pyghmi/ipmi/private/util.py#L71-L77 | train |
openstack/pyghmi | pyghmi/ipmi/private/session.py | _aespad | def _aespad(data):
"""ipmi demands a certain pad scheme,
per table 13-20 AES-CBC encrypted payload fields.
"""
currlen = len(data) + 1 # need to count the pad length field as well
neededpad = currlen % 16
if neededpad: # if it happens to be zero, hurray, but otherwise invert the
# sens... | python | def _aespad(data):
"""ipmi demands a certain pad scheme,
per table 13-20 AES-CBC encrypted payload fields.
"""
currlen = len(data) + 1 # need to count the pad length field as well
neededpad = currlen % 16
if neededpad: # if it happens to be zero, hurray, but otherwise invert the
# sens... | [
"def",
"_aespad",
"(",
"data",
")",
":",
"currlen",
"=",
"len",
"(",
"data",
")",
"+",
"1",
"neededpad",
"=",
"currlen",
"%",
"16",
"if",
"neededpad",
":",
"neededpad",
"=",
"16",
"-",
"neededpad",
"padval",
"=",
"1",
"pad",
"=",
"bytearray",
"(",
... | ipmi demands a certain pad scheme,
per table 13-20 AES-CBC encrypted payload fields. | [
"ipmi",
"demands",
"a",
"certain",
"pad",
"scheme",
"per",
"table",
"13",
"-",
"20",
"AES",
"-",
"CBC",
"encrypted",
"payload",
"fields",
"."
] | f710b1d30a8eed19a9e86f01f9351c737666f3e5 | https://github.com/openstack/pyghmi/blob/f710b1d30a8eed19a9e86f01f9351c737666f3e5/pyghmi/ipmi/private/session.py#L252-L267 | train |
openstack/pyghmi | pyghmi/ipmi/private/session.py | Session._make_bridge_request_msg | def _make_bridge_request_msg(self, channel, netfn, command):
"""This function generate message for bridge request. It is a
part of ipmi payload.
"""
head = bytearray((constants.IPMI_BMC_ADDRESS,
constants.netfn_codes['application'] << 2))
check_sum = _ch... | python | def _make_bridge_request_msg(self, channel, netfn, command):
"""This function generate message for bridge request. It is a
part of ipmi payload.
"""
head = bytearray((constants.IPMI_BMC_ADDRESS,
constants.netfn_codes['application'] << 2))
check_sum = _ch... | [
"def",
"_make_bridge_request_msg",
"(",
"self",
",",
"channel",
",",
"netfn",
",",
"command",
")",
":",
"head",
"=",
"bytearray",
"(",
"(",
"constants",
".",
"IPMI_BMC_ADDRESS",
",",
"constants",
".",
"netfn_codes",
"[",
"'application'",
"]",
"<<",
"2",
")",... | This function generate message for bridge request. It is a
part of ipmi payload. | [
"This",
"function",
"generate",
"message",
"for",
"bridge",
"request",
".",
"It",
"is",
"a",
"part",
"of",
"ipmi",
"payload",
"."
] | f710b1d30a8eed19a9e86f01f9351c737666f3e5 | https://github.com/openstack/pyghmi/blob/f710b1d30a8eed19a9e86f01f9351c737666f3e5/pyghmi/ipmi/private/session.py#L611-L624 | train |
openstack/pyghmi | pyghmi/ipmi/private/session.py | Session.wait_for_rsp | def wait_for_rsp(cls, timeout=None, callout=True):
"""IPMI Session Event loop iteration
This watches for any activity on IPMI handles and handles registered
by register_handle_callback. Callers are satisfied in the order that
packets return from network, not in the order of calling.
... | python | def wait_for_rsp(cls, timeout=None, callout=True):
"""IPMI Session Event loop iteration
This watches for any activity on IPMI handles and handles registered
by register_handle_callback. Callers are satisfied in the order that
packets return from network, not in the order of calling.
... | [
"def",
"wait_for_rsp",
"(",
"cls",
",",
"timeout",
"=",
"None",
",",
"callout",
"=",
"True",
")",
":",
"global",
"iosockets",
"curtime",
"=",
"_monotonic_time",
"(",
")",
"if",
"timeout",
"!=",
"0",
":",
"with",
"util",
".",
"protect",
"(",
"WAITING_SESS... | IPMI Session Event loop iteration
This watches for any activity on IPMI handles and handles registered
by register_handle_callback. Callers are satisfied in the order that
packets return from network, not in the order of calling.
:param timeout: Maximum time to wait for data to come a... | [
"IPMI",
"Session",
"Event",
"loop",
"iteration"
] | f710b1d30a8eed19a9e86f01f9351c737666f3e5 | https://github.com/openstack/pyghmi/blob/f710b1d30a8eed19a9e86f01f9351c737666f3e5/pyghmi/ipmi/private/session.py#L1078-L1169 | train |
openstack/pyghmi | pyghmi/ipmi/private/session.py | Session.register_keepalive | def register_keepalive(self, cmd, callback):
"""Register custom keepalive IPMI command
This is mostly intended for use by the console code.
calling code would have an easier time just scheduling in their
own threading scheme. Such a behavior would naturally cause
the default k... | python | def register_keepalive(self, cmd, callback):
"""Register custom keepalive IPMI command
This is mostly intended for use by the console code.
calling code would have an easier time just scheduling in their
own threading scheme. Such a behavior would naturally cause
the default k... | [
"def",
"register_keepalive",
"(",
"self",
",",
"cmd",
",",
"callback",
")",
":",
"regid",
"=",
"random",
".",
"random",
"(",
")",
"if",
"self",
".",
"_customkeepalives",
"is",
"None",
":",
"self",
".",
"_customkeepalives",
"=",
"{",
"regid",
":",
"(",
... | Register custom keepalive IPMI command
This is mostly intended for use by the console code.
calling code would have an easier time just scheduling in their
own threading scheme. Such a behavior would naturally cause
the default keepalive to not occur anyway if the calling code
... | [
"Register",
"custom",
"keepalive",
"IPMI",
"command"
] | f710b1d30a8eed19a9e86f01f9351c737666f3e5 | https://github.com/openstack/pyghmi/blob/f710b1d30a8eed19a9e86f01f9351c737666f3e5/pyghmi/ipmi/private/session.py#L1171-L1191 | train |
openstack/pyghmi | pyghmi/ipmi/private/session.py | Session._keepalive | def _keepalive(self):
"""Performs a keepalive to avoid idle disconnect
"""
try:
keptalive = False
if self._customkeepalives:
kaids = list(self._customkeepalives.keys())
for keepalive in kaids:
try:
... | python | def _keepalive(self):
"""Performs a keepalive to avoid idle disconnect
"""
try:
keptalive = False
if self._customkeepalives:
kaids = list(self._customkeepalives.keys())
for keepalive in kaids:
try:
... | [
"def",
"_keepalive",
"(",
"self",
")",
":",
"try",
":",
"keptalive",
"=",
"False",
"if",
"self",
".",
"_customkeepalives",
":",
"kaids",
"=",
"list",
"(",
"self",
".",
"_customkeepalives",
".",
"keys",
"(",
")",
")",
"for",
"keepalive",
"in",
"kaids",
... | Performs a keepalive to avoid idle disconnect | [
"Performs",
"a",
"keepalive",
"to",
"avoid",
"idle",
"disconnect"
] | f710b1d30a8eed19a9e86f01f9351c737666f3e5 | https://github.com/openstack/pyghmi/blob/f710b1d30a8eed19a9e86f01f9351c737666f3e5/pyghmi/ipmi/private/session.py#L1215-L1245 | train |
openstack/pyghmi | pyghmi/util/webclient.py | SecureHTTPConnection.download | def download(self, url, file):
"""Download a file to filename or file object
"""
if isinstance(file, str) or isinstance(file, unicode):
file = open(file, 'wb')
webclient = self.dupe()
webclient.request('GET', url)
rsp = webclient.getresponse()
self._c... | python | def download(self, url, file):
"""Download a file to filename or file object
"""
if isinstance(file, str) or isinstance(file, unicode):
file = open(file, 'wb')
webclient = self.dupe()
webclient.request('GET', url)
rsp = webclient.getresponse()
self._c... | [
"def",
"download",
"(",
"self",
",",
"url",
",",
"file",
")",
":",
"if",
"isinstance",
"(",
"file",
",",
"str",
")",
"or",
"isinstance",
"(",
"file",
",",
"unicode",
")",
":",
"file",
"=",
"open",
"(",
"file",
",",
"'wb'",
")",
"webclient",
"=",
... | Download a file to filename or file object | [
"Download",
"a",
"file",
"to",
"filename",
"or",
"file",
"object"
] | f710b1d30a8eed19a9e86f01f9351c737666f3e5 | https://github.com/openstack/pyghmi/blob/f710b1d30a8eed19a9e86f01f9351c737666f3e5/pyghmi/util/webclient.py#L202-L216 | train |
openstack/pyghmi | pyghmi/util/webclient.py | SecureHTTPConnection.upload | def upload(self, url, filename, data=None, formname=None,
otherfields=()):
"""Upload a file to the url
:param url:
:param filename: The name of the file
:param data: A file object or data to use rather than reading from
the file.
:return:
... | python | def upload(self, url, filename, data=None, formname=None,
otherfields=()):
"""Upload a file to the url
:param url:
:param filename: The name of the file
:param data: A file object or data to use rather than reading from
the file.
:return:
... | [
"def",
"upload",
"(",
"self",
",",
"url",
",",
"filename",
",",
"data",
"=",
"None",
",",
"formname",
"=",
"None",
",",
"otherfields",
"=",
"(",
")",
")",
":",
"if",
"data",
"is",
"None",
":",
"data",
"=",
"open",
"(",
"filename",
",",
"'rb'",
")... | Upload a file to the url
:param url:
:param filename: The name of the file
:param data: A file object or data to use rather than reading from
the file.
:return: | [
"Upload",
"a",
"file",
"to",
"the",
"url"
] | f710b1d30a8eed19a9e86f01f9351c737666f3e5 | https://github.com/openstack/pyghmi/blob/f710b1d30a8eed19a9e86f01f9351c737666f3e5/pyghmi/util/webclient.py#L224-L257 | train |
openstack/pyghmi | pyghmi/ipmi/oem/lenovo/inventory.py | parse_inventory_category_entry | def parse_inventory_category_entry(raw, fields):
"""Parses one entry in an inventory category.
:param raw: the raw data to the entry. May contain more than one entry,
only one entry will be read in that case.
:param fields: an iterable of EntryField objects to be used for parsing the
... | python | def parse_inventory_category_entry(raw, fields):
"""Parses one entry in an inventory category.
:param raw: the raw data to the entry. May contain more than one entry,
only one entry will be read in that case.
:param fields: an iterable of EntryField objects to be used for parsing the
... | [
"def",
"parse_inventory_category_entry",
"(",
"raw",
",",
"fields",
")",
":",
"r",
"=",
"raw",
"obj",
"=",
"{",
"}",
"bytes_read",
"=",
"0",
"discard",
"=",
"False",
"for",
"field",
"in",
"fields",
":",
"value",
"=",
"struct",
".",
"unpack_from",
"(",
... | Parses one entry in an inventory category.
:param raw: the raw data to the entry. May contain more than one entry,
only one entry will be read in that case.
:param fields: an iterable of EntryField objects to be used for parsing the
entry.
:returns: dict -- a tuple with ... | [
"Parses",
"one",
"entry",
"in",
"an",
"inventory",
"category",
"."
] | f710b1d30a8eed19a9e86f01f9351c737666f3e5 | https://github.com/openstack/pyghmi/blob/f710b1d30a8eed19a9e86f01f9351c737666f3e5/pyghmi/ipmi/oem/lenovo/inventory.py#L105-L147 | train |
openstack/pyghmi | pyghmi/ipmi/private/serversession.py | IpmiServer.sessionless_data | def sessionless_data(self, data, sockaddr):
"""Examines unsolocited packet and decides appropriate action.
For a listening IpmiServer, a packet without an active session
comes here for examination. If it is something that is utterly
sessionless (e.g. get channel authentication), send t... | python | def sessionless_data(self, data, sockaddr):
"""Examines unsolocited packet and decides appropriate action.
For a listening IpmiServer, a packet without an active session
comes here for examination. If it is something that is utterly
sessionless (e.g. get channel authentication), send t... | [
"def",
"sessionless_data",
"(",
"self",
",",
"data",
",",
"sockaddr",
")",
":",
"if",
"len",
"(",
"data",
")",
"<",
"22",
":",
"return",
"data",
"=",
"bytearray",
"(",
"data",
")",
"if",
"not",
"(",
"data",
"[",
"0",
"]",
"==",
"6",
"and",
"data"... | Examines unsolocited packet and decides appropriate action.
For a listening IpmiServer, a packet without an active session
comes here for examination. If it is something that is utterly
sessionless (e.g. get channel authentication), send the appropriate
response. If it is a get sessio... | [
"Examines",
"unsolocited",
"packet",
"and",
"decides",
"appropriate",
"action",
"."
] | f710b1d30a8eed19a9e86f01f9351c737666f3e5 | https://github.com/openstack/pyghmi/blob/f710b1d30a8eed19a9e86f01f9351c737666f3e5/pyghmi/ipmi/private/serversession.py#L297-L341 | train |
openstack/pyghmi | pyghmi/ipmi/private/serversession.py | IpmiServer.set_kg | def set_kg(self, kg):
"""Sets the Kg for the BMC to use
In RAKP, Kg is a BMC-specific integrity key that can be set. If not
set, Kuid is used for the integrity key
"""
try:
self.kg = kg.encode('utf-8')
except AttributeError:
self.kg = kg | python | def set_kg(self, kg):
"""Sets the Kg for the BMC to use
In RAKP, Kg is a BMC-specific integrity key that can be set. If not
set, Kuid is used for the integrity key
"""
try:
self.kg = kg.encode('utf-8')
except AttributeError:
self.kg = kg | [
"def",
"set_kg",
"(",
"self",
",",
"kg",
")",
":",
"try",
":",
"self",
".",
"kg",
"=",
"kg",
".",
"encode",
"(",
"'utf-8'",
")",
"except",
"AttributeError",
":",
"self",
".",
"kg",
"=",
"kg"
] | Sets the Kg for the BMC to use
In RAKP, Kg is a BMC-specific integrity key that can be set. If not
set, Kuid is used for the integrity key | [
"Sets",
"the",
"Kg",
"for",
"the",
"BMC",
"to",
"use"
] | f710b1d30a8eed19a9e86f01f9351c737666f3e5 | https://github.com/openstack/pyghmi/blob/f710b1d30a8eed19a9e86f01f9351c737666f3e5/pyghmi/ipmi/private/serversession.py#L343-L352 | train |
astraw/stdeb | stdeb/util.py | source_debianize_name | def source_debianize_name(name):
"make name acceptable as a Debian source package name"
name = name.replace('_','-')
name = name.replace('.','-')
name = name.lower()
return name | python | def source_debianize_name(name):
"make name acceptable as a Debian source package name"
name = name.replace('_','-')
name = name.replace('.','-')
name = name.lower()
return name | [
"def",
"source_debianize_name",
"(",
"name",
")",
":",
"\"make name acceptable as a Debian source package name\"",
"name",
"=",
"name",
".",
"replace",
"(",
"'_'",
",",
"'-'",
")",
"name",
"=",
"name",
".",
"replace",
"(",
"'.'",
",",
"'-'",
")",
"name",
"=",
... | make name acceptable as a Debian source package name | [
"make",
"name",
"acceptable",
"as",
"a",
"Debian",
"source",
"package",
"name"
] | 493ab88e8a60be053b1baef81fb39b45e17ceef5 | https://github.com/astraw/stdeb/blob/493ab88e8a60be053b1baef81fb39b45e17ceef5/stdeb/util.py#L220-L225 | train |
astraw/stdeb | stdeb/util.py | get_date_822 | def get_date_822():
"""return output of 822-date command"""
cmd = '/bin/date'
if not os.path.exists(cmd):
raise ValueError('%s command does not exist.'%cmd)
args = [cmd,'-R']
result = get_cmd_stdout(args).strip()
result = normstr(result)
return result | python | def get_date_822():
"""return output of 822-date command"""
cmd = '/bin/date'
if not os.path.exists(cmd):
raise ValueError('%s command does not exist.'%cmd)
args = [cmd,'-R']
result = get_cmd_stdout(args).strip()
result = normstr(result)
return result | [
"def",
"get_date_822",
"(",
")",
":",
"cmd",
"=",
"'/bin/date'",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"cmd",
")",
":",
"raise",
"ValueError",
"(",
"'%s command does not exist.'",
"%",
"cmd",
")",
"args",
"=",
"[",
"cmd",
",",
"'-R'",
"]"... | return output of 822-date command | [
"return",
"output",
"of",
"822",
"-",
"date",
"command"
] | 493ab88e8a60be053b1baef81fb39b45e17ceef5 | https://github.com/astraw/stdeb/blob/493ab88e8a60be053b1baef81fb39b45e17ceef5/stdeb/util.py#L261-L269 | train |
astraw/stdeb | stdeb/util.py | make_tarball | def make_tarball(tarball_fname,directory,cwd=None):
"create a tarball from a directory"
if tarball_fname.endswith('.gz'): opts = 'czf'
else: opts = 'cf'
args = ['/bin/tar',opts,tarball_fname,directory]
process_command(args, cwd=cwd) | python | def make_tarball(tarball_fname,directory,cwd=None):
"create a tarball from a directory"
if tarball_fname.endswith('.gz'): opts = 'czf'
else: opts = 'cf'
args = ['/bin/tar',opts,tarball_fname,directory]
process_command(args, cwd=cwd) | [
"def",
"make_tarball",
"(",
"tarball_fname",
",",
"directory",
",",
"cwd",
"=",
"None",
")",
":",
"\"create a tarball from a directory\"",
"if",
"tarball_fname",
".",
"endswith",
"(",
"'.gz'",
")",
":",
"opts",
"=",
"'czf'",
"else",
":",
"opts",
"=",
"'cf'",
... | create a tarball from a directory | [
"create",
"a",
"tarball",
"from",
"a",
"directory"
] | 493ab88e8a60be053b1baef81fb39b45e17ceef5 | https://github.com/astraw/stdeb/blob/493ab88e8a60be053b1baef81fb39b45e17ceef5/stdeb/util.py#L458-L463 | train |
astraw/stdeb | stdeb/util.py | expand_tarball | def expand_tarball(tarball_fname,cwd=None):
"expand a tarball"
if tarball_fname.endswith('.gz'): opts = 'xzf'
elif tarball_fname.endswith('.bz2'): opts = 'xjf'
else: opts = 'xf'
args = ['/bin/tar',opts,tarball_fname]
process_command(args, cwd=cwd) | python | def expand_tarball(tarball_fname,cwd=None):
"expand a tarball"
if tarball_fname.endswith('.gz'): opts = 'xzf'
elif tarball_fname.endswith('.bz2'): opts = 'xjf'
else: opts = 'xf'
args = ['/bin/tar',opts,tarball_fname]
process_command(args, cwd=cwd) | [
"def",
"expand_tarball",
"(",
"tarball_fname",
",",
"cwd",
"=",
"None",
")",
":",
"\"expand a tarball\"",
"if",
"tarball_fname",
".",
"endswith",
"(",
"'.gz'",
")",
":",
"opts",
"=",
"'xzf'",
"elif",
"tarball_fname",
".",
"endswith",
"(",
"'.bz2'",
")",
":",... | expand a tarball | [
"expand",
"a",
"tarball"
] | 493ab88e8a60be053b1baef81fb39b45e17ceef5 | https://github.com/astraw/stdeb/blob/493ab88e8a60be053b1baef81fb39b45e17ceef5/stdeb/util.py#L466-L472 | train |
astraw/stdeb | stdeb/util.py | expand_zip | def expand_zip(zip_fname,cwd=None):
"expand a zip"
unzip_path = '/usr/bin/unzip'
if not os.path.exists(unzip_path):
log.error('ERROR: {} does not exist'.format(unzip_path))
sys.exit(1)
args = [unzip_path, zip_fname]
# Does it have a top dir
res = subprocess.Popen(
[args[0... | python | def expand_zip(zip_fname,cwd=None):
"expand a zip"
unzip_path = '/usr/bin/unzip'
if not os.path.exists(unzip_path):
log.error('ERROR: {} does not exist'.format(unzip_path))
sys.exit(1)
args = [unzip_path, zip_fname]
# Does it have a top dir
res = subprocess.Popen(
[args[0... | [
"def",
"expand_zip",
"(",
"zip_fname",
",",
"cwd",
"=",
"None",
")",
":",
"\"expand a zip\"",
"unzip_path",
"=",
"'/usr/bin/unzip'",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"unzip_path",
")",
":",
"log",
".",
"error",
"(",
"'ERROR: {} does not ex... | expand a zip | [
"expand",
"a",
"zip"
] | 493ab88e8a60be053b1baef81fb39b45e17ceef5 | https://github.com/astraw/stdeb/blob/493ab88e8a60be053b1baef81fb39b45e17ceef5/stdeb/util.py#L475-L496 | train |
astraw/stdeb | stdeb/util.py | parse_vals | def parse_vals(cfg,section,option):
"""parse comma separated values in debian control file style from .cfg"""
try:
vals = cfg.get(section,option)
except ConfigParser.NoSectionError as err:
if section != 'DEFAULT':
vals = cfg.get('DEFAULT',option)
else:
raise e... | python | def parse_vals(cfg,section,option):
"""parse comma separated values in debian control file style from .cfg"""
try:
vals = cfg.get(section,option)
except ConfigParser.NoSectionError as err:
if section != 'DEFAULT':
vals = cfg.get('DEFAULT',option)
else:
raise e... | [
"def",
"parse_vals",
"(",
"cfg",
",",
"section",
",",
"option",
")",
":",
"try",
":",
"vals",
"=",
"cfg",
".",
"get",
"(",
"section",
",",
"option",
")",
"except",
"ConfigParser",
".",
"NoSectionError",
"as",
"err",
":",
"if",
"section",
"!=",
"'DEFAUL... | parse comma separated values in debian control file style from .cfg | [
"parse",
"comma",
"separated",
"values",
"in",
"debian",
"control",
"file",
"style",
"from",
".",
"cfg"
] | 493ab88e8a60be053b1baef81fb39b45e17ceef5 | https://github.com/astraw/stdeb/blob/493ab88e8a60be053b1baef81fb39b45e17ceef5/stdeb/util.py#L595-L609 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.