partition stringclasses 3
values | func_name stringlengths 1 134 | docstring stringlengths 1 46.9k | path stringlengths 4 223 | original_string stringlengths 75 104k | code stringlengths 75 104k | docstring_tokens listlengths 1 1.97k | repo stringlengths 7 55 | language stringclasses 1
value | url stringlengths 87 315 | code_tokens listlengths 19 28.4k | sha stringlengths 40 40 |
|---|---|---|---|---|---|---|---|---|---|---|---|
test | is_square_matrix | Test if an array is a square matrix. | qiskit/quantum_info/operators/predicates.py | def is_square_matrix(mat):
"""Test if an array is a square matrix."""
mat = np.array(mat)
if mat.ndim != 2:
return False
shape = mat.shape
return shape[0] == shape[1] | def is_square_matrix(mat):
"""Test if an array is a square matrix."""
mat = np.array(mat)
if mat.ndim != 2:
return False
shape = mat.shape
return shape[0] == shape[1] | [
"Test",
"if",
"an",
"array",
"is",
"a",
"square",
"matrix",
"."
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/quantum_info/operators/predicates.py#L65-L71 | [
"def",
"is_square_matrix",
"(",
"mat",
")",
":",
"mat",
"=",
"np",
".",
"array",
"(",
"mat",
")",
"if",
"mat",
".",
"ndim",
"!=",
"2",
":",
"return",
"False",
"shape",
"=",
"mat",
".",
"shape",
"return",
"shape",
"[",
"0",
"]",
"==",
"shape",
"["... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | is_diagonal_matrix | Test if an array is a diagonal matrix | qiskit/quantum_info/operators/predicates.py | def is_diagonal_matrix(mat, rtol=RTOL_DEFAULT, atol=ATOL_DEFAULT):
"""Test if an array is a diagonal matrix"""
if atol is None:
atol = ATOL_DEFAULT
if rtol is None:
rtol = RTOL_DEFAULT
mat = np.array(mat)
if mat.ndim != 2:
return False
return np.allclose(mat, np.diag(np.d... | def is_diagonal_matrix(mat, rtol=RTOL_DEFAULT, atol=ATOL_DEFAULT):
"""Test if an array is a diagonal matrix"""
if atol is None:
atol = ATOL_DEFAULT
if rtol is None:
rtol = RTOL_DEFAULT
mat = np.array(mat)
if mat.ndim != 2:
return False
return np.allclose(mat, np.diag(np.d... | [
"Test",
"if",
"an",
"array",
"is",
"a",
"diagonal",
"matrix"
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/quantum_info/operators/predicates.py#L74-L83 | [
"def",
"is_diagonal_matrix",
"(",
"mat",
",",
"rtol",
"=",
"RTOL_DEFAULT",
",",
"atol",
"=",
"ATOL_DEFAULT",
")",
":",
"if",
"atol",
"is",
"None",
":",
"atol",
"=",
"ATOL_DEFAULT",
"if",
"rtol",
"is",
"None",
":",
"rtol",
"=",
"RTOL_DEFAULT",
"mat",
"=",... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | is_symmetric_matrix | Test if an array is a symmetrix matrix | qiskit/quantum_info/operators/predicates.py | def is_symmetric_matrix(op, rtol=RTOL_DEFAULT, atol=ATOL_DEFAULT):
"""Test if an array is a symmetrix matrix"""
if atol is None:
atol = ATOL_DEFAULT
if rtol is None:
rtol = RTOL_DEFAULT
mat = np.array(op)
if mat.ndim != 2:
return False
return np.allclose(mat, mat.T, rtol=... | def is_symmetric_matrix(op, rtol=RTOL_DEFAULT, atol=ATOL_DEFAULT):
"""Test if an array is a symmetrix matrix"""
if atol is None:
atol = ATOL_DEFAULT
if rtol is None:
rtol = RTOL_DEFAULT
mat = np.array(op)
if mat.ndim != 2:
return False
return np.allclose(mat, mat.T, rtol=... | [
"Test",
"if",
"an",
"array",
"is",
"a",
"symmetrix",
"matrix"
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/quantum_info/operators/predicates.py#L86-L95 | [
"def",
"is_symmetric_matrix",
"(",
"op",
",",
"rtol",
"=",
"RTOL_DEFAULT",
",",
"atol",
"=",
"ATOL_DEFAULT",
")",
":",
"if",
"atol",
"is",
"None",
":",
"atol",
"=",
"ATOL_DEFAULT",
"if",
"rtol",
"is",
"None",
":",
"rtol",
"=",
"RTOL_DEFAULT",
"mat",
"=",... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | is_hermitian_matrix | Test if an array is a Hermitian matrix | qiskit/quantum_info/operators/predicates.py | def is_hermitian_matrix(mat, rtol=RTOL_DEFAULT, atol=ATOL_DEFAULT):
"""Test if an array is a Hermitian matrix"""
if atol is None:
atol = ATOL_DEFAULT
if rtol is None:
rtol = RTOL_DEFAULT
mat = np.array(mat)
if mat.ndim != 2:
return False
return np.allclose(mat, np.conj(ma... | def is_hermitian_matrix(mat, rtol=RTOL_DEFAULT, atol=ATOL_DEFAULT):
"""Test if an array is a Hermitian matrix"""
if atol is None:
atol = ATOL_DEFAULT
if rtol is None:
rtol = RTOL_DEFAULT
mat = np.array(mat)
if mat.ndim != 2:
return False
return np.allclose(mat, np.conj(ma... | [
"Test",
"if",
"an",
"array",
"is",
"a",
"Hermitian",
"matrix"
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/quantum_info/operators/predicates.py#L98-L107 | [
"def",
"is_hermitian_matrix",
"(",
"mat",
",",
"rtol",
"=",
"RTOL_DEFAULT",
",",
"atol",
"=",
"ATOL_DEFAULT",
")",
":",
"if",
"atol",
"is",
"None",
":",
"atol",
"=",
"ATOL_DEFAULT",
"if",
"rtol",
"is",
"None",
":",
"rtol",
"=",
"RTOL_DEFAULT",
"mat",
"="... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | is_positive_semidefinite_matrix | Test if a matrix is positive semidefinite | qiskit/quantum_info/operators/predicates.py | def is_positive_semidefinite_matrix(mat, rtol=RTOL_DEFAULT, atol=ATOL_DEFAULT):
"""Test if a matrix is positive semidefinite"""
if atol is None:
atol = ATOL_DEFAULT
if rtol is None:
rtol = RTOL_DEFAULT
if not is_hermitian_matrix(mat, rtol=rtol, atol=atol):
return False
# Chec... | def is_positive_semidefinite_matrix(mat, rtol=RTOL_DEFAULT, atol=ATOL_DEFAULT):
"""Test if a matrix is positive semidefinite"""
if atol is None:
atol = ATOL_DEFAULT
if rtol is None:
rtol = RTOL_DEFAULT
if not is_hermitian_matrix(mat, rtol=rtol, atol=atol):
return False
# Chec... | [
"Test",
"if",
"a",
"matrix",
"is",
"positive",
"semidefinite"
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/quantum_info/operators/predicates.py#L110-L123 | [
"def",
"is_positive_semidefinite_matrix",
"(",
"mat",
",",
"rtol",
"=",
"RTOL_DEFAULT",
",",
"atol",
"=",
"ATOL_DEFAULT",
")",
":",
"if",
"atol",
"is",
"None",
":",
"atol",
"=",
"ATOL_DEFAULT",
"if",
"rtol",
"is",
"None",
":",
"rtol",
"=",
"RTOL_DEFAULT",
... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | is_identity_matrix | Test if an array is an identity matrix. | qiskit/quantum_info/operators/predicates.py | def is_identity_matrix(mat,
ignore_phase=False,
rtol=RTOL_DEFAULT,
atol=ATOL_DEFAULT):
"""Test if an array is an identity matrix."""
if atol is None:
atol = ATOL_DEFAULT
if rtol is None:
rtol = RTOL_DEFAULT
mat = np.arr... | def is_identity_matrix(mat,
ignore_phase=False,
rtol=RTOL_DEFAULT,
atol=ATOL_DEFAULT):
"""Test if an array is an identity matrix."""
if atol is None:
atol = ATOL_DEFAULT
if rtol is None:
rtol = RTOL_DEFAULT
mat = np.arr... | [
"Test",
"if",
"an",
"array",
"is",
"an",
"identity",
"matrix",
"."
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/quantum_info/operators/predicates.py#L126-L146 | [
"def",
"is_identity_matrix",
"(",
"mat",
",",
"ignore_phase",
"=",
"False",
",",
"rtol",
"=",
"RTOL_DEFAULT",
",",
"atol",
"=",
"ATOL_DEFAULT",
")",
":",
"if",
"atol",
"is",
"None",
":",
"atol",
"=",
"ATOL_DEFAULT",
"if",
"rtol",
"is",
"None",
":",
"rtol... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | is_unitary_matrix | Test if an array is a unitary matrix. | qiskit/quantum_info/operators/predicates.py | def is_unitary_matrix(mat, rtol=RTOL_DEFAULT, atol=ATOL_DEFAULT):
"""Test if an array is a unitary matrix."""
if atol is None:
atol = ATOL_DEFAULT
if rtol is None:
rtol = RTOL_DEFAULT
mat = np.array(mat)
# Compute A^dagger.A and see if it is identity matrix
mat = np.conj(mat.T).d... | def is_unitary_matrix(mat, rtol=RTOL_DEFAULT, atol=ATOL_DEFAULT):
"""Test if an array is a unitary matrix."""
if atol is None:
atol = ATOL_DEFAULT
if rtol is None:
rtol = RTOL_DEFAULT
mat = np.array(mat)
# Compute A^dagger.A and see if it is identity matrix
mat = np.conj(mat.T).d... | [
"Test",
"if",
"an",
"array",
"is",
"a",
"unitary",
"matrix",
"."
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/quantum_info/operators/predicates.py#L149-L158 | [
"def",
"is_unitary_matrix",
"(",
"mat",
",",
"rtol",
"=",
"RTOL_DEFAULT",
",",
"atol",
"=",
"ATOL_DEFAULT",
")",
":",
"if",
"atol",
"is",
"None",
":",
"atol",
"=",
"ATOL_DEFAULT",
"if",
"rtol",
"is",
"None",
":",
"rtol",
"=",
"RTOL_DEFAULT",
"mat",
"=",
... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | OptimizeSwapBeforeMeasure.run | Return a new circuit that has been optimized. | qiskit/transpiler/passes/optimize_swap_before_measure.py | def run(self, dag):
"""Return a new circuit that has been optimized."""
swaps = dag.op_nodes(SwapGate)
for swap in swaps:
final_successor = []
for successor in dag.successors(swap):
final_successor.append(successor.type == 'out' or (successor.type == 'op' ... | def run(self, dag):
"""Return a new circuit that has been optimized."""
swaps = dag.op_nodes(SwapGate)
for swap in swaps:
final_successor = []
for successor in dag.successors(swap):
final_successor.append(successor.type == 'out' or (successor.type == 'op' ... | [
"Return",
"a",
"new",
"circuit",
"that",
"has",
"been",
"optimized",
"."
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/transpiler/passes/optimize_swap_before_measure.py#L23-L50 | [
"def",
"run",
"(",
"self",
",",
"dag",
")",
":",
"swaps",
"=",
"dag",
".",
"op_nodes",
"(",
"SwapGate",
")",
"for",
"swap",
"in",
"swaps",
":",
"final_successor",
"=",
"[",
"]",
"for",
"successor",
"in",
"dag",
".",
"successors",
"(",
"swap",
")",
... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | left_sample | Left sample a continuous function.
Args:
continuous_pulse: Continuous pulse function to sample.
duration: Duration to sample for.
*args: Continuous pulse function args.
**kwargs: Continuous pulse function kwargs. | qiskit/pulse/samplers/strategies.py | def left_sample(continuous_pulse: Callable, duration: int, *args, **kwargs) -> np.ndarray:
"""Left sample a continuous function.
Args:
continuous_pulse: Continuous pulse function to sample.
duration: Duration to sample for.
*args: Continuous pulse function args.
**kwargs: Continu... | def left_sample(continuous_pulse: Callable, duration: int, *args, **kwargs) -> np.ndarray:
"""Left sample a continuous function.
Args:
continuous_pulse: Continuous pulse function to sample.
duration: Duration to sample for.
*args: Continuous pulse function args.
**kwargs: Continu... | [
"Left",
"sample",
"a",
"continuous",
"function",
".",
"Args",
":",
"continuous_pulse",
":",
"Continuous",
"pulse",
"function",
"to",
"sample",
".",
"duration",
":",
"Duration",
"to",
"sample",
"for",
".",
"*",
"args",
":",
"Continuous",
"pulse",
"function",
... | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/pulse/samplers/strategies.py#L31-L40 | [
"def",
"left_sample",
"(",
"continuous_pulse",
":",
"Callable",
",",
"duration",
":",
"int",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"->",
"np",
".",
"ndarray",
":",
"times",
"=",
"np",
".",
"arange",
"(",
"duration",
")",
"return",
"continuous... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | _to_choi | Transform a QuantumChannel to the Choi representation. | qiskit/quantum_info/operators/channel/transformations.py | def _to_choi(rep, data, input_dim, output_dim):
"""Transform a QuantumChannel to the Choi representation."""
if rep == 'Choi':
return data
if rep == 'Operator':
return _from_operator('Choi', data, input_dim, output_dim)
if rep == 'SuperOp':
return _superop_to_choi(data, input_dim... | def _to_choi(rep, data, input_dim, output_dim):
"""Transform a QuantumChannel to the Choi representation."""
if rep == 'Choi':
return data
if rep == 'Operator':
return _from_operator('Choi', data, input_dim, output_dim)
if rep == 'SuperOp':
return _superop_to_choi(data, input_dim... | [
"Transform",
"a",
"QuantumChannel",
"to",
"the",
"Choi",
"representation",
"."
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/quantum_info/operators/channel/transformations.py#L21-L38 | [
"def",
"_to_choi",
"(",
"rep",
",",
"data",
",",
"input_dim",
",",
"output_dim",
")",
":",
"if",
"rep",
"==",
"'Choi'",
":",
"return",
"data",
"if",
"rep",
"==",
"'Operator'",
":",
"return",
"_from_operator",
"(",
"'Choi'",
",",
"data",
",",
"input_dim",... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | _to_superop | Transform a QuantumChannel to the SuperOp representation. | qiskit/quantum_info/operators/channel/transformations.py | def _to_superop(rep, data, input_dim, output_dim):
"""Transform a QuantumChannel to the SuperOp representation."""
if rep == 'SuperOp':
return data
if rep == 'Operator':
return _from_operator('SuperOp', data, input_dim, output_dim)
if rep == 'Choi':
return _choi_to_superop(data, ... | def _to_superop(rep, data, input_dim, output_dim):
"""Transform a QuantumChannel to the SuperOp representation."""
if rep == 'SuperOp':
return data
if rep == 'Operator':
return _from_operator('SuperOp', data, input_dim, output_dim)
if rep == 'Choi':
return _choi_to_superop(data, ... | [
"Transform",
"a",
"QuantumChannel",
"to",
"the",
"SuperOp",
"representation",
"."
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/quantum_info/operators/channel/transformations.py#L41-L58 | [
"def",
"_to_superop",
"(",
"rep",
",",
"data",
",",
"input_dim",
",",
"output_dim",
")",
":",
"if",
"rep",
"==",
"'SuperOp'",
":",
"return",
"data",
"if",
"rep",
"==",
"'Operator'",
":",
"return",
"_from_operator",
"(",
"'SuperOp'",
",",
"data",
",",
"in... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | _to_kraus | Transform a QuantumChannel to the Kraus representation. | qiskit/quantum_info/operators/channel/transformations.py | def _to_kraus(rep, data, input_dim, output_dim):
"""Transform a QuantumChannel to the Kraus representation."""
if rep == 'Kraus':
return data
if rep == 'Stinespring':
return _stinespring_to_kraus(data, input_dim, output_dim)
if rep == 'Operator':
return _from_operator('Kraus', da... | def _to_kraus(rep, data, input_dim, output_dim):
"""Transform a QuantumChannel to the Kraus representation."""
if rep == 'Kraus':
return data
if rep == 'Stinespring':
return _stinespring_to_kraus(data, input_dim, output_dim)
if rep == 'Operator':
return _from_operator('Kraus', da... | [
"Transform",
"a",
"QuantumChannel",
"to",
"the",
"Kraus",
"representation",
"."
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/quantum_info/operators/channel/transformations.py#L61-L72 | [
"def",
"_to_kraus",
"(",
"rep",
",",
"data",
",",
"input_dim",
",",
"output_dim",
")",
":",
"if",
"rep",
"==",
"'Kraus'",
":",
"return",
"data",
"if",
"rep",
"==",
"'Stinespring'",
":",
"return",
"_stinespring_to_kraus",
"(",
"data",
",",
"input_dim",
",",... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | _to_chi | Transform a QuantumChannel to the Chi representation. | qiskit/quantum_info/operators/channel/transformations.py | def _to_chi(rep, data, input_dim, output_dim):
"""Transform a QuantumChannel to the Chi representation."""
if rep == 'Chi':
return data
# Check valid n-qubit input
_check_nqubit_dim(input_dim, output_dim)
if rep == 'Operator':
return _from_operator('Chi', data, input_dim, output_dim)... | def _to_chi(rep, data, input_dim, output_dim):
"""Transform a QuantumChannel to the Chi representation."""
if rep == 'Chi':
return data
# Check valid n-qubit input
_check_nqubit_dim(input_dim, output_dim)
if rep == 'Operator':
return _from_operator('Chi', data, input_dim, output_dim)... | [
"Transform",
"a",
"QuantumChannel",
"to",
"the",
"Chi",
"representation",
"."
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/quantum_info/operators/channel/transformations.py#L75-L86 | [
"def",
"_to_chi",
"(",
"rep",
",",
"data",
",",
"input_dim",
",",
"output_dim",
")",
":",
"if",
"rep",
"==",
"'Chi'",
":",
"return",
"data",
"# Check valid n-qubit input",
"_check_nqubit_dim",
"(",
"input_dim",
",",
"output_dim",
")",
"if",
"rep",
"==",
"'Op... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | _to_ptm | Transform a QuantumChannel to the PTM representation. | qiskit/quantum_info/operators/channel/transformations.py | def _to_ptm(rep, data, input_dim, output_dim):
"""Transform a QuantumChannel to the PTM representation."""
if rep == 'PTM':
return data
# Check valid n-qubit input
_check_nqubit_dim(input_dim, output_dim)
if rep == 'Operator':
return _from_operator('PTM', data, input_dim, output_dim)... | def _to_ptm(rep, data, input_dim, output_dim):
"""Transform a QuantumChannel to the PTM representation."""
if rep == 'PTM':
return data
# Check valid n-qubit input
_check_nqubit_dim(input_dim, output_dim)
if rep == 'Operator':
return _from_operator('PTM', data, input_dim, output_dim)... | [
"Transform",
"a",
"QuantumChannel",
"to",
"the",
"PTM",
"representation",
"."
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/quantum_info/operators/channel/transformations.py#L89-L100 | [
"def",
"_to_ptm",
"(",
"rep",
",",
"data",
",",
"input_dim",
",",
"output_dim",
")",
":",
"if",
"rep",
"==",
"'PTM'",
":",
"return",
"data",
"# Check valid n-qubit input",
"_check_nqubit_dim",
"(",
"input_dim",
",",
"output_dim",
")",
"if",
"rep",
"==",
"'Op... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | _to_stinespring | Transform a QuantumChannel to the Stinespring representation. | qiskit/quantum_info/operators/channel/transformations.py | def _to_stinespring(rep, data, input_dim, output_dim):
"""Transform a QuantumChannel to the Stinespring representation."""
if rep == 'Stinespring':
return data
if rep == 'Operator':
return _from_operator('Stinespring', data, input_dim, output_dim)
# Convert via Superoperator representati... | def _to_stinespring(rep, data, input_dim, output_dim):
"""Transform a QuantumChannel to the Stinespring representation."""
if rep == 'Stinespring':
return data
if rep == 'Operator':
return _from_operator('Stinespring', data, input_dim, output_dim)
# Convert via Superoperator representati... | [
"Transform",
"a",
"QuantumChannel",
"to",
"the",
"Stinespring",
"representation",
"."
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/quantum_info/operators/channel/transformations.py#L103-L112 | [
"def",
"_to_stinespring",
"(",
"rep",
",",
"data",
",",
"input_dim",
",",
"output_dim",
")",
":",
"if",
"rep",
"==",
"'Stinespring'",
":",
"return",
"data",
"if",
"rep",
"==",
"'Operator'",
":",
"return",
"_from_operator",
"(",
"'Stinespring'",
",",
"data",
... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | _to_operator | Transform a QuantumChannel to the Operator representation. | qiskit/quantum_info/operators/channel/transformations.py | def _to_operator(rep, data, input_dim, output_dim):
"""Transform a QuantumChannel to the Operator representation."""
if rep == 'Operator':
return data
if rep == 'Stinespring':
return _stinespring_to_operator(data, input_dim, output_dim)
# Convert via Kraus representation
if rep != 'K... | def _to_operator(rep, data, input_dim, output_dim):
"""Transform a QuantumChannel to the Operator representation."""
if rep == 'Operator':
return data
if rep == 'Stinespring':
return _stinespring_to_operator(data, input_dim, output_dim)
# Convert via Kraus representation
if rep != 'K... | [
"Transform",
"a",
"QuantumChannel",
"to",
"the",
"Operator",
"representation",
"."
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/quantum_info/operators/channel/transformations.py#L115-L124 | [
"def",
"_to_operator",
"(",
"rep",
",",
"data",
",",
"input_dim",
",",
"output_dim",
")",
":",
"if",
"rep",
"==",
"'Operator'",
":",
"return",
"data",
"if",
"rep",
"==",
"'Stinespring'",
":",
"return",
"_stinespring_to_operator",
"(",
"data",
",",
"input_dim... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | _from_operator | Transform Operator representation to other representation. | qiskit/quantum_info/operators/channel/transformations.py | def _from_operator(rep, data, input_dim, output_dim):
"""Transform Operator representation to other representation."""
if rep == 'Operator':
return data
if rep == 'SuperOp':
return np.kron(np.conj(data), data)
if rep == 'Choi':
vec = np.ravel(data, order='F')
return np.ou... | def _from_operator(rep, data, input_dim, output_dim):
"""Transform Operator representation to other representation."""
if rep == 'Operator':
return data
if rep == 'SuperOp':
return np.kron(np.conj(data), data)
if rep == 'Choi':
vec = np.ravel(data, order='F')
return np.ou... | [
"Transform",
"Operator",
"representation",
"to",
"other",
"representation",
"."
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/quantum_info/operators/channel/transformations.py#L127-L148 | [
"def",
"_from_operator",
"(",
"rep",
",",
"data",
",",
"input_dim",
",",
"output_dim",
")",
":",
"if",
"rep",
"==",
"'Operator'",
":",
"return",
"data",
"if",
"rep",
"==",
"'SuperOp'",
":",
"return",
"np",
".",
"kron",
"(",
"np",
".",
"conj",
"(",
"d... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | _stinespring_to_operator | Transform Stinespring representation to Operator representation. | qiskit/quantum_info/operators/channel/transformations.py | def _stinespring_to_operator(data, input_dim, output_dim):
"""Transform Stinespring representation to Operator representation."""
trace_dim = data[0].shape[0] // output_dim
if data[1] is not None or trace_dim != 1:
raise QiskitError(
'Channel cannot be converted to Operator representatio... | def _stinespring_to_operator(data, input_dim, output_dim):
"""Transform Stinespring representation to Operator representation."""
trace_dim = data[0].shape[0] // output_dim
if data[1] is not None or trace_dim != 1:
raise QiskitError(
'Channel cannot be converted to Operator representatio... | [
"Transform",
"Stinespring",
"representation",
"to",
"Operator",
"representation",
"."
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/quantum_info/operators/channel/transformations.py#L159-L165 | [
"def",
"_stinespring_to_operator",
"(",
"data",
",",
"input_dim",
",",
"output_dim",
")",
":",
"trace_dim",
"=",
"data",
"[",
"0",
"]",
".",
"shape",
"[",
"0",
"]",
"//",
"output_dim",
"if",
"data",
"[",
"1",
"]",
"is",
"not",
"None",
"or",
"trace_dim"... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | _superop_to_choi | Transform SuperOp representation to Choi representation. | qiskit/quantum_info/operators/channel/transformations.py | def _superop_to_choi(data, input_dim, output_dim):
"""Transform SuperOp representation to Choi representation."""
shape = (output_dim, output_dim, input_dim, input_dim)
return _reshuffle(data, shape) | def _superop_to_choi(data, input_dim, output_dim):
"""Transform SuperOp representation to Choi representation."""
shape = (output_dim, output_dim, input_dim, input_dim)
return _reshuffle(data, shape) | [
"Transform",
"SuperOp",
"representation",
"to",
"Choi",
"representation",
"."
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/quantum_info/operators/channel/transformations.py#L168-L171 | [
"def",
"_superop_to_choi",
"(",
"data",
",",
"input_dim",
",",
"output_dim",
")",
":",
"shape",
"=",
"(",
"output_dim",
",",
"output_dim",
",",
"input_dim",
",",
"input_dim",
")",
"return",
"_reshuffle",
"(",
"data",
",",
"shape",
")"
] | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | _choi_to_superop | Transform Choi to SuperOp representation. | qiskit/quantum_info/operators/channel/transformations.py | def _choi_to_superop(data, input_dim, output_dim):
"""Transform Choi to SuperOp representation."""
shape = (input_dim, output_dim, input_dim, output_dim)
return _reshuffle(data, shape) | def _choi_to_superop(data, input_dim, output_dim):
"""Transform Choi to SuperOp representation."""
shape = (input_dim, output_dim, input_dim, output_dim)
return _reshuffle(data, shape) | [
"Transform",
"Choi",
"to",
"SuperOp",
"representation",
"."
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/quantum_info/operators/channel/transformations.py#L174-L177 | [
"def",
"_choi_to_superop",
"(",
"data",
",",
"input_dim",
",",
"output_dim",
")",
":",
"shape",
"=",
"(",
"input_dim",
",",
"output_dim",
",",
"input_dim",
",",
"output_dim",
")",
"return",
"_reshuffle",
"(",
"data",
",",
"shape",
")"
] | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | _kraus_to_choi | Transform Kraus representation to Choi representation. | qiskit/quantum_info/operators/channel/transformations.py | def _kraus_to_choi(data, input_dim, output_dim):
"""Transform Kraus representation to Choi representation."""
choi = 0
kraus_l, kraus_r = data
if kraus_r is None:
for i in kraus_l:
vec = i.ravel(order='F')
choi += np.outer(vec, vec.conj())
else:
for i, j in zi... | def _kraus_to_choi(data, input_dim, output_dim):
"""Transform Kraus representation to Choi representation."""
choi = 0
kraus_l, kraus_r = data
if kraus_r is None:
for i in kraus_l:
vec = i.ravel(order='F')
choi += np.outer(vec, vec.conj())
else:
for i, j in zi... | [
"Transform",
"Kraus",
"representation",
"to",
"Choi",
"representation",
"."
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/quantum_info/operators/channel/transformations.py#L180-L191 | [
"def",
"_kraus_to_choi",
"(",
"data",
",",
"input_dim",
",",
"output_dim",
")",
":",
"choi",
"=",
"0",
"kraus_l",
",",
"kraus_r",
"=",
"data",
"if",
"kraus_r",
"is",
"None",
":",
"for",
"i",
"in",
"kraus_l",
":",
"vec",
"=",
"i",
".",
"ravel",
"(",
... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | _choi_to_kraus | Transform Choi representation to Kraus representation. | qiskit/quantum_info/operators/channel/transformations.py | def _choi_to_kraus(data, input_dim, output_dim, atol=ATOL_DEFAULT):
"""Transform Choi representation to Kraus representation."""
# Check if hermitian matrix
if is_hermitian_matrix(data, atol=atol):
# Get eigen-decomposition of Choi-matrix
w, v = la.eigh(data)
# Check eigenvaleus are ... | def _choi_to_kraus(data, input_dim, output_dim, atol=ATOL_DEFAULT):
"""Transform Choi representation to Kraus representation."""
# Check if hermitian matrix
if is_hermitian_matrix(data, atol=atol):
# Get eigen-decomposition of Choi-matrix
w, v = la.eigh(data)
# Check eigenvaleus are ... | [
"Transform",
"Choi",
"representation",
"to",
"Kraus",
"representation",
"."
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/quantum_info/operators/channel/transformations.py#L194-L223 | [
"def",
"_choi_to_kraus",
"(",
"data",
",",
"input_dim",
",",
"output_dim",
",",
"atol",
"=",
"ATOL_DEFAULT",
")",
":",
"# Check if hermitian matrix",
"if",
"is_hermitian_matrix",
"(",
"data",
",",
"atol",
"=",
"atol",
")",
":",
"# Get eigen-decomposition of Choi-mat... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | _stinespring_to_kraus | Transform Stinespring representation to Kraus representation. | qiskit/quantum_info/operators/channel/transformations.py | def _stinespring_to_kraus(data, input_dim, output_dim):
"""Transform Stinespring representation to Kraus representation."""
kraus_pair = []
for stine in data:
if stine is None:
kraus_pair.append(None)
else:
trace_dim = stine.shape[0] // output_dim
iden = n... | def _stinespring_to_kraus(data, input_dim, output_dim):
"""Transform Stinespring representation to Kraus representation."""
kraus_pair = []
for stine in data:
if stine is None:
kraus_pair.append(None)
else:
trace_dim = stine.shape[0] // output_dim
iden = n... | [
"Transform",
"Stinespring",
"representation",
"to",
"Kraus",
"representation",
"."
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/quantum_info/operators/channel/transformations.py#L226-L241 | [
"def",
"_stinespring_to_kraus",
"(",
"data",
",",
"input_dim",
",",
"output_dim",
")",
":",
"kraus_pair",
"=",
"[",
"]",
"for",
"stine",
"in",
"data",
":",
"if",
"stine",
"is",
"None",
":",
"kraus_pair",
".",
"append",
"(",
"None",
")",
"else",
":",
"t... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | _stinespring_to_choi | Transform Stinespring representation to Choi representation. | qiskit/quantum_info/operators/channel/transformations.py | def _stinespring_to_choi(data, input_dim, output_dim):
"""Transform Stinespring representation to Choi representation."""
trace_dim = data[0].shape[0] // output_dim
stine_l = np.reshape(data[0], (output_dim, trace_dim, input_dim))
if data[1] is None:
stine_r = stine_l
else:
stine_r =... | def _stinespring_to_choi(data, input_dim, output_dim):
"""Transform Stinespring representation to Choi representation."""
trace_dim = data[0].shape[0] // output_dim
stine_l = np.reshape(data[0], (output_dim, trace_dim, input_dim))
if data[1] is None:
stine_r = stine_l
else:
stine_r =... | [
"Transform",
"Stinespring",
"representation",
"to",
"Choi",
"representation",
"."
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/quantum_info/operators/channel/transformations.py#L244-L254 | [
"def",
"_stinespring_to_choi",
"(",
"data",
",",
"input_dim",
",",
"output_dim",
")",
":",
"trace_dim",
"=",
"data",
"[",
"0",
"]",
".",
"shape",
"[",
"0",
"]",
"//",
"output_dim",
"stine_l",
"=",
"np",
".",
"reshape",
"(",
"data",
"[",
"0",
"]",
","... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | _kraus_to_stinespring | Transform Kraus representation to Stinespring representation. | qiskit/quantum_info/operators/channel/transformations.py | def _kraus_to_stinespring(data, input_dim, output_dim):
"""Transform Kraus representation to Stinespring representation."""
stine_pair = [None, None]
for i, kraus in enumerate(data):
if kraus is not None:
num_kraus = len(kraus)
stine = np.zeros((output_dim * num_kraus, input_... | def _kraus_to_stinespring(data, input_dim, output_dim):
"""Transform Kraus representation to Stinespring representation."""
stine_pair = [None, None]
for i, kraus in enumerate(data):
if kraus is not None:
num_kraus = len(kraus)
stine = np.zeros((output_dim * num_kraus, input_... | [
"Transform",
"Kraus",
"representation",
"to",
"Stinespring",
"representation",
"."
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/quantum_info/operators/channel/transformations.py#L270-L283 | [
"def",
"_kraus_to_stinespring",
"(",
"data",
",",
"input_dim",
",",
"output_dim",
")",
":",
"stine_pair",
"=",
"[",
"None",
",",
"None",
"]",
"for",
"i",
",",
"kraus",
"in",
"enumerate",
"(",
"data",
")",
":",
"if",
"kraus",
"is",
"not",
"None",
":",
... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | _kraus_to_superop | Transform Kraus representation to SuperOp representation. | qiskit/quantum_info/operators/channel/transformations.py | def _kraus_to_superop(data, input_dim, output_dim):
"""Transform Kraus representation to SuperOp representation."""
kraus_l, kraus_r = data
superop = 0
if kraus_r is None:
for i in kraus_l:
superop += np.kron(np.conj(i), i)
else:
for i, j in zip(kraus_l, kraus_r):
... | def _kraus_to_superop(data, input_dim, output_dim):
"""Transform Kraus representation to SuperOp representation."""
kraus_l, kraus_r = data
superop = 0
if kraus_r is None:
for i in kraus_l:
superop += np.kron(np.conj(i), i)
else:
for i, j in zip(kraus_l, kraus_r):
... | [
"Transform",
"Kraus",
"representation",
"to",
"SuperOp",
"representation",
"."
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/quantum_info/operators/channel/transformations.py#L286-L296 | [
"def",
"_kraus_to_superop",
"(",
"data",
",",
"input_dim",
",",
"output_dim",
")",
":",
"kraus_l",
",",
"kraus_r",
"=",
"data",
"superop",
"=",
"0",
"if",
"kraus_r",
"is",
"None",
":",
"for",
"i",
"in",
"kraus_l",
":",
"superop",
"+=",
"np",
".",
"kron... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | _chi_to_choi | Transform Chi representation to a Choi representation. | qiskit/quantum_info/operators/channel/transformations.py | def _chi_to_choi(data, input_dim, output_dim):
"""Transform Chi representation to a Choi representation."""
num_qubits = int(np.log2(input_dim))
return _transform_from_pauli(data, num_qubits) | def _chi_to_choi(data, input_dim, output_dim):
"""Transform Chi representation to a Choi representation."""
num_qubits = int(np.log2(input_dim))
return _transform_from_pauli(data, num_qubits) | [
"Transform",
"Chi",
"representation",
"to",
"a",
"Choi",
"representation",
"."
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/quantum_info/operators/channel/transformations.py#L299-L302 | [
"def",
"_chi_to_choi",
"(",
"data",
",",
"input_dim",
",",
"output_dim",
")",
":",
"num_qubits",
"=",
"int",
"(",
"np",
".",
"log2",
"(",
"input_dim",
")",
")",
"return",
"_transform_from_pauli",
"(",
"data",
",",
"num_qubits",
")"
] | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | _choi_to_chi | Transform Choi representation to the Chi representation. | qiskit/quantum_info/operators/channel/transformations.py | def _choi_to_chi(data, input_dim, output_dim):
"""Transform Choi representation to the Chi representation."""
num_qubits = int(np.log2(input_dim))
return _transform_to_pauli(data, num_qubits) | def _choi_to_chi(data, input_dim, output_dim):
"""Transform Choi representation to the Chi representation."""
num_qubits = int(np.log2(input_dim))
return _transform_to_pauli(data, num_qubits) | [
"Transform",
"Choi",
"representation",
"to",
"the",
"Chi",
"representation",
"."
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/quantum_info/operators/channel/transformations.py#L305-L308 | [
"def",
"_choi_to_chi",
"(",
"data",
",",
"input_dim",
",",
"output_dim",
")",
":",
"num_qubits",
"=",
"int",
"(",
"np",
".",
"log2",
"(",
"input_dim",
")",
")",
"return",
"_transform_to_pauli",
"(",
"data",
",",
"num_qubits",
")"
] | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | _bipartite_tensor | Tensor product (A ⊗ B) to bipartite matrices and reravel indicies.
This is used for tensor product of superoperators and Choi matrices.
Args:
mat1 (matrix_like): a bipartite matrix A
mat2 (matrix_like): a bipartite matrix B
shape1 (tuple): bipartite-shape for matrix A (a0, a1, a2, a3)
... | qiskit/quantum_info/operators/channel/transformations.py | def _bipartite_tensor(mat1, mat2, shape1=None, shape2=None):
"""Tensor product (A ⊗ B) to bipartite matrices and reravel indicies.
This is used for tensor product of superoperators and Choi matrices.
Args:
mat1 (matrix_like): a bipartite matrix A
mat2 (matrix_like): a bipartite matrix B
... | def _bipartite_tensor(mat1, mat2, shape1=None, shape2=None):
"""Tensor product (A ⊗ B) to bipartite matrices and reravel indicies.
This is used for tensor product of superoperators and Choi matrices.
Args:
mat1 (matrix_like): a bipartite matrix A
mat2 (matrix_like): a bipartite matrix B
... | [
"Tensor",
"product",
"(",
"A",
"⊗",
"B",
")",
"to",
"bipartite",
"matrices",
"and",
"reravel",
"indicies",
"."
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/quantum_info/operators/channel/transformations.py#L323-L363 | [
"def",
"_bipartite_tensor",
"(",
"mat1",
",",
"mat2",
",",
"shape1",
"=",
"None",
",",
"shape2",
"=",
"None",
")",
":",
"# Convert inputs to numpy arrays",
"mat1",
"=",
"np",
".",
"array",
"(",
"mat1",
")",
"mat2",
"=",
"np",
".",
"array",
"(",
"mat2",
... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | _reravel | Reravel two bipartite matrices. | qiskit/quantum_info/operators/channel/transformations.py | def _reravel(mat1, mat2, shape1, shape2):
"""Reravel two bipartite matrices."""
# Reshuffle indicies
left_dims = shape1[:2] + shape2[:2]
right_dims = shape1[2:] + shape2[2:]
tensor_shape = left_dims + right_dims
final_shape = (np.product(left_dims), np.product(right_dims))
# Tensor product m... | def _reravel(mat1, mat2, shape1, shape2):
"""Reravel two bipartite matrices."""
# Reshuffle indicies
left_dims = shape1[:2] + shape2[:2]
right_dims = shape1[2:] + shape2[2:]
tensor_shape = left_dims + right_dims
final_shape = (np.product(left_dims), np.product(right_dims))
# Tensor product m... | [
"Reravel",
"two",
"bipartite",
"matrices",
"."
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/quantum_info/operators/channel/transformations.py#L366-L378 | [
"def",
"_reravel",
"(",
"mat1",
",",
"mat2",
",",
"shape1",
",",
"shape2",
")",
":",
"# Reshuffle indicies",
"left_dims",
"=",
"shape1",
"[",
":",
"2",
"]",
"+",
"shape2",
"[",
":",
"2",
"]",
"right_dims",
"=",
"shape1",
"[",
"2",
":",
"]",
"+",
"s... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | _transform_from_pauli | Change of basis of bipartite matrix represenation. | qiskit/quantum_info/operators/channel/transformations.py | def _transform_from_pauli(data, num_qubits):
"""Change of basis of bipartite matrix represenation."""
# Change basis: sum_{i=0}^3 =|\sigma_i>><i|
basis_mat = np.array(
[[1, 0, 0, 1], [0, 1, 1j, 0], [0, 1, -1j, 0], [1, 0j, 0, -1]],
dtype=complex)
# Note that we manually renormalized after... | def _transform_from_pauli(data, num_qubits):
"""Change of basis of bipartite matrix represenation."""
# Change basis: sum_{i=0}^3 =|\sigma_i>><i|
basis_mat = np.array(
[[1, 0, 0, 1], [0, 1, 1j, 0], [0, 1, -1j, 0], [1, 0j, 0, -1]],
dtype=complex)
# Note that we manually renormalized after... | [
"Change",
"of",
"basis",
"of",
"bipartite",
"matrix",
"represenation",
"."
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/quantum_info/operators/channel/transformations.py#L400-L416 | [
"def",
"_transform_from_pauli",
"(",
"data",
",",
"num_qubits",
")",
":",
"# Change basis: sum_{i=0}^3 =|\\sigma_i>><i|",
"basis_mat",
"=",
"np",
".",
"array",
"(",
"[",
"[",
"1",
",",
"0",
",",
"0",
",",
"1",
"]",
",",
"[",
"0",
",",
"1",
",",
"1j",
"... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | _reshuffle | Reshuffle the indicies of a bipartite matrix A[ij,kl] -> A[lj,ki]. | qiskit/quantum_info/operators/channel/transformations.py | def _reshuffle(mat, shape):
"""Reshuffle the indicies of a bipartite matrix A[ij,kl] -> A[lj,ki]."""
return np.reshape(
np.transpose(np.reshape(mat, shape), (3, 1, 2, 0)),
(shape[3] * shape[1], shape[0] * shape[2])) | def _reshuffle(mat, shape):
"""Reshuffle the indicies of a bipartite matrix A[ij,kl] -> A[lj,ki]."""
return np.reshape(
np.transpose(np.reshape(mat, shape), (3, 1, 2, 0)),
(shape[3] * shape[1], shape[0] * shape[2])) | [
"Reshuffle",
"the",
"indicies",
"of",
"a",
"bipartite",
"matrix",
"A",
"[",
"ij",
"kl",
"]",
"-",
">",
"A",
"[",
"lj",
"ki",
"]",
"."
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/quantum_info/operators/channel/transformations.py#L419-L423 | [
"def",
"_reshuffle",
"(",
"mat",
",",
"shape",
")",
":",
"return",
"np",
".",
"reshape",
"(",
"np",
".",
"transpose",
"(",
"np",
".",
"reshape",
"(",
"mat",
",",
"shape",
")",
",",
"(",
"3",
",",
"1",
",",
"2",
",",
"0",
")",
")",
",",
"(",
... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | _check_nqubit_dim | Return true if dims correspond to an n-qubit channel. | qiskit/quantum_info/operators/channel/transformations.py | def _check_nqubit_dim(input_dim, output_dim):
"""Return true if dims correspond to an n-qubit channel."""
if input_dim != output_dim:
raise QiskitError(
'Not an n-qubit channel: input_dim' +
' ({}) != output_dim ({})'.format(input_dim, output_dim))
num_qubits = int(np.log2(in... | def _check_nqubit_dim(input_dim, output_dim):
"""Return true if dims correspond to an n-qubit channel."""
if input_dim != output_dim:
raise QiskitError(
'Not an n-qubit channel: input_dim' +
' ({}) != output_dim ({})'.format(input_dim, output_dim))
num_qubits = int(np.log2(in... | [
"Return",
"true",
"if",
"dims",
"correspond",
"to",
"an",
"n",
"-",
"qubit",
"channel",
"."
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/quantum_info/operators/channel/transformations.py#L426-L434 | [
"def",
"_check_nqubit_dim",
"(",
"input_dim",
",",
"output_dim",
")",
":",
"if",
"input_dim",
"!=",
"output_dim",
":",
"raise",
"QiskitError",
"(",
"'Not an n-qubit channel: input_dim'",
"+",
"' ({}) != output_dim ({})'",
".",
"format",
"(",
"input_dim",
",",
"output_... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | _hide_tick_lines_and_labels | Set visible property of ticklines and ticklabels of an axis to False | qiskit/visualization/bloch.py | def _hide_tick_lines_and_labels(axis):
"""
Set visible property of ticklines and ticklabels of an axis to False
"""
for item in axis.get_ticklines() + axis.get_ticklabels():
item.set_visible(False) | def _hide_tick_lines_and_labels(axis):
"""
Set visible property of ticklines and ticklabels of an axis to False
"""
for item in axis.get_ticklines() + axis.get_ticklabels():
item.set_visible(False) | [
"Set",
"visible",
"property",
"of",
"ticklines",
"and",
"ticklabels",
"of",
"an",
"axis",
"to",
"False"
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/visualization/bloch.py#L625-L630 | [
"def",
"_hide_tick_lines_and_labels",
"(",
"axis",
")",
":",
"for",
"item",
"in",
"axis",
".",
"get_ticklines",
"(",
")",
"+",
"axis",
".",
"get_ticklabels",
"(",
")",
":",
"item",
".",
"set_visible",
"(",
"False",
")"
] | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | Bloch.set_label_convention | Set x, y and z labels according to one of conventions.
Args:
convention (str):
One of the following:
- "original"
- "xyz"
- "sx sy sz"
- "01"
- "polarization jones"
... | qiskit/visualization/bloch.py | def set_label_convention(self, convention):
"""Set x, y and z labels according to one of conventions.
Args:
convention (str):
One of the following:
- "original"
- "xyz"
- "sx sy sz"
- "01"
... | def set_label_convention(self, convention):
"""Set x, y and z labels according to one of conventions.
Args:
convention (str):
One of the following:
- "original"
- "xyz"
- "sx sy sz"
- "01"
... | [
"Set",
"x",
"y",
"and",
"z",
"labels",
"according",
"to",
"one",
"of",
"conventions",
"."
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/visualization/bloch.py#L207-L260 | [
"def",
"set_label_convention",
"(",
"self",
",",
"convention",
")",
":",
"ketex",
"=",
"\"$\\\\left.|%s\\\\right\\\\rangle$\"",
"# \\left.| is on purpose, so that every ket has the same size",
"if",
"convention",
"==",
"\"original\"",
":",
"self",
".",
"xlabel",
"=",
"[",
... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | Bloch.clear | Resets Bloch sphere data sets to empty. | qiskit/visualization/bloch.py | def clear(self):
"""Resets Bloch sphere data sets to empty.
"""
self.points = []
self.vectors = []
self.point_style = []
self.annotations = [] | def clear(self):
"""Resets Bloch sphere data sets to empty.
"""
self.points = []
self.vectors = []
self.point_style = []
self.annotations = [] | [
"Resets",
"Bloch",
"sphere",
"data",
"sets",
"to",
"empty",
"."
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/visualization/bloch.py#L295-L301 | [
"def",
"clear",
"(",
"self",
")",
":",
"self",
".",
"points",
"=",
"[",
"]",
"self",
".",
"vectors",
"=",
"[",
"]",
"self",
".",
"point_style",
"=",
"[",
"]",
"self",
".",
"annotations",
"=",
"[",
"]"
] | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | Bloch.add_points | Add a list of data points to bloch sphere.
Args:
points (array_like):
Collection of data points.
meth (str):
Type of points to plot, use 'm' for multicolored, 'l' for points
connected with a line. | qiskit/visualization/bloch.py | def add_points(self, points, meth='s'):
"""Add a list of data points to bloch sphere.
Args:
points (array_like):
Collection of data points.
meth (str):
Type of points to plot, use 'm' for multicolored, 'l' for points
connected with ... | def add_points(self, points, meth='s'):
"""Add a list of data points to bloch sphere.
Args:
points (array_like):
Collection of data points.
meth (str):
Type of points to plot, use 'm' for multicolored, 'l' for points
connected with ... | [
"Add",
"a",
"list",
"of",
"data",
"points",
"to",
"bloch",
"sphere",
".",
"Args",
":",
"points",
"(",
"array_like",
")",
":",
"Collection",
"of",
"data",
"points",
".",
"meth",
"(",
"str",
")",
":",
"Type",
"of",
"points",
"to",
"plot",
"use",
"m",
... | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/visualization/bloch.py#L303-L329 | [
"def",
"add_points",
"(",
"self",
",",
"points",
",",
"meth",
"=",
"'s'",
")",
":",
"if",
"not",
"isinstance",
"(",
"points",
"[",
"0",
"]",
",",
"(",
"list",
",",
"np",
".",
"ndarray",
")",
")",
":",
"points",
"=",
"[",
"[",
"points",
"[",
"0"... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | Bloch.add_vectors | Add a list of vectors to Bloch sphere.
Args:
vectors (array_like):
Array with vectors of unit length or smaller. | qiskit/visualization/bloch.py | def add_vectors(self, vectors):
"""Add a list of vectors to Bloch sphere.
Args:
vectors (array_like):
Array with vectors of unit length or smaller.
"""
if isinstance(vectors[0], (list, np.ndarray)):
for vec in vectors:
self.vectors... | def add_vectors(self, vectors):
"""Add a list of vectors to Bloch sphere.
Args:
vectors (array_like):
Array with vectors of unit length or smaller.
"""
if isinstance(vectors[0], (list, np.ndarray)):
for vec in vectors:
self.vectors... | [
"Add",
"a",
"list",
"of",
"vectors",
"to",
"Bloch",
"sphere",
"."
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/visualization/bloch.py#L331-L342 | [
"def",
"add_vectors",
"(",
"self",
",",
"vectors",
")",
":",
"if",
"isinstance",
"(",
"vectors",
"[",
"0",
"]",
",",
"(",
"list",
",",
"np",
".",
"ndarray",
")",
")",
":",
"for",
"vec",
"in",
"vectors",
":",
"self",
".",
"vectors",
".",
"append",
... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | Bloch.add_annotation | Add a text or LaTeX annotation to Bloch sphere,
parametrized by a qubit state or a vector.
Args:
state_or_vector (array_like):
Position for the annotation.
Qobj of a qubit or a vector of 3 elements.
text (str):
Annotation text.
... | qiskit/visualization/bloch.py | def add_annotation(self, state_or_vector, text, **kwargs):
"""Add a text or LaTeX annotation to Bloch sphere,
parametrized by a qubit state or a vector.
Args:
state_or_vector (array_like):
Position for the annotation.
Qobj of a qubit or a vector of 3 ... | def add_annotation(self, state_or_vector, text, **kwargs):
"""Add a text or LaTeX annotation to Bloch sphere,
parametrized by a qubit state or a vector.
Args:
state_or_vector (array_like):
Position for the annotation.
Qobj of a qubit or a vector of 3 ... | [
"Add",
"a",
"text",
"or",
"LaTeX",
"annotation",
"to",
"Bloch",
"sphere",
"parametrized",
"by",
"a",
"qubit",
"state",
"or",
"a",
"vector",
"."
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/visualization/bloch.py#L344-L372 | [
"def",
"add_annotation",
"(",
"self",
",",
"state_or_vector",
",",
"text",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"isinstance",
"(",
"state_or_vector",
",",
"(",
"list",
",",
"np",
".",
"ndarray",
",",
"tuple",
")",
")",
"and",
"len",
"(",
"state_or_... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | Bloch.render | Render the Bloch sphere and its data sets in on given figure and axes. | qiskit/visualization/bloch.py | def render(self, title=''):
"""
Render the Bloch sphere and its data sets in on given figure and axes.
"""
if self._rendered:
self.axes.clear()
self._rendered = True
# Figure instance for Bloch sphere plot
if not self._ext_fig:
self.fig =... | def render(self, title=''):
"""
Render the Bloch sphere and its data sets in on given figure and axes.
"""
if self._rendered:
self.axes.clear()
self._rendered = True
# Figure instance for Bloch sphere plot
if not self._ext_fig:
self.fig =... | [
"Render",
"the",
"Bloch",
"sphere",
"and",
"its",
"data",
"sets",
"in",
"on",
"given",
"figure",
"and",
"axes",
"."
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/visualization/bloch.py#L380-L415 | [
"def",
"render",
"(",
"self",
",",
"title",
"=",
"''",
")",
":",
"if",
"self",
".",
"_rendered",
":",
"self",
".",
"axes",
".",
"clear",
"(",
")",
"self",
".",
"_rendered",
"=",
"True",
"# Figure instance for Bloch sphere plot",
"if",
"not",
"self",
".",... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | Bloch.plot_front | front half of sphere | qiskit/visualization/bloch.py | def plot_front(self):
"""front half of sphere"""
u_angle = np.linspace(-np.pi, 0, 25)
v_angle = np.linspace(0, np.pi, 25)
x_dir = np.outer(np.cos(u_angle), np.sin(v_angle))
y_dir = np.outer(np.sin(u_angle), np.sin(v_angle))
z_dir = np.outer(np.ones(u_angle.shape[0]), np.c... | def plot_front(self):
"""front half of sphere"""
u_angle = np.linspace(-np.pi, 0, 25)
v_angle = np.linspace(0, np.pi, 25)
x_dir = np.outer(np.cos(u_angle), np.sin(v_angle))
y_dir = np.outer(np.sin(u_angle), np.sin(v_angle))
z_dir = np.outer(np.ones(u_angle.shape[0]), np.c... | [
"front",
"half",
"of",
"sphere"
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/visualization/bloch.py#L437-L457 | [
"def",
"plot_front",
"(",
"self",
")",
":",
"u_angle",
"=",
"np",
".",
"linspace",
"(",
"-",
"np",
".",
"pi",
",",
"0",
",",
"25",
")",
"v_angle",
"=",
"np",
".",
"linspace",
"(",
"0",
",",
"np",
".",
"pi",
",",
"25",
")",
"x_dir",
"=",
"np",... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | Bloch.plot_axes | axes | qiskit/visualization/bloch.py | def plot_axes(self):
"""axes"""
span = np.linspace(-1.0, 1.0, 2)
self.axes.plot(span, 0 * span, zs=0, zdir='z', label='X',
lw=self.frame_width, color=self.frame_color)
self.axes.plot(0 * span, span, zs=0, zdir='z', label='Y',
lw=self.frame_wi... | def plot_axes(self):
"""axes"""
span = np.linspace(-1.0, 1.0, 2)
self.axes.plot(span, 0 * span, zs=0, zdir='z', label='X',
lw=self.frame_width, color=self.frame_color)
self.axes.plot(0 * span, span, zs=0, zdir='z', label='Y',
lw=self.frame_wi... | [
"axes"
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/visualization/bloch.py#L459-L467 | [
"def",
"plot_axes",
"(",
"self",
")",
":",
"span",
"=",
"np",
".",
"linspace",
"(",
"-",
"1.0",
",",
"1.0",
",",
"2",
")",
"self",
".",
"axes",
".",
"plot",
"(",
"span",
",",
"0",
"*",
"span",
",",
"zs",
"=",
"0",
",",
"zdir",
"=",
"'z'",
"... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | Bloch.plot_axes_labels | axes labels | qiskit/visualization/bloch.py | def plot_axes_labels(self):
"""axes labels"""
opts = {'fontsize': self.font_size,
'color': self.font_color,
'horizontalalignment': 'center',
'verticalalignment': 'center'}
self.axes.text(0, -self.xlpos[0], 0, self.xlabel[0], **opts)
self.ax... | def plot_axes_labels(self):
"""axes labels"""
opts = {'fontsize': self.font_size,
'color': self.font_color,
'horizontalalignment': 'center',
'verticalalignment': 'center'}
self.axes.text(0, -self.xlpos[0], 0, self.xlabel[0], **opts)
self.ax... | [
"axes",
"labels"
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/visualization/bloch.py#L469-L492 | [
"def",
"plot_axes_labels",
"(",
"self",
")",
":",
"opts",
"=",
"{",
"'fontsize'",
":",
"self",
".",
"font_size",
",",
"'color'",
":",
"self",
".",
"font_color",
",",
"'horizontalalignment'",
":",
"'center'",
",",
"'verticalalignment'",
":",
"'center'",
"}",
... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | Bloch.plot_vectors | Plot vector | qiskit/visualization/bloch.py | def plot_vectors(self):
"""Plot vector"""
# -X and Y data are switched for plotting purposes
for k in range(len(self.vectors)):
xs3d = self.vectors[k][1] * np.array([0, 1])
ys3d = -self.vectors[k][0] * np.array([0, 1])
zs3d = self.vectors[k][2] * np.array([0,... | def plot_vectors(self):
"""Plot vector"""
# -X and Y data are switched for plotting purposes
for k in range(len(self.vectors)):
xs3d = self.vectors[k][1] * np.array([0, 1])
ys3d = -self.vectors[k][0] * np.array([0, 1])
zs3d = self.vectors[k][2] * np.array([0,... | [
"Plot",
"vector"
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/visualization/bloch.py#L494-L518 | [
"def",
"plot_vectors",
"(",
"self",
")",
":",
"# -X and Y data are switched for plotting purposes",
"for",
"k",
"in",
"range",
"(",
"len",
"(",
"self",
".",
"vectors",
")",
")",
":",
"xs3d",
"=",
"self",
".",
"vectors",
"[",
"k",
"]",
"[",
"1",
"]",
"*",... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | Bloch.plot_points | Plot points | qiskit/visualization/bloch.py | def plot_points(self):
"""Plot points"""
# -X and Y data are switched for plotting purposes
for k in range(len(self.points)):
num = len(self.points[k][0])
dist = [np.sqrt(self.points[k][0][j] ** 2 +
self.points[k][1][j] ** 2 +
... | def plot_points(self):
"""Plot points"""
# -X and Y data are switched for plotting purposes
for k in range(len(self.points)):
num = len(self.points[k][0])
dist = [np.sqrt(self.points[k][0][j] ** 2 +
self.points[k][1][j] ** 2 +
... | [
"Plot",
"points"
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/visualization/bloch.py#L520-L571 | [
"def",
"plot_points",
"(",
"self",
")",
":",
"# -X and Y data are switched for plotting purposes",
"for",
"k",
"in",
"range",
"(",
"len",
"(",
"self",
".",
"points",
")",
")",
":",
"num",
"=",
"len",
"(",
"self",
".",
"points",
"[",
"k",
"]",
"[",
"0",
... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | Bloch.plot_annotations | Plot annotations | qiskit/visualization/bloch.py | def plot_annotations(self):
"""Plot annotations"""
# -X and Y data are switched for plotting purposes
for annotation in self.annotations:
vec = annotation['position']
opts = {'fontsize': self.font_size,
'color': self.font_color,
'ho... | def plot_annotations(self):
"""Plot annotations"""
# -X and Y data are switched for plotting purposes
for annotation in self.annotations:
vec = annotation['position']
opts = {'fontsize': self.font_size,
'color': self.font_color,
'ho... | [
"Plot",
"annotations"
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/visualization/bloch.py#L573-L584 | [
"def",
"plot_annotations",
"(",
"self",
")",
":",
"# -X and Y data are switched for plotting purposes",
"for",
"annotation",
"in",
"self",
".",
"annotations",
":",
"vec",
"=",
"annotation",
"[",
"'position'",
"]",
"opts",
"=",
"{",
"'fontsize'",
":",
"self",
".",
... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | Bloch.show | Display Bloch sphere and corresponding data sets. | qiskit/visualization/bloch.py | def show(self, title=''):
"""
Display Bloch sphere and corresponding data sets.
"""
self.render(title=title)
if self.fig:
plt.show(self.fig) | def show(self, title=''):
"""
Display Bloch sphere and corresponding data sets.
"""
self.render(title=title)
if self.fig:
plt.show(self.fig) | [
"Display",
"Bloch",
"sphere",
"and",
"corresponding",
"data",
"sets",
"."
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/visualization/bloch.py#L586-L592 | [
"def",
"show",
"(",
"self",
",",
"title",
"=",
"''",
")",
":",
"self",
".",
"render",
"(",
"title",
"=",
"title",
")",
"if",
"self",
".",
"fig",
":",
"plt",
".",
"show",
"(",
"self",
".",
"fig",
")"
] | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | Bloch.save | Saves Bloch sphere to file of type ``format`` in directory ``dirc``.
Args:
name (str):
Name of saved image. Must include path and format as well.
i.e. '/Users/Paul/Desktop/bloch.png'
This overrides the 'format' and 'dirc' arguments.
output ... | qiskit/visualization/bloch.py | def save(self, name=None, output='png', dirc=None):
"""Saves Bloch sphere to file of type ``format`` in directory ``dirc``.
Args:
name (str):
Name of saved image. Must include path and format as well.
i.e. '/Users/Paul/Desktop/bloch.png'
This o... | def save(self, name=None, output='png', dirc=None):
"""Saves Bloch sphere to file of type ``format`` in directory ``dirc``.
Args:
name (str):
Name of saved image. Must include path and format as well.
i.e. '/Users/Paul/Desktop/bloch.png'
This o... | [
"Saves",
"Bloch",
"sphere",
"to",
"file",
"of",
"type",
"format",
"in",
"directory",
"dirc",
".",
"Args",
":",
"name",
"(",
"str",
")",
":",
"Name",
"of",
"saved",
"image",
".",
"Must",
"include",
"path",
"and",
"format",
"as",
"well",
".",
"i",
".",... | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/visualization/bloch.py#L594-L622 | [
"def",
"save",
"(",
"self",
",",
"name",
"=",
"None",
",",
"output",
"=",
"'png'",
",",
"dirc",
"=",
"None",
")",
":",
"self",
".",
"render",
"(",
")",
"if",
"dirc",
":",
"if",
"not",
"os",
".",
"path",
".",
"isdir",
"(",
"os",
".",
"getcwd",
... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | two_qubit_kak | Deprecated after 0.8 | qiskit/mapper/compiling.py | def two_qubit_kak(unitary_matrix, verify_gate_sequence=False):
"""Deprecated after 0.8
"""
warnings.warn("two_qubit_kak function is now accessible under "
"qiskit.quantum_info.synthesis", DeprecationWarning)
return synthesis.two_qubit_kak(unitary_matrix) | def two_qubit_kak(unitary_matrix, verify_gate_sequence=False):
"""Deprecated after 0.8
"""
warnings.warn("two_qubit_kak function is now accessible under "
"qiskit.quantum_info.synthesis", DeprecationWarning)
return synthesis.two_qubit_kak(unitary_matrix) | [
"Deprecated",
"after",
"0",
".",
"8"
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/mapper/compiling.py#L27-L32 | [
"def",
"two_qubit_kak",
"(",
"unitary_matrix",
",",
"verify_gate_sequence",
"=",
"False",
")",
":",
"warnings",
".",
"warn",
"(",
"\"two_qubit_kak function is now accessible under \"",
"\"qiskit.quantum_info.synthesis\"",
",",
"DeprecationWarning",
")",
"return",
"synthesis",... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | DrawElement.top | Constructs the top line of the element | qiskit/visualization/text.py | def top(self):
""" Constructs the top line of the element"""
ret = self.top_format % self.top_connect.center(
self.width, self.top_pad)
if self.right_fill:
ret = ret.ljust(self.right_fill, self.top_pad)
if self.left_fill:
ret = ret.rjust(self.left_fill... | def top(self):
""" Constructs the top line of the element"""
ret = self.top_format % self.top_connect.center(
self.width, self.top_pad)
if self.right_fill:
ret = ret.ljust(self.right_fill, self.top_pad)
if self.left_fill:
ret = ret.rjust(self.left_fill... | [
"Constructs",
"the",
"top",
"line",
"of",
"the",
"element"
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/visualization/text.py#L36-L45 | [
"def",
"top",
"(",
"self",
")",
":",
"ret",
"=",
"self",
".",
"top_format",
"%",
"self",
".",
"top_connect",
".",
"center",
"(",
"self",
".",
"width",
",",
"self",
".",
"top_pad",
")",
"if",
"self",
".",
"right_fill",
":",
"ret",
"=",
"ret",
".",
... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | DrawElement.mid | Constructs the middle line of the element | qiskit/visualization/text.py | def mid(self):
""" Constructs the middle line of the element"""
ret = self.mid_format % self.mid_content.center(
self.width, self._mid_padding)
if self.right_fill:
ret = ret.ljust(self.right_fill, self._mid_padding)
if self.left_fill:
ret = ret.rjust(s... | def mid(self):
""" Constructs the middle line of the element"""
ret = self.mid_format % self.mid_content.center(
self.width, self._mid_padding)
if self.right_fill:
ret = ret.ljust(self.right_fill, self._mid_padding)
if self.left_fill:
ret = ret.rjust(s... | [
"Constructs",
"the",
"middle",
"line",
"of",
"the",
"element"
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/visualization/text.py#L48-L57 | [
"def",
"mid",
"(",
"self",
")",
":",
"ret",
"=",
"self",
".",
"mid_format",
"%",
"self",
".",
"mid_content",
".",
"center",
"(",
"self",
".",
"width",
",",
"self",
".",
"_mid_padding",
")",
"if",
"self",
".",
"right_fill",
":",
"ret",
"=",
"ret",
"... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | DrawElement.bot | Constructs the bottom line of the element | qiskit/visualization/text.py | def bot(self):
""" Constructs the bottom line of the element"""
ret = self.bot_format % self.bot_connect.center(
self.width, self.bot_pad)
if self.right_fill:
ret = ret.ljust(self.right_fill, self.bot_pad)
if self.left_fill:
ret = ret.rjust(self.left_f... | def bot(self):
""" Constructs the bottom line of the element"""
ret = self.bot_format % self.bot_connect.center(
self.width, self.bot_pad)
if self.right_fill:
ret = ret.ljust(self.right_fill, self.bot_pad)
if self.left_fill:
ret = ret.rjust(self.left_f... | [
"Constructs",
"the",
"bottom",
"line",
"of",
"the",
"element"
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/visualization/text.py#L60-L69 | [
"def",
"bot",
"(",
"self",
")",
":",
"ret",
"=",
"self",
".",
"bot_format",
"%",
"self",
".",
"bot_connect",
".",
"center",
"(",
"self",
".",
"width",
",",
"self",
".",
"bot_pad",
")",
"if",
"self",
".",
"right_fill",
":",
"ret",
"=",
"ret",
".",
... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | DrawElement.length | Returns the length of the element, including the box around. | qiskit/visualization/text.py | def length(self):
""" Returns the length of the element, including the box around."""
return max(len(self.top), len(self.mid), len(self.bot)) | def length(self):
""" Returns the length of the element, including the box around."""
return max(len(self.top), len(self.mid), len(self.bot)) | [
"Returns",
"the",
"length",
"of",
"the",
"element",
"including",
"the",
"box",
"around",
"."
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/visualization/text.py#L72-L74 | [
"def",
"length",
"(",
"self",
")",
":",
"return",
"max",
"(",
"len",
"(",
"self",
".",
"top",
")",
",",
"len",
"(",
"self",
".",
"mid",
")",
",",
"len",
"(",
"self",
".",
"bot",
")",
")"
] | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | DrawElement.connect | Connects boxes and elements using wire_char and setting proper connectors.
Args:
wire_char (char): For example '║' or '│'.
where (list["top", "bot"]): Where the connector should be set.
label (string): Some connectors have a label (see cu1, for example). | qiskit/visualization/text.py | def connect(self, wire_char, where, label=None):
"""
Connects boxes and elements using wire_char and setting proper connectors.
Args:
wire_char (char): For example '║' or '│'.
where (list["top", "bot"]): Where the connector should be set.
label (string): Some ... | def connect(self, wire_char, where, label=None):
"""
Connects boxes and elements using wire_char and setting proper connectors.
Args:
wire_char (char): For example '║' or '│'.
where (list["top", "bot"]): Where the connector should be set.
label (string): Some ... | [
"Connects",
"boxes",
"and",
"elements",
"using",
"wire_char",
"and",
"setting",
"proper",
"connectors",
".",
"Args",
":",
"wire_char",
"(",
"char",
")",
":",
"For",
"example",
"║",
"or",
"│",
".",
"where",
"(",
"list",
"[",
"top",
"bot",
"]",
")",
":",... | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/visualization/text.py#L87-L103 | [
"def",
"connect",
"(",
"self",
",",
"wire_char",
",",
"where",
",",
"label",
"=",
"None",
")",
":",
"if",
"'top'",
"in",
"where",
"and",
"self",
".",
"top_connector",
":",
"self",
".",
"top_connect",
"=",
"self",
".",
"top_connector",
"[",
"wire_char",
... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | MultiBox.center_label | In multi-bit elements, the label is centered vertically.
Args:
input_length (int): Rhe amount of wires affected.
order (int): Which middle element is this one? | qiskit/visualization/text.py | def center_label(self, input_length, order):
"""
In multi-bit elements, the label is centered vertically.
Args:
input_length (int): Rhe amount of wires affected.
order (int): Which middle element is this one?
"""
location_in_the_box = '*'.center(input_leng... | def center_label(self, input_length, order):
"""
In multi-bit elements, the label is centered vertically.
Args:
input_length (int): Rhe amount of wires affected.
order (int): Which middle element is this one?
"""
location_in_the_box = '*'.center(input_leng... | [
"In",
"multi",
"-",
"bit",
"elements",
"the",
"label",
"is",
"centered",
"vertically",
".",
"Args",
":",
"input_length",
"(",
"int",
")",
":",
"Rhe",
"amount",
"of",
"wires",
"affected",
".",
"order",
"(",
"int",
")",
":",
"Which",
"middle",
"element",
... | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/visualization/text.py#L181-L197 | [
"def",
"center_label",
"(",
"self",
",",
"input_length",
",",
"order",
")",
":",
"location_in_the_box",
"=",
"'*'",
".",
"center",
"(",
"input_length",
"*",
"2",
"-",
"1",
")",
".",
"index",
"(",
"'*'",
")",
"+",
"1",
"top_limit",
"=",
"order",
"*",
... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | EmptyWire.fillup_layer | Given a layer, replace the Nones in it with EmptyWire elements.
Args:
layer (list): The layer that contains Nones.
first_clbit (int): The first wire that is classic.
Returns:
list: The new layer, with no Nones. | qiskit/visualization/text.py | def fillup_layer(layer, first_clbit):
"""
Given a layer, replace the Nones in it with EmptyWire elements.
Args:
layer (list): The layer that contains Nones.
first_clbit (int): The first wire that is classic.
Returns:
list: The new layer, with no Nones... | def fillup_layer(layer, first_clbit):
"""
Given a layer, replace the Nones in it with EmptyWire elements.
Args:
layer (list): The layer that contains Nones.
first_clbit (int): The first wire that is classic.
Returns:
list: The new layer, with no Nones... | [
"Given",
"a",
"layer",
"replace",
"the",
"Nones",
"in",
"it",
"with",
"EmptyWire",
"elements",
".",
"Args",
":",
"layer",
"(",
"list",
")",
":",
"The",
"layer",
"that",
"contains",
"Nones",
".",
"first_clbit",
"(",
"int",
")",
":",
"The",
"first",
"wir... | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/visualization/text.py#L367-L379 | [
"def",
"fillup_layer",
"(",
"layer",
",",
"first_clbit",
")",
":",
"for",
"nones",
"in",
"[",
"i",
"for",
"i",
",",
"x",
"in",
"enumerate",
"(",
"layer",
")",
"if",
"x",
"is",
"None",
"]",
":",
"layer",
"[",
"nones",
"]",
"=",
"EmptyWire",
"(",
"... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | BreakWire.fillup_layer | Creates a layer with BreakWire elements.
Args:
layer_length (int): The length of the layer to create
arrow_char (char): The char used to create the BreakWire element.
Returns:
list: The new layer. | qiskit/visualization/text.py | def fillup_layer(layer_length, arrow_char):
"""
Creates a layer with BreakWire elements.
Args:
layer_length (int): The length of the layer to create
arrow_char (char): The char used to create the BreakWire element.
Returns:
list: The new layer.
... | def fillup_layer(layer_length, arrow_char):
"""
Creates a layer with BreakWire elements.
Args:
layer_length (int): The length of the layer to create
arrow_char (char): The char used to create the BreakWire element.
Returns:
list: The new layer.
... | [
"Creates",
"a",
"layer",
"with",
"BreakWire",
"elements",
".",
"Args",
":",
"layer_length",
"(",
"int",
")",
":",
"The",
"length",
"of",
"the",
"layer",
"to",
"create",
"arrow_char",
"(",
"char",
")",
":",
"The",
"char",
"used",
"to",
"create",
"the",
... | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/visualization/text.py#L393-L406 | [
"def",
"fillup_layer",
"(",
"layer_length",
",",
"arrow_char",
")",
":",
"breakwire_layer",
"=",
"[",
"]",
"for",
"_",
"in",
"range",
"(",
"layer_length",
")",
":",
"breakwire_layer",
".",
"append",
"(",
"BreakWire",
"(",
"arrow_char",
")",
")",
"return",
... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | InputWire.fillup_layer | Creates a layer with InputWire elements.
Args:
names (list): List of names for the wires.
Returns:
list: The new layer | qiskit/visualization/text.py | def fillup_layer(names): # pylint: disable=arguments-differ
"""
Creates a layer with InputWire elements.
Args:
names (list): List of names for the wires.
Returns:
list: The new layer
"""
longest = max([len(name) for name in names])
inputs... | def fillup_layer(names): # pylint: disable=arguments-differ
"""
Creates a layer with InputWire elements.
Args:
names (list): List of names for the wires.
Returns:
list: The new layer
"""
longest = max([len(name) for name in names])
inputs... | [
"Creates",
"a",
"layer",
"with",
"InputWire",
"elements",
".",
"Args",
":",
"names",
"(",
"list",
")",
":",
"List",
"of",
"names",
"for",
"the",
"wires",
"."
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/visualization/text.py#L416-L429 | [
"def",
"fillup_layer",
"(",
"names",
")",
":",
"# pylint: disable=arguments-differ",
"longest",
"=",
"max",
"(",
"[",
"len",
"(",
"name",
")",
"for",
"name",
"in",
"names",
"]",
")",
"inputs_wires",
"=",
"[",
"]",
"for",
"name",
"in",
"names",
":",
"inpu... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | TextDrawing.dump | Dumps the ascii art in the file.
Args:
filename (str): File to dump the ascii art.
encoding (str): Optional. Default "utf-8". | qiskit/visualization/text.py | def dump(self, filename, encoding="utf8"):
"""
Dumps the ascii art in the file.
Args:
filename (str): File to dump the ascii art.
encoding (str): Optional. Default "utf-8".
"""
with open(filename, mode='w', encoding=encoding) as text_file:
text... | def dump(self, filename, encoding="utf8"):
"""
Dumps the ascii art in the file.
Args:
filename (str): File to dump the ascii art.
encoding (str): Optional. Default "utf-8".
"""
with open(filename, mode='w', encoding=encoding) as text_file:
text... | [
"Dumps",
"the",
"ascii",
"art",
"in",
"the",
"file",
".",
"Args",
":",
"filename",
"(",
"str",
")",
":",
"File",
"to",
"dump",
"the",
"ascii",
"art",
".",
"encoding",
"(",
"str",
")",
":",
"Optional",
".",
"Default",
"utf",
"-",
"8",
"."
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/visualization/text.py#L473-L481 | [
"def",
"dump",
"(",
"self",
",",
"filename",
",",
"encoding",
"=",
"\"utf8\"",
")",
":",
"with",
"open",
"(",
"filename",
",",
"mode",
"=",
"'w'",
",",
"encoding",
"=",
"encoding",
")",
"as",
"text_file",
":",
"text_file",
".",
"write",
"(",
"self",
... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | TextDrawing.lines | Generates a list with lines. These lines form the text drawing.
Args:
line_length (int): Optional. Breaks the circuit drawing to this length. This
useful when the drawing does not fit in the console. If
None (default), it will try to gues... | qiskit/visualization/text.py | def lines(self, line_length=None):
"""
Generates a list with lines. These lines form the text drawing.
Args:
line_length (int): Optional. Breaks the circuit drawing to this length. This
useful when the drawing does not fit in the console. If
... | def lines(self, line_length=None):
"""
Generates a list with lines. These lines form the text drawing.
Args:
line_length (int): Optional. Breaks the circuit drawing to this length. This
useful when the drawing does not fit in the console. If
... | [
"Generates",
"a",
"list",
"with",
"lines",
".",
"These",
"lines",
"form",
"the",
"text",
"drawing",
".",
"Args",
":",
"line_length",
"(",
"int",
")",
":",
"Optional",
".",
"Breaks",
"the",
"circuit",
"drawing",
"to",
"this",
"length",
".",
"This",
"usefu... | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/visualization/text.py#L483-L549 | [
"def",
"lines",
"(",
"self",
",",
"line_length",
"=",
"None",
")",
":",
"if",
"line_length",
"is",
"None",
":",
"line_length",
"=",
"self",
".",
"line_length",
"if",
"line_length",
"is",
"None",
":",
"if",
"(",
"'ipykernel'",
"in",
"sys",
".",
"modules",... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | TextDrawing.wire_names | Returns a list of names for each wire.
Args:
with_initial_value (bool): Optional (Default: True). If true, adds the initial value to
the name.
Returns:
List: The list of wire names. | qiskit/visualization/text.py | def wire_names(self, with_initial_value=True):
"""
Returns a list of names for each wire.
Args:
with_initial_value (bool): Optional (Default: True). If true, adds the initial value to
the name.
Returns:
List: The list of wir... | def wire_names(self, with_initial_value=True):
"""
Returns a list of names for each wire.
Args:
with_initial_value (bool): Optional (Default: True). If true, adds the initial value to
the name.
Returns:
List: The list of wir... | [
"Returns",
"a",
"list",
"of",
"names",
"for",
"each",
"wire",
".",
"Args",
":",
"with_initial_value",
"(",
"bool",
")",
":",
"Optional",
"(",
"Default",
":",
"True",
")",
".",
"If",
"true",
"adds",
"the",
"initial",
"value",
"to",
"the",
"name",
"."
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/visualization/text.py#L551-L571 | [
"def",
"wire_names",
"(",
"self",
",",
"with_initial_value",
"=",
"True",
")",
":",
"qubit_labels",
"=",
"self",
".",
"_get_qubit_labels",
"(",
")",
"clbit_labels",
"=",
"self",
".",
"_get_clbit_labels",
"(",
")",
"if",
"with_initial_value",
":",
"qubit_labels",... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | TextDrawing.draw_wires | Given a list of wires, creates a list of lines with the text drawing.
Args:
wires (list): A list of wires with instructions.
vertically_compressed (bool): Default is `True`. It merges the lines
so the drawing will take less vertical room.
Retu... | qiskit/visualization/text.py | def draw_wires(wires, vertically_compressed=True):
"""
Given a list of wires, creates a list of lines with the text drawing.
Args:
wires (list): A list of wires with instructions.
vertically_compressed (bool): Default is `True`. It merges the lines
... | def draw_wires(wires, vertically_compressed=True):
"""
Given a list of wires, creates a list of lines with the text drawing.
Args:
wires (list): A list of wires with instructions.
vertically_compressed (bool): Default is `True`. It merges the lines
... | [
"Given",
"a",
"list",
"of",
"wires",
"creates",
"a",
"list",
"of",
"lines",
"with",
"the",
"text",
"drawing",
".",
"Args",
":",
"wires",
"(",
"list",
")",
":",
"A",
"list",
"of",
"wires",
"with",
"instructions",
".",
"vertically_compressed",
"(",
"bool",... | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/visualization/text.py#L574-L612 | [
"def",
"draw_wires",
"(",
"wires",
",",
"vertically_compressed",
"=",
"True",
")",
":",
"lines",
"=",
"[",
"]",
"bot_line",
"=",
"None",
"for",
"wire",
"in",
"wires",
":",
"# TOP",
"top_line",
"=",
"''",
"for",
"instruction",
"in",
"wire",
":",
"top_line... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | TextDrawing.params_for_label | Get the params and format them to add them to a label. None if there
are no params of if the params are numpy.ndarrays. | qiskit/visualization/text.py | def params_for_label(instruction):
"""Get the params and format them to add them to a label. None if there
are no params of if the params are numpy.ndarrays."""
if not hasattr(instruction.op, 'params'):
return None
if all([isinstance(param, ndarray) for param in instruction... | def params_for_label(instruction):
"""Get the params and format them to add them to a label. None if there
are no params of if the params are numpy.ndarrays."""
if not hasattr(instruction.op, 'params'):
return None
if all([isinstance(param, ndarray) for param in instruction... | [
"Get",
"the",
"params",
"and",
"format",
"them",
"to",
"add",
"them",
"to",
"a",
"label",
".",
"None",
"if",
"there",
"are",
"no",
"params",
"of",
"if",
"the",
"params",
"are",
"numpy",
".",
"ndarrays",
"."
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/visualization/text.py#L620-L635 | [
"def",
"params_for_label",
"(",
"instruction",
")",
":",
"if",
"not",
"hasattr",
"(",
"instruction",
".",
"op",
",",
"'params'",
")",
":",
"return",
"None",
"if",
"all",
"(",
"[",
"isinstance",
"(",
"param",
",",
"ndarray",
")",
"for",
"param",
"in",
"... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | TextDrawing.label_for_box | Creates the label for a box. | qiskit/visualization/text.py | def label_for_box(instruction):
""" Creates the label for a box."""
label = instruction.name.capitalize()
params = TextDrawing.params_for_label(instruction)
if params:
label += "(%s)" % ','.join(params)
return label | def label_for_box(instruction):
""" Creates the label for a box."""
label = instruction.name.capitalize()
params = TextDrawing.params_for_label(instruction)
if params:
label += "(%s)" % ','.join(params)
return label | [
"Creates",
"the",
"label",
"for",
"a",
"box",
"."
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/visualization/text.py#L638-L644 | [
"def",
"label_for_box",
"(",
"instruction",
")",
":",
"label",
"=",
"instruction",
".",
"name",
".",
"capitalize",
"(",
")",
"params",
"=",
"TextDrawing",
".",
"params_for_label",
"(",
"instruction",
")",
"if",
"params",
":",
"label",
"+=",
"\"(%s)\"",
"%",
... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | TextDrawing.merge_lines | Merges two lines (top and bot) in the way that the overlapping make senses.
Args:
top (str): the top line
bot (str): the bottom line
icod (top or bot): in case of doubt, which line should have priority? Default: "top".
Returns:
str: The merge of both lines... | qiskit/visualization/text.py | def merge_lines(top, bot, icod="top"):
"""
Merges two lines (top and bot) in the way that the overlapping make senses.
Args:
top (str): the top line
bot (str): the bottom line
icod (top or bot): in case of doubt, which line should have priority? Default: "top"... | def merge_lines(top, bot, icod="top"):
"""
Merges two lines (top and bot) in the way that the overlapping make senses.
Args:
top (str): the top line
bot (str): the bottom line
icod (top or bot): in case of doubt, which line should have priority? Default: "top"... | [
"Merges",
"two",
"lines",
"(",
"top",
"and",
"bot",
")",
"in",
"the",
"way",
"that",
"the",
"overlapping",
"make",
"senses",
".",
"Args",
":",
"top",
"(",
"str",
")",
":",
"the",
"top",
"line",
"bot",
"(",
"str",
")",
":",
"the",
"bottom",
"line",
... | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/visualization/text.py#L647-L697 | [
"def",
"merge_lines",
"(",
"top",
",",
"bot",
",",
"icod",
"=",
"\"top\"",
")",
":",
"ret",
"=",
"\"\"",
"for",
"topc",
",",
"botc",
"in",
"zip",
"(",
"top",
",",
"bot",
")",
":",
"if",
"topc",
"==",
"botc",
":",
"ret",
"+=",
"topc",
"elif",
"t... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | TextDrawing.normalize_width | When the elements of the layer have different widths, sets the width to the max elements.
Args:
layer (list): A list of elements. | qiskit/visualization/text.py | def normalize_width(layer):
"""
When the elements of the layer have different widths, sets the width to the max elements.
Args:
layer (list): A list of elements.
"""
instructions = [instruction for instruction in filter(lambda x: x is not None, layer)]
longest... | def normalize_width(layer):
"""
When the elements of the layer have different widths, sets the width to the max elements.
Args:
layer (list): A list of elements.
"""
instructions = [instruction for instruction in filter(lambda x: x is not None, layer)]
longest... | [
"When",
"the",
"elements",
"of",
"the",
"layer",
"have",
"different",
"widths",
"sets",
"the",
"width",
"to",
"the",
"max",
"elements",
".",
"Args",
":",
"layer",
"(",
"list",
")",
":",
"A",
"list",
"of",
"elements",
"."
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/visualization/text.py#L700-L709 | [
"def",
"normalize_width",
"(",
"layer",
")",
":",
"instructions",
"=",
"[",
"instruction",
"for",
"instruction",
"in",
"filter",
"(",
"lambda",
"x",
":",
"x",
"is",
"not",
"None",
",",
"layer",
")",
"]",
"longest",
"=",
"max",
"(",
"[",
"instruction",
... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | TextDrawing._instruction_to_gate | Convert an instruction into its corresponding Gate object, and establish
any connections it introduces between qubits | qiskit/visualization/text.py | def _instruction_to_gate(self, instruction, layer):
""" Convert an instruction into its corresponding Gate object, and establish
any connections it introduces between qubits"""
current_cons = []
connection_label = None
# add in a gate that operates over multiple qubits
... | def _instruction_to_gate(self, instruction, layer):
""" Convert an instruction into its corresponding Gate object, and establish
any connections it introduces between qubits"""
current_cons = []
connection_label = None
# add in a gate that operates over multiple qubits
... | [
"Convert",
"an",
"instruction",
"into",
"its",
"corresponding",
"Gate",
"object",
"and",
"establish",
"any",
"connections",
"it",
"introduces",
"between",
"qubits"
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/visualization/text.py#L711-L828 | [
"def",
"_instruction_to_gate",
"(",
"self",
",",
"instruction",
",",
"layer",
")",
":",
"current_cons",
"=",
"[",
"]",
"connection_label",
"=",
"None",
"# add in a gate that operates over multiple qubits",
"def",
"add_connected_gate",
"(",
"instruction",
",",
"gates",
... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | TextDrawing.build_layers | Constructs layers.
Returns:
list: List of DrawElements.
Raises:
VisualizationError: When the drawing is, for some reason, impossible to be drawn. | qiskit/visualization/text.py | def build_layers(self):
"""
Constructs layers.
Returns:
list: List of DrawElements.
Raises:
VisualizationError: When the drawing is, for some reason, impossible to be drawn.
"""
wire_names = self.wire_names(with_initial_value=True)
if not w... | def build_layers(self):
"""
Constructs layers.
Returns:
list: List of DrawElements.
Raises:
VisualizationError: When the drawing is, for some reason, impossible to be drawn.
"""
wire_names = self.wire_names(with_initial_value=True)
if not w... | [
"Constructs",
"layers",
".",
"Returns",
":",
"list",
":",
"List",
"of",
"DrawElements",
".",
"Raises",
":",
"VisualizationError",
":",
"When",
"the",
"drawing",
"is",
"for",
"some",
"reason",
"impossible",
"to",
"be",
"drawn",
"."
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/visualization/text.py#L830-L855 | [
"def",
"build_layers",
"(",
"self",
")",
":",
"wire_names",
"=",
"self",
".",
"wire_names",
"(",
"with_initial_value",
"=",
"True",
")",
"if",
"not",
"wire_names",
":",
"return",
"[",
"]",
"layers",
"=",
"[",
"InputWire",
".",
"fillup_layer",
"(",
"wire_na... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | Layer.set_qubit | Sets the qubit to the element
Args:
qubit (qbit): Element of self.qregs.
element (DrawElement): Element to set in the qubit | qiskit/visualization/text.py | def set_qubit(self, qubit, element):
"""
Sets the qubit to the element
Args:
qubit (qbit): Element of self.qregs.
element (DrawElement): Element to set in the qubit
"""
self.qubit_layer[self.qregs.index(qubit)] = element | def set_qubit(self, qubit, element):
"""
Sets the qubit to the element
Args:
qubit (qbit): Element of self.qregs.
element (DrawElement): Element to set in the qubit
"""
self.qubit_layer[self.qregs.index(qubit)] = element | [
"Sets",
"the",
"qubit",
"to",
"the",
"element",
"Args",
":",
"qubit",
"(",
"qbit",
")",
":",
"Element",
"of",
"self",
".",
"qregs",
".",
"element",
"(",
"DrawElement",
")",
":",
"Element",
"to",
"set",
"in",
"the",
"qubit"
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/visualization/text.py#L877-L884 | [
"def",
"set_qubit",
"(",
"self",
",",
"qubit",
",",
"element",
")",
":",
"self",
".",
"qubit_layer",
"[",
"self",
".",
"qregs",
".",
"index",
"(",
"qubit",
")",
"]",
"=",
"element"
] | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | Layer.set_clbit | Sets the clbit to the element
Args:
clbit (cbit): Element of self.cregs.
element (DrawElement): Element to set in the clbit | qiskit/visualization/text.py | def set_clbit(self, clbit, element):
"""
Sets the clbit to the element
Args:
clbit (cbit): Element of self.cregs.
element (DrawElement): Element to set in the clbit
"""
self.clbit_layer[self.cregs.index(clbit)] = element | def set_clbit(self, clbit, element):
"""
Sets the clbit to the element
Args:
clbit (cbit): Element of self.cregs.
element (DrawElement): Element to set in the clbit
"""
self.clbit_layer[self.cregs.index(clbit)] = element | [
"Sets",
"the",
"clbit",
"to",
"the",
"element",
"Args",
":",
"clbit",
"(",
"cbit",
")",
":",
"Element",
"of",
"self",
".",
"cregs",
".",
"element",
"(",
"DrawElement",
")",
":",
"Element",
"to",
"set",
"in",
"the",
"clbit"
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/visualization/text.py#L886-L893 | [
"def",
"set_clbit",
"(",
"self",
",",
"clbit",
",",
"element",
")",
":",
"self",
".",
"clbit_layer",
"[",
"self",
".",
"cregs",
".",
"index",
"(",
"clbit",
")",
"]",
"=",
"element"
] | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | Layer.set_cl_multibox | Sets the multi clbit box.
Args:
creg (string): The affected classical register.
label (string): The label for the multi clbit box.
top_connect (char): The char to connect the box on the top. | qiskit/visualization/text.py | def set_cl_multibox(self, creg, label, top_connect='┴'):
"""
Sets the multi clbit box.
Args:
creg (string): The affected classical register.
label (string): The label for the multi clbit box.
top_connect (char): The char to connect the box on the top.
... | def set_cl_multibox(self, creg, label, top_connect='┴'):
"""
Sets the multi clbit box.
Args:
creg (string): The affected classical register.
label (string): The label for the multi clbit box.
top_connect (char): The char to connect the box on the top.
... | [
"Sets",
"the",
"multi",
"clbit",
"box",
".",
"Args",
":",
"creg",
"(",
"string",
")",
":",
"The",
"affected",
"classical",
"register",
".",
"label",
"(",
"string",
")",
":",
"The",
"label",
"for",
"the",
"multi",
"clbit",
"box",
".",
"top_connect",
"("... | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/visualization/text.py#L935-L944 | [
"def",
"set_cl_multibox",
"(",
"self",
",",
"creg",
",",
"label",
",",
"top_connect",
"=",
"'┴'):",
"",
"",
"clbit",
"=",
"[",
"bit",
"for",
"bit",
"in",
"self",
".",
"cregs",
"if",
"bit",
"[",
"0",
"]",
"==",
"creg",
"]",
"self",
".",
"_set_multib... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | Layer.connect_with | Connects the elements in the layer using wire_char.
Args:
wire_char (char): For example '║' or '│'. | qiskit/visualization/text.py | def connect_with(self, wire_char):
"""
Connects the elements in the layer using wire_char.
Args:
wire_char (char): For example '║' or '│'.
"""
if len([qbit for qbit in self.qubit_layer if qbit is not None]) == 1:
# Nothing to connect
return
... | def connect_with(self, wire_char):
"""
Connects the elements in the layer using wire_char.
Args:
wire_char (char): For example '║' or '│'.
"""
if len([qbit for qbit in self.qubit_layer if qbit is not None]) == 1:
# Nothing to connect
return
... | [
"Connects",
"the",
"elements",
"in",
"the",
"layer",
"using",
"wire_char",
".",
"Args",
":",
"wire_char",
"(",
"char",
")",
":",
"For",
"example",
"║",
"or",
"│",
"."
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/visualization/text.py#L955-L979 | [
"def",
"connect_with",
"(",
"self",
",",
"wire_char",
")",
":",
"if",
"len",
"(",
"[",
"qbit",
"for",
"qbit",
"in",
"self",
".",
"qubit_layer",
"if",
"qbit",
"is",
"not",
"None",
"]",
")",
"==",
"1",
":",
"# Nothing to connect",
"return",
"for",
"label... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | Id.latex | Return the correspond math mode latex string. | qiskit/qasm/node/id.py | def latex(self, prec=15, nested_scope=None):
"""Return the correspond math mode latex string."""
if not nested_scope:
return "\textrm{" + self.name + "}"
else:
if self.name not in nested_scope[-1]:
raise NodeException("Expected local parameter name: ",
... | def latex(self, prec=15, nested_scope=None):
"""Return the correspond math mode latex string."""
if not nested_scope:
return "\textrm{" + self.name + "}"
else:
if self.name not in nested_scope[-1]:
raise NodeException("Expected local parameter name: ",
... | [
"Return",
"the",
"correspond",
"math",
"mode",
"latex",
"string",
"."
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/qasm/node/id.py#L42-L54 | [
"def",
"latex",
"(",
"self",
",",
"prec",
"=",
"15",
",",
"nested_scope",
"=",
"None",
")",
":",
"if",
"not",
"nested_scope",
":",
"return",
"\"\\textrm{\"",
"+",
"self",
".",
"name",
"+",
"\"}\"",
"else",
":",
"if",
"self",
".",
"name",
"not",
"in",... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | Id.sym | Return the correspond symbolic number. | qiskit/qasm/node/id.py | def sym(self, nested_scope=None):
"""Return the correspond symbolic number."""
if not nested_scope or self.name not in nested_scope[-1]:
raise NodeException("Expected local parameter name: ",
"name=%s, line=%s, file=%s" % (
... | def sym(self, nested_scope=None):
"""Return the correspond symbolic number."""
if not nested_scope or self.name not in nested_scope[-1]:
raise NodeException("Expected local parameter name: ",
"name=%s, line=%s, file=%s" % (
... | [
"Return",
"the",
"correspond",
"symbolic",
"number",
"."
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/qasm/node/id.py#L56-L63 | [
"def",
"sym",
"(",
"self",
",",
"nested_scope",
"=",
"None",
")",
":",
"if",
"not",
"nested_scope",
"or",
"self",
".",
"name",
"not",
"in",
"nested_scope",
"[",
"-",
"1",
"]",
":",
"raise",
"NodeException",
"(",
"\"Expected local parameter name: \"",
",",
... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | Id.real | Return the correspond floating point number. | qiskit/qasm/node/id.py | def real(self, nested_scope=None):
"""Return the correspond floating point number."""
if not nested_scope or self.name not in nested_scope[-1]:
raise NodeException("Expected local parameter name: ",
"name=%s, line=%s, file=%s" % (
... | def real(self, nested_scope=None):
"""Return the correspond floating point number."""
if not nested_scope or self.name not in nested_scope[-1]:
raise NodeException("Expected local parameter name: ",
"name=%s, line=%s, file=%s" % (
... | [
"Return",
"the",
"correspond",
"floating",
"point",
"number",
"."
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/qasm/node/id.py#L65-L72 | [
"def",
"real",
"(",
"self",
",",
"nested_scope",
"=",
"None",
")",
":",
"if",
"not",
"nested_scope",
"or",
"self",
".",
"name",
"not",
"in",
"nested_scope",
"[",
"-",
"1",
"]",
":",
"raise",
"NodeException",
"(",
"\"Expected local parameter name: \"",
",",
... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | compile | Compile a list of circuits into a qobj.
Args:
circuits (QuantumCircuit or list[QuantumCircuit]): circuits to compile
backend (BaseBackend): a backend to compile for
config (dict): dictionary of parameters (e.g. noise) used by runner
basis_gates (list[str]): list of basis gates names... | qiskit/tools/compiler.py | def compile(circuits, backend,
config=None, basis_gates=None, coupling_map=None, initial_layout=None,
shots=1024, max_credits=10, seed=None, qobj_id=None, seed_mapper=None,
pass_manager=None, memory=False):
"""Compile a list of circuits into a qobj.
Args:
circuits (Q... | def compile(circuits, backend,
config=None, basis_gates=None, coupling_map=None, initial_layout=None,
shots=1024, max_credits=10, seed=None, qobj_id=None, seed_mapper=None,
pass_manager=None, memory=False):
"""Compile a list of circuits into a qobj.
Args:
circuits (Q... | [
"Compile",
"a",
"list",
"of",
"circuits",
"into",
"a",
"qobj",
"."
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/tools/compiler.py#L19-L69 | [
"def",
"compile",
"(",
"circuits",
",",
"backend",
",",
"config",
"=",
"None",
",",
"basis_gates",
"=",
"None",
",",
"coupling_map",
"=",
"None",
",",
"initial_layout",
"=",
"None",
",",
"shots",
"=",
"1024",
",",
"max_credits",
"=",
"10",
",",
"seed",
... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | _filter_deprecation_warnings | Apply filters to deprecation warnings.
Force the `DeprecationWarning` warnings to be displayed for the qiskit
module, overriding the system configuration as they are ignored by default
[1] for end-users. Additionally, silence the `ChangedInMarshmallow3Warning`
messages.
TODO: on Python 3.7, this m... | qiskit/util.py | def _filter_deprecation_warnings():
"""Apply filters to deprecation warnings.
Force the `DeprecationWarning` warnings to be displayed for the qiskit
module, overriding the system configuration as they are ignored by default
[1] for end-users. Additionally, silence the `ChangedInMarshmallow3Warning`
... | def _filter_deprecation_warnings():
"""Apply filters to deprecation warnings.
Force the `DeprecationWarning` warnings to be displayed for the qiskit
module, overriding the system configuration as they are ignored by default
[1] for end-users. Additionally, silence the `ChangedInMarshmallow3Warning`
... | [
"Apply",
"filters",
"to",
"deprecation",
"warnings",
"."
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/util.py#L28-L56 | [
"def",
"_filter_deprecation_warnings",
"(",
")",
":",
"deprecation_filter",
"=",
"(",
"'always'",
",",
"None",
",",
"DeprecationWarning",
",",
"re",
".",
"compile",
"(",
"r'^qiskit\\.*'",
",",
"re",
".",
"UNICODE",
")",
",",
"0",
")",
"# Instead of using warning... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | local_hardware_info | Basic hardware information about the local machine.
Gives actual number of CPU's in the machine, even when hyperthreading is
turned on. CPU count defaults to 1 when true count can't be determined.
Returns:
dict: The hardware information. | qiskit/util.py | def local_hardware_info():
"""Basic hardware information about the local machine.
Gives actual number of CPU's in the machine, even when hyperthreading is
turned on. CPU count defaults to 1 when true count can't be determined.
Returns:
dict: The hardware information.
"""
results = {
... | def local_hardware_info():
"""Basic hardware information about the local machine.
Gives actual number of CPU's in the machine, even when hyperthreading is
turned on. CPU count defaults to 1 when true count can't be determined.
Returns:
dict: The hardware information.
"""
results = {
... | [
"Basic",
"hardware",
"information",
"about",
"the",
"local",
"machine",
"."
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/util.py#L63-L77 | [
"def",
"local_hardware_info",
"(",
")",
":",
"results",
"=",
"{",
"'os'",
":",
"platform",
".",
"system",
"(",
")",
",",
"'memory'",
":",
"psutil",
".",
"virtual_memory",
"(",
")",
".",
"total",
"/",
"(",
"1024",
"**",
"3",
")",
",",
"'cpus'",
":",
... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | _has_connection | Checks if internet connection exists to host via specified port.
If any exception is raised while trying to open a socket this will return
false.
Args:
hostname (str): Hostname to connect to.
port (int): Port to connect to
Returns:
bool: Has connection or not | qiskit/util.py | def _has_connection(hostname, port):
"""Checks if internet connection exists to host via specified port.
If any exception is raised while trying to open a socket this will return
false.
Args:
hostname (str): Hostname to connect to.
port (int): Port to connect to
Returns:
b... | def _has_connection(hostname, port):
"""Checks if internet connection exists to host via specified port.
If any exception is raised while trying to open a socket this will return
false.
Args:
hostname (str): Hostname to connect to.
port (int): Port to connect to
Returns:
b... | [
"Checks",
"if",
"internet",
"connection",
"exists",
"to",
"host",
"via",
"specified",
"port",
"."
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/util.py#L80-L99 | [
"def",
"_has_connection",
"(",
"hostname",
",",
"port",
")",
":",
"try",
":",
"host",
"=",
"socket",
".",
"gethostbyname",
"(",
"hostname",
")",
"socket",
".",
"create_connection",
"(",
"(",
"host",
",",
"port",
")",
",",
"2",
")",
"return",
"True",
"e... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | PTM.compose | Return the composition channel self∘other.
Args:
other (QuantumChannel): a quantum channel.
qargs (list): a list of subsystem positions to compose other on.
front (bool): If False compose in standard order other(self(input))
otherwise compose in rev... | qiskit/quantum_info/operators/channel/ptm.py | def compose(self, other, qargs=None, front=False):
"""Return the composition channel self∘other.
Args:
other (QuantumChannel): a quantum channel.
qargs (list): a list of subsystem positions to compose other on.
front (bool): If False compose in standard order other(s... | def compose(self, other, qargs=None, front=False):
"""Return the composition channel self∘other.
Args:
other (QuantumChannel): a quantum channel.
qargs (list): a list of subsystem positions to compose other on.
front (bool): If False compose in standard order other(s... | [
"Return",
"the",
"composition",
"channel",
"self∘other",
"."
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/quantum_info/operators/channel/ptm.py#L131-L170 | [
"def",
"compose",
"(",
"self",
",",
"other",
",",
"qargs",
"=",
"None",
",",
"front",
"=",
"False",
")",
":",
"if",
"qargs",
"is",
"not",
"None",
":",
"return",
"PTM",
"(",
"SuperOp",
"(",
"self",
")",
".",
"compose",
"(",
"other",
",",
"qargs",
... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | PTM.power | The matrix power of the channel.
Args:
n (int): compute the matrix power of the superoperator matrix.
Returns:
PTM: the matrix power of the SuperOp converted to a PTM channel.
Raises:
QiskitError: if the input and output dimensions of the
Quantu... | qiskit/quantum_info/operators/channel/ptm.py | def power(self, n):
"""The matrix power of the channel.
Args:
n (int): compute the matrix power of the superoperator matrix.
Returns:
PTM: the matrix power of the SuperOp converted to a PTM channel.
Raises:
QiskitError: if the input and output dimen... | def power(self, n):
"""The matrix power of the channel.
Args:
n (int): compute the matrix power of the superoperator matrix.
Returns:
PTM: the matrix power of the SuperOp converted to a PTM channel.
Raises:
QiskitError: if the input and output dimen... | [
"The",
"matrix",
"power",
"of",
"the",
"channel",
"."
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/quantum_info/operators/channel/ptm.py#L172-L187 | [
"def",
"power",
"(",
"self",
",",
"n",
")",
":",
"if",
"n",
">",
"0",
":",
"return",
"super",
"(",
")",
".",
"power",
"(",
"n",
")",
"return",
"PTM",
"(",
"SuperOp",
"(",
"self",
")",
".",
"power",
"(",
"n",
")",
")"
] | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | _html_checker | Internal function that updates the status
of a HTML job monitor.
Args:
job_var (BaseJob): The job to keep track of.
interval (int): The status check interval
status (widget): HTML ipywidget for output ot screen
header (str): String representing HTML code for status.
_int... | qiskit/tools/jupyter/jupyter_magics.py | def _html_checker(job_var, interval, status, header,
_interval_set=False):
"""Internal function that updates the status
of a HTML job monitor.
Args:
job_var (BaseJob): The job to keep track of.
interval (int): The status check interval
status (widget): HTML ipywidg... | def _html_checker(job_var, interval, status, header,
_interval_set=False):
"""Internal function that updates the status
of a HTML job monitor.
Args:
job_var (BaseJob): The job to keep track of.
interval (int): The status check interval
status (widget): HTML ipywidg... | [
"Internal",
"function",
"that",
"updates",
"the",
"status",
"of",
"a",
"HTML",
"job",
"monitor",
"."
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/tools/jupyter/jupyter_magics.py#L25-L58 | [
"def",
"_html_checker",
"(",
"job_var",
",",
"interval",
",",
"status",
",",
"header",
",",
"_interval_set",
"=",
"False",
")",
":",
"job_status",
"=",
"job_var",
".",
"status",
"(",
")",
"job_status_name",
"=",
"job_status",
".",
"name",
"job_status_msg",
"... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | constant | Continuous constant pulse.
Args:
times: Times to output pulse for.
amp: Complex pulse amplitude. | qiskit/pulse/pulse_lib/continuous.py | def constant(times: np.ndarray, amp: complex) -> np.ndarray:
"""Continuous constant pulse.
Args:
times: Times to output pulse for.
amp: Complex pulse amplitude.
"""
return np.full(len(times), amp, dtype=np.complex_) | def constant(times: np.ndarray, amp: complex) -> np.ndarray:
"""Continuous constant pulse.
Args:
times: Times to output pulse for.
amp: Complex pulse amplitude.
"""
return np.full(len(times), amp, dtype=np.complex_) | [
"Continuous",
"constant",
"pulse",
"."
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/pulse/pulse_lib/continuous.py#L18-L25 | [
"def",
"constant",
"(",
"times",
":",
"np",
".",
"ndarray",
",",
"amp",
":",
"complex",
")",
"->",
"np",
".",
"ndarray",
":",
"return",
"np",
".",
"full",
"(",
"len",
"(",
"times",
")",
",",
"amp",
",",
"dtype",
"=",
"np",
".",
"complex_",
")"
] | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | square | Continuous square wave.
Args:
times: Times to output wave for.
amp: Pulse amplitude. Wave range is [-amp, amp].
period: Pulse period, units of dt.
phase: Pulse phase. | qiskit/pulse/pulse_lib/continuous.py | def square(times: np.ndarray, amp: complex, period: float, phase: float = 0) -> np.ndarray:
"""Continuous square wave.
Args:
times: Times to output wave for.
amp: Pulse amplitude. Wave range is [-amp, amp].
period: Pulse period, units of dt.
phase: Pulse phase.
"""
x = t... | def square(times: np.ndarray, amp: complex, period: float, phase: float = 0) -> np.ndarray:
"""Continuous square wave.
Args:
times: Times to output wave for.
amp: Pulse amplitude. Wave range is [-amp, amp].
period: Pulse period, units of dt.
phase: Pulse phase.
"""
x = t... | [
"Continuous",
"square",
"wave",
"."
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/pulse/pulse_lib/continuous.py#L37-L47 | [
"def",
"square",
"(",
"times",
":",
"np",
".",
"ndarray",
",",
"amp",
":",
"complex",
",",
"period",
":",
"float",
",",
"phase",
":",
"float",
"=",
"0",
")",
"->",
"np",
".",
"ndarray",
":",
"x",
"=",
"times",
"/",
"period",
"+",
"phase",
"/",
... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | triangle | Continuous triangle wave.
Args:
times: Times to output wave for.
amp: Pulse amplitude. Wave range is [-amp, amp].
period: Pulse period, units of dt.
phase: Pulse phase. | qiskit/pulse/pulse_lib/continuous.py | def triangle(times: np.ndarray, amp: complex, period: float, phase: float = 0) -> np.ndarray:
"""Continuous triangle wave.
Args:
times: Times to output wave for.
amp: Pulse amplitude. Wave range is [-amp, amp].
period: Pulse period, units of dt.
phase: Pulse phase.
"""
r... | def triangle(times: np.ndarray, amp: complex, period: float, phase: float = 0) -> np.ndarray:
"""Continuous triangle wave.
Args:
times: Times to output wave for.
amp: Pulse amplitude. Wave range is [-amp, amp].
period: Pulse period, units of dt.
phase: Pulse phase.
"""
r... | [
"Continuous",
"triangle",
"wave",
"."
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/pulse/pulse_lib/continuous.py#L63-L72 | [
"def",
"triangle",
"(",
"times",
":",
"np",
".",
"ndarray",
",",
"amp",
":",
"complex",
",",
"period",
":",
"float",
",",
"phase",
":",
"float",
"=",
"0",
")",
"->",
"np",
".",
"ndarray",
":",
"return",
"amp",
"*",
"(",
"-",
"2",
"*",
"np",
"."... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | cos | Continuous cosine wave.
Args:
times: Times to output wave for.
amp: Pulse amplitude.
freq: Pulse frequency, units of 1/dt.
phase: Pulse phase. | qiskit/pulse/pulse_lib/continuous.py | def cos(times: np.ndarray, amp: complex, freq: float, phase: float = 0) -> np.ndarray:
"""Continuous cosine wave.
Args:
times: Times to output wave for.
amp: Pulse amplitude.
freq: Pulse frequency, units of 1/dt.
phase: Pulse phase.
"""
return amp*np.cos(2*np.pi*freq*tim... | def cos(times: np.ndarray, amp: complex, freq: float, phase: float = 0) -> np.ndarray:
"""Continuous cosine wave.
Args:
times: Times to output wave for.
amp: Pulse amplitude.
freq: Pulse frequency, units of 1/dt.
phase: Pulse phase.
"""
return amp*np.cos(2*np.pi*freq*tim... | [
"Continuous",
"cosine",
"wave",
"."
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/pulse/pulse_lib/continuous.py#L75-L84 | [
"def",
"cos",
"(",
"times",
":",
"np",
".",
"ndarray",
",",
"amp",
":",
"complex",
",",
"freq",
":",
"float",
",",
"phase",
":",
"float",
"=",
"0",
")",
"->",
"np",
".",
"ndarray",
":",
"return",
"amp",
"*",
"np",
".",
"cos",
"(",
"2",
"*",
"... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | _fix_gaussian_width | r"""Enforce that the supplied gaussian pulse is zeroed at a specific width.
This is acheived by subtracting $\Omega_g(center \pm zeroed_width/2)$ from all samples.
amp: Pulse amplitude at `2\times center+1`.
center: Center (mean) of pulse.
sigma: Width (standard deviation) of pulse.
zeroed_width: ... | qiskit/pulse/pulse_lib/continuous.py | def _fix_gaussian_width(gaussian_samples, amp: float, center: float, sigma: float,
zeroed_width: Union[None, float] = None, rescale_amp: bool = False,
ret_scale_factor: bool = False) -> np.ndarray:
r"""Enforce that the supplied gaussian pulse is zeroed at a specific w... | def _fix_gaussian_width(gaussian_samples, amp: float, center: float, sigma: float,
zeroed_width: Union[None, float] = None, rescale_amp: bool = False,
ret_scale_factor: bool = False) -> np.ndarray:
r"""Enforce that the supplied gaussian pulse is zeroed at a specific w... | [
"r",
"Enforce",
"that",
"the",
"supplied",
"gaussian",
"pulse",
"is",
"zeroed",
"at",
"a",
"specific",
"width",
"."
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/pulse/pulse_lib/continuous.py#L99-L129 | [
"def",
"_fix_gaussian_width",
"(",
"gaussian_samples",
",",
"amp",
":",
"float",
",",
"center",
":",
"float",
",",
"sigma",
":",
"float",
",",
"zeroed_width",
":",
"Union",
"[",
"None",
",",
"float",
"]",
"=",
"None",
",",
"rescale_amp",
":",
"bool",
"="... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | gaussian | r"""Continuous unnormalized gaussian pulse.
Integrated area under curve is $\Omega_g(amp, sigma) = amp \times np.sqrt(2\pi \sigma^2)$
Args:
times: Times to output pulse for.
amp: Pulse amplitude at `center`. If `zeroed_width` is set pulse amplitude at center
will be $amp-\Omega_g(c... | qiskit/pulse/pulse_lib/continuous.py | def gaussian(times: np.ndarray, amp: complex, center: float, sigma: float,
zeroed_width: Union[None, float] = None, rescale_amp: bool = False,
ret_x: bool = False) -> Union[np.ndarray, Tuple[np.ndarray, np.ndarray]]:
r"""Continuous unnormalized gaussian pulse.
Integrated area under cu... | def gaussian(times: np.ndarray, amp: complex, center: float, sigma: float,
zeroed_width: Union[None, float] = None, rescale_amp: bool = False,
ret_x: bool = False) -> Union[np.ndarray, Tuple[np.ndarray, np.ndarray]]:
r"""Continuous unnormalized gaussian pulse.
Integrated area under cu... | [
"r",
"Continuous",
"unnormalized",
"gaussian",
"pulse",
"."
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/pulse/pulse_lib/continuous.py#L132-L165 | [
"def",
"gaussian",
"(",
"times",
":",
"np",
".",
"ndarray",
",",
"amp",
":",
"complex",
",",
"center",
":",
"float",
",",
"sigma",
":",
"float",
",",
"zeroed_width",
":",
"Union",
"[",
"None",
",",
"float",
"]",
"=",
"None",
",",
"rescale_amp",
":",
... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | gaussian_deriv | Continuous unnormalized gaussian derivative pulse.
Args:
times: Times to output pulse for.
amp: Pulse amplitude at `center`.
center: Center (mean) of pulse.
sigma: Width (standard deviation) of pulse.
ret_gaussian: Return gaussian with which derivative was taken with. | qiskit/pulse/pulse_lib/continuous.py | def gaussian_deriv(times: np.ndarray, amp: complex, center: float, sigma: float,
ret_gaussian: bool = False) -> np.ndarray:
"""Continuous unnormalized gaussian derivative pulse.
Args:
times: Times to output pulse for.
amp: Pulse amplitude at `center`.
center: Center (... | def gaussian_deriv(times: np.ndarray, amp: complex, center: float, sigma: float,
ret_gaussian: bool = False) -> np.ndarray:
"""Continuous unnormalized gaussian derivative pulse.
Args:
times: Times to output pulse for.
amp: Pulse amplitude at `center`.
center: Center (... | [
"Continuous",
"unnormalized",
"gaussian",
"derivative",
"pulse",
"."
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/pulse/pulse_lib/continuous.py#L168-L183 | [
"def",
"gaussian_deriv",
"(",
"times",
":",
"np",
".",
"ndarray",
",",
"amp",
":",
"complex",
",",
"center",
":",
"float",
",",
"sigma",
":",
"float",
",",
"ret_gaussian",
":",
"bool",
"=",
"False",
")",
"->",
"np",
".",
"ndarray",
":",
"gauss",
",",... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | gaussian_square | r"""Continuous gaussian square pulse.
Args:
times: Times to output pulse for.
amp: Pulse amplitude.
center: Center of the square pulse component.
width: Width of the square pulse component.
sigma: Width (standard deviation) of gaussian rise/fall portion of the pulse.
... | qiskit/pulse/pulse_lib/continuous.py | def gaussian_square(times: np.ndarray, amp: complex, center: float, width: float,
sigma: float, zeroed_width: Union[None, float] = None) -> np.ndarray:
r"""Continuous gaussian square pulse.
Args:
times: Times to output pulse for.
amp: Pulse amplitude.
center: Center ... | def gaussian_square(times: np.ndarray, amp: complex, center: float, width: float,
sigma: float, zeroed_width: Union[None, float] = None) -> np.ndarray:
r"""Continuous gaussian square pulse.
Args:
times: Times to output pulse for.
amp: Pulse amplitude.
center: Center ... | [
"r",
"Continuous",
"gaussian",
"square",
"pulse",
"."
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/pulse/pulse_lib/continuous.py#L186-L213 | [
"def",
"gaussian_square",
"(",
"times",
":",
"np",
".",
"ndarray",
",",
"amp",
":",
"complex",
",",
"center",
":",
"float",
",",
"width",
":",
"float",
",",
"sigma",
":",
"float",
",",
"zeroed_width",
":",
"Union",
"[",
"None",
",",
"float",
"]",
"="... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | drag | r"""Continuous Y-only correction DRAG pulse for standard nonlinear oscillator (SNO) [1].
[1] Gambetta, J. M., Motzoi, F., Merkel, S. T. & Wilhelm, F. K.
Analytic control methods for high-fidelity unitary operations
in a weakly nonlinear oscillator. Phys. Rev. A 83, 012308 (2011).
Args:
... | qiskit/pulse/pulse_lib/continuous.py | def drag(times: np.ndarray, amp: complex, center: float, sigma: float, beta: float,
zeroed_width: Union[None, float] = None, rescale_amp: bool = False) -> np.ndarray:
r"""Continuous Y-only correction DRAG pulse for standard nonlinear oscillator (SNO) [1].
[1] Gambetta, J. M., Motzoi, F., Merkel, S. T.... | def drag(times: np.ndarray, amp: complex, center: float, sigma: float, beta: float,
zeroed_width: Union[None, float] = None, rescale_amp: bool = False) -> np.ndarray:
r"""Continuous Y-only correction DRAG pulse for standard nonlinear oscillator (SNO) [1].
[1] Gambetta, J. M., Motzoi, F., Merkel, S. T.... | [
"r",
"Continuous",
"Y",
"-",
"only",
"correction",
"DRAG",
"pulse",
"for",
"standard",
"nonlinear",
"oscillator",
"(",
"SNO",
")",
"[",
"1",
"]",
"."
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/pulse/pulse_lib/continuous.py#L216-L249 | [
"def",
"drag",
"(",
"times",
":",
"np",
".",
"ndarray",
",",
"amp",
":",
"complex",
",",
"center",
":",
"float",
",",
"sigma",
":",
"float",
",",
"beta",
":",
"float",
",",
"zeroed_width",
":",
"Union",
"[",
"None",
",",
"float",
"]",
"=",
"None",
... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | default_pass_manager | The default pass manager that maps to the coupling map.
Args:
basis_gates (list[str]): list of basis gate names supported by the target.
coupling_map (CouplingMap): coupling map to target in mapping.
initial_layout (Layout or None): initial layout of virtual qubits on physical qubits
... | qiskit/transpiler/preset_passmanagers/default.py | def default_pass_manager(basis_gates, coupling_map, initial_layout, seed_transpiler):
"""
The default pass manager that maps to the coupling map.
Args:
basis_gates (list[str]): list of basis gate names supported by the target.
coupling_map (CouplingMap): coupling map to target in mapping.
... | def default_pass_manager(basis_gates, coupling_map, initial_layout, seed_transpiler):
"""
The default pass manager that maps to the coupling map.
Args:
basis_gates (list[str]): list of basis gate names supported by the target.
coupling_map (CouplingMap): coupling map to target in mapping.
... | [
"The",
"default",
"pass",
"manager",
"that",
"maps",
"to",
"the",
"coupling",
"map",
"."
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/transpiler/preset_passmanagers/default.py#L30-L83 | [
"def",
"default_pass_manager",
"(",
"basis_gates",
",",
"coupling_map",
",",
"initial_layout",
",",
"seed_transpiler",
")",
":",
"pass_manager",
"=",
"PassManager",
"(",
")",
"pass_manager",
".",
"property_set",
"[",
"'layout'",
"]",
"=",
"initial_layout",
"pass_man... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | default_pass_manager_simulator | The default pass manager without a coupling map.
Args:
basis_gates (list[str]): list of basis gate names to unroll to.
Returns:
PassManager: A passmanager that just unrolls, without any optimization. | qiskit/transpiler/preset_passmanagers/default.py | def default_pass_manager_simulator(basis_gates):
"""
The default pass manager without a coupling map.
Args:
basis_gates (list[str]): list of basis gate names to unroll to.
Returns:
PassManager: A passmanager that just unrolls, without any optimization.
"""
pass_manager = PassMa... | def default_pass_manager_simulator(basis_gates):
"""
The default pass manager without a coupling map.
Args:
basis_gates (list[str]): list of basis gate names to unroll to.
Returns:
PassManager: A passmanager that just unrolls, without any optimization.
"""
pass_manager = PassMa... | [
"The",
"default",
"pass",
"manager",
"without",
"a",
"coupling",
"map",
"."
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/transpiler/preset_passmanagers/default.py#L86-L103 | [
"def",
"default_pass_manager_simulator",
"(",
"basis_gates",
")",
":",
"pass_manager",
"=",
"PassManager",
"(",
")",
"pass_manager",
".",
"append",
"(",
"Unroller",
"(",
"basis_gates",
")",
")",
"pass_manager",
".",
"append",
"(",
"[",
"RemoveResetInZeroState",
"(... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | QuantumCircuit.has_register | Test if this circuit has the register r.
Args:
register (Register): a quantum or classical register.
Returns:
bool: True if the register is contained in this circuit. | qiskit/circuit/quantumcircuit.py | def has_register(self, register):
"""
Test if this circuit has the register r.
Args:
register (Register): a quantum or classical register.
Returns:
bool: True if the register is contained in this circuit.
"""
has_reg = False
if (isinstanc... | def has_register(self, register):
"""
Test if this circuit has the register r.
Args:
register (Register): a quantum or classical register.
Returns:
bool: True if the register is contained in this circuit.
"""
has_reg = False
if (isinstanc... | [
"Test",
"if",
"this",
"circuit",
"has",
"the",
"register",
"r",
"."
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/circuit/quantumcircuit.py#L104-L121 | [
"def",
"has_register",
"(",
"self",
",",
"register",
")",
":",
"has_reg",
"=",
"False",
"if",
"(",
"isinstance",
"(",
"register",
",",
"QuantumRegister",
")",
"and",
"register",
"in",
"self",
".",
"qregs",
")",
":",
"has_reg",
"=",
"True",
"elif",
"(",
... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | QuantumCircuit.mirror | Mirror the circuit by reversing the instructions.
This is done by recursively mirroring all instructions.
It does not invert any gate.
Returns:
QuantumCircuit: the mirrored circuit | qiskit/circuit/quantumcircuit.py | def mirror(self):
"""Mirror the circuit by reversing the instructions.
This is done by recursively mirroring all instructions.
It does not invert any gate.
Returns:
QuantumCircuit: the mirrored circuit
"""
reverse_circ = self.copy(name=self.name+'_mirror')
... | def mirror(self):
"""Mirror the circuit by reversing the instructions.
This is done by recursively mirroring all instructions.
It does not invert any gate.
Returns:
QuantumCircuit: the mirrored circuit
"""
reverse_circ = self.copy(name=self.name+'_mirror')
... | [
"Mirror",
"the",
"circuit",
"by",
"reversing",
"the",
"instructions",
"."
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/circuit/quantumcircuit.py#L123-L136 | [
"def",
"mirror",
"(",
"self",
")",
":",
"reverse_circ",
"=",
"self",
".",
"copy",
"(",
"name",
"=",
"self",
".",
"name",
"+",
"'_mirror'",
")",
"reverse_circ",
".",
"data",
"=",
"[",
"]",
"for",
"inst",
",",
"qargs",
",",
"cargs",
"in",
"reversed",
... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | QuantumCircuit.inverse | Invert this circuit.
This is done by recursively inverting all gates.
Returns:
QuantumCircuit: the inverted circuit
Raises:
QiskitError: if the circuit cannot be inverted. | qiskit/circuit/quantumcircuit.py | def inverse(self):
"""Invert this circuit.
This is done by recursively inverting all gates.
Returns:
QuantumCircuit: the inverted circuit
Raises:
QiskitError: if the circuit cannot be inverted.
"""
inverse_circ = self.copy(name=self.name+'_dg')
... | def inverse(self):
"""Invert this circuit.
This is done by recursively inverting all gates.
Returns:
QuantumCircuit: the inverted circuit
Raises:
QiskitError: if the circuit cannot be inverted.
"""
inverse_circ = self.copy(name=self.name+'_dg')
... | [
"Invert",
"this",
"circuit",
"."
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/circuit/quantumcircuit.py#L138-L153 | [
"def",
"inverse",
"(",
"self",
")",
":",
"inverse_circ",
"=",
"self",
".",
"copy",
"(",
"name",
"=",
"self",
".",
"name",
"+",
"'_dg'",
")",
"inverse_circ",
".",
"data",
"=",
"[",
"]",
"for",
"inst",
",",
"qargs",
",",
"cargs",
"in",
"reversed",
"(... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | QuantumCircuit.combine | Append rhs to self if self contains compatible registers.
Two circuits are compatible if they contain the same registers
or if they contain different registers with unique names. The
returned circuit will contain all unique registers between both
circuits.
Return self + rhs as ... | qiskit/circuit/quantumcircuit.py | def combine(self, rhs):
"""
Append rhs to self if self contains compatible registers.
Two circuits are compatible if they contain the same registers
or if they contain different registers with unique names. The
returned circuit will contain all unique registers between both
... | def combine(self, rhs):
"""
Append rhs to self if self contains compatible registers.
Two circuits are compatible if they contain the same registers
or if they contain different registers with unique names. The
returned circuit will contain all unique registers between both
... | [
"Append",
"rhs",
"to",
"self",
"if",
"self",
"contains",
"compatible",
"registers",
"."
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/circuit/quantumcircuit.py#L155-L182 | [
"def",
"combine",
"(",
"self",
",",
"rhs",
")",
":",
"# Check registers in LHS are compatible with RHS",
"self",
".",
"_check_compatible_regs",
"(",
"rhs",
")",
"# Make new circuit with combined registers",
"combined_qregs",
"=",
"deepcopy",
"(",
"self",
".",
"qregs",
"... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | QuantumCircuit.extend | Append rhs to self if self contains compatible registers.
Two circuits are compatible if they contain the same registers
or if they contain different registers with unique names. The
returned circuit will contain all unique registers between both
circuits.
Modify and return sel... | qiskit/circuit/quantumcircuit.py | def extend(self, rhs):
"""
Append rhs to self if self contains compatible registers.
Two circuits are compatible if they contain the same registers
or if they contain different registers with unique names. The
returned circuit will contain all unique registers between both
... | def extend(self, rhs):
"""
Append rhs to self if self contains compatible registers.
Two circuits are compatible if they contain the same registers
or if they contain different registers with unique names. The
returned circuit will contain all unique registers between both
... | [
"Append",
"rhs",
"to",
"self",
"if",
"self",
"contains",
"compatible",
"registers",
"."
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/circuit/quantumcircuit.py#L184-L209 | [
"def",
"extend",
"(",
"self",
",",
"rhs",
")",
":",
"# Check registers in LHS are compatible with RHS",
"self",
".",
"_check_compatible_regs",
"(",
"rhs",
")",
"# Add new registers",
"for",
"element",
"in",
"rhs",
".",
"qregs",
":",
"if",
"element",
"not",
"in",
... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | QuantumCircuit.append | Append an instruction to the end of the circuit, modifying
the circuit in place.
Args:
instruction (Instruction or Operator): Instruction instance to append
qargs (list(tuple)): qubits to attach instruction to
cargs (list(tuple)): clbits to attach instruction to
... | qiskit/circuit/quantumcircuit.py | def append(self, instruction, qargs=None, cargs=None):
"""Append an instruction to the end of the circuit, modifying
the circuit in place.
Args:
instruction (Instruction or Operator): Instruction instance to append
qargs (list(tuple)): qubits to attach instruction to
... | def append(self, instruction, qargs=None, cargs=None):
"""Append an instruction to the end of the circuit, modifying
the circuit in place.
Args:
instruction (Instruction or Operator): Instruction instance to append
qargs (list(tuple)): qubits to attach instruction to
... | [
"Append",
"an",
"instruction",
"to",
"the",
"end",
"of",
"the",
"circuit",
"modifying",
"the",
"circuit",
"in",
"place",
"."
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/circuit/quantumcircuit.py#L239-L290 | [
"def",
"append",
"(",
"self",
",",
"instruction",
",",
"qargs",
"=",
"None",
",",
"cargs",
"=",
"None",
")",
":",
"qargs",
"=",
"qargs",
"or",
"[",
"]",
"cargs",
"=",
"cargs",
"or",
"[",
"]",
"# Convert input to instruction",
"if",
"not",
"isinstance",
... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | QuantumCircuit._attach | DEPRECATED after 0.8 | qiskit/circuit/quantumcircuit.py | def _attach(self, instruction, qargs, cargs):
"""DEPRECATED after 0.8"""
self.append(instruction, qargs, cargs) | def _attach(self, instruction, qargs, cargs):
"""DEPRECATED after 0.8"""
self.append(instruction, qargs, cargs) | [
"DEPRECATED",
"after",
"0",
".",
"8"
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/circuit/quantumcircuit.py#L292-L294 | [
"def",
"_attach",
"(",
"self",
",",
"instruction",
",",
"qargs",
",",
"cargs",
")",
":",
"self",
".",
"append",
"(",
"instruction",
",",
"qargs",
",",
"cargs",
")"
] | d4f58d903bc96341b816f7c35df936d6421267d1 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.