repo stringlengths 7 54 | path stringlengths 4 223 | func_name stringlengths 1 134 | original_string stringlengths 75 104k | language stringclasses 1
value | code stringlengths 75 104k | code_tokens listlengths 20 28.4k | docstring stringlengths 1 46.3k | docstring_tokens listlengths 1 1.66k | sha stringlengths 40 40 | url stringlengths 87 315 | partition stringclasses 1
value | summary stringlengths 4 350 | obf_code stringlengths 7.85k 764k |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
quantumlib/Cirq | cirq/google/sim/xmon_simulator.py | XmonSimulator._run | def _run(
self,
circuit: circuits.Circuit,
param_resolver: study.ParamResolver,
repetitions: int,
) -> Dict[str, List[np.ndarray]]:
"""See definition in `cirq.SimulatesSamples`."""
circuit = protocols.resolve_parameters(circuit, param_resolver)
_verify_xmon_c... | python | def _run(
self,
circuit: circuits.Circuit,
param_resolver: study.ParamResolver,
repetitions: int,
) -> Dict[str, List[np.ndarray]]:
"""See definition in `cirq.SimulatesSamples`."""
circuit = protocols.resolve_parameters(circuit, param_resolver)
_verify_xmon_c... | [
"def",
"_run",
"(",
"self",
",",
"circuit",
":",
"circuits",
".",
"Circuit",
",",
"param_resolver",
":",
"study",
".",
"ParamResolver",
",",
"repetitions",
":",
"int",
",",
")",
"->",
"Dict",
"[",
"str",
",",
"List",
"[",
"np",
".",
"ndarray",
"]",
"... | See definition in `cirq.SimulatesSamples`. | [
"See",
"definition",
"in",
"cirq",
".",
"SimulatesSamples",
"."
] | 0827da80dd7880e5b923eb69407e980ed9bc0bd2 | https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/google/sim/xmon_simulator.py#L144-L159 | train | Runs the sweeps for the given set of time - related objects. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
quantumlib/Cirq | cirq/google/sim/xmon_simulator.py | XmonSimulator._base_iterator | def _base_iterator(
self,
circuit: circuits.Circuit,
qubit_order: ops.QubitOrderOrList,
initial_state: Union[int, np.ndarray],
perform_measurements: bool=True,
) -> Iterator['XmonStepResult']:
"""See definition in `cirq.SimulatesIntermediateState`.
If the ini... | python | def _base_iterator(
self,
circuit: circuits.Circuit,
qubit_order: ops.QubitOrderOrList,
initial_state: Union[int, np.ndarray],
perform_measurements: bool=True,
) -> Iterator['XmonStepResult']:
"""See definition in `cirq.SimulatesIntermediateState`.
If the ini... | [
"def",
"_base_iterator",
"(",
"self",
",",
"circuit",
":",
"circuits",
".",
"Circuit",
",",
"qubit_order",
":",
"ops",
".",
"QubitOrderOrList",
",",
"initial_state",
":",
"Union",
"[",
"int",
",",
"np",
".",
"ndarray",
"]",
",",
"perform_measurements",
":",
... | See definition in `cirq.SimulatesIntermediateState`.
If the initial state is an int, the state is set to the computational
basis state corresponding to this state. Otherwise if the initial
state is a np.ndarray it is the full initial state. In this case it
must be the correct size, be ... | [
"See",
"definition",
"in",
"cirq",
".",
"SimulatesIntermediateState",
"."
] | 0827da80dd7880e5b923eb69407e980ed9bc0bd2 | https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/google/sim/xmon_simulator.py#L211-L290 | train | A base iterator for the internal state of the system. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
quantumlib/Cirq | cirq/google/sim/xmon_simulator.py | XmonStepResult.set_state_vector | def set_state_vector(self, state: Union[int, np.ndarray]):
"""Updates the state of the simulator to the given new state.
Args:
state: If this is an int, then this is the state to reset
the stepper to, expressed as an integer of the computational basis.
Integer to bit... | python | def set_state_vector(self, state: Union[int, np.ndarray]):
"""Updates the state of the simulator to the given new state.
Args:
state: If this is an int, then this is the state to reset
the stepper to, expressed as an integer of the computational basis.
Integer to bit... | [
"def",
"set_state_vector",
"(",
"self",
",",
"state",
":",
"Union",
"[",
"int",
",",
"np",
".",
"ndarray",
"]",
")",
":",
"self",
".",
"_stepper",
".",
"reset_state",
"(",
"state",
")"
] | Updates the state of the simulator to the given new state.
Args:
state: If this is an int, then this is the state to reset
the stepper to, expressed as an integer of the computational basis.
Integer to bitwise indices is little endian. Otherwise if this is
a np.n... | [
"Updates",
"the",
"state",
"of",
"the",
"simulator",
"to",
"the",
"given",
"new",
"state",
"."
] | 0827da80dd7880e5b923eb69407e980ed9bc0bd2 | https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/google/sim/xmon_simulator.py#L356-L370 | train | Updates the state of the simulator to the given state. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
quantumlib/Cirq | cirq/google/sim/xmon_simulator.py | XmonStepResult.sample | def sample(self, qubits: List[ops.Qid], repetitions: int=1):
"""Samples from the wave function at this point in the computation.
Note that this does not collapse the wave function.
Returns:
Measurement results with True corresponding to the `|1>` state.
The outer list i... | python | def sample(self, qubits: List[ops.Qid], repetitions: int=1):
"""Samples from the wave function at this point in the computation.
Note that this does not collapse the wave function.
Returns:
Measurement results with True corresponding to the `|1>` state.
The outer list i... | [
"def",
"sample",
"(",
"self",
",",
"qubits",
":",
"List",
"[",
"ops",
".",
"Qid",
"]",
",",
"repetitions",
":",
"int",
"=",
"1",
")",
":",
"return",
"self",
".",
"_stepper",
".",
"sample_measurements",
"(",
"indices",
"=",
"[",
"self",
".",
"qubit_ma... | Samples from the wave function at this point in the computation.
Note that this does not collapse the wave function.
Returns:
Measurement results with True corresponding to the `|1>` state.
The outer list is for repetitions, and the inner corresponds to
measurements... | [
"Samples",
"from",
"the",
"wave",
"function",
"at",
"this",
"point",
"in",
"the",
"computation",
"."
] | 0827da80dd7880e5b923eb69407e980ed9bc0bd2 | https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/google/sim/xmon_simulator.py#L372-L384 | train | Samples from the wave function at this point in the computation. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
quantumlib/Cirq | cirq/devices/noise_model.py | NoiseModel.noisy_moments | def noisy_moments(self, moments: 'Iterable[cirq.Moment]',
system_qubits: Sequence['cirq.Qid']
) -> Sequence['cirq.OP_TREE']:
"""Adds possibly stateful noise to a series of moments.
Args:
moments: The moments to add noise to.
system_qubi... | python | def noisy_moments(self, moments: 'Iterable[cirq.Moment]',
system_qubits: Sequence['cirq.Qid']
) -> Sequence['cirq.OP_TREE']:
"""Adds possibly stateful noise to a series of moments.
Args:
moments: The moments to add noise to.
system_qubi... | [
"def",
"noisy_moments",
"(",
"self",
",",
"moments",
":",
"'Iterable[cirq.Moment]'",
",",
"system_qubits",
":",
"Sequence",
"[",
"'cirq.Qid'",
"]",
")",
"->",
"Sequence",
"[",
"'cirq.OP_TREE'",
"]",
":",
"if",
"not",
"hasattr",
"(",
"self",
".",
"noisy_moment"... | Adds possibly stateful noise to a series of moments.
Args:
moments: The moments to add noise to.
system_qubits: A list of all qubits in the system.
Returns:
A sequence of OP_TREEs, with the k'th tree corresponding to the
noisy operations for the k'th mom... | [
"Adds",
"possibly",
"stateful",
"noise",
"to",
"a",
"series",
"of",
"moments",
"."
] | 0827da80dd7880e5b923eb69407e980ed9bc0bd2 | https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/devices/noise_model.py#L48-L73 | train | Adds possibly stateful noise to a series of moments. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
quantumlib/Cirq | cirq/devices/noise_model.py | NoiseModel.noisy_moment | def noisy_moment(self, moment: 'cirq.Moment',
system_qubits: Sequence['cirq.Qid']) -> 'cirq.OP_TREE':
"""Adds noise to the operations from a moment.
Args:
moment: The moment to add noise to.
system_qubits: A list of all qubits in the system.
Returns... | python | def noisy_moment(self, moment: 'cirq.Moment',
system_qubits: Sequence['cirq.Qid']) -> 'cirq.OP_TREE':
"""Adds noise to the operations from a moment.
Args:
moment: The moment to add noise to.
system_qubits: A list of all qubits in the system.
Returns... | [
"def",
"noisy_moment",
"(",
"self",
",",
"moment",
":",
"'cirq.Moment'",
",",
"system_qubits",
":",
"Sequence",
"[",
"'cirq.Qid'",
"]",
")",
"->",
"'cirq.OP_TREE'",
":",
"if",
"not",
"hasattr",
"(",
"self",
".",
"noisy_moments",
",",
"'_not_overridden'",
")",
... | Adds noise to the operations from a moment.
Args:
moment: The moment to add noise to.
system_qubits: A list of all qubits in the system.
Returns:
An OP_TREE corresponding to the noisy operations for the moment. | [
"Adds",
"noise",
"to",
"the",
"operations",
"from",
"a",
"moment",
"."
] | 0827da80dd7880e5b923eb69407e980ed9bc0bd2 | https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/devices/noise_model.py#L75-L92 | train | Adds noise to the operations from a moment. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
quantumlib/Cirq | cirq/devices/noise_model.py | NoiseModel.noisy_operation | def noisy_operation(self, operation: 'cirq.Operation') -> 'cirq.OP_TREE':
"""Adds noise to an individual operation.
Args:
operation: The operation to make noisy.
Returns:
An OP_TREE corresponding to the noisy operations implementing the
noisy version of the ... | python | def noisy_operation(self, operation: 'cirq.Operation') -> 'cirq.OP_TREE':
"""Adds noise to an individual operation.
Args:
operation: The operation to make noisy.
Returns:
An OP_TREE corresponding to the noisy operations implementing the
noisy version of the ... | [
"def",
"noisy_operation",
"(",
"self",
",",
"operation",
":",
"'cirq.Operation'",
")",
"->",
"'cirq.OP_TREE'",
":",
"if",
"not",
"hasattr",
"(",
"self",
".",
"noisy_moments",
",",
"'_not_overridden'",
")",
":",
"return",
"self",
".",
"noisy_moments",
"(",
"[",... | Adds noise to an individual operation.
Args:
operation: The operation to make noisy.
Returns:
An OP_TREE corresponding to the noisy operations implementing the
noisy version of the given operation. | [
"Adds",
"noise",
"to",
"an",
"individual",
"operation",
"."
] | 0827da80dd7880e5b923eb69407e980ed9bc0bd2 | https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/devices/noise_model.py#L94-L111 | train | Adds noise to an individual operation. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
quantumlib/Cirq | cirq/protocols/measurement_key.py | measurement_key | def measurement_key(
val: Any,
default: Any = RaiseTypeErrorIfNotProvided):
"""Get the measurement key for the given value.
Args:
val: The value which has the measurement key..
default: Determines the fallback behavior when `val` doesn't have
a measurement key. If `d... | python | def measurement_key(
val: Any,
default: Any = RaiseTypeErrorIfNotProvided):
"""Get the measurement key for the given value.
Args:
val: The value which has the measurement key..
default: Determines the fallback behavior when `val` doesn't have
a measurement key. If `d... | [
"def",
"measurement_key",
"(",
"val",
":",
"Any",
",",
"default",
":",
"Any",
"=",
"RaiseTypeErrorIfNotProvided",
")",
":",
"getter",
"=",
"getattr",
"(",
"val",
",",
"'_measurement_key_'",
",",
"None",
")",
"result",
"=",
"NotImplemented",
"if",
"getter",
"... | Get the measurement key for the given value.
Args:
val: The value which has the measurement key..
default: Determines the fallback behavior when `val` doesn't have
a measurement key. If `default` is not set, a TypeError is raised.
If default is set to a value, that value is ... | [
"Get",
"the",
"measurement",
"key",
"for",
"the",
"given",
"value",
"."
] | 0827da80dd7880e5b923eb69407e980ed9bc0bd2 | https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/protocols/measurement_key.py#L51-L86 | train | Returns the measurement key for the given value. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
quantumlib/Cirq | cirq/experiments/google_v2_supremacy_circuit.py | generate_supremacy_circuit_google_v2 | def generate_supremacy_circuit_google_v2(qubits: Iterable[devices.GridQubit],
cz_depth: int,
seed: int) -> circuits.Circuit:
"""
Generates Google Random Circuits v2 as in github.com/sboixo/GRCS cz_v2.
See also https://arxiv.or... | python | def generate_supremacy_circuit_google_v2(qubits: Iterable[devices.GridQubit],
cz_depth: int,
seed: int) -> circuits.Circuit:
"""
Generates Google Random Circuits v2 as in github.com/sboixo/GRCS cz_v2.
See also https://arxiv.or... | [
"def",
"generate_supremacy_circuit_google_v2",
"(",
"qubits",
":",
"Iterable",
"[",
"devices",
".",
"GridQubit",
"]",
",",
"cz_depth",
":",
"int",
",",
"seed",
":",
"int",
")",
"->",
"circuits",
".",
"Circuit",
":",
"non_diagonal_gates",
"=",
"[",
"ops",
"."... | Generates Google Random Circuits v2 as in github.com/sboixo/GRCS cz_v2.
See also https://arxiv.org/abs/1807.10749
Args:
qubits: qubit grid in which to generate the circuit.
cz_depth: number of layers with CZ gates.
seed: seed for the random instance.
Returns:
A circuit corr... | [
"Generates",
"Google",
"Random",
"Circuits",
"v2",
"as",
"in",
"github",
".",
"com",
"/",
"sboixo",
"/",
"GRCS",
"cz_v2",
".",
"See",
"also",
"https",
":",
"//",
"arxiv",
".",
"org",
"/",
"abs",
"/",
"1807",
".",
"10749"
] | 0827da80dd7880e5b923eb69407e980ed9bc0bd2 | https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/experiments/google_v2_supremacy_circuit.py#L22-L81 | train | Generates a Google Random Circuits v2 for the given set of qubits. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
quantumlib/Cirq | cirq/experiments/google_v2_supremacy_circuit.py | generate_supremacy_circuit_google_v2_grid | def generate_supremacy_circuit_google_v2_grid(n_rows: int, n_cols: int,
cz_depth: int, seed: int
) -> circuits.Circuit:
"""
Generates Google Random Circuits v2 as in github.com/sboixo/GRCS cz_v2.
See also https://arx... | python | def generate_supremacy_circuit_google_v2_grid(n_rows: int, n_cols: int,
cz_depth: int, seed: int
) -> circuits.Circuit:
"""
Generates Google Random Circuits v2 as in github.com/sboixo/GRCS cz_v2.
See also https://arx... | [
"def",
"generate_supremacy_circuit_google_v2_grid",
"(",
"n_rows",
":",
"int",
",",
"n_cols",
":",
"int",
",",
"cz_depth",
":",
"int",
",",
"seed",
":",
"int",
")",
"->",
"circuits",
".",
"Circuit",
":",
"qubits",
"=",
"[",
"devices",
".",
"GridQubit",
"("... | Generates Google Random Circuits v2 as in github.com/sboixo/GRCS cz_v2.
See also https://arxiv.org/abs/1807.10749
Args:
n_rows: number of rows of a 2D lattice.
n_cols: number of columns.
cz_depth: number of layers with CZ gates.
seed: seed for the random instance.
Returns:
... | [
"Generates",
"Google",
"Random",
"Circuits",
"v2",
"as",
"in",
"github",
".",
"com",
"/",
"sboixo",
"/",
"GRCS",
"cz_v2",
".",
"See",
"also",
"https",
":",
"//",
"arxiv",
".",
"org",
"/",
"abs",
"/",
"1807",
".",
"10749"
] | 0827da80dd7880e5b923eb69407e980ed9bc0bd2 | https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/experiments/google_v2_supremacy_circuit.py#L84-L106 | train | Generates a 2D supremacy circuit for a random instance of the class. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
quantumlib/Cirq | cirq/experiments/google_v2_supremacy_circuit.py | generate_supremacy_circuit_google_v2_bristlecone | def generate_supremacy_circuit_google_v2_bristlecone(n_rows: int,
cz_depth: int, seed: int
) -> circuits.Circuit:
"""
Generates Google Random Circuits v2 in Bristlecone.
See also https://arxiv.org/abs/1... | python | def generate_supremacy_circuit_google_v2_bristlecone(n_rows: int,
cz_depth: int, seed: int
) -> circuits.Circuit:
"""
Generates Google Random Circuits v2 in Bristlecone.
See also https://arxiv.org/abs/1... | [
"def",
"generate_supremacy_circuit_google_v2_bristlecone",
"(",
"n_rows",
":",
"int",
",",
"cz_depth",
":",
"int",
",",
"seed",
":",
"int",
")",
"->",
"circuits",
".",
"Circuit",
":",
"def",
"get_qubits",
"(",
"n_rows",
")",
":",
"def",
"count_neighbors",
"(",... | Generates Google Random Circuits v2 in Bristlecone.
See also https://arxiv.org/abs/1807.10749
Args:
n_rows: number of rows in a Bristlecone lattice.
Note that we do not include single qubit corners.
cz_depth: number of layers with CZ gates.
seed: seed for the random instance.
... | [
"Generates",
"Google",
"Random",
"Circuits",
"v2",
"in",
"Bristlecone",
".",
"See",
"also",
"https",
":",
"//",
"arxiv",
".",
"org",
"/",
"abs",
"/",
"1807",
".",
"10749"
] | 0827da80dd7880e5b923eb69407e980ed9bc0bd2 | https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/experiments/google_v2_supremacy_circuit.py#L109-L149 | train | Generates a supremacy circuit for a given number of rows in a Bristlecone lattice. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
quantumlib/Cirq | cirq/experiments/google_v2_supremacy_circuit.py | _choice | def _choice(rand_gen: Callable[[], float], sequence: Sequence[T]) -> T:
"""Choose a random element from a non-empty sequence.
Use this instead of random.choice, with random.random(), for reproducibility
"""
return sequence[int(rand_gen() * len(sequence))] | python | def _choice(rand_gen: Callable[[], float], sequence: Sequence[T]) -> T:
"""Choose a random element from a non-empty sequence.
Use this instead of random.choice, with random.random(), for reproducibility
"""
return sequence[int(rand_gen() * len(sequence))] | [
"def",
"_choice",
"(",
"rand_gen",
":",
"Callable",
"[",
"[",
"]",
",",
"float",
"]",
",",
"sequence",
":",
"Sequence",
"[",
"T",
"]",
")",
"->",
"T",
":",
"return",
"sequence",
"[",
"int",
"(",
"rand_gen",
"(",
")",
"*",
"len",
"(",
"sequence",
... | Choose a random element from a non-empty sequence.
Use this instead of random.choice, with random.random(), for reproducibility | [
"Choose",
"a",
"random",
"element",
"from",
"a",
"non",
"-",
"empty",
"sequence",
"."
] | 0827da80dd7880e5b923eb69407e980ed9bc0bd2 | https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/experiments/google_v2_supremacy_circuit.py#L155-L160 | train | Choose a random element from a non - empty sequence. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
quantumlib/Cirq | cirq/experiments/google_v2_supremacy_circuit.py | _make_cz_layer | def _make_cz_layer(qubits: Iterable[devices.GridQubit], layer_index: int
) -> Iterable[ops.Operation]:
"""
Each layer index corresponds to a shift/transpose of this CZ pattern:
●───● ● ● ●───● ● ● . . .
● ● ●───● ● ● ●───● . . .
●───● ● ● ●... | python | def _make_cz_layer(qubits: Iterable[devices.GridQubit], layer_index: int
) -> Iterable[ops.Operation]:
"""
Each layer index corresponds to a shift/transpose of this CZ pattern:
●───● ● ● ●───● ● ● . . .
● ● ●───● ● ● ●───● . . .
●───● ● ● ●... | [
"def",
"_make_cz_layer",
"(",
"qubits",
":",
"Iterable",
"[",
"devices",
".",
"GridQubit",
"]",
",",
"layer_index",
":",
"int",
")",
"->",
"Iterable",
"[",
"ops",
".",
"Operation",
"]",
":",
"# map to an internal layer index to match the cycle order of public circuits... | Each layer index corresponds to a shift/transpose of this CZ pattern:
●───● ● ● ●───● ● ● . . .
● ● ●───● ● ● ●───● . . .
●───● ● ● ●───● ● ● . . .
● ● ●───● ● ● ●───● . . .
●───● ● ● ●───● ● ● . . .
● ● ●───● ... | [
"Each",
"layer",
"index",
"corresponds",
"to",
"a",
"shift",
"/",
"transpose",
"of",
"this",
"CZ",
"pattern",
":"
] | 0827da80dd7880e5b923eb69407e980ed9bc0bd2 | https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/experiments/google_v2_supremacy_circuit.py#L174-L229 | train | Creates a CZ layer for the given set of qubits. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
quantumlib/Cirq | cirq/optimizers/merge_interactions.py | MergeInteractions._op_to_matrix | def _op_to_matrix(self,
op: Optional[ops.Operation],
qubits: Tuple[ops.Qid, ...]
) -> Optional[np.ndarray]:
"""Determines the effect of an operation on the given qubits.
If the operation is a 1-qubit operation on one of the given qubits,... | python | def _op_to_matrix(self,
op: Optional[ops.Operation],
qubits: Tuple[ops.Qid, ...]
) -> Optional[np.ndarray]:
"""Determines the effect of an operation on the given qubits.
If the operation is a 1-qubit operation on one of the given qubits,... | [
"def",
"_op_to_matrix",
"(",
"self",
",",
"op",
":",
"Optional",
"[",
"ops",
".",
"Operation",
"]",
",",
"qubits",
":",
"Tuple",
"[",
"ops",
".",
"Qid",
",",
"...",
"]",
")",
"->",
"Optional",
"[",
"np",
".",
"ndarray",
"]",
":",
"q1",
",",
"q2",... | Determines the effect of an operation on the given qubits.
If the operation is a 1-qubit operation on one of the given qubits,
or a 2-qubit operation on both of the given qubits, and also the
operation has a known matrix, then a matrix is returned. Otherwise None
is returned.
A... | [
"Determines",
"the",
"effect",
"of",
"an",
"operation",
"on",
"the",
"given",
"qubits",
"."
] | 0827da80dd7880e5b923eb69407e980ed9bc0bd2 | https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/optimizers/merge_interactions.py#L90-L125 | train | Determines the effect of an operation on the given qubits and returns a matrix equivalent to the effect of the operation on the given qubits. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
quantumlib/Cirq | cirq/optimizers/merge_interactions.py | MergeInteractions._scan_two_qubit_ops_into_matrix | def _scan_two_qubit_ops_into_matrix(
self,
circuit: circuits.Circuit,
index: Optional[int],
qubits: Tuple[ops.Qid, ...]
) -> Tuple[List[ops.Operation], List[int], np.ndarray]:
"""Accumulates operations affecting the given pair of qubits.
The scan term... | python | def _scan_two_qubit_ops_into_matrix(
self,
circuit: circuits.Circuit,
index: Optional[int],
qubits: Tuple[ops.Qid, ...]
) -> Tuple[List[ops.Operation], List[int], np.ndarray]:
"""Accumulates operations affecting the given pair of qubits.
The scan term... | [
"def",
"_scan_two_qubit_ops_into_matrix",
"(",
"self",
",",
"circuit",
":",
"circuits",
".",
"Circuit",
",",
"index",
":",
"Optional",
"[",
"int",
"]",
",",
"qubits",
":",
"Tuple",
"[",
"ops",
".",
"Qid",
",",
"...",
"]",
")",
"->",
"Tuple",
"[",
"List... | Accumulates operations affecting the given pair of qubits.
The scan terminates when it hits the end of the circuit, finds an
operation without a known matrix, or finds an operation that interacts
the given qubits with other qubits.
Args:
circuit: The circuit to scan for ope... | [
"Accumulates",
"operations",
"affecting",
"the",
"given",
"pair",
"of",
"qubits",
"."
] | 0827da80dd7880e5b923eb69407e980ed9bc0bd2 | https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/optimizers/merge_interactions.py#L127-L176 | train | Scan the two qubit operations into a matrix. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
quantumlib/Cirq | cirq/optimizers/merge_interactions.py | MergeInteractions._flip_kron_order | def _flip_kron_order(mat4x4: np.ndarray) -> np.ndarray:
"""Given M = sum(kron(a_i, b_i)), returns M' = sum(kron(b_i, a_i))."""
result = np.array([[0] * 4] * 4, dtype=np.complex128)
order = [0, 2, 1, 3]
for i in range(4):
for j in range(4):
result[order[i], ord... | python | def _flip_kron_order(mat4x4: np.ndarray) -> np.ndarray:
"""Given M = sum(kron(a_i, b_i)), returns M' = sum(kron(b_i, a_i))."""
result = np.array([[0] * 4] * 4, dtype=np.complex128)
order = [0, 2, 1, 3]
for i in range(4):
for j in range(4):
result[order[i], ord... | [
"def",
"_flip_kron_order",
"(",
"mat4x4",
":",
"np",
".",
"ndarray",
")",
"->",
"np",
".",
"ndarray",
":",
"result",
"=",
"np",
".",
"array",
"(",
"[",
"[",
"0",
"]",
"*",
"4",
"]",
"*",
"4",
",",
"dtype",
"=",
"np",
".",
"complex128",
")",
"or... | Given M = sum(kron(a_i, b_i)), returns M' = sum(kron(b_i, a_i)). | [
"Given",
"M",
"=",
"sum",
"(",
"kron",
"(",
"a_i",
"b_i",
"))",
"returns",
"M",
"=",
"sum",
"(",
"kron",
"(",
"b_i",
"a_i",
"))",
"."
] | 0827da80dd7880e5b923eb69407e980ed9bc0bd2 | https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/optimizers/merge_interactions.py#L179-L186 | train | Given mat4x4 returns M = sum of krons of a_i and b_i. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
quantumlib/Cirq | cirq/protocols/control.py | control | def control(controllee: Union['cirq.Gate', op_tree.OP_TREE],
control_qubits: Sequence['cirq.Qid'] = None,
default: Any = RaiseTypeErrorIfNotProvided) -> Any:
"""Returns a Controlled version of the given value, if defined.
Controllees define how to be controlled by defining a method
... | python | def control(controllee: Union['cirq.Gate', op_tree.OP_TREE],
control_qubits: Sequence['cirq.Qid'] = None,
default: Any = RaiseTypeErrorIfNotProvided) -> Any:
"""Returns a Controlled version of the given value, if defined.
Controllees define how to be controlled by defining a method
... | [
"def",
"control",
"(",
"controllee",
":",
"Union",
"[",
"'cirq.Gate'",
",",
"op_tree",
".",
"OP_TREE",
"]",
",",
"control_qubits",
":",
"Sequence",
"[",
"'cirq.Qid'",
"]",
"=",
"None",
",",
"default",
":",
"Any",
"=",
"RaiseTypeErrorIfNotProvided",
")",
"->"... | Returns a Controlled version of the given value, if defined.
Controllees define how to be controlled by defining a method
controlled_by(self, control_qubits). Note that the method may return
NotImplemented to indicate a particular controlling can't be done.
Args:
controllee: The gate, operatio... | [
"Returns",
"a",
"Controlled",
"version",
"of",
"the",
"given",
"value",
"if",
"defined",
"."
] | 0827da80dd7880e5b923eb69407e980ed9bc0bd2 | https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/protocols/control.py#L33-L79 | train | Returns a new version of the given value if the given controlling is defined. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
quantumlib/Cirq | cirq/protocols/inverse.py | inverse | def inverse(val: Any, default: Any = RaiseTypeErrorIfNotProvided) -> Any:
"""Returns the inverse `val**-1` of the given value, if defined.
An object can define an inverse by defining a __pow__(self, exponent) method
that returns something besides NotImplemented when given the exponent -1.
The inverse o... | python | def inverse(val: Any, default: Any = RaiseTypeErrorIfNotProvided) -> Any:
"""Returns the inverse `val**-1` of the given value, if defined.
An object can define an inverse by defining a __pow__(self, exponent) method
that returns something besides NotImplemented when given the exponent -1.
The inverse o... | [
"def",
"inverse",
"(",
"val",
":",
"Any",
",",
"default",
":",
"Any",
"=",
"RaiseTypeErrorIfNotProvided",
")",
"->",
"Any",
":",
"from",
"cirq",
"import",
"ops",
"# HACK: avoid circular import",
"# Check if object defines an inverse via __pow__.",
"raiser",
"=",
"geta... | Returns the inverse `val**-1` of the given value, if defined.
An object can define an inverse by defining a __pow__(self, exponent) method
that returns something besides NotImplemented when given the exponent -1.
The inverse of iterables is by default defined to be the iterable's items,
each inverted, ... | [
"Returns",
"the",
"inverse",
"val",
"**",
"-",
"1",
"of",
"the",
"given",
"value",
"if",
"defined",
"."
] | 0827da80dd7880e5b923eb69407e980ed9bc0bd2 | https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/protocols/inverse.py#L81-L131 | train | Returns the inverse of the given value if defined. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
quantumlib/Cirq | cirq/ion/ion_decomposition.py | two_qubit_matrix_to_ion_operations | def two_qubit_matrix_to_ion_operations(q0: ops.Qid,
q1: ops.Qid,
mat: np.ndarray,
atol: float = 1e-8
) -> List[ops.Operation]:
"""Decomposes a two-qubit operati... | python | def two_qubit_matrix_to_ion_operations(q0: ops.Qid,
q1: ops.Qid,
mat: np.ndarray,
atol: float = 1e-8
) -> List[ops.Operation]:
"""Decomposes a two-qubit operati... | [
"def",
"two_qubit_matrix_to_ion_operations",
"(",
"q0",
":",
"ops",
".",
"Qid",
",",
"q1",
":",
"ops",
".",
"Qid",
",",
"mat",
":",
"np",
".",
"ndarray",
",",
"atol",
":",
"float",
"=",
"1e-8",
")",
"->",
"List",
"[",
"ops",
".",
"Operation",
"]",
... | Decomposes a two-qubit operation into MS/single-qubit rotation gates.
Args:
q0: The first qubit being operated on.
q1: The other qubit being operated on.
mat: Defines the operation to apply to the pair of qubits.
tolerance: A limit on the amount of error introduced by the
... | [
"Decomposes",
"a",
"two",
"-",
"qubit",
"operation",
"into",
"MS",
"/",
"single",
"-",
"qubit",
"rotation",
"gates",
"."
] | 0827da80dd7880e5b923eb69407e980ed9bc0bd2 | https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/ion/ion_decomposition.py#L32-L52 | train | Decomposes a two - qubit operation into MS - single - qubit rotation gates. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
quantumlib/Cirq | cirq/ion/ion_decomposition.py | _parity_interaction | def _parity_interaction(q0: ops.Qid,
q1: ops.Qid,
rads: float,
atol: float,
gate: Optional[ops.Gate] = None):
"""Yields an XX interaction framed by the given operation."""
if abs(rads) < atol:
return
if... | python | def _parity_interaction(q0: ops.Qid,
q1: ops.Qid,
rads: float,
atol: float,
gate: Optional[ops.Gate] = None):
"""Yields an XX interaction framed by the given operation."""
if abs(rads) < atol:
return
if... | [
"def",
"_parity_interaction",
"(",
"q0",
":",
"ops",
".",
"Qid",
",",
"q1",
":",
"ops",
".",
"Qid",
",",
"rads",
":",
"float",
",",
"atol",
":",
"float",
",",
"gate",
":",
"Optional",
"[",
"ops",
".",
"Gate",
"]",
"=",
"None",
")",
":",
"if",
"... | Yields an XX interaction framed by the given operation. | [
"Yields",
"an",
"XX",
"interaction",
"framed",
"by",
"the",
"given",
"operation",
"."
] | 0827da80dd7880e5b923eb69407e980ed9bc0bd2 | https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/ion/ion_decomposition.py#L93-L111 | train | Yields an XX interaction framed by the given operation. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
quantumlib/Cirq | cirq/ion/ion_decomposition.py | _non_local_part | def _non_local_part(q0: ops.Qid,
q1: ops.Qid,
interaction_coefficients: Tuple[float, float, float],
atol: float = 1e-8):
"""Yields non-local operation of KAK decomposition."""
x, y, z = interaction_coefficients
return [
_parity_interactio... | python | def _non_local_part(q0: ops.Qid,
q1: ops.Qid,
interaction_coefficients: Tuple[float, float, float],
atol: float = 1e-8):
"""Yields non-local operation of KAK decomposition."""
x, y, z = interaction_coefficients
return [
_parity_interactio... | [
"def",
"_non_local_part",
"(",
"q0",
":",
"ops",
".",
"Qid",
",",
"q1",
":",
"ops",
".",
"Qid",
",",
"interaction_coefficients",
":",
"Tuple",
"[",
"float",
",",
"float",
",",
"float",
"]",
",",
"atol",
":",
"float",
"=",
"1e-8",
")",
":",
"x",
","... | Yields non-local operation of KAK decomposition. | [
"Yields",
"non",
"-",
"local",
"operation",
"of",
"KAK",
"decomposition",
"."
] | 0827da80dd7880e5b923eb69407e980ed9bc0bd2 | https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/ion/ion_decomposition.py#L114-L125 | train | Yields non - local part of KAK decomposition. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
quantumlib/Cirq | cirq/study/resolver.py | ParamResolver.value_of | def value_of(
self,
value: Union[sympy.Basic, float, str]
) -> Union[sympy.Basic, float]:
"""Attempt to resolve a Symbol or name or float to its assigned value.
If unable to resolve a sympy.Symbol, returns it unchanged.
If unable to resolve a name, returns a sympy.Sy... | python | def value_of(
self,
value: Union[sympy.Basic, float, str]
) -> Union[sympy.Basic, float]:
"""Attempt to resolve a Symbol or name or float to its assigned value.
If unable to resolve a sympy.Symbol, returns it unchanged.
If unable to resolve a name, returns a sympy.Sy... | [
"def",
"value_of",
"(",
"self",
",",
"value",
":",
"Union",
"[",
"sympy",
".",
"Basic",
",",
"float",
",",
"str",
"]",
")",
"->",
"Union",
"[",
"sympy",
".",
"Basic",
",",
"float",
"]",
":",
"if",
"isinstance",
"(",
"value",
",",
"str",
")",
":",... | Attempt to resolve a Symbol or name or float to its assigned value.
If unable to resolve a sympy.Symbol, returns it unchanged.
If unable to resolve a name, returns a sympy.Symbol with that name.
Args:
value: The sympy.Symbol or name or float to try to resolve into just
... | [
"Attempt",
"to",
"resolve",
"a",
"Symbol",
"or",
"name",
"or",
"float",
"to",
"its",
"assigned",
"value",
"."
] | 0827da80dd7880e5b923eb69407e980ed9bc0bd2 | https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/study/resolver.py#L57-L84 | train | Attempt to resolve a Symbol or name or float to its assigned value. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
quantumlib/Cirq | cirq/value/value_equality.py | value_equality | def value_equality(cls: type = None,
*,
unhashable: bool = False,
distinct_child_types: bool = False,
manual_cls: bool = False,
approximate: bool = False
) -> Union[Callable[[type], type], type]:
"""Impl... | python | def value_equality(cls: type = None,
*,
unhashable: bool = False,
distinct_child_types: bool = False,
manual_cls: bool = False,
approximate: bool = False
) -> Union[Callable[[type], type], type]:
"""Impl... | [
"def",
"value_equality",
"(",
"cls",
":",
"type",
"=",
"None",
",",
"*",
",",
"unhashable",
":",
"bool",
"=",
"False",
",",
"distinct_child_types",
":",
"bool",
"=",
"False",
",",
"manual_cls",
":",
"bool",
"=",
"False",
",",
"approximate",
":",
"bool",
... | Implements __eq__/__ne__/__hash__ via a _value_equality_values_ method.
_value_equality_values_ is a method that the decorated class must implement.
_value_equality_approximate_values_ is a method that the decorated class
might implement if special support for approximate equality is required.
This is... | [
"Implements",
"__eq__",
"/",
"__ne__",
"/",
"__hash__",
"via",
"a",
"_value_equality_values_",
"method",
"."
] | 0827da80dd7880e5b923eb69407e980ed9bc0bd2 | https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/value/value_equality.py#L135-L223 | train | Returns a function that can be used to compare two value types of a given class. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
quantumlib/Cirq | dev_tools/incremental_coverage.py | diff_to_new_interesting_lines | def diff_to_new_interesting_lines(unified_diff_lines: List[str]
) -> Dict[int, str]:
"""
Extracts a set of 'interesting' lines out of a GNU unified diff format.
Format:
gnu.org/software/diffutils/manual/html_node/Detailed-Unified.html
@@ from-line-numbers to-l... | python | def diff_to_new_interesting_lines(unified_diff_lines: List[str]
) -> Dict[int, str]:
"""
Extracts a set of 'interesting' lines out of a GNU unified diff format.
Format:
gnu.org/software/diffutils/manual/html_node/Detailed-Unified.html
@@ from-line-numbers to-l... | [
"def",
"diff_to_new_interesting_lines",
"(",
"unified_diff_lines",
":",
"List",
"[",
"str",
"]",
")",
"->",
"Dict",
"[",
"int",
",",
"str",
"]",
":",
"interesting_lines",
"=",
"dict",
"(",
")",
"for",
"diff_line",
"in",
"unified_diff_lines",
":",
"# Parse the ... | Extracts a set of 'interesting' lines out of a GNU unified diff format.
Format:
gnu.org/software/diffutils/manual/html_node/Detailed-Unified.html
@@ from-line-numbers to-line-numbers @@
line-from-either-file
...
@@ start,count start,count @@
line-from-either-file
... | [
"Extracts",
"a",
"set",
"of",
"interesting",
"lines",
"out",
"of",
"a",
"GNU",
"unified",
"diff",
"format",
"."
] | 0827da80dd7880e5b923eb69407e980ed9bc0bd2 | https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/dev_tools/incremental_coverage.py#L48-L105 | train | Returns a set of interesting lines from a GNU unified diff format. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
quantumlib/Cirq | dev_tools/incremental_coverage.py | get_incremental_uncovered_lines | def get_incremental_uncovered_lines(abs_path: str,
base_commit: str,
actual_commit: Optional[str]
) -> List[Tuple[int, str, str]]:
"""
Uses git diff and the annotation files created by
`pytest --cov-r... | python | def get_incremental_uncovered_lines(abs_path: str,
base_commit: str,
actual_commit: Optional[str]
) -> List[Tuple[int, str, str]]:
"""
Uses git diff and the annotation files created by
`pytest --cov-r... | [
"def",
"get_incremental_uncovered_lines",
"(",
"abs_path",
":",
"str",
",",
"base_commit",
":",
"str",
",",
"actual_commit",
":",
"Optional",
"[",
"str",
"]",
")",
"->",
"List",
"[",
"Tuple",
"[",
"int",
",",
"str",
",",
"str",
"]",
"]",
":",
"# Deleted ... | Uses git diff and the annotation files created by
`pytest --cov-report annotate` to find touched but uncovered lines in the
given file.
Args:
abs_path: The path of a file to look for uncovered lines in.
base_commit: Old state to diff against.
actual_commit: Current state. Use None t... | [
"Uses",
"git",
"diff",
"and",
"the",
"annotation",
"files",
"created",
"by",
"pytest",
"--",
"cov",
"-",
"report",
"annotate",
"to",
"find",
"touched",
"but",
"uncovered",
"lines",
"in",
"the",
"given",
"file",
"."
] | 0827da80dd7880e5b923eb69407e980ed9bc0bd2 | https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/dev_tools/incremental_coverage.py#L115-L162 | train | Returns a list of tuples of indices content and reason - for - including of those uncovered lines in the given file. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
quantumlib/Cirq | dev_tools/incremental_coverage.py | line_content_counts_as_uncovered_manual | def line_content_counts_as_uncovered_manual(content: str) -> bool:
"""
Args:
content: A line with indentation and tail comments/space removed.
Returns:
Whether the line could be included in the coverage report.
"""
# Omit empty lines.
if not content:
return False
# ... | python | def line_content_counts_as_uncovered_manual(content: str) -> bool:
"""
Args:
content: A line with indentation and tail comments/space removed.
Returns:
Whether the line could be included in the coverage report.
"""
# Omit empty lines.
if not content:
return False
# ... | [
"def",
"line_content_counts_as_uncovered_manual",
"(",
"content",
":",
"str",
")",
"->",
"bool",
":",
"# Omit empty lines.",
"if",
"not",
"content",
":",
"return",
"False",
"# Omit declarations.",
"for",
"keyword",
"in",
"[",
"'def'",
",",
"'class'",
"]",
":",
"... | Args:
content: A line with indentation and tail comments/space removed.
Returns:
Whether the line could be included in the coverage report. | [
"Args",
":",
"content",
":",
"A",
"line",
"with",
"indentation",
"and",
"tail",
"comments",
"/",
"space",
"removed",
"."
] | 0827da80dd7880e5b923eb69407e980ed9bc0bd2 | https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/dev_tools/incremental_coverage.py#L165-L183 | train | Returns True if the line content counts as uncovered in the coverage report. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
quantumlib/Cirq | dev_tools/incremental_coverage.py | line_counts_as_uncovered | def line_counts_as_uncovered(line: str,
is_from_cover_annotation_file: bool) -> bool:
"""
Args:
line: The line of code (including coverage annotation).
is_from_cover_annotation_file: Whether this line has been annotated.
Returns:
Does the line count as un... | python | def line_counts_as_uncovered(line: str,
is_from_cover_annotation_file: bool) -> bool:
"""
Args:
line: The line of code (including coverage annotation).
is_from_cover_annotation_file: Whether this line has been annotated.
Returns:
Does the line count as un... | [
"def",
"line_counts_as_uncovered",
"(",
"line",
":",
"str",
",",
"is_from_cover_annotation_file",
":",
"bool",
")",
"->",
"bool",
":",
"# Ignore this line?",
"if",
"is_from_cover_annotation_file",
":",
"# Already covered, or the tool deemed it not relevant for coverage.",
"if",... | Args:
line: The line of code (including coverage annotation).
is_from_cover_annotation_file: Whether this line has been annotated.
Returns:
Does the line count as uncovered? | [
"Args",
":",
"line",
":",
"The",
"line",
"of",
"code",
"(",
"including",
"coverage",
"annotation",
")",
".",
"is_from_cover_annotation_file",
":",
"Whether",
"this",
"line",
"has",
"been",
"annotated",
".",
"Returns",
":",
"Does",
"the",
"line",
"count",
"as... | 0827da80dd7880e5b923eb69407e980ed9bc0bd2 | https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/dev_tools/incremental_coverage.py#L222-L255 | train | Returns True if the line counts as uncovered. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
quantumlib/Cirq | dev_tools/incremental_coverage.py | is_applicable_python_file | def is_applicable_python_file(rel_path: str) -> bool:
"""
Determines if a file should be included in incremental coverage analysis.
Args:
rel_path: The repo-relative file path being considered.
Returns:
Whether to include the file.
"""
return (rel_path.endswith('.py') and
... | python | def is_applicable_python_file(rel_path: str) -> bool:
"""
Determines if a file should be included in incremental coverage analysis.
Args:
rel_path: The repo-relative file path being considered.
Returns:
Whether to include the file.
"""
return (rel_path.endswith('.py') and
... | [
"def",
"is_applicable_python_file",
"(",
"rel_path",
":",
"str",
")",
"->",
"bool",
":",
"return",
"(",
"rel_path",
".",
"endswith",
"(",
"'.py'",
")",
"and",
"not",
"any",
"(",
"re",
".",
"search",
"(",
"pat",
",",
"rel_path",
")",
"for",
"pat",
"in",... | Determines if a file should be included in incremental coverage analysis.
Args:
rel_path: The repo-relative file path being considered.
Returns:
Whether to include the file. | [
"Determines",
"if",
"a",
"file",
"should",
"be",
"included",
"in",
"incremental",
"coverage",
"analysis",
"."
] | 0827da80dd7880e5b923eb69407e980ed9bc0bd2 | https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/dev_tools/incremental_coverage.py#L258-L268 | train | Determines if a file should be included in incremental coverage analysis. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
quantumlib/Cirq | cirq/ops/eigen_gate.py | _approximate_common_period | def _approximate_common_period(periods: List[float],
approx_denom: int = 60,
reject_atol: float = 1e-8) -> Optional[float]:
"""Finds a value that is nearly an integer multiple of multiple periods.
The returned value should be the smallest non-negati... | python | def _approximate_common_period(periods: List[float],
approx_denom: int = 60,
reject_atol: float = 1e-8) -> Optional[float]:
"""Finds a value that is nearly an integer multiple of multiple periods.
The returned value should be the smallest non-negati... | [
"def",
"_approximate_common_period",
"(",
"periods",
":",
"List",
"[",
"float",
"]",
",",
"approx_denom",
":",
"int",
"=",
"60",
",",
"reject_atol",
":",
"float",
"=",
"1e-8",
")",
"->",
"Optional",
"[",
"float",
"]",
":",
"if",
"not",
"periods",
":",
... | Finds a value that is nearly an integer multiple of multiple periods.
The returned value should be the smallest non-negative number with this
property. If `approx_denom` is too small the computation can fail to satisfy
the `reject_atol` criteria and return `None`. This is actually desirable
behavior, s... | [
"Finds",
"a",
"value",
"that",
"is",
"nearly",
"an",
"integer",
"multiple",
"of",
"multiple",
"periods",
"."
] | 0827da80dd7880e5b923eb69407e980ed9bc0bd2 | https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/ops/eigen_gate.py#L330-L374 | train | Calculates the approximate common period of the given list of periods. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
quantumlib/Cirq | cirq/ops/eigen_gate.py | _common_rational_period | def _common_rational_period(rational_periods: List[fractions.Fraction]
) -> fractions.Fraction:
"""Finds the least common integer multiple of some fractions.
The solution is the smallest positive integer c such that there
exists integers n_k satisfying p_k * n_k = c for all k.
... | python | def _common_rational_period(rational_periods: List[fractions.Fraction]
) -> fractions.Fraction:
"""Finds the least common integer multiple of some fractions.
The solution is the smallest positive integer c such that there
exists integers n_k satisfying p_k * n_k = c for all k.
... | [
"def",
"_common_rational_period",
"(",
"rational_periods",
":",
"List",
"[",
"fractions",
".",
"Fraction",
"]",
")",
"->",
"fractions",
".",
"Fraction",
":",
"assert",
"rational_periods",
",",
"\"no well-defined solution for an empty list\"",
"common_denom",
"=",
"_lcm"... | Finds the least common integer multiple of some fractions.
The solution is the smallest positive integer c such that there
exists integers n_k satisfying p_k * n_k = c for all k. | [
"Finds",
"the",
"least",
"common",
"integer",
"multiple",
"of",
"some",
"fractions",
"."
] | 0827da80dd7880e5b923eb69407e980ed9bc0bd2 | https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/ops/eigen_gate.py#L377-L389 | train | Finds the least common integer multiple of some fractions. rational_periods | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
combust/mleap | python/mleap/sklearn/preprocessing/data.py | LabelEncoder.fit | def fit(self, X):
"""Fit label encoder
Parameters
----------
y : array-like of shape (n_samples,)
Target values.
Returns
-------
self : returns an instance of self.
"""
X = column_or_1d(X, warn=True)
_check_numpy_unicode_bug(X... | python | def fit(self, X):
"""Fit label encoder
Parameters
----------
y : array-like of shape (n_samples,)
Target values.
Returns
-------
self : returns an instance of self.
"""
X = column_or_1d(X, warn=True)
_check_numpy_unicode_bug(X... | [
"def",
"fit",
"(",
"self",
",",
"X",
")",
":",
"X",
"=",
"column_or_1d",
"(",
"X",
",",
"warn",
"=",
"True",
")",
"_check_numpy_unicode_bug",
"(",
"X",
")",
"self",
".",
"classes_",
"=",
"np",
".",
"unique",
"(",
"X",
")",
"return",
"self"
] | Fit label encoder
Parameters
----------
y : array-like of shape (n_samples,)
Target values.
Returns
-------
self : returns an instance of self. | [
"Fit",
"label",
"encoder"
] | dc6b79db03ec27a0ba08b289842551e73d517ab3 | https://github.com/combust/mleap/blob/dc6b79db03ec27a0ba08b289842551e73d517ab3/python/mleap/sklearn/preprocessing/data.py#L361-L376 | train | Fit label encoder to a set of target values. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
combust/mleap | python/mleap/sklearn/preprocessing/data.py | LabelEncoder.fit_transform | def fit_transform(self, X, y=None, **fit_params):
"""Fit label encoder and return encoded labels
Parameters
----------
y : array-like of shape [n_samples]
Target values.
Returns
-------
y : array-like of shape [n_samples]
"""
y = colu... | python | def fit_transform(self, X, y=None, **fit_params):
"""Fit label encoder and return encoded labels
Parameters
----------
y : array-like of shape [n_samples]
Target values.
Returns
-------
y : array-like of shape [n_samples]
"""
y = colu... | [
"def",
"fit_transform",
"(",
"self",
",",
"X",
",",
"y",
"=",
"None",
",",
"*",
"*",
"fit_params",
")",
":",
"y",
"=",
"column_or_1d",
"(",
"X",
",",
"warn",
"=",
"True",
")",
"_check_numpy_unicode_bug",
"(",
"X",
")",
"self",
".",
"classes_",
",",
... | Fit label encoder and return encoded labels
Parameters
----------
y : array-like of shape [n_samples]
Target values.
Returns
-------
y : array-like of shape [n_samples] | [
"Fit",
"label",
"encoder",
"and",
"return",
"encoded",
"labels"
] | dc6b79db03ec27a0ba08b289842551e73d517ab3 | https://github.com/combust/mleap/blob/dc6b79db03ec27a0ba08b289842551e73d517ab3/python/mleap/sklearn/preprocessing/data.py#L378-L393 | train | Fit label encoder and return encoded labels. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
combust/mleap | python/mleap/sklearn/preprocessing/data.py | LabelEncoder.transform | def transform(self, y):
"""Transform labels to normalized encoding.
Parameters
----------
y : array-like of shape [n_samples]
Target values.
Returns
-------
y : array-like of shape [n_samples]
"""
check_is_fitted(self, 'classes_')
... | python | def transform(self, y):
"""Transform labels to normalized encoding.
Parameters
----------
y : array-like of shape [n_samples]
Target values.
Returns
-------
y : array-like of shape [n_samples]
"""
check_is_fitted(self, 'classes_')
... | [
"def",
"transform",
"(",
"self",
",",
"y",
")",
":",
"check_is_fitted",
"(",
"self",
",",
"'classes_'",
")",
"y",
"=",
"column_or_1d",
"(",
"y",
",",
"warn",
"=",
"True",
")",
"classes",
"=",
"np",
".",
"unique",
"(",
"y",
")",
"_check_numpy_unicode_bu... | Transform labels to normalized encoding.
Parameters
----------
y : array-like of shape [n_samples]
Target values.
Returns
-------
y : array-like of shape [n_samples] | [
"Transform",
"labels",
"to",
"normalized",
"encoding",
"."
] | dc6b79db03ec27a0ba08b289842551e73d517ab3 | https://github.com/combust/mleap/blob/dc6b79db03ec27a0ba08b289842551e73d517ab3/python/mleap/sklearn/preprocessing/data.py#L395-L415 | train | Transform labels to normalized encoding. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
combust/mleap | python/mleap/sklearn/preprocessing/data.py | LabelEncoder.inverse_transform | def inverse_transform(self, y):
"""Transform labels back to original encoding.
Parameters
----------
y : numpy array of shape [n_samples]
Target values.
Returns
-------
y : numpy array of shape [n_samples]
"""
check_is_fitted(self, 'c... | python | def inverse_transform(self, y):
"""Transform labels back to original encoding.
Parameters
----------
y : numpy array of shape [n_samples]
Target values.
Returns
-------
y : numpy array of shape [n_samples]
"""
check_is_fitted(self, 'c... | [
"def",
"inverse_transform",
"(",
"self",
",",
"y",
")",
":",
"check_is_fitted",
"(",
"self",
",",
"'classes_'",
")",
"diff",
"=",
"np",
".",
"setdiff1d",
"(",
"y",
",",
"np",
".",
"arange",
"(",
"len",
"(",
"self",
".",
"classes_",
")",
")",
")",
"... | Transform labels back to original encoding.
Parameters
----------
y : numpy array of shape [n_samples]
Target values.
Returns
-------
y : numpy array of shape [n_samples] | [
"Transform",
"labels",
"back",
"to",
"original",
"encoding",
"."
] | dc6b79db03ec27a0ba08b289842551e73d517ab3 | https://github.com/combust/mleap/blob/dc6b79db03ec27a0ba08b289842551e73d517ab3/python/mleap/sklearn/preprocessing/data.py#L417-L435 | train | Transform labels back to original encoding. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
combust/mleap | python/mleap/sklearn/preprocessing/data.py | MathUnary.transform | def transform(self, y):
"""
Transform features per specified math function.
:param y:
:return:
"""
if self.transform_type == 'log':
return np.log(y)
elif self.transform_type == 'exp':
return np.exp(y)
elif self.transform_type == 'sq... | python | def transform(self, y):
"""
Transform features per specified math function.
:param y:
:return:
"""
if self.transform_type == 'log':
return np.log(y)
elif self.transform_type == 'exp':
return np.exp(y)
elif self.transform_type == 'sq... | [
"def",
"transform",
"(",
"self",
",",
"y",
")",
":",
"if",
"self",
".",
"transform_type",
"==",
"'log'",
":",
"return",
"np",
".",
"log",
"(",
"y",
")",
"elif",
"self",
".",
"transform_type",
"==",
"'exp'",
":",
"return",
"np",
".",
"exp",
"(",
"y"... | Transform features per specified math function.
:param y:
:return: | [
"Transform",
"features",
"per",
"specified",
"math",
"function",
".",
":",
"param",
"y",
":",
":",
"return",
":"
] | dc6b79db03ec27a0ba08b289842551e73d517ab3 | https://github.com/combust/mleap/blob/dc6b79db03ec27a0ba08b289842551e73d517ab3/python/mleap/sklearn/preprocessing/data.py#L907-L926 | train | Transform features per specified math function. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
combust/mleap | python/mleap/sklearn/preprocessing/data.py | MathBinary.fit | def fit(self, X, y=None, **fit_params):
"""
Fit Unary Math Operator
:param y:
:return:
"""
if self.transform_type not in self.valid_transforms:
warnings.warn("Invalid transform type.", stacklevel=2)
return self | python | def fit(self, X, y=None, **fit_params):
"""
Fit Unary Math Operator
:param y:
:return:
"""
if self.transform_type not in self.valid_transforms:
warnings.warn("Invalid transform type.", stacklevel=2)
return self | [
"def",
"fit",
"(",
"self",
",",
"X",
",",
"y",
"=",
"None",
",",
"*",
"*",
"fit_params",
")",
":",
"if",
"self",
".",
"transform_type",
"not",
"in",
"self",
".",
"valid_transforms",
":",
"warnings",
".",
"warn",
"(",
"\"Invalid transform type.\"",
",",
... | Fit Unary Math Operator
:param y:
:return: | [
"Fit",
"Unary",
"Math",
"Operator",
":",
"param",
"y",
":",
":",
"return",
":"
] | dc6b79db03ec27a0ba08b289842551e73d517ab3 | https://github.com/combust/mleap/blob/dc6b79db03ec27a0ba08b289842551e73d517ab3/python/mleap/sklearn/preprocessing/data.py#L994-L1002 | train | Fit a binary math operator on the data. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
combust/mleap | python/mleap/sklearn/preprocessing/data.py | MathBinary.transform | def transform(self, y):
"""
Transform features per specified math function.
:param y:
:return:
"""
if isinstance(y, pd.DataFrame):
x = y.ix[:,0]
y = y.ix[:,1]
else:
x = y[:,0]
y = y[:,1]
if self.transform_typ... | python | def transform(self, y):
"""
Transform features per specified math function.
:param y:
:return:
"""
if isinstance(y, pd.DataFrame):
x = y.ix[:,0]
y = y.ix[:,1]
else:
x = y[:,0]
y = y[:,1]
if self.transform_typ... | [
"def",
"transform",
"(",
"self",
",",
"y",
")",
":",
"if",
"isinstance",
"(",
"y",
",",
"pd",
".",
"DataFrame",
")",
":",
"x",
"=",
"y",
".",
"ix",
"[",
":",
",",
"0",
"]",
"y",
"=",
"y",
".",
"ix",
"[",
":",
",",
"1",
"]",
"else",
":",
... | Transform features per specified math function.
:param y:
:return: | [
"Transform",
"features",
"per",
"specified",
"math",
"function",
".",
":",
"param",
"y",
":",
":",
"return",
":"
] | dc6b79db03ec27a0ba08b289842551e73d517ab3 | https://github.com/combust/mleap/blob/dc6b79db03ec27a0ba08b289842551e73d517ab3/python/mleap/sklearn/preprocessing/data.py#L1004-L1027 | train | Transform features per specified math function. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
combust/mleap | python/mleap/sklearn/tree/tree.py | SimpleSerializer.serialize_tree | def serialize_tree(tree, feature_names, outfile):
"""
:type feature_names: list
:type tree: sklearn.tree.tree.BaseDecisionTree
:param tree: sklearn.tree.tree
:param feature_names:
:return:
"""
tree_ = tree.tree_
feature_name = [feature_names[i] if... | python | def serialize_tree(tree, feature_names, outfile):
"""
:type feature_names: list
:type tree: sklearn.tree.tree.BaseDecisionTree
:param tree: sklearn.tree.tree
:param feature_names:
:return:
"""
tree_ = tree.tree_
feature_name = [feature_names[i] if... | [
"def",
"serialize_tree",
"(",
"tree",
",",
"feature_names",
",",
"outfile",
")",
":",
"tree_",
"=",
"tree",
".",
"tree_",
"feature_name",
"=",
"[",
"feature_names",
"[",
"i",
"]",
"if",
"i",
"!=",
"_tree",
".",
"TREE_UNDEFINED",
"else",
"'n/a'",
"for",
"... | :type feature_names: list
:type tree: sklearn.tree.tree.BaseDecisionTree
:param tree: sklearn.tree.tree
:param feature_names:
:return: | [
":",
"type",
"feature_names",
":",
"list",
":",
"type",
"tree",
":",
"sklearn",
".",
"tree",
".",
"tree",
".",
"BaseDecisionTree",
":",
"param",
"tree",
":",
"sklearn",
".",
"tree",
".",
"tree",
":",
"param",
"feature_names",
":",
":",
"return",
":"
] | dc6b79db03ec27a0ba08b289842551e73d517ab3 | https://github.com/combust/mleap/blob/dc6b79db03ec27a0ba08b289842551e73d517ab3/python/mleap/sklearn/tree/tree.py#L54-L100 | train | Serialize the tree to a file. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
combust/mleap | python/mleap/sklearn/tree/tree.py | SimpleSerializer.serialize_to_bundle | def serialize_to_bundle(self, transformer, path, model_name, serialize_node=True):
"""
:type transformer: sklearn.tree.tree.BaseDecisionTree
:type path: str
:type model_name: str
:type serialize_node: bool
:param transformer:
:param path:
:param model_name... | python | def serialize_to_bundle(self, transformer, path, model_name, serialize_node=True):
"""
:type transformer: sklearn.tree.tree.BaseDecisionTree
:type path: str
:type model_name: str
:type serialize_node: bool
:param transformer:
:param path:
:param model_name... | [
"def",
"serialize_to_bundle",
"(",
"self",
",",
"transformer",
",",
"path",
",",
"model_name",
",",
"serialize_node",
"=",
"True",
")",
":",
"# Define attributes",
"attributes",
"=",
"list",
"(",
")",
"attributes",
".",
"append",
"(",
"(",
"'num_features'",
",... | :type transformer: sklearn.tree.tree.BaseDecisionTree
:type path: str
:type model_name: str
:type serialize_node: bool
:param transformer:
:param path:
:param model_name:
:return: | [
":",
"type",
"transformer",
":",
"sklearn",
".",
"tree",
".",
"tree",
".",
"BaseDecisionTree",
":",
"type",
"path",
":",
"str",
":",
"type",
"model_name",
":",
"str",
":",
"type",
"serialize_node",
":",
"bool",
":",
"param",
"transformer",
":",
":",
"par... | dc6b79db03ec27a0ba08b289842551e73d517ab3 | https://github.com/combust/mleap/blob/dc6b79db03ec27a0ba08b289842551e73d517ab3/python/mleap/sklearn/tree/tree.py#L102-L141 | train | Serialize the decision tree to a bundle. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
combust/mleap | python/mleap/gensim/word2vec.py | SimpleSparkSerializer.sent2vec | def sent2vec(self, words, transformer):
"""
Used with sqrt kernel
:param words:
:param transformer:
:return:
"""
sent_vec = np.zeros(transformer.vector_size)
numw = 0
for w in words:
try:
sent_vec = np.add(sent_vec, tran... | python | def sent2vec(self, words, transformer):
"""
Used with sqrt kernel
:param words:
:param transformer:
:return:
"""
sent_vec = np.zeros(transformer.vector_size)
numw = 0
for w in words:
try:
sent_vec = np.add(sent_vec, tran... | [
"def",
"sent2vec",
"(",
"self",
",",
"words",
",",
"transformer",
")",
":",
"sent_vec",
"=",
"np",
".",
"zeros",
"(",
"transformer",
".",
"vector_size",
")",
"numw",
"=",
"0",
"for",
"w",
"in",
"words",
":",
"try",
":",
"sent_vec",
"=",
"np",
".",
... | Used with sqrt kernel
:param words:
:param transformer:
:return: | [
"Used",
"with",
"sqrt",
"kernel",
":",
"param",
"words",
":",
":",
"param",
"transformer",
":",
":",
"return",
":"
] | dc6b79db03ec27a0ba08b289842551e73d517ab3 | https://github.com/combust/mleap/blob/dc6b79db03ec27a0ba08b289842551e73d517ab3/python/mleap/gensim/word2vec.py#L85-L100 | train | Used with sqrt kernel
Used with sqrt kernel
| Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
combust/mleap | python/mleap/sklearn/ensemble/forest.py | SimpleSerializer.serialize_to_bundle | def serialize_to_bundle(self, transformer, path, model):
"""
:param transformer: Random Forest Regressor or Classifier
:param path: Root path where to serialize the model
:param model: Name of the model to be serialized
:type transformer: sklearn.ensemble.forest.BaseForest
... | python | def serialize_to_bundle(self, transformer, path, model):
"""
:param transformer: Random Forest Regressor or Classifier
:param path: Root path where to serialize the model
:param model: Name of the model to be serialized
:type transformer: sklearn.ensemble.forest.BaseForest
... | [
"def",
"serialize_to_bundle",
"(",
"self",
",",
"transformer",
",",
"path",
",",
"model",
")",
":",
"# Define Node Inputs and Outputs",
"inputs",
"=",
"[",
"{",
"\"name\"",
":",
"transformer",
".",
"input_features",
",",
"\"port\"",
":",
"\"features\"",
"}",
"]"... | :param transformer: Random Forest Regressor or Classifier
:param path: Root path where to serialize the model
:param model: Name of the model to be serialized
:type transformer: sklearn.ensemble.forest.BaseForest
:type path: str
:type model: str
:return: None | [
":",
"param",
"transformer",
":",
"Random",
"Forest",
"Regressor",
"or",
"Classifier",
":",
"param",
"path",
":",
"Root",
"path",
"where",
"to",
"serialize",
"the",
"model",
":",
"param",
"model",
":",
"Name",
"of",
"the",
"model",
"to",
"be",
"serialized"... | dc6b79db03ec27a0ba08b289842551e73d517ab3 | https://github.com/combust/mleap/blob/dc6b79db03ec27a0ba08b289842551e73d517ab3/python/mleap/sklearn/ensemble/forest.py#L53-L107 | train | This method serializes the model to a sklearn bundle. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
combust/mleap | python/mleap/bundle/serialize.py | MLeapSerializer.get_mleap_model | def get_mleap_model(self, transformer, attributes_to_serialize=None):
"""
Generates the model.json given a list of attributes, which are a tuple comprised of:
- name
- value
Type is figured out automatically, but we should consider specifying it explicitly.
Note: ... | python | def get_mleap_model(self, transformer, attributes_to_serialize=None):
"""
Generates the model.json given a list of attributes, which are a tuple comprised of:
- name
- value
Type is figured out automatically, but we should consider specifying it explicitly.
Note: ... | [
"def",
"get_mleap_model",
"(",
"self",
",",
"transformer",
",",
"attributes_to_serialize",
"=",
"None",
")",
":",
"js",
"=",
"{",
"'op'",
":",
"transformer",
".",
"op",
"}",
"# If the transformer doesn't have any attributes, return just the op name",
"if",
"attributes_t... | Generates the model.json given a list of attributes, which are a tuple comprised of:
- name
- value
Type is figured out automatically, but we should consider specifying it explicitly.
Note: this only supports doubles and tensors that are vectors/lists of doubles.
:param t... | [
"Generates",
"the",
"model",
".",
"json",
"given",
"a",
"list",
"of",
"attributes",
"which",
"are",
"a",
"tuple",
"comprised",
"of",
":",
"-",
"name",
"-",
"value",
"Type",
"is",
"figured",
"out",
"automatically",
"but",
"we",
"should",
"consider",
"specif... | dc6b79db03ec27a0ba08b289842551e73d517ab3 | https://github.com/combust/mleap/blob/dc6b79db03ec27a0ba08b289842551e73d517ab3/python/mleap/bundle/serialize.py#L29-L129 | train | Generates the model. json given a list of attributes which are a tuple comprised of name value. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
combust/mleap | python/mleap/bundle/serialize.py | MLeapDeserializer.deserialize_single_input_output | def deserialize_single_input_output(self, transformer, node_path, attributes_map=None):
"""
:attributes_map: Map of attributes names. For example StandardScaler has `mean_` but is serialized as `mean`
:param transformer: Scikit or Pandas transformer
:param node: bundle.ml node json file
... | python | def deserialize_single_input_output(self, transformer, node_path, attributes_map=None):
"""
:attributes_map: Map of attributes names. For example StandardScaler has `mean_` but is serialized as `mean`
:param transformer: Scikit or Pandas transformer
:param node: bundle.ml node json file
... | [
"def",
"deserialize_single_input_output",
"(",
"self",
",",
"transformer",
",",
"node_path",
",",
"attributes_map",
"=",
"None",
")",
":",
"# Load the model file",
"with",
"open",
"(",
"\"{}/model.json\"",
".",
"format",
"(",
"node_path",
")",
")",
"as",
"json_dat... | :attributes_map: Map of attributes names. For example StandardScaler has `mean_` but is serialized as `mean`
:param transformer: Scikit or Pandas transformer
:param node: bundle.ml node json file
:param model: bundle.ml model json file
:return: Transformer | [
":",
"attributes_map",
":",
"Map",
"of",
"attributes",
"names",
".",
"For",
"example",
"StandardScaler",
"has",
"mean_",
"but",
"is",
"serialized",
"as",
"mean",
":",
"param",
"transformer",
":",
"Scikit",
"or",
"Pandas",
"transformer",
":",
"param",
"node",
... | dc6b79db03ec27a0ba08b289842551e73d517ab3 | https://github.com/combust/mleap/blob/dc6b79db03ec27a0ba08b289842551e73d517ab3/python/mleap/bundle/serialize.py#L187-L219 | train | Deserializes a single input and output transformer. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
openthread/openthread | tools/harness-automation/autothreadharness/harness_case.py | wait_until | def wait_until(what, times=-1):
"""Wait until `what` return True
Args:
what (Callable[bool]): Call `wait()` again and again until it returns True
times (int): Maximum times of trials before giving up
Returns:
True if success, False if times threshold reached
"""
while time... | python | def wait_until(what, times=-1):
"""Wait until `what` return True
Args:
what (Callable[bool]): Call `wait()` again and again until it returns True
times (int): Maximum times of trials before giving up
Returns:
True if success, False if times threshold reached
"""
while time... | [
"def",
"wait_until",
"(",
"what",
",",
"times",
"=",
"-",
"1",
")",
":",
"while",
"times",
":",
"logger",
".",
"info",
"(",
"'Waiting times left %d'",
",",
"times",
")",
"try",
":",
"if",
"what",
"(",
")",
"is",
"True",
":",
"return",
"True",
"except... | Wait until `what` return True
Args:
what (Callable[bool]): Call `wait()` again and again until it returns True
times (int): Maximum times of trials before giving up
Returns:
True if success, False if times threshold reached | [
"Wait",
"until",
"what",
"return",
"True"
] | 0208d10563aa21c518092985c78ecf9cd223ab74 | https://github.com/openthread/openthread/blob/0208d10563aa21c518092985c78ecf9cd223ab74/tools/harness-automation/autothreadharness/harness_case.py#L64-L87 | train | Wait until what returns True. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
openthread/openthread | tools/harness-automation/autothreadharness/harness_case.py | HarnessCase._init_devices | def _init_devices(self):
"""Reboot all usb devices.
Note:
If PDU_CONTROLLER_TYPE is not valid, usb devices is not rebooted.
"""
if not settings.PDU_CONTROLLER_TYPE:
if settings.AUTO_DUT:
return
for device in settings.GOLDEN_DEVICES:
... | python | def _init_devices(self):
"""Reboot all usb devices.
Note:
If PDU_CONTROLLER_TYPE is not valid, usb devices is not rebooted.
"""
if not settings.PDU_CONTROLLER_TYPE:
if settings.AUTO_DUT:
return
for device in settings.GOLDEN_DEVICES:
... | [
"def",
"_init_devices",
"(",
"self",
")",
":",
"if",
"not",
"settings",
".",
"PDU_CONTROLLER_TYPE",
":",
"if",
"settings",
".",
"AUTO_DUT",
":",
"return",
"for",
"device",
"in",
"settings",
".",
"GOLDEN_DEVICES",
":",
"port",
",",
"_",
"=",
"device",
"try"... | Reboot all usb devices.
Note:
If PDU_CONTROLLER_TYPE is not valid, usb devices is not rebooted. | [
"Reboot",
"all",
"usb",
"devices",
"."
] | 0208d10563aa21c518092985c78ecf9cd223ab74 | https://github.com/openthread/openthread/blob/0208d10563aa21c518092985c78ecf9cd223ab74/tools/harness-automation/autothreadharness/harness_case.py#L170-L213 | train | Initialize all usb devices. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
openthread/openthread | tools/harness-automation/autothreadharness/harness_case.py | HarnessCase._init_harness | def _init_harness(self):
"""Restart harness backend service.
Please start the harness controller before running the cases, otherwise, nothing happens
"""
self._hc = HarnessController(self.result_dir)
self._hc.stop()
time.sleep(1)
self._hc.start()
time.sle... | python | def _init_harness(self):
"""Restart harness backend service.
Please start the harness controller before running the cases, otherwise, nothing happens
"""
self._hc = HarnessController(self.result_dir)
self._hc.stop()
time.sleep(1)
self._hc.start()
time.sle... | [
"def",
"_init_harness",
"(",
"self",
")",
":",
"self",
".",
"_hc",
"=",
"HarnessController",
"(",
"self",
".",
"result_dir",
")",
"self",
".",
"_hc",
".",
"stop",
"(",
")",
"time",
".",
"sleep",
"(",
"1",
")",
"self",
".",
"_hc",
".",
"start",
"(",... | Restart harness backend service.
Please start the harness controller before running the cases, otherwise, nothing happens | [
"Restart",
"harness",
"backend",
"service",
"."
] | 0208d10563aa21c518092985c78ecf9cd223ab74 | https://github.com/openthread/openthread/blob/0208d10563aa21c518092985c78ecf9cd223ab74/tools/harness-automation/autothreadharness/harness_case.py#L215-L236 | train | Restart the harness backend service. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
openthread/openthread | tools/harness-automation/autothreadharness/harness_case.py | HarnessCase._init_dut | def _init_dut(self):
"""Initialize the DUT.
DUT will be restarted. and openthread will started.
"""
if self.auto_dut:
self.dut = None
return
dut_port = settings.DUT_DEVICE[0]
dut = OpenThreadController(dut_port)
self.dut = dut | python | def _init_dut(self):
"""Initialize the DUT.
DUT will be restarted. and openthread will started.
"""
if self.auto_dut:
self.dut = None
return
dut_port = settings.DUT_DEVICE[0]
dut = OpenThreadController(dut_port)
self.dut = dut | [
"def",
"_init_dut",
"(",
"self",
")",
":",
"if",
"self",
".",
"auto_dut",
":",
"self",
".",
"dut",
"=",
"None",
"return",
"dut_port",
"=",
"settings",
".",
"DUT_DEVICE",
"[",
"0",
"]",
"dut",
"=",
"OpenThreadController",
"(",
"dut_port",
")",
"self",
"... | Initialize the DUT.
DUT will be restarted. and openthread will started. | [
"Initialize",
"the",
"DUT",
"."
] | 0208d10563aa21c518092985c78ecf9cd223ab74 | https://github.com/openthread/openthread/blob/0208d10563aa21c518092985c78ecf9cd223ab74/tools/harness-automation/autothreadharness/harness_case.py#L246-L257 | train | Initialize the DUT. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
openthread/openthread | tools/harness-automation/autothreadharness/harness_case.py | HarnessCase.setUp | def setUp(self):
"""Prepare to run test case.
Start harness service, init golden devices, reset DUT and open browser.
"""
if self.__class__ is HarnessCase:
return
logger.info('Setting up')
# clear files
logger.info('Deleting all .pdf')
os.sys... | python | def setUp(self):
"""Prepare to run test case.
Start harness service, init golden devices, reset DUT and open browser.
"""
if self.__class__ is HarnessCase:
return
logger.info('Setting up')
# clear files
logger.info('Deleting all .pdf')
os.sys... | [
"def",
"setUp",
"(",
"self",
")",
":",
"if",
"self",
".",
"__class__",
"is",
"HarnessCase",
":",
"return",
"logger",
".",
"info",
"(",
"'Setting up'",
")",
"# clear files",
"logger",
".",
"info",
"(",
"'Deleting all .pdf'",
")",
"os",
".",
"system",
"(",
... | Prepare to run test case.
Start harness service, init golden devices, reset DUT and open browser. | [
"Prepare",
"to",
"run",
"test",
"case",
"."
] | 0208d10563aa21c518092985c78ecf9cd223ab74 | https://github.com/openthread/openthread/blob/0208d10563aa21c518092985c78ecf9cd223ab74/tools/harness-automation/autothreadharness/harness_case.py#L305-L331 | train | Set up the Harness instance. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
openthread/openthread | tools/harness-automation/autothreadharness/harness_case.py | HarnessCase.tearDown | def tearDown(self):
"""Clean up after each case.
Stop harness service, close browser and close DUT.
"""
if self.__class__ is HarnessCase:
return
logger.info('Tearing down')
self._destroy_harness()
self._destroy_browser()
self._destroy_dut()
... | python | def tearDown(self):
"""Clean up after each case.
Stop harness service, close browser and close DUT.
"""
if self.__class__ is HarnessCase:
return
logger.info('Tearing down')
self._destroy_harness()
self._destroy_browser()
self._destroy_dut()
... | [
"def",
"tearDown",
"(",
"self",
")",
":",
"if",
"self",
".",
"__class__",
"is",
"HarnessCase",
":",
"return",
"logger",
".",
"info",
"(",
"'Tearing down'",
")",
"self",
".",
"_destroy_harness",
"(",
")",
"self",
".",
"_destroy_browser",
"(",
")",
"self",
... | Clean up after each case.
Stop harness service, close browser and close DUT. | [
"Clean",
"up",
"after",
"each",
"case",
"."
] | 0208d10563aa21c518092985c78ecf9cd223ab74 | https://github.com/openthread/openthread/blob/0208d10563aa21c518092985c78ecf9cd223ab74/tools/harness-automation/autothreadharness/harness_case.py#L333-L345 | train | Clean up after each case. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
openthread/openthread | tools/harness-automation/autothreadharness/harness_case.py | HarnessCase._setup_page | def _setup_page(self):
"""Do sniffer settings and general settings
"""
if not self.started:
self.started = time.time()
if time.time() - self.started > 5*len(settings.GOLDEN_DEVICES):
self._browser.refresh()
return
# Detect Sniffer
try... | python | def _setup_page(self):
"""Do sniffer settings and general settings
"""
if not self.started:
self.started = time.time()
if time.time() - self.started > 5*len(settings.GOLDEN_DEVICES):
self._browser.refresh()
return
# Detect Sniffer
try... | [
"def",
"_setup_page",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"started",
":",
"self",
".",
"started",
"=",
"time",
".",
"time",
"(",
")",
"if",
"time",
".",
"time",
"(",
")",
"-",
"self",
".",
"started",
">",
"5",
"*",
"len",
"(",
"set... | Do sniffer settings and general settings | [
"Do",
"sniffer",
"settings",
"and",
"general",
"settings"
] | 0208d10563aa21c518092985c78ecf9cd223ab74 | https://github.com/openthread/openthread/blob/0208d10563aa21c518092985c78ecf9cd223ab74/tools/harness-automation/autothreadharness/harness_case.py#L347-L440 | train | Do sniffer settings and general setup | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
openthread/openthread | tools/harness-automation/autothreadharness/harness_case.py | HarnessCase._select_case | def _select_case(self, role, case):
"""Select the test case.
"""
# select the case
elem = Select(self._browser.find_element_by_id('select-dut'))
elem.select_by_value(str(role))
time.sleep(1)
checkbox = None
wait_until(lambda: self._browser.find_elements_b... | python | def _select_case(self, role, case):
"""Select the test case.
"""
# select the case
elem = Select(self._browser.find_element_by_id('select-dut'))
elem.select_by_value(str(role))
time.sleep(1)
checkbox = None
wait_until(lambda: self._browser.find_elements_b... | [
"def",
"_select_case",
"(",
"self",
",",
"role",
",",
"case",
")",
":",
"# select the case",
"elem",
"=",
"Select",
"(",
"self",
".",
"_browser",
".",
"find_element_by_id",
"(",
"'select-dut'",
")",
")",
"elem",
".",
"select_by_value",
"(",
"str",
"(",
"ro... | Select the test case. | [
"Select",
"the",
"test",
"case",
"."
] | 0208d10563aa21c518092985c78ecf9cd223ab74 | https://github.com/openthread/openthread/blob/0208d10563aa21c518092985c78ecf9cd223ab74/tools/harness-automation/autothreadharness/harness_case.py#L642-L676 | train | Select the test case. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
openthread/openthread | tools/harness-automation/autothreadharness/harness_case.py | HarnessCase._collect_result | def _collect_result(self):
"""Collect test result.
Generate PDF, excel and pcap file
"""
# generate pdf
self._browser.find_element_by_class_name('save-pdf').click()
time.sleep(1)
try:
dialog = self._browser.find_element_by_id('Testinfo')
excep... | python | def _collect_result(self):
"""Collect test result.
Generate PDF, excel and pcap file
"""
# generate pdf
self._browser.find_element_by_class_name('save-pdf').click()
time.sleep(1)
try:
dialog = self._browser.find_element_by_id('Testinfo')
excep... | [
"def",
"_collect_result",
"(",
"self",
")",
":",
"# generate pdf",
"self",
".",
"_browser",
".",
"find_element_by_class_name",
"(",
"'save-pdf'",
")",
".",
"click",
"(",
")",
"time",
".",
"sleep",
"(",
"1",
")",
"try",
":",
"dialog",
"=",
"self",
".",
"_... | Collect test result.
Generate PDF, excel and pcap file | [
"Collect",
"test",
"result",
"."
] | 0208d10563aa21c518092985c78ecf9cd223ab74 | https://github.com/openthread/openthread/blob/0208d10563aa21c518092985c78ecf9cd223ab74/tools/harness-automation/autothreadharness/harness_case.py#L678-L729 | train | Collect test result. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
openthread/openthread | tools/harness-automation/autothreadharness/harness_case.py | HarnessCase._wait_dialog | def _wait_dialog(self):
"""Wait for dialogs and handle them until done.
"""
logger.debug('waiting for dialog')
done = False
error = False
logger.info("self timeout %d",self.timeout)
while not done and self.timeout:
try:
dialog = self._... | python | def _wait_dialog(self):
"""Wait for dialogs and handle them until done.
"""
logger.debug('waiting for dialog')
done = False
error = False
logger.info("self timeout %d",self.timeout)
while not done and self.timeout:
try:
dialog = self._... | [
"def",
"_wait_dialog",
"(",
"self",
")",
":",
"logger",
".",
"debug",
"(",
"'waiting for dialog'",
")",
"done",
"=",
"False",
"error",
"=",
"False",
"logger",
".",
"info",
"(",
"\"self timeout %d\"",
",",
"self",
".",
"timeout",
")",
"while",
"not",
"done"... | Wait for dialogs and handle them until done. | [
"Wait",
"for",
"dialogs",
"and",
"handle",
"them",
"until",
"done",
"."
] | 0208d10563aa21c518092985c78ecf9cd223ab74 | https://github.com/openthread/openthread/blob/0208d10563aa21c518092985c78ecf9cd223ab74/tools/harness-automation/autothreadharness/harness_case.py#L731-L790 | train | Wait for dialogs and handle them until done. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
openthread/openthread | tools/harness-automation/autothreadharness/harness_case.py | HarnessCase._handle_dialog | def _handle_dialog(self, dialog, title):
"""Handle a dialog.
Returns:
bool True if no more dialogs expected,
False if more dialogs needed, and
None if not handled
"""
done = self.on_dialog(dialog, title)
if isinstance(done, bool):
... | python | def _handle_dialog(self, dialog, title):
"""Handle a dialog.
Returns:
bool True if no more dialogs expected,
False if more dialogs needed, and
None if not handled
"""
done = self.on_dialog(dialog, title)
if isinstance(done, bool):
... | [
"def",
"_handle_dialog",
"(",
"self",
",",
"dialog",
",",
"title",
")",
":",
"done",
"=",
"self",
".",
"on_dialog",
"(",
"dialog",
",",
"title",
")",
"if",
"isinstance",
"(",
"done",
",",
"bool",
")",
":",
"return",
"done",
"if",
"title",
".",
"start... | Handle a dialog.
Returns:
bool True if no more dialogs expected,
False if more dialogs needed, and
None if not handled | [
"Handle",
"a",
"dialog",
"."
] | 0208d10563aa21c518092985c78ecf9cd223ab74 | https://github.com/openthread/openthread/blob/0208d10563aa21c518092985c78ecf9cd223ab74/tools/harness-automation/autothreadharness/harness_case.py#L792-L918 | train | Handles a dialog. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
openthread/openthread | tools/harness-automation/autothreadharness/runner.py | list_devices | def list_devices(names=None, continue_from=None, **kwargs):
"""List devices in settings file and print versions"""
if not names:
names = [device for device, _type in settings.GOLDEN_DEVICES if _type == 'OpenThread']
if continue_from:
continue_from = names.index(continue_from)
else:
... | python | def list_devices(names=None, continue_from=None, **kwargs):
"""List devices in settings file and print versions"""
if not names:
names = [device for device, _type in settings.GOLDEN_DEVICES if _type == 'OpenThread']
if continue_from:
continue_from = names.index(continue_from)
else:
... | [
"def",
"list_devices",
"(",
"names",
"=",
"None",
",",
"continue_from",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"not",
"names",
":",
"names",
"=",
"[",
"device",
"for",
"device",
",",
"_type",
"in",
"settings",
".",
"GOLDEN_DEVICES",
"if"... | List devices in settings file and print versions | [
"List",
"devices",
"in",
"settings",
"file",
"and",
"print",
"versions"
] | 0208d10563aa21c518092985c78ecf9cd223ab74 | https://github.com/openthread/openthread/blob/0208d10563aa21c518092985c78ecf9cd223ab74/tools/harness-automation/autothreadharness/runner.py#L151-L167 | train | List devices in settings file and print versions | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
openthread/openthread | tools/harness-automation/autothreadharness/runner.py | discover | def discover(names=None, pattern=['*.py'], skip='efp', dry_run=False, blacklist=None, name_greps=None,
manual_reset=False, delete_history=False, max_devices=0,
continue_from=None, result_file='./result.json', auto_reboot=False, keep_explorer=False,
add_all_devices=False):
"""D... | python | def discover(names=None, pattern=['*.py'], skip='efp', dry_run=False, blacklist=None, name_greps=None,
manual_reset=False, delete_history=False, max_devices=0,
continue_from=None, result_file='./result.json', auto_reboot=False, keep_explorer=False,
add_all_devices=False):
"""D... | [
"def",
"discover",
"(",
"names",
"=",
"None",
",",
"pattern",
"=",
"[",
"'*.py'",
"]",
",",
"skip",
"=",
"'efp'",
",",
"dry_run",
"=",
"False",
",",
"blacklist",
"=",
"None",
",",
"name_greps",
"=",
"None",
",",
"manual_reset",
"=",
"False",
",",
"de... | Discover all test cases and skip those passed
Args:
pattern (str): Pattern to match case modules, refer python's unittest
documentation for more details
skip (str): types cases to skip | [
"Discover",
"all",
"test",
"cases",
"and",
"skip",
"those",
"passed"
] | 0208d10563aa21c518092985c78ecf9cd223ab74 | https://github.com/openthread/openthread/blob/0208d10563aa21c518092985c78ecf9cd223ab74/tools/harness-automation/autothreadharness/runner.py#L169-L292 | train | Discover all test cases and skip them | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
openthread/openthread | tools/harness-thci/OpenThread.py | OpenThread._readline | def _readline(self):
"""Read exactly one line from the device
Returns:
None on no data
"""
logging.info('%s: reading line', self.port)
if len(self._lines) > 1:
return self._lines.pop(0)
tail = ''
if len(self._lines):
tail = se... | python | def _readline(self):
"""Read exactly one line from the device
Returns:
None on no data
"""
logging.info('%s: reading line', self.port)
if len(self._lines) > 1:
return self._lines.pop(0)
tail = ''
if len(self._lines):
tail = se... | [
"def",
"_readline",
"(",
"self",
")",
":",
"logging",
".",
"info",
"(",
"'%s: reading line'",
",",
"self",
".",
"port",
")",
"if",
"len",
"(",
"self",
".",
"_lines",
")",
">",
"1",
":",
"return",
"self",
".",
"_lines",
".",
"pop",
"(",
"0",
")",
... | Read exactly one line from the device
Returns:
None on no data | [
"Read",
"exactly",
"one",
"line",
"from",
"the",
"device"
] | 0208d10563aa21c518092985c78ecf9cd223ab74 | https://github.com/openthread/openthread/blob/0208d10563aa21c518092985c78ecf9cd223ab74/tools/harness-thci/OpenThread.py#L129-L151 | train | Read exactly one line from the device returning the first line on success Returns None on no data | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
openthread/openthread | tools/harness-thci/OpenThread.py | OpenThread.__sendCommand | def __sendCommand(self, cmd):
"""send specific command to reference unit over serial port
Args:
cmd: OpenThread CLI string
Returns:
Done: successfully send the command to reference unit and parse it
Value: successfully retrieve the desired value from referen... | python | def __sendCommand(self, cmd):
"""send specific command to reference unit over serial port
Args:
cmd: OpenThread CLI string
Returns:
Done: successfully send the command to reference unit and parse it
Value: successfully retrieve the desired value from referen... | [
"def",
"__sendCommand",
"(",
"self",
",",
"cmd",
")",
":",
"logging",
".",
"info",
"(",
"'%s: sendCommand[%s]'",
",",
"self",
".",
"port",
",",
"cmd",
")",
"if",
"self",
".",
"logThreadStatus",
"==",
"self",
".",
"logStatus",
"[",
"'running'",
"]",
":",
... | send specific command to reference unit over serial port
Args:
cmd: OpenThread CLI string
Returns:
Done: successfully send the command to reference unit and parse it
Value: successfully retrieve the desired value from reference unit
Error: some errors oc... | [
"send",
"specific",
"command",
"to",
"reference",
"unit",
"over",
"serial",
"port"
] | 0208d10563aa21c518092985c78ecf9cd223ab74 | https://github.com/openthread/openthread/blob/0208d10563aa21c518092985c78ecf9cd223ab74/tools/harness-thci/OpenThread.py#L173-L224 | train | send specific command to the OpenThread CLI string and parse the response | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
openthread/openthread | tools/harness-thci/OpenThread.py | OpenThread.__getIp6Address | def __getIp6Address(self, addressType):
"""get specific type of IPv6 address configured on thread device
Args:
addressType: the specific type of IPv6 address
link local: link local unicast IPv6 address that's within one-hop scope
global: global unicast IPv6 address
... | python | def __getIp6Address(self, addressType):
"""get specific type of IPv6 address configured on thread device
Args:
addressType: the specific type of IPv6 address
link local: link local unicast IPv6 address that's within one-hop scope
global: global unicast IPv6 address
... | [
"def",
"__getIp6Address",
"(",
"self",
",",
"addressType",
")",
":",
"addrType",
"=",
"[",
"'link local'",
",",
"'global'",
",",
"'rloc'",
",",
"'mesh EID'",
"]",
"addrs",
"=",
"[",
"]",
"globalAddr",
"=",
"[",
"]",
"linkLocal64Addr",
"=",
"''",
"rlocAddr"... | get specific type of IPv6 address configured on thread device
Args:
addressType: the specific type of IPv6 address
link local: link local unicast IPv6 address that's within one-hop scope
global: global unicast IPv6 address
rloc: mesh local unicast IPv6 address f... | [
"get",
"specific",
"type",
"of",
"IPv6",
"address",
"configured",
"on",
"thread",
"device"
] | 0208d10563aa21c518092985c78ecf9cd223ab74 | https://github.com/openthread/openthread/blob/0208d10563aa21c518092985c78ecf9cd223ab74/tools/harness-thci/OpenThread.py#L226-L281 | train | get specific type of IPv6 address configured on thread device | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
openthread/openthread | tools/harness-thci/OpenThread.py | OpenThread.__convertIp6PrefixStringToIp6Address | def __convertIp6PrefixStringToIp6Address(self, strIp6Prefix):
"""convert IPv6 prefix string to IPv6 dotted-quad format
for example:
2001000000000000 -> 2001::
Args:
strIp6Prefix: IPv6 address string
Returns:
IPv6 address dotted-quad format
... | python | def __convertIp6PrefixStringToIp6Address(self, strIp6Prefix):
"""convert IPv6 prefix string to IPv6 dotted-quad format
for example:
2001000000000000 -> 2001::
Args:
strIp6Prefix: IPv6 address string
Returns:
IPv6 address dotted-quad format
... | [
"def",
"__convertIp6PrefixStringToIp6Address",
"(",
"self",
",",
"strIp6Prefix",
")",
":",
"prefix1",
"=",
"strIp6Prefix",
".",
"rstrip",
"(",
"'L'",
")",
"prefix2",
"=",
"prefix1",
".",
"lstrip",
"(",
"\"0x\"",
")",
"hexPrefix",
"=",
"str",
"(",
"prefix2",
... | convert IPv6 prefix string to IPv6 dotted-quad format
for example:
2001000000000000 -> 2001::
Args:
strIp6Prefix: IPv6 address string
Returns:
IPv6 address dotted-quad format | [
"convert",
"IPv6",
"prefix",
"string",
"to",
"IPv6",
"dotted",
"-",
"quad",
"format",
"for",
"example",
":",
"2001000000000000",
"-",
">",
"2001",
"::"
] | 0208d10563aa21c518092985c78ecf9cd223ab74 | https://github.com/openthread/openthread/blob/0208d10563aa21c518092985c78ecf9cd223ab74/tools/harness-thci/OpenThread.py#L485-L503 | train | convert IPv6 prefix string to IPv6 dotted - quad format | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
openthread/openthread | tools/harness-thci/OpenThread.py | OpenThread.__convertLongToString | def __convertLongToString(self, iValue):
"""convert a long hex integer to string
remove '0x' and 'L' return string
Args:
iValue: long integer in hex format
Returns:
string of this long integer without "0x" and "L"
"""
string = ''
strVa... | python | def __convertLongToString(self, iValue):
"""convert a long hex integer to string
remove '0x' and 'L' return string
Args:
iValue: long integer in hex format
Returns:
string of this long integer without "0x" and "L"
"""
string = ''
strVa... | [
"def",
"__convertLongToString",
"(",
"self",
",",
"iValue",
")",
":",
"string",
"=",
"''",
"strValue",
"=",
"str",
"(",
"hex",
"(",
"iValue",
")",
")",
"string",
"=",
"strValue",
".",
"lstrip",
"(",
"'0x'",
")",
"string",
"=",
"string",
".",
"rstrip",
... | convert a long hex integer to string
remove '0x' and 'L' return string
Args:
iValue: long integer in hex format
Returns:
string of this long integer without "0x" and "L" | [
"convert",
"a",
"long",
"hex",
"integer",
"to",
"string",
"remove",
"0x",
"and",
"L",
"return",
"string"
] | 0208d10563aa21c518092985c78ecf9cd223ab74 | https://github.com/openthread/openthread/blob/0208d10563aa21c518092985c78ecf9cd223ab74/tools/harness-thci/OpenThread.py#L505-L521 | train | convert a long hex integer to string | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
openthread/openthread | tools/harness-thci/OpenThread.py | OpenThread.__convertChannelMask | def __convertChannelMask(self, channelsArray):
"""convert channelsArray to bitmask format
Args:
channelsArray: channel array (i.e. [21, 22])
Returns:
bitmask format corresponding to a given channel array
"""
maskSet = 0
for eachChannel in channe... | python | def __convertChannelMask(self, channelsArray):
"""convert channelsArray to bitmask format
Args:
channelsArray: channel array (i.e. [21, 22])
Returns:
bitmask format corresponding to a given channel array
"""
maskSet = 0
for eachChannel in channe... | [
"def",
"__convertChannelMask",
"(",
"self",
",",
"channelsArray",
")",
":",
"maskSet",
"=",
"0",
"for",
"eachChannel",
"in",
"channelsArray",
":",
"mask",
"=",
"1",
"<<",
"eachChannel",
"maskSet",
"=",
"(",
"maskSet",
"|",
"mask",
")",
"return",
"maskSet"
] | convert channelsArray to bitmask format
Args:
channelsArray: channel array (i.e. [21, 22])
Returns:
bitmask format corresponding to a given channel array | [
"convert",
"channelsArray",
"to",
"bitmask",
"format"
] | 0208d10563aa21c518092985c78ecf9cd223ab74 | https://github.com/openthread/openthread/blob/0208d10563aa21c518092985c78ecf9cd223ab74/tools/harness-thci/OpenThread.py#L563-L578 | train | convert channelsArray to bitmask format corresponding to a given channel array | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
openthread/openthread | tools/harness-automation/autothreadharness/open_thread_controller.py | OpenThreadController._expect | def _expect(self, expected, times=50):
"""Find the `expected` line within `times` trials.
Args:
expected str: the expected string
times int: number of trials
"""
logger.debug('[%s] Expecting [%s]', self.port, expected)
retry_times = 10
wh... | python | def _expect(self, expected, times=50):
"""Find the `expected` line within `times` trials.
Args:
expected str: the expected string
times int: number of trials
"""
logger.debug('[%s] Expecting [%s]', self.port, expected)
retry_times = 10
wh... | [
"def",
"_expect",
"(",
"self",
",",
"expected",
",",
"times",
"=",
"50",
")",
":",
"logger",
".",
"debug",
"(",
"'[%s] Expecting [%s]'",
",",
"self",
".",
"port",
",",
"expected",
")",
"retry_times",
"=",
"10",
"while",
"times",
":",
"if",
"not",
"retr... | Find the `expected` line within `times` trials.
Args:
expected str: the expected string
times int: number of trials | [
"Find",
"the",
"expected",
"line",
"within",
"times",
"trials",
"."
] | 0208d10563aa21c518092985c78ecf9cd223ab74 | https://github.com/openthread/openthread/blob/0208d10563aa21c518092985c78ecf9cd223ab74/tools/harness-automation/autothreadharness/open_thread_controller.py#L123-L147 | train | Find the expected string within times. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
openthread/openthread | tools/harness-automation/autothreadharness/open_thread_controller.py | OpenThreadController._readline | def _readline(self):
"""Read exactly one line from the device, nonblocking.
Returns:
None on no data
"""
if len(self.lines) > 1:
return self.lines.pop(0)
tail = ''
if len(self.lines):
tail = self.lines.pop()
try:
... | python | def _readline(self):
"""Read exactly one line from the device, nonblocking.
Returns:
None on no data
"""
if len(self.lines) > 1:
return self.lines.pop(0)
tail = ''
if len(self.lines):
tail = self.lines.pop()
try:
... | [
"def",
"_readline",
"(",
"self",
")",
":",
"if",
"len",
"(",
"self",
".",
"lines",
")",
">",
"1",
":",
"return",
"self",
".",
"lines",
".",
"pop",
"(",
"0",
")",
"tail",
"=",
"''",
"if",
"len",
"(",
"self",
".",
"lines",
")",
":",
"tail",
"="... | Read exactly one line from the device, nonblocking.
Returns:
None on no data | [
"Read",
"exactly",
"one",
"line",
"from",
"the",
"device",
"nonblocking",
"."
] | 0208d10563aa21c518092985c78ecf9cd223ab74 | https://github.com/openthread/openthread/blob/0208d10563aa21c518092985c78ecf9cd223ab74/tools/harness-automation/autothreadharness/open_thread_controller.py#L149-L170 | train | Read exactly one line from the device nonblocking. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
openthread/openthread | tools/harness-automation/autothreadharness/open_thread_controller.py | OpenThreadController._sendline | def _sendline(self, line):
"""Send exactly one line to the device
Args:
line str: data send to device
"""
self.lines = []
try:
self._read()
except socket.error:
logging.debug('Nothing cleared')
logger.debug('sending [%s]', lin... | python | def _sendline(self, line):
"""Send exactly one line to the device
Args:
line str: data send to device
"""
self.lines = []
try:
self._read()
except socket.error:
logging.debug('Nothing cleared')
logger.debug('sending [%s]', lin... | [
"def",
"_sendline",
"(",
"self",
",",
"line",
")",
":",
"self",
".",
"lines",
"=",
"[",
"]",
"try",
":",
"self",
".",
"_read",
"(",
")",
"except",
"socket",
".",
"error",
":",
"logging",
".",
"debug",
"(",
"'Nothing cleared'",
")",
"logger",
".",
"... | Send exactly one line to the device
Args:
line str: data send to device | [
"Send",
"exactly",
"one",
"line",
"to",
"the",
"device"
] | 0208d10563aa21c518092985c78ecf9cd223ab74 | https://github.com/openthread/openthread/blob/0208d10563aa21c518092985c78ecf9cd223ab74/tools/harness-automation/autothreadharness/open_thread_controller.py#L172-L188 | train | Send exactly one line to the device | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
openthread/openthread | tools/harness-automation/autothreadharness/open_thread_controller.py | OpenThreadController._req | def _req(self, req):
"""Send command and wait for response.
The command will be repeated 3 times at most in case data loss of serial port.
Args:
req (str): Command to send, please do not include new line in the end.
Returns:
[str]: The output lines
"""
... | python | def _req(self, req):
"""Send command and wait for response.
The command will be repeated 3 times at most in case data loss of serial port.
Args:
req (str): Command to send, please do not include new line in the end.
Returns:
[str]: The output lines
"""
... | [
"def",
"_req",
"(",
"self",
",",
"req",
")",
":",
"logger",
".",
"debug",
"(",
"'DUT> %s'",
",",
"req",
")",
"self",
".",
"_log",
"and",
"self",
".",
"pause",
"(",
")",
"times",
"=",
"3",
"res",
"=",
"None",
"while",
"times",
":",
"times",
"=",
... | Send command and wait for response.
The command will be repeated 3 times at most in case data loss of serial port.
Args:
req (str): Command to send, please do not include new line in the end.
Returns:
[str]: The output lines | [
"Send",
"command",
"and",
"wait",
"for",
"response",
"."
] | 0208d10563aa21c518092985c78ecf9cd223ab74 | https://github.com/openthread/openthread/blob/0208d10563aa21c518092985c78ecf9cd223ab74/tools/harness-automation/autothreadharness/open_thread_controller.py#L190-L232 | train | Send command and wait for response. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
openthread/openthread | tools/harness-automation/autothreadharness/open_thread_controller.py | OpenThreadController.run | def run(self):
"""Threading callback"""
self.viewing = True
while self.viewing and self._lock.acquire():
try:
line = self._readline()
except:
pass
else:
logger.info(line)
self._lock.release()
... | python | def run(self):
"""Threading callback"""
self.viewing = True
while self.viewing and self._lock.acquire():
try:
line = self._readline()
except:
pass
else:
logger.info(line)
self._lock.release()
... | [
"def",
"run",
"(",
"self",
")",
":",
"self",
".",
"viewing",
"=",
"True",
"while",
"self",
".",
"viewing",
"and",
"self",
".",
"_lock",
".",
"acquire",
"(",
")",
":",
"try",
":",
"line",
"=",
"self",
".",
"_readline",
"(",
")",
"except",
":",
"pa... | Threading callback | [
"Threading",
"callback"
] | 0208d10563aa21c518092985c78ecf9cd223ab74 | https://github.com/openthread/openthread/blob/0208d10563aa21c518092985c78ecf9cd223ab74/tools/harness-automation/autothreadharness/open_thread_controller.py#L234-L246 | train | Threading callback | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
openthread/openthread | tools/harness-automation/autothreadharness/open_thread_controller.py | OpenThreadController.reset | def reset(self):
"""Reset openthread device, not equivalent to stop and start
"""
logger.debug('DUT> reset')
self._log and self.pause()
self._sendline('reset')
self._read()
self._log and self.resume() | python | def reset(self):
"""Reset openthread device, not equivalent to stop and start
"""
logger.debug('DUT> reset')
self._log and self.pause()
self._sendline('reset')
self._read()
self._log and self.resume() | [
"def",
"reset",
"(",
"self",
")",
":",
"logger",
".",
"debug",
"(",
"'DUT> reset'",
")",
"self",
".",
"_log",
"and",
"self",
".",
"pause",
"(",
")",
"self",
".",
"_sendline",
"(",
"'reset'",
")",
"self",
".",
"_read",
"(",
")",
"self",
".",
"_log",... | Reset openthread device, not equivalent to stop and start | [
"Reset",
"openthread",
"device",
"not",
"equivalent",
"to",
"stop",
"and",
"start"
] | 0208d10563aa21c518092985c78ecf9cd223ab74 | https://github.com/openthread/openthread/blob/0208d10563aa21c518092985c78ecf9cd223ab74/tools/harness-automation/autothreadharness/open_thread_controller.py#L269-L276 | train | Reset the openthread device not equivalent to stop and start | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
openthread/openthread | tools/harness-automation/autothreadharness/open_thread_controller.py | OpenThreadController.add_prefix | def add_prefix(self, prefix, flags, prf):
"""Add network prefix.
Args:
prefix (str): network prefix.
flags (str): network prefix flags, please refer thread documentation for details
prf (str): network prf, please refer thread documentation for details
"""
... | python | def add_prefix(self, prefix, flags, prf):
"""Add network prefix.
Args:
prefix (str): network prefix.
flags (str): network prefix flags, please refer thread documentation for details
prf (str): network prf, please refer thread documentation for details
"""
... | [
"def",
"add_prefix",
"(",
"self",
",",
"prefix",
",",
"flags",
",",
"prf",
")",
":",
"self",
".",
"_req",
"(",
"'prefix add %s %s %s'",
"%",
"(",
"prefix",
",",
"flags",
",",
"prf",
")",
")",
"time",
".",
"sleep",
"(",
"1",
")",
"self",
".",
"_req"... | Add network prefix.
Args:
prefix (str): network prefix.
flags (str): network prefix flags, please refer thread documentation for details
prf (str): network prf, please refer thread documentation for details | [
"Add",
"network",
"prefix",
"."
] | 0208d10563aa21c518092985c78ecf9cd223ab74 | https://github.com/openthread/openthread/blob/0208d10563aa21c518092985c78ecf9cd223ab74/tools/harness-automation/autothreadharness/open_thread_controller.py#L360-L370 | train | Add a network prefix. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
openthread/openthread | tools/harness-automation/autothreadharness/open_thread_controller.py | OpenThreadController.remove_prefix | def remove_prefix(self, prefix):
"""Remove network prefix.
"""
self._req('prefix remove %s' % prefix)
time.sleep(1)
self._req('netdataregister') | python | def remove_prefix(self, prefix):
"""Remove network prefix.
"""
self._req('prefix remove %s' % prefix)
time.sleep(1)
self._req('netdataregister') | [
"def",
"remove_prefix",
"(",
"self",
",",
"prefix",
")",
":",
"self",
".",
"_req",
"(",
"'prefix remove %s'",
"%",
"prefix",
")",
"time",
".",
"sleep",
"(",
"1",
")",
"self",
".",
"_req",
"(",
"'netdataregister'",
")"
] | Remove network prefix. | [
"Remove",
"network",
"prefix",
"."
] | 0208d10563aa21c518092985c78ecf9cd223ab74 | https://github.com/openthread/openthread/blob/0208d10563aa21c518092985c78ecf9cd223ab74/tools/harness-automation/autothreadharness/open_thread_controller.py#L372-L377 | train | Remove network prefix. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
openthread/openthread | tools/harness-automation/autothreadharness/pdu_controller.py | ApcPduController._init | def _init(self):
"""Initialize the telnet connection
"""
self.tn = telnetlib.Telnet(self.ip, self.port)
self.tn.read_until('User Name')
self.tn.write('apc\r\n')
self.tn.read_until('Password')
self.tn.write('apc\r\n')
self.until_done() | python | def _init(self):
"""Initialize the telnet connection
"""
self.tn = telnetlib.Telnet(self.ip, self.port)
self.tn.read_until('User Name')
self.tn.write('apc\r\n')
self.tn.read_until('Password')
self.tn.write('apc\r\n')
self.until_done() | [
"def",
"_init",
"(",
"self",
")",
":",
"self",
".",
"tn",
"=",
"telnetlib",
".",
"Telnet",
"(",
"self",
".",
"ip",
",",
"self",
".",
"port",
")",
"self",
".",
"tn",
".",
"read_until",
"(",
"'User Name'",
")",
"self",
".",
"tn",
".",
"write",
"(",... | Initialize the telnet connection | [
"Initialize",
"the",
"telnet",
"connection"
] | 0208d10563aa21c518092985c78ecf9cd223ab74 | https://github.com/openthread/openthread/blob/0208d10563aa21c518092985c78ecf9cd223ab74/tools/harness-automation/autothreadharness/pdu_controller.py#L82-L90 | train | Initialize the telnet connection | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
openthread/openthread | tools/harness-automation/autothreadharness/pdu_controller.py | ApcPduController.open | def open(self, **params):
"""Open telnet connection
Args:
params (dict), must contain two parameters "ip" - ip address or hostname and "port" - port number
Example:
params = {'port': 23, 'ip': 'localhost'}
"""
logger.info('opening telnet')
self.p... | python | def open(self, **params):
"""Open telnet connection
Args:
params (dict), must contain two parameters "ip" - ip address or hostname and "port" - port number
Example:
params = {'port': 23, 'ip': 'localhost'}
"""
logger.info('opening telnet')
self.p... | [
"def",
"open",
"(",
"self",
",",
"*",
"*",
"params",
")",
":",
"logger",
".",
"info",
"(",
"'opening telnet'",
")",
"self",
".",
"port",
"=",
"params",
"[",
"'port'",
"]",
"self",
".",
"ip",
"=",
"params",
"[",
"'ip'",
"]",
"self",
".",
"tn",
"="... | Open telnet connection
Args:
params (dict), must contain two parameters "ip" - ip address or hostname and "port" - port number
Example:
params = {'port': 23, 'ip': 'localhost'} | [
"Open",
"telnet",
"connection"
] | 0208d10563aa21c518092985c78ecf9cd223ab74 | https://github.com/openthread/openthread/blob/0208d10563aa21c518092985c78ecf9cd223ab74/tools/harness-automation/autothreadharness/pdu_controller.py#L92-L105 | train | Open a new telnet connection | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
openthread/openthread | tools/harness-automation/autothreadharness/pdu_controller.py | ApcPduController.until | def until(self, regex):
"""Wait until the regex encountered
"""
logger.debug('waiting for %s', regex)
r = re.compile(regex, re.M)
self.tn.expect([r]) | python | def until(self, regex):
"""Wait until the regex encountered
"""
logger.debug('waiting for %s', regex)
r = re.compile(regex, re.M)
self.tn.expect([r]) | [
"def",
"until",
"(",
"self",
",",
"regex",
")",
":",
"logger",
".",
"debug",
"(",
"'waiting for %s'",
",",
"regex",
")",
"r",
"=",
"re",
".",
"compile",
"(",
"regex",
",",
"re",
".",
"M",
")",
"self",
".",
"tn",
".",
"expect",
"(",
"[",
"r",
"]... | Wait until the regex encountered | [
"Wait",
"until",
"the",
"regex",
"encountered"
] | 0208d10563aa21c518092985c78ecf9cd223ab74 | https://github.com/openthread/openthread/blob/0208d10563aa21c518092985c78ecf9cd223ab74/tools/harness-automation/autothreadharness/pdu_controller.py#L118-L123 | train | Wait until the regex encountered
| Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
openthread/openthread | tools/harness-automation/autothreadharness/pdu_controller.py | ApcPduController.reboot | def reboot(self, **params):
"""Reboot outlet
Args:
params (dict), must contain parameter "outlet" - outlet number
Example:
params = {'outlet': 1}
"""
outlet = params['outlet']
# main menu
self.tn.write('\x1b\r\n')
self.until_done... | python | def reboot(self, **params):
"""Reboot outlet
Args:
params (dict), must contain parameter "outlet" - outlet number
Example:
params = {'outlet': 1}
"""
outlet = params['outlet']
# main menu
self.tn.write('\x1b\r\n')
self.until_done... | [
"def",
"reboot",
"(",
"self",
",",
"*",
"*",
"params",
")",
":",
"outlet",
"=",
"params",
"[",
"'outlet'",
"]",
"# main menu",
"self",
".",
"tn",
".",
"write",
"(",
"'\\x1b\\r\\n'",
")",
"self",
".",
"until_done",
"(",
")",
"# Device Manager",
"self",
... | Reboot outlet
Args:
params (dict), must contain parameter "outlet" - outlet number
Example:
params = {'outlet': 1} | [
"Reboot",
"outlet"
] | 0208d10563aa21c518092985c78ecf9cd223ab74 | https://github.com/openthread/openthread/blob/0208d10563aa21c518092985c78ecf9cd223ab74/tools/harness-automation/autothreadharness/pdu_controller.py#L125-L169 | train | Reboot the outlet of the current instance. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
openthread/openthread | tools/harness-thci/OpenThread_WpanCtl.py | OpenThread_WpanCtl.__stripValue | def __stripValue(self, value):
"""strip the special characters in the value
Args:
value: value string
Returns:
value string without special characters
"""
if isinstance(value, str):
if ( value[0] == '"' and val... | python | def __stripValue(self, value):
"""strip the special characters in the value
Args:
value: value string
Returns:
value string without special characters
"""
if isinstance(value, str):
if ( value[0] == '"' and val... | [
"def",
"__stripValue",
"(",
"self",
",",
"value",
")",
":",
"if",
"isinstance",
"(",
"value",
",",
"str",
")",
":",
"if",
"(",
"value",
"[",
"0",
"]",
"==",
"'\"'",
"and",
"value",
"[",
"-",
"1",
"]",
"==",
"'\"'",
")",
"or",
"(",
"value",
"[",... | strip the special characters in the value
Args:
value: value string
Returns:
value string without special characters | [
"strip",
"the",
"special",
"characters",
"in",
"the",
"value"
] | 0208d10563aa21c518092985c78ecf9cd223ab74 | https://github.com/openthread/openthread/blob/0208d10563aa21c518092985c78ecf9cd223ab74/tools/harness-thci/OpenThread_WpanCtl.py#L273-L285 | train | strip the special characters in the value
COOKIENAME | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
openthread/openthread | tools/harness-thci/OpenThread_WpanCtl.py | OpenThread_WpanCtl.__getJoinerState | def __getJoinerState(self):
""" get joiner state """
maxDuration = 150 # seconds
t_end = time.time() + maxDuration
while time.time() < t_end:
joinerState = self.__stripValue(self.__sendCommand('sudo wpanctl getprop -v NCP:State')[0])
if joinerState == 'offline:co... | python | def __getJoinerState(self):
""" get joiner state """
maxDuration = 150 # seconds
t_end = time.time() + maxDuration
while time.time() < t_end:
joinerState = self.__stripValue(self.__sendCommand('sudo wpanctl getprop -v NCP:State')[0])
if joinerState == 'offline:co... | [
"def",
"__getJoinerState",
"(",
"self",
")",
":",
"maxDuration",
"=",
"150",
"# seconds",
"t_end",
"=",
"time",
".",
"time",
"(",
")",
"+",
"maxDuration",
"while",
"time",
".",
"time",
"(",
")",
"<",
"t_end",
":",
"joinerState",
"=",
"self",
".",
"__st... | get joiner state | [
"get",
"joiner",
"state"
] | 0208d10563aa21c518092985c78ecf9cd223ab74 | https://github.com/openthread/openthread/blob/0208d10563aa21c518092985c78ecf9cd223ab74/tools/harness-thci/OpenThread_WpanCtl.py#L727-L740 | train | get joiner state | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
nornir-automation/nornir | nornir/core/task.py | Task.start | def start(self, host, nornir):
"""
Run the task for the given host.
Arguments:
host (:obj:`nornir.core.inventory.Host`): Host we are operating with. Populated right
before calling the ``task``
nornir(:obj:`nornir.core.Nornir`): Populated right before callin... | python | def start(self, host, nornir):
"""
Run the task for the given host.
Arguments:
host (:obj:`nornir.core.inventory.Host`): Host we are operating with. Populated right
before calling the ``task``
nornir(:obj:`nornir.core.Nornir`): Populated right before callin... | [
"def",
"start",
"(",
"self",
",",
"host",
",",
"nornir",
")",
":",
"self",
".",
"host",
"=",
"host",
"self",
".",
"nornir",
"=",
"nornir",
"try",
":",
"logger",
".",
"debug",
"(",
"\"Host %r: running task %r\"",
",",
"self",
".",
"host",
".",
"name",
... | Run the task for the given host.
Arguments:
host (:obj:`nornir.core.inventory.Host`): Host we are operating with. Populated right
before calling the ``task``
nornir(:obj:`nornir.core.Nornir`): Populated right before calling
the ``task``
Returns:
... | [
"Run",
"the",
"task",
"for",
"the",
"given",
"host",
"."
] | 3425c47fd870db896cb80f619bae23bd98d50c74 | https://github.com/nornir-automation/nornir/blob/3425c47fd870db896cb80f619bae23bd98d50c74/nornir/core/task.py#L49-L95 | train | Starts the task for the given host and returns a list of the results and the subtasks that were executed. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
nornir-automation/nornir | nornir/core/task.py | Task.run | def run(self, task, **kwargs):
"""
This is a utility method to call a task from within a task. For instance:
def grouped_tasks(task):
task.run(my_first_task)
task.run(my_second_task)
nornir.run(grouped_tasks)
This method will ensure the ... | python | def run(self, task, **kwargs):
"""
This is a utility method to call a task from within a task. For instance:
def grouped_tasks(task):
task.run(my_first_task)
task.run(my_second_task)
nornir.run(grouped_tasks)
This method will ensure the ... | [
"def",
"run",
"(",
"self",
",",
"task",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"not",
"self",
".",
"host",
"or",
"not",
"self",
".",
"nornir",
":",
"msg",
"=",
"(",
"\"You have to call this after setting host and nornir attributes. \"",
",",
"\"You probably ... | This is a utility method to call a task from within a task. For instance:
def grouped_tasks(task):
task.run(my_first_task)
task.run(my_second_task)
nornir.run(grouped_tasks)
This method will ensure the subtask is run only for the host in the current thr... | [
"This",
"is",
"a",
"utility",
"method",
"to",
"call",
"a",
"task",
"from",
"within",
"a",
"task",
".",
"For",
"instance",
":"
] | 3425c47fd870db896cb80f619bae23bd98d50c74 | https://github.com/nornir-automation/nornir/blob/3425c47fd870db896cb80f619bae23bd98d50c74/nornir/core/task.py#L97-L126 | train | This method runs a task from within a task. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
nornir-automation/nornir | nornir/core/task.py | Task.is_dry_run | def is_dry_run(self, override: bool = None) -> bool:
"""
Returns whether current task is a dry_run or not.
"""
return override if override is not None else self.nornir.data.dry_run | python | def is_dry_run(self, override: bool = None) -> bool:
"""
Returns whether current task is a dry_run or not.
"""
return override if override is not None else self.nornir.data.dry_run | [
"def",
"is_dry_run",
"(",
"self",
",",
"override",
":",
"bool",
"=",
"None",
")",
"->",
"bool",
":",
"return",
"override",
"if",
"override",
"is",
"not",
"None",
"else",
"self",
".",
"nornir",
".",
"data",
".",
"dry_run"
] | Returns whether current task is a dry_run or not. | [
"Returns",
"whether",
"current",
"task",
"is",
"a",
"dry_run",
"or",
"not",
"."
] | 3425c47fd870db896cb80f619bae23bd98d50c74 | https://github.com/nornir-automation/nornir/blob/3425c47fd870db896cb80f619bae23bd98d50c74/nornir/core/task.py#L128-L132 | train | Returns whether the current task is a dry_run or not. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
nornir-automation/nornir | nornir/core/task.py | AggregatedResult.failed_hosts | def failed_hosts(self):
"""Hosts that failed during the execution of the task."""
return {h: r for h, r in self.items() if r.failed} | python | def failed_hosts(self):
"""Hosts that failed during the execution of the task."""
return {h: r for h, r in self.items() if r.failed} | [
"def",
"failed_hosts",
"(",
"self",
")",
":",
"return",
"{",
"h",
":",
"r",
"for",
"h",
",",
"r",
"in",
"self",
".",
"items",
"(",
")",
"if",
"r",
".",
"failed",
"}"
] | Hosts that failed during the execution of the task. | [
"Hosts",
"that",
"failed",
"during",
"the",
"execution",
"of",
"the",
"task",
"."
] | 3425c47fd870db896cb80f619bae23bd98d50c74 | https://github.com/nornir-automation/nornir/blob/3425c47fd870db896cb80f619bae23bd98d50c74/nornir/core/task.py#L216-L218 | train | Returns a dict of hosts that failed during the execution of the task. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
nornir-automation/nornir | nornir/plugins/tasks/networking/napalm_validate.py | napalm_validate | def napalm_validate(
task: Task,
src: Optional[str] = None,
validation_source: ValidationSourceData = None,
) -> Result:
"""
Gather information with napalm and validate it:
http://napalm.readthedocs.io/en/develop/validate/index.html
Arguments:
src: file to use as validation sou... | python | def napalm_validate(
task: Task,
src: Optional[str] = None,
validation_source: ValidationSourceData = None,
) -> Result:
"""
Gather information with napalm and validate it:
http://napalm.readthedocs.io/en/develop/validate/index.html
Arguments:
src: file to use as validation sou... | [
"def",
"napalm_validate",
"(",
"task",
":",
"Task",
",",
"src",
":",
"Optional",
"[",
"str",
"]",
"=",
"None",
",",
"validation_source",
":",
"ValidationSourceData",
"=",
"None",
",",
")",
"->",
"Result",
":",
"device",
"=",
"task",
".",
"host",
".",
"... | Gather information with napalm and validate it:
http://napalm.readthedocs.io/en/develop/validate/index.html
Arguments:
src: file to use as validation source
validation_source (list): data to validate device's state
Returns:
Result object with the following attributes set:
... | [
"Gather",
"information",
"with",
"napalm",
"and",
"validate",
"it",
":"
] | 3425c47fd870db896cb80f619bae23bd98d50c74 | https://github.com/nornir-automation/nornir/blob/3425c47fd870db896cb80f619bae23bd98d50c74/nornir/plugins/tasks/networking/napalm_validate.py#L8-L31 | train | Gather information with napalm and validate it | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
nornir-automation/nornir | nornir/plugins/tasks/networking/netmiko_save_config.py | netmiko_save_config | def netmiko_save_config(
task: Task, cmd: str = "", confirm: bool = False, confirm_response: str = ""
) -> Result:
"""
Execute Netmiko save_config method
Arguments:
cmd(str, optional): Command used to save the configuration.
confirm(bool, optional): Does device prompt for confirmation be... | python | def netmiko_save_config(
task: Task, cmd: str = "", confirm: bool = False, confirm_response: str = ""
) -> Result:
"""
Execute Netmiko save_config method
Arguments:
cmd(str, optional): Command used to save the configuration.
confirm(bool, optional): Does device prompt for confirmation be... | [
"def",
"netmiko_save_config",
"(",
"task",
":",
"Task",
",",
"cmd",
":",
"str",
"=",
"\"\"",
",",
"confirm",
":",
"bool",
"=",
"False",
",",
"confirm_response",
":",
"str",
"=",
"\"\"",
")",
"->",
"Result",
":",
"conn",
"=",
"task",
".",
"host",
".",... | Execute Netmiko save_config method
Arguments:
cmd(str, optional): Command used to save the configuration.
confirm(bool, optional): Does device prompt for confirmation before executing save operation
confirm_response(str, optional): Response send to device when it prompts for confirmation
... | [
"Execute",
"Netmiko",
"save_config",
"method",
"Arguments",
":",
"cmd",
"(",
"str",
"optional",
")",
":",
"Command",
"used",
"to",
"save",
"the",
"configuration",
".",
"confirm",
"(",
"bool",
"optional",
")",
":",
"Does",
"device",
"prompt",
"for",
"confirma... | 3425c47fd870db896cb80f619bae23bd98d50c74 | https://github.com/nornir-automation/nornir/blob/3425c47fd870db896cb80f619bae23bd98d50c74/nornir/plugins/tasks/networking/netmiko_save_config.py#L6-L27 | train | Execute Netmiko save_config method on the node with optional command | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
nornir-automation/nornir | nornir/plugins/tasks/networking/netmiko_send_command.py | netmiko_send_command | def netmiko_send_command(
task: Task,
command_string: str,
use_timing: bool = False,
enable: bool = False,
**kwargs: Any
) -> Result:
"""
Execute Netmiko send_command method (or send_command_timing)
Arguments:
command_string: Command to execute on the remote network device.
... | python | def netmiko_send_command(
task: Task,
command_string: str,
use_timing: bool = False,
enable: bool = False,
**kwargs: Any
) -> Result:
"""
Execute Netmiko send_command method (or send_command_timing)
Arguments:
command_string: Command to execute on the remote network device.
... | [
"def",
"netmiko_send_command",
"(",
"task",
":",
"Task",
",",
"command_string",
":",
"str",
",",
"use_timing",
":",
"bool",
"=",
"False",
",",
"enable",
":",
"bool",
"=",
"False",
",",
"*",
"*",
"kwargs",
":",
"Any",
")",
"->",
"Result",
":",
"net_conn... | Execute Netmiko send_command method (or send_command_timing)
Arguments:
command_string: Command to execute on the remote network device.
use_timing: Set to True to switch to send_command_timing method.
enable: Set to True to force Netmiko .enable() call.
kwargs: Additional arguments... | [
"Execute",
"Netmiko",
"send_command",
"method",
"(",
"or",
"send_command_timing",
")"
] | 3425c47fd870db896cb80f619bae23bd98d50c74 | https://github.com/nornir-automation/nornir/blob/3425c47fd870db896cb80f619bae23bd98d50c74/nornir/plugins/tasks/networking/netmiko_send_command.py#L6-L33 | train | Execute a Netmiko command on the remote network device. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
nornir-automation/nornir | nornir/core/inventory.py | Host.has_parent_group | def has_parent_group(self, group):
"""Retuns whether the object is a child of the :obj:`Group` ``group``"""
if isinstance(group, str):
return self._has_parent_group_by_name(group)
else:
return self._has_parent_group_by_object(group) | python | def has_parent_group(self, group):
"""Retuns whether the object is a child of the :obj:`Group` ``group``"""
if isinstance(group, str):
return self._has_parent_group_by_name(group)
else:
return self._has_parent_group_by_object(group) | [
"def",
"has_parent_group",
"(",
"self",
",",
"group",
")",
":",
"if",
"isinstance",
"(",
"group",
",",
"str",
")",
":",
"return",
"self",
".",
"_has_parent_group_by_name",
"(",
"group",
")",
"else",
":",
"return",
"self",
".",
"_has_parent_group_by_object",
... | Retuns whether the object is a child of the :obj:`Group` ``group`` | [
"Retuns",
"whether",
"the",
"object",
"is",
"a",
"child",
"of",
"the",
":",
"obj",
":",
"Group",
"group"
] | 3425c47fd870db896cb80f619bae23bd98d50c74 | https://github.com/nornir-automation/nornir/blob/3425c47fd870db896cb80f619bae23bd98d50c74/nornir/core/inventory.py#L130-L136 | train | Retuns whether the object is a child of the group. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
nornir-automation/nornir | nornir/core/inventory.py | Host.get | def get(self, item, default=None):
"""
Returns the value ``item`` from the host or hosts group variables.
Arguments:
item(``str``): The variable to get
default(``any``): Return value if item not found
"""
if hasattr(self, item):
return getattr... | python | def get(self, item, default=None):
"""
Returns the value ``item`` from the host or hosts group variables.
Arguments:
item(``str``): The variable to get
default(``any``): Return value if item not found
"""
if hasattr(self, item):
return getattr... | [
"def",
"get",
"(",
"self",
",",
"item",
",",
"default",
"=",
"None",
")",
":",
"if",
"hasattr",
"(",
"self",
",",
"item",
")",
":",
"return",
"getattr",
"(",
"self",
",",
"item",
")",
"try",
":",
"return",
"self",
".",
"__getitem__",
"(",
"item",
... | Returns the value ``item`` from the host or hosts group variables.
Arguments:
item(``str``): The variable to get
default(``any``): Return value if item not found | [
"Returns",
"the",
"value",
"item",
"from",
"the",
"host",
"or",
"hosts",
"group",
"variables",
"."
] | 3425c47fd870db896cb80f619bae23bd98d50c74 | https://github.com/nornir-automation/nornir/blob/3425c47fd870db896cb80f619bae23bd98d50c74/nornir/core/inventory.py#L198-L212 | train | Returns the value of the given item from the host or hosts group variables. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
nornir-automation/nornir | nornir/core/inventory.py | Host.get_connection | def get_connection(self, connection: str, configuration: Config) -> Any:
"""
The function of this method is twofold:
1. If an existing connection is already established for the given type return it
2. If none exists, establish a new connection of that type with default parameter... | python | def get_connection(self, connection: str, configuration: Config) -> Any:
"""
The function of this method is twofold:
1. If an existing connection is already established for the given type return it
2. If none exists, establish a new connection of that type with default parameter... | [
"def",
"get_connection",
"(",
"self",
",",
"connection",
":",
"str",
",",
"configuration",
":",
"Config",
")",
"->",
"Any",
":",
"if",
"connection",
"not",
"in",
"self",
".",
"connections",
":",
"conn",
"=",
"self",
".",
"get_connection_parameters",
"(",
"... | The function of this method is twofold:
1. If an existing connection is already established for the given type return it
2. If none exists, establish a new connection of that type with default parameters
and return it
Raises:
AttributeError: if it's unknown h... | [
"The",
"function",
"of",
"this",
"method",
"is",
"twofold",
":"
] | 3425c47fd870db896cb80f619bae23bd98d50c74 | https://github.com/nornir-automation/nornir/blob/3425c47fd870db896cb80f619bae23bd98d50c74/nornir/core/inventory.py#L275-L304 | train | Returns an existing connection for the given connection type. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
nornir-automation/nornir | nornir/core/inventory.py | Host.get_connection_state | def get_connection_state(self, connection: str) -> Dict[str, Any]:
"""
For an already established connection return its state.
"""
if connection not in self.connections:
raise ConnectionNotOpen(connection)
return self.connections[connection].state | python | def get_connection_state(self, connection: str) -> Dict[str, Any]:
"""
For an already established connection return its state.
"""
if connection not in self.connections:
raise ConnectionNotOpen(connection)
return self.connections[connection].state | [
"def",
"get_connection_state",
"(",
"self",
",",
"connection",
":",
"str",
")",
"->",
"Dict",
"[",
"str",
",",
"Any",
"]",
":",
"if",
"connection",
"not",
"in",
"self",
".",
"connections",
":",
"raise",
"ConnectionNotOpen",
"(",
"connection",
")",
"return"... | For an already established connection return its state. | [
"For",
"an",
"already",
"established",
"connection",
"return",
"its",
"state",
"."
] | 3425c47fd870db896cb80f619bae23bd98d50c74 | https://github.com/nornir-automation/nornir/blob/3425c47fd870db896cb80f619bae23bd98d50c74/nornir/core/inventory.py#L306-L313 | train | Get the state of a connection. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
nornir-automation/nornir | nornir/core/inventory.py | Host.open_connection | def open_connection(
self,
connection: str,
configuration: Config,
hostname: Optional[str] = None,
username: Optional[str] = None,
password: Optional[str] = None,
port: Optional[int] = None,
platform: Optional[str] = None,
extras: Optional[Dict[str... | python | def open_connection(
self,
connection: str,
configuration: Config,
hostname: Optional[str] = None,
username: Optional[str] = None,
password: Optional[str] = None,
port: Optional[int] = None,
platform: Optional[str] = None,
extras: Optional[Dict[str... | [
"def",
"open_connection",
"(",
"self",
",",
"connection",
":",
"str",
",",
"configuration",
":",
"Config",
",",
"hostname",
":",
"Optional",
"[",
"str",
"]",
"=",
"None",
",",
"username",
":",
"Optional",
"[",
"str",
"]",
"=",
"None",
",",
"password",
... | Open a new connection.
If ``default_to_host_attributes`` is set to ``True`` arguments will default to host
attributes if not specified.
Raises:
AttributeError: if it's unknown how to establish a connection for the given type
Returns:
An already established conn... | [
"Open",
"a",
"new",
"connection",
"."
] | 3425c47fd870db896cb80f619bae23bd98d50c74 | https://github.com/nornir-automation/nornir/blob/3425c47fd870db896cb80f619bae23bd98d50c74/nornir/core/inventory.py#L315-L364 | train | Open a new connection. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
nornir-automation/nornir | nornir/core/inventory.py | Host.close_connection | def close_connection(self, connection: str) -> None:
""" Close the connection"""
if connection not in self.connections:
raise ConnectionNotOpen(connection)
self.connections.pop(connection).close() | python | def close_connection(self, connection: str) -> None:
""" Close the connection"""
if connection not in self.connections:
raise ConnectionNotOpen(connection)
self.connections.pop(connection).close() | [
"def",
"close_connection",
"(",
"self",
",",
"connection",
":",
"str",
")",
"->",
"None",
":",
"if",
"connection",
"not",
"in",
"self",
".",
"connections",
":",
"raise",
"ConnectionNotOpen",
"(",
"connection",
")",
"self",
".",
"connections",
".",
"pop",
"... | Close the connection | [
"Close",
"the",
"connection"
] | 3425c47fd870db896cb80f619bae23bd98d50c74 | https://github.com/nornir-automation/nornir/blob/3425c47fd870db896cb80f619bae23bd98d50c74/nornir/core/inventory.py#L366-L371 | train | Close the connection. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
nornir-automation/nornir | nornir/core/inventory.py | Inventory.children_of_group | def children_of_group(self, group: Union[str, Group]) -> Set[Host]:
"""
Returns set of hosts that belongs to a group including those that belong
indirectly via inheritance
"""
hosts: List[Host] = set()
for host in self.hosts.values():
if host.has_parent_group(... | python | def children_of_group(self, group: Union[str, Group]) -> Set[Host]:
"""
Returns set of hosts that belongs to a group including those that belong
indirectly via inheritance
"""
hosts: List[Host] = set()
for host in self.hosts.values():
if host.has_parent_group(... | [
"def",
"children_of_group",
"(",
"self",
",",
"group",
":",
"Union",
"[",
"str",
",",
"Group",
"]",
")",
"->",
"Set",
"[",
"Host",
"]",
":",
"hosts",
":",
"List",
"[",
"Host",
"]",
"=",
"set",
"(",
")",
"for",
"host",
"in",
"self",
".",
"hosts",
... | Returns set of hosts that belongs to a group including those that belong
indirectly via inheritance | [
"Returns",
"set",
"of",
"hosts",
"that",
"belongs",
"to",
"a",
"group",
"including",
"those",
"that",
"belong",
"indirectly",
"via",
"inheritance"
] | 3425c47fd870db896cb80f619bae23bd98d50c74 | https://github.com/nornir-automation/nornir/blob/3425c47fd870db896cb80f619bae23bd98d50c74/nornir/core/inventory.py#L431-L440 | train | Returns the set of hosts that belong to a group including those that belong to those that belong to a group including those that belong to a group including those that belong to the group indirectly via inheritance
. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
nornir-automation/nornir | nornir/core/inventory.py | Inventory.add_host | def add_host(self, name: str, **kwargs) -> None:
"""
Add a host to the inventory after initialization
"""
host = {
name: deserializer.inventory.InventoryElement.deserialize_host(
name=name, defaults=self.defaults, **kwargs
)
}
self.... | python | def add_host(self, name: str, **kwargs) -> None:
"""
Add a host to the inventory after initialization
"""
host = {
name: deserializer.inventory.InventoryElement.deserialize_host(
name=name, defaults=self.defaults, **kwargs
)
}
self.... | [
"def",
"add_host",
"(",
"self",
",",
"name",
":",
"str",
",",
"*",
"*",
"kwargs",
")",
"->",
"None",
":",
"host",
"=",
"{",
"name",
":",
"deserializer",
".",
"inventory",
".",
"InventoryElement",
".",
"deserialize_host",
"(",
"name",
"=",
"name",
",",
... | Add a host to the inventory after initialization | [
"Add",
"a",
"host",
"to",
"the",
"inventory",
"after",
"initialization"
] | 3425c47fd870db896cb80f619bae23bd98d50c74 | https://github.com/nornir-automation/nornir/blob/3425c47fd870db896cb80f619bae23bd98d50c74/nornir/core/inventory.py#L442-L451 | train | Add a host to the inventory after initialization | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
nornir-automation/nornir | nornir/core/inventory.py | Inventory.add_group | def add_group(self, name: str, **kwargs) -> None:
"""
Add a group to the inventory after initialization
"""
group = {
name: deserializer.inventory.InventoryElement.deserialize_group(
name=name, defaults=self.defaults, **kwargs
)
}
s... | python | def add_group(self, name: str, **kwargs) -> None:
"""
Add a group to the inventory after initialization
"""
group = {
name: deserializer.inventory.InventoryElement.deserialize_group(
name=name, defaults=self.defaults, **kwargs
)
}
s... | [
"def",
"add_group",
"(",
"self",
",",
"name",
":",
"str",
",",
"*",
"*",
"kwargs",
")",
"->",
"None",
":",
"group",
"=",
"{",
"name",
":",
"deserializer",
".",
"inventory",
".",
"InventoryElement",
".",
"deserialize_group",
"(",
"name",
"=",
"name",
",... | Add a group to the inventory after initialization | [
"Add",
"a",
"group",
"to",
"the",
"inventory",
"after",
"initialization"
] | 3425c47fd870db896cb80f619bae23bd98d50c74 | https://github.com/nornir-automation/nornir/blob/3425c47fd870db896cb80f619bae23bd98d50c74/nornir/core/inventory.py#L453-L462 | train | Add a group to the inventory after initialization | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
nornir-automation/nornir | nornir/core/inventory.py | Inventory.get_defaults_dict | def get_defaults_dict(self) -> Dict:
"""
Returns serialized dictionary of defaults from inventory
"""
return deserializer.inventory.Defaults.serialize(self.defaults).dict() | python | def get_defaults_dict(self) -> Dict:
"""
Returns serialized dictionary of defaults from inventory
"""
return deserializer.inventory.Defaults.serialize(self.defaults).dict() | [
"def",
"get_defaults_dict",
"(",
"self",
")",
"->",
"Dict",
":",
"return",
"deserializer",
".",
"inventory",
".",
"Defaults",
".",
"serialize",
"(",
"self",
".",
"defaults",
")",
".",
"dict",
"(",
")"
] | Returns serialized dictionary of defaults from inventory | [
"Returns",
"serialized",
"dictionary",
"of",
"defaults",
"from",
"inventory"
] | 3425c47fd870db896cb80f619bae23bd98d50c74 | https://github.com/nornir-automation/nornir/blob/3425c47fd870db896cb80f619bae23bd98d50c74/nornir/core/inventory.py#L470-L474 | train | Returns serialized dictionary of defaults from inventory
| Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
nornir-automation/nornir | nornir/core/inventory.py | Inventory.get_groups_dict | def get_groups_dict(self) -> Dict:
"""
Returns serialized dictionary of groups from inventory
"""
return {
k: deserializer.inventory.InventoryElement.serialize(v).dict()
for k, v in self.groups.items()
} | python | def get_groups_dict(self) -> Dict:
"""
Returns serialized dictionary of groups from inventory
"""
return {
k: deserializer.inventory.InventoryElement.serialize(v).dict()
for k, v in self.groups.items()
} | [
"def",
"get_groups_dict",
"(",
"self",
")",
"->",
"Dict",
":",
"return",
"{",
"k",
":",
"deserializer",
".",
"inventory",
".",
"InventoryElement",
".",
"serialize",
"(",
"v",
")",
".",
"dict",
"(",
")",
"for",
"k",
",",
"v",
"in",
"self",
".",
"group... | Returns serialized dictionary of groups from inventory | [
"Returns",
"serialized",
"dictionary",
"of",
"groups",
"from",
"inventory"
] | 3425c47fd870db896cb80f619bae23bd98d50c74 | https://github.com/nornir-automation/nornir/blob/3425c47fd870db896cb80f619bae23bd98d50c74/nornir/core/inventory.py#L476-L483 | train | Returns serialized dictionary of groups from inventory
| Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
nornir-automation/nornir | nornir/core/inventory.py | Inventory.get_hosts_dict | def get_hosts_dict(self) -> Dict:
"""
Returns serialized dictionary of hosts from inventory
"""
return {
k: deserializer.inventory.InventoryElement.serialize(v).dict()
for k, v in self.hosts.items()
} | python | def get_hosts_dict(self) -> Dict:
"""
Returns serialized dictionary of hosts from inventory
"""
return {
k: deserializer.inventory.InventoryElement.serialize(v).dict()
for k, v in self.hosts.items()
} | [
"def",
"get_hosts_dict",
"(",
"self",
")",
"->",
"Dict",
":",
"return",
"{",
"k",
":",
"deserializer",
".",
"inventory",
".",
"InventoryElement",
".",
"serialize",
"(",
"v",
")",
".",
"dict",
"(",
")",
"for",
"k",
",",
"v",
"in",
"self",
".",
"hosts"... | Returns serialized dictionary of hosts from inventory | [
"Returns",
"serialized",
"dictionary",
"of",
"hosts",
"from",
"inventory"
] | 3425c47fd870db896cb80f619bae23bd98d50c74 | https://github.com/nornir-automation/nornir/blob/3425c47fd870db896cb80f619bae23bd98d50c74/nornir/core/inventory.py#L485-L492 | train | Returns serialized dictionary of hosts from inventory | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
nornir-automation/nornir | nornir/plugins/tasks/files/sftp.py | sftp | def sftp(
task: Task, src: str, dst: str, action: str, dry_run: Optional[bool] = None
) -> Result:
"""
Transfer files from/to the device using sftp protocol
Example::
nornir.run(files.sftp,
action="put",
src="README.md",
dst="/tmp/REA... | python | def sftp(
task: Task, src: str, dst: str, action: str, dry_run: Optional[bool] = None
) -> Result:
"""
Transfer files from/to the device using sftp protocol
Example::
nornir.run(files.sftp,
action="put",
src="README.md",
dst="/tmp/REA... | [
"def",
"sftp",
"(",
"task",
":",
"Task",
",",
"src",
":",
"str",
",",
"dst",
":",
"str",
",",
"action",
":",
"str",
",",
"dry_run",
":",
"Optional",
"[",
"bool",
"]",
"=",
"None",
")",
"->",
"Result",
":",
"dry_run",
"=",
"task",
".",
"is_dry_run... | Transfer files from/to the device using sftp protocol
Example::
nornir.run(files.sftp,
action="put",
src="README.md",
dst="/tmp/README.md")
Arguments:
dry_run: Whether to apply changes or not
src: source file
dst: des... | [
"Transfer",
"files",
"from",
"/",
"to",
"the",
"device",
"using",
"sftp",
"protocol"
] | 3425c47fd870db896cb80f619bae23bd98d50c74 | https://github.com/nornir-automation/nornir/blob/3425c47fd870db896cb80f619bae23bd98d50c74/nornir/plugins/tasks/files/sftp.py#L126-L158 | train | Transfer files from src to dst using sftp protocol. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
nornir-automation/nornir | nornir/plugins/tasks/text/template_file.py | template_file | def template_file(
task: Task,
template: str,
path: str,
jinja_filters: FiltersDict = None,
**kwargs: Any
) -> Result:
"""
Renders contants of a file with jinja2. All the host data is available in the template
Arguments:
template: filename
path: path to dir with template... | python | def template_file(
task: Task,
template: str,
path: str,
jinja_filters: FiltersDict = None,
**kwargs: Any
) -> Result:
"""
Renders contants of a file with jinja2. All the host data is available in the template
Arguments:
template: filename
path: path to dir with template... | [
"def",
"template_file",
"(",
"task",
":",
"Task",
",",
"template",
":",
"str",
",",
"path",
":",
"str",
",",
"jinja_filters",
":",
"FiltersDict",
"=",
"None",
",",
"*",
"*",
"kwargs",
":",
"Any",
")",
"->",
"Result",
":",
"jinja_filters",
"=",
"jinja_f... | Renders contants of a file with jinja2. All the host data is available in the template
Arguments:
template: filename
path: path to dir with templates
jinja_filters: jinja filters to enable. Defaults to nornir.config.jinja2.filters
**kwargs: additional data to pass to the template
... | [
"Renders",
"contants",
"of",
"a",
"file",
"with",
"jinja2",
".",
"All",
"the",
"host",
"data",
"is",
"available",
"in",
"the",
"template"
] | 3425c47fd870db896cb80f619bae23bd98d50c74 | https://github.com/nornir-automation/nornir/blob/3425c47fd870db896cb80f619bae23bd98d50c74/nornir/plugins/tasks/text/template_file.py#L9-L37 | train | Renders a file with jinja2 and returns the rendered text | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
nornir-automation/nornir | nornir/plugins/tasks/apis/http_method.py | http_method | def http_method(
task: Optional[Task] = None,
method: str = "get",
url: str = "",
raise_for_status: bool = True,
**kwargs: Any
) -> Result:
"""
This is a convenience task that uses `requests <http://docs.python-requests.org/en/master/>`_ to
interact with an HTTP server.
Arguments:
... | python | def http_method(
task: Optional[Task] = None,
method: str = "get",
url: str = "",
raise_for_status: bool = True,
**kwargs: Any
) -> Result:
"""
This is a convenience task that uses `requests <http://docs.python-requests.org/en/master/>`_ to
interact with an HTTP server.
Arguments:
... | [
"def",
"http_method",
"(",
"task",
":",
"Optional",
"[",
"Task",
"]",
"=",
"None",
",",
"method",
":",
"str",
"=",
"\"get\"",
",",
"url",
":",
"str",
"=",
"\"\"",
",",
"raise_for_status",
":",
"bool",
"=",
"True",
",",
"*",
"*",
"kwargs",
":",
"Any... | This is a convenience task that uses `requests <http://docs.python-requests.org/en/master/>`_ to
interact with an HTTP server.
Arguments:
method: HTTP method to call
url: URL to connect to
raise_for_status: Whether to call `raise_for_status
<http://docs.python-requests.org/e... | [
"This",
"is",
"a",
"convenience",
"task",
"that",
"uses",
"requests",
"<http",
":",
"//",
"docs",
".",
"python",
"-",
"requests",
".",
"org",
"/",
"en",
"/",
"master",
"/",
">",
"_",
"to",
"interact",
"with",
"an",
"HTTP",
"server",
"."
] | 3425c47fd870db896cb80f619bae23bd98d50c74 | https://github.com/nornir-automation/nornir/blob/3425c47fd870db896cb80f619bae23bd98d50c74/nornir/plugins/tasks/apis/http_method.py#L7-L48 | train | This is a convenience task that interacts with an HTTP server and returns the response body of the HTTP request. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
nornir-automation/nornir | nornir/plugins/tasks/networking/netmiko_send_config.py | netmiko_send_config | def netmiko_send_config(
task: Task,
config_commands: Optional[List[str]] = None,
config_file: Optional[str] = None,
**kwargs: Any
) -> Result:
"""
Execute Netmiko send_config_set method (or send_config_from_file)
Arguments:
config_commands: Commands to configure on the remote netwo... | python | def netmiko_send_config(
task: Task,
config_commands: Optional[List[str]] = None,
config_file: Optional[str] = None,
**kwargs: Any
) -> Result:
"""
Execute Netmiko send_config_set method (or send_config_from_file)
Arguments:
config_commands: Commands to configure on the remote netwo... | [
"def",
"netmiko_send_config",
"(",
"task",
":",
"Task",
",",
"config_commands",
":",
"Optional",
"[",
"List",
"[",
"str",
"]",
"]",
"=",
"None",
",",
"config_file",
":",
"Optional",
"[",
"str",
"]",
"=",
"None",
",",
"*",
"*",
"kwargs",
":",
"Any",
"... | Execute Netmiko send_config_set method (or send_config_from_file)
Arguments:
config_commands: Commands to configure on the remote network device.
config_file: File to read configuration commands from.
kwargs: Additional arguments to pass to method.
Returns:
Result object with t... | [
"Execute",
"Netmiko",
"send_config_set",
"method",
"(",
"or",
"send_config_from_file",
")"
] | 3425c47fd870db896cb80f619bae23bd98d50c74 | https://github.com/nornir-automation/nornir/blob/3425c47fd870db896cb80f619bae23bd98d50c74/nornir/plugins/tasks/networking/netmiko_send_config.py#L6-L33 | train | Execute Netmiko send_config_set or send_config_from_file method on the remote network device. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
nornir-automation/nornir | nornir/plugins/tasks/networking/napalm_configure.py | napalm_configure | def napalm_configure(
task: Task,
dry_run: Optional[bool] = None,
filename: Optional[str] = None,
configuration: Optional[str] = None,
replace: bool = False,
) -> Result:
"""
Loads configuration into a network devices using napalm
Arguments:
dry_run: Whether to apply changes or ... | python | def napalm_configure(
task: Task,
dry_run: Optional[bool] = None,
filename: Optional[str] = None,
configuration: Optional[str] = None,
replace: bool = False,
) -> Result:
"""
Loads configuration into a network devices using napalm
Arguments:
dry_run: Whether to apply changes or ... | [
"def",
"napalm_configure",
"(",
"task",
":",
"Task",
",",
"dry_run",
":",
"Optional",
"[",
"bool",
"]",
"=",
"None",
",",
"filename",
":",
"Optional",
"[",
"str",
"]",
"=",
"None",
",",
"configuration",
":",
"Optional",
"[",
"str",
"]",
"=",
"None",
... | Loads configuration into a network devices using napalm
Arguments:
dry_run: Whether to apply changes or not
filename: filename containing the configuration to load into the device
configuration: configuration to load into the device
replace: whether to replace or merge the configura... | [
"Loads",
"configuration",
"into",
"a",
"network",
"devices",
"using",
"napalm"
] | 3425c47fd870db896cb80f619bae23bd98d50c74 | https://github.com/nornir-automation/nornir/blob/3425c47fd870db896cb80f619bae23bd98d50c74/nornir/plugins/tasks/networking/napalm_configure.py#L6-L40 | train | Configure the nornir system with the given configuration. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.