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 | single_gate_matrix | Get the matrix for a single qubit.
Args:
gate(str): the single qubit gate name
params(list): the operation parameters op['params']
Returns:
array: A numpy array representing the matrix | qiskit/providers/basicaer/basicaertools.py | def single_gate_matrix(gate, params=None):
"""Get the matrix for a single qubit.
Args:
gate(str): the single qubit gate name
params(list): the operation parameters op['params']
Returns:
array: A numpy array representing the matrix
"""
# Converting sym to floats improves the... | def single_gate_matrix(gate, params=None):
"""Get the matrix for a single qubit.
Args:
gate(str): the single qubit gate name
params(list): the operation parameters op['params']
Returns:
array: A numpy array representing the matrix
"""
# Converting sym to floats improves the... | [
"Get",
"the",
"matrix",
"for",
"a",
"single",
"qubit",
"."
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/providers/basicaer/basicaertools.py#L41-L58 | [
"def",
"single_gate_matrix",
"(",
"gate",
",",
"params",
"=",
"None",
")",
":",
"# Converting sym to floats improves the performance of the simulator 10x.",
"# This a is a probable a FIXME since it might show bugs in the simulator.",
"(",
"theta",
",",
"phi",
",",
"lam",
")",
"... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | einsum_matmul_index | Return the index string for Numpy.eignsum matrix-matrix multiplication.
The returned indices are to perform a matrix multiplication A.B where
the matrix A is an M-qubit matrix, matrix B is an N-qubit matrix, and
M <= N, and identity matrices are implied on the subsystems where A has no
support on B.
... | qiskit/providers/basicaer/basicaertools.py | def einsum_matmul_index(gate_indices, number_of_qubits):
"""Return the index string for Numpy.eignsum matrix-matrix multiplication.
The returned indices are to perform a matrix multiplication A.B where
the matrix A is an M-qubit matrix, matrix B is an N-qubit matrix, and
M <= N, and identity matrices a... | def einsum_matmul_index(gate_indices, number_of_qubits):
"""Return the index string for Numpy.eignsum matrix-matrix multiplication.
The returned indices are to perform a matrix multiplication A.B where
the matrix A is an M-qubit matrix, matrix B is an N-qubit matrix, and
M <= N, and identity matrices a... | [
"Return",
"the",
"index",
"string",
"for",
"Numpy",
".",
"eignsum",
"matrix",
"-",
"matrix",
"multiplication",
"."
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/providers/basicaer/basicaertools.py#L69-L97 | [
"def",
"einsum_matmul_index",
"(",
"gate_indices",
",",
"number_of_qubits",
")",
":",
"mat_l",
",",
"mat_r",
",",
"tens_lin",
",",
"tens_lout",
"=",
"_einsum_matmul_index_helper",
"(",
"gate_indices",
",",
"number_of_qubits",
")",
"# Right indices for the N-qubit input an... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | einsum_vecmul_index | Return the index string for Numpy.eignsum matrix-vector multiplication.
The returned indices are to perform a matrix multiplication A.v where
the matrix A is an M-qubit matrix, vector v is an N-qubit vector, and
M <= N, and identity matrices are implied on the subsystems where A has no
support on v.
... | qiskit/providers/basicaer/basicaertools.py | def einsum_vecmul_index(gate_indices, number_of_qubits):
"""Return the index string for Numpy.eignsum matrix-vector multiplication.
The returned indices are to perform a matrix multiplication A.v where
the matrix A is an M-qubit matrix, vector v is an N-qubit vector, and
M <= N, and identity matrices a... | def einsum_vecmul_index(gate_indices, number_of_qubits):
"""Return the index string for Numpy.eignsum matrix-vector multiplication.
The returned indices are to perform a matrix multiplication A.v where
the matrix A is an M-qubit matrix, vector v is an N-qubit vector, and
M <= N, and identity matrices a... | [
"Return",
"the",
"index",
"string",
"for",
"Numpy",
".",
"eignsum",
"matrix",
"-",
"vector",
"multiplication",
"."
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/providers/basicaer/basicaertools.py#L100-L124 | [
"def",
"einsum_vecmul_index",
"(",
"gate_indices",
",",
"number_of_qubits",
")",
":",
"mat_l",
",",
"mat_r",
",",
"tens_lin",
",",
"tens_lout",
"=",
"_einsum_matmul_index_helper",
"(",
"gate_indices",
",",
"number_of_qubits",
")",
"# Combine indices into matrix multiplica... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | _einsum_matmul_index_helper | Return the index string for Numpy.eignsum matrix multiplication.
The returned indices are to perform a matrix multiplication A.v where
the matrix A is an M-qubit matrix, matrix v is an N-qubit vector, and
M <= N, and identity matrices are implied on the subsystems where A has no
support on v.
Args... | qiskit/providers/basicaer/basicaertools.py | def _einsum_matmul_index_helper(gate_indices, number_of_qubits):
"""Return the index string for Numpy.eignsum matrix multiplication.
The returned indices are to perform a matrix multiplication A.v where
the matrix A is an M-qubit matrix, matrix v is an N-qubit vector, and
M <= N, and identity matrices ... | def _einsum_matmul_index_helper(gate_indices, number_of_qubits):
"""Return the index string for Numpy.eignsum matrix multiplication.
The returned indices are to perform a matrix multiplication A.v where
the matrix A is an M-qubit matrix, matrix v is an N-qubit vector, and
M <= N, and identity matrices ... | [
"Return",
"the",
"index",
"string",
"for",
"Numpy",
".",
"eignsum",
"matrix",
"multiplication",
"."
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/providers/basicaer/basicaertools.py#L127-L175 | [
"def",
"_einsum_matmul_index_helper",
"(",
"gate_indices",
",",
"number_of_qubits",
")",
":",
"# Since we use ASCII alphabet for einsum index labels we are limited",
"# to 26 total free left (lowercase) and 26 right (uppercase) indexes.",
"# The rank of the contracted tensor reduces this as we n... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | circuit_to_dag | Build a ``DAGCircuit`` object from a ``QuantumCircuit``.
Args:
circuit (QuantumCircuit): the input circuit.
Return:
DAGCircuit: the DAG representing the input circuit. | qiskit/converters/circuit_to_dag.py | def circuit_to_dag(circuit):
"""Build a ``DAGCircuit`` object from a ``QuantumCircuit``.
Args:
circuit (QuantumCircuit): the input circuit.
Return:
DAGCircuit: the DAG representing the input circuit.
"""
dagcircuit = DAGCircuit()
dagcircuit.name = circuit.name
for register ... | def circuit_to_dag(circuit):
"""Build a ``DAGCircuit`` object from a ``QuantumCircuit``.
Args:
circuit (QuantumCircuit): the input circuit.
Return:
DAGCircuit: the DAG representing the input circuit.
"""
dagcircuit = DAGCircuit()
dagcircuit.name = circuit.name
for register ... | [
"Build",
"a",
"DAGCircuit",
"object",
"from",
"a",
"QuantumCircuit",
"."
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/converters/circuit_to_dag.py#L13-L39 | [
"def",
"circuit_to_dag",
"(",
"circuit",
")",
":",
"dagcircuit",
"=",
"DAGCircuit",
"(",
")",
"dagcircuit",
".",
"name",
"=",
"circuit",
".",
"name",
"for",
"register",
"in",
"circuit",
".",
"qregs",
":",
"dagcircuit",
".",
"add_qreg",
"(",
"register",
")"... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | exp_fit_fun | Function used to fit the exponential decay. | qiskit/tools/qcvv/fitters.py | def exp_fit_fun(x, a, tau, c):
"""Function used to fit the exponential decay."""
# pylint: disable=invalid-name
return a * np.exp(-x / tau) + c | def exp_fit_fun(x, a, tau, c):
"""Function used to fit the exponential decay."""
# pylint: disable=invalid-name
return a * np.exp(-x / tau) + c | [
"Function",
"used",
"to",
"fit",
"the",
"exponential",
"decay",
"."
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/tools/qcvv/fitters.py#L23-L26 | [
"def",
"exp_fit_fun",
"(",
"x",
",",
"a",
",",
"tau",
",",
"c",
")",
":",
"# pylint: disable=invalid-name",
"return",
"a",
"*",
"np",
".",
"exp",
"(",
"-",
"x",
"/",
"tau",
")",
"+",
"c"
] | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | osc_fit_fun | Function used to fit the decay cosine. | qiskit/tools/qcvv/fitters.py | def osc_fit_fun(x, a, tau, f, phi, c):
"""Function used to fit the decay cosine."""
# pylint: disable=invalid-name
return a * np.exp(-x / tau) * np.cos(2 * np.pi * f * x + phi) + c | def osc_fit_fun(x, a, tau, f, phi, c):
"""Function used to fit the decay cosine."""
# pylint: disable=invalid-name
return a * np.exp(-x / tau) * np.cos(2 * np.pi * f * x + phi) + c | [
"Function",
"used",
"to",
"fit",
"the",
"decay",
"cosine",
"."
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/tools/qcvv/fitters.py#L29-L32 | [
"def",
"osc_fit_fun",
"(",
"x",
",",
"a",
",",
"tau",
",",
"f",
",",
"phi",
",",
"c",
")",
":",
"# pylint: disable=invalid-name",
"return",
"a",
"*",
"np",
".",
"exp",
"(",
"-",
"x",
"/",
"tau",
")",
"*",
"np",
".",
"cos",
"(",
"2",
"*",
"np",
... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | plot_coherence | Plot coherence data.
Args:
xdata
ydata
std_error
fit
fit_function
xunit
exp_str
qubit_label
Raises:
ImportError: If matplotlib is not installed. | qiskit/tools/qcvv/fitters.py | def plot_coherence(xdata, ydata, std_error, fit, fit_function, xunit, exp_str,
qubit_label):
"""Plot coherence data.
Args:
xdata
ydata
std_error
fit
fit_function
xunit
exp_str
qubit_label
Raises:
ImportError: If matp... | def plot_coherence(xdata, ydata, std_error, fit, fit_function, xunit, exp_str,
qubit_label):
"""Plot coherence data.
Args:
xdata
ydata
std_error
fit
fit_function
xunit
exp_str
qubit_label
Raises:
ImportError: If matp... | [
"Plot",
"coherence",
"data",
"."
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/tools/qcvv/fitters.py#L42-L72 | [
"def",
"plot_coherence",
"(",
"xdata",
",",
"ydata",
",",
"std_error",
",",
"fit",
",",
"fit_function",
",",
"xunit",
",",
"exp_str",
",",
"qubit_label",
")",
":",
"if",
"not",
"HAS_MATPLOTLIB",
":",
"raise",
"ImportError",
"(",
"'The function plot_coherence nee... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | shape_rb_data | Take the raw rb data and convert it into averages and std dev
Args:
raw_rb (numpy.array): m x n x l list where m is the number of seeds, n
is the number of Clifford sequences and l is the number of qubits
Return:
numpy_array: 2 x n x l list where index 0 is the mean over seeds, 1 i... | qiskit/tools/qcvv/fitters.py | def shape_rb_data(raw_rb):
"""Take the raw rb data and convert it into averages and std dev
Args:
raw_rb (numpy.array): m x n x l list where m is the number of seeds, n
is the number of Clifford sequences and l is the number of qubits
Return:
numpy_array: 2 x n x l list where i... | def shape_rb_data(raw_rb):
"""Take the raw rb data and convert it into averages and std dev
Args:
raw_rb (numpy.array): m x n x l list where m is the number of seeds, n
is the number of Clifford sequences and l is the number of qubits
Return:
numpy_array: 2 x n x l list where i... | [
"Take",
"the",
"raw",
"rb",
"data",
"and",
"convert",
"it",
"into",
"averages",
"and",
"std",
"dev"
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/tools/qcvv/fitters.py#L75-L90 | [
"def",
"shape_rb_data",
"(",
"raw_rb",
")",
":",
"rb_data",
"=",
"[",
"]",
"rb_data",
".",
"append",
"(",
"np",
".",
"mean",
"(",
"raw_rb",
",",
"0",
")",
")",
"rb_data",
".",
"append",
"(",
"np",
".",
"std",
"(",
"raw_rb",
",",
"0",
")",
")",
... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | rb_epc | Take the rb fit data and convert it into EPC (error per Clifford)
Args:
fit (dict): dictionary of the fit quantities (A, alpha, B) with the
keys 'qn' where n is the qubit and subkeys 'fit', e.g.
{'q0':{'fit': [1, 0, 0.9], 'fiterr': [0, 0, 0]}}}
rb_pattern (list): (see rando... | qiskit/tools/qcvv/fitters.py | def rb_epc(fit, rb_pattern):
"""Take the rb fit data and convert it into EPC (error per Clifford)
Args:
fit (dict): dictionary of the fit quantities (A, alpha, B) with the
keys 'qn' where n is the qubit and subkeys 'fit', e.g.
{'q0':{'fit': [1, 0, 0.9], 'fiterr': [0, 0, 0]}}}
... | def rb_epc(fit, rb_pattern):
"""Take the rb fit data and convert it into EPC (error per Clifford)
Args:
fit (dict): dictionary of the fit quantities (A, alpha, B) with the
keys 'qn' where n is the qubit and subkeys 'fit', e.g.
{'q0':{'fit': [1, 0, 0.9], 'fiterr': [0, 0, 0]}}}
... | [
"Take",
"the",
"rb",
"fit",
"data",
"and",
"convert",
"it",
"into",
"EPC",
"(",
"error",
"per",
"Clifford",
")"
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/tools/qcvv/fitters.py#L93-L119 | [
"def",
"rb_epc",
"(",
"fit",
",",
"rb_pattern",
")",
":",
"for",
"patterns",
"in",
"rb_pattern",
":",
"for",
"qubit",
"in",
"patterns",
":",
"fitalpha",
"=",
"fit",
"[",
"'q%d'",
"%",
"qubit",
"]",
"[",
"'fit'",
"]",
"[",
"1",
"]",
"fitalphaerr",
"="... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | plot_rb_data | Plot randomized benchmarking data.
Args:
xdata (list): list of subsequence lengths
ydatas (list): list of lists of survival probabilities for each
sequence
yavg (list): mean of the survival probabilities at each sequence
length
yerr (list): error of the survi... | qiskit/tools/qcvv/fitters.py | def plot_rb_data(xdata, ydatas, yavg, yerr, fit, survival_prob, ax=None,
show_plt=True):
"""Plot randomized benchmarking data.
Args:
xdata (list): list of subsequence lengths
ydatas (list): list of lists of survival probabilities for each
sequence
yavg (list... | def plot_rb_data(xdata, ydatas, yavg, yerr, fit, survival_prob, ax=None,
show_plt=True):
"""Plot randomized benchmarking data.
Args:
xdata (list): list of subsequence lengths
ydatas (list): list of lists of survival probabilities for each
sequence
yavg (list... | [
"Plot",
"randomized",
"benchmarking",
"data",
"."
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/tools/qcvv/fitters.py#L122-L166 | [
"def",
"plot_rb_data",
"(",
"xdata",
",",
"ydatas",
",",
"yavg",
",",
"yerr",
",",
"fit",
",",
"survival_prob",
",",
"ax",
"=",
"None",
",",
"show_plt",
"=",
"True",
")",
":",
"# pylint: disable=invalid-name",
"if",
"not",
"HAS_MATPLOTLIB",
":",
"raise",
"... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | _split_runs_on_parameters | Finds runs containing parameterized gates and splits them into sequential
runs excluding the parameterized gates. | qiskit/transpiler/passes/optimize_1q_gates.py | def _split_runs_on_parameters(runs):
"""Finds runs containing parameterized gates and splits them into sequential
runs excluding the parameterized gates.
"""
def _is_dagnode_parameterized(node):
return any(isinstance(param, Parameter) for param in node.op.params)
out = []
for run in ru... | def _split_runs_on_parameters(runs):
"""Finds runs containing parameterized gates and splits them into sequential
runs excluding the parameterized gates.
"""
def _is_dagnode_parameterized(node):
return any(isinstance(param, Parameter) for param in node.op.params)
out = []
for run in ru... | [
"Finds",
"runs",
"containing",
"parameterized",
"gates",
"and",
"splits",
"them",
"into",
"sequential",
"runs",
"excluding",
"the",
"parameterized",
"gates",
"."
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/transpiler/passes/optimize_1q_gates.py#L238-L254 | [
"def",
"_split_runs_on_parameters",
"(",
"runs",
")",
":",
"def",
"_is_dagnode_parameterized",
"(",
"node",
")",
":",
"return",
"any",
"(",
"isinstance",
"(",
"param",
",",
"Parameter",
")",
"for",
"param",
"in",
"node",
".",
"op",
".",
"params",
")",
"out... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | Optimize1qGates.run | Return a new circuit that has been optimized. | qiskit/transpiler/passes/optimize_1q_gates.py | def run(self, dag):
"""Return a new circuit that has been optimized."""
runs = dag.collect_runs(["u1", "u2", "u3", "id"])
runs = _split_runs_on_parameters(runs)
for run in runs:
right_name = "u1"
right_parameters = (0, 0, 0) # (theta, phi, lambda)
fo... | def run(self, dag):
"""Return a new circuit that has been optimized."""
runs = dag.collect_runs(["u1", "u2", "u3", "id"])
runs = _split_runs_on_parameters(runs)
for run in runs:
right_name = "u1"
right_parameters = (0, 0, 0) # (theta, phi, lambda)
fo... | [
"Return",
"a",
"new",
"circuit",
"that",
"has",
"been",
"optimized",
"."
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/transpiler/passes/optimize_1q_gates.py#L39-L191 | [
"def",
"run",
"(",
"self",
",",
"dag",
")",
":",
"runs",
"=",
"dag",
".",
"collect_runs",
"(",
"[",
"\"u1\"",
",",
"\"u2\"",
",",
"\"u3\"",
",",
"\"id\"",
"]",
")",
"runs",
"=",
"_split_runs_on_parameters",
"(",
"runs",
")",
"for",
"run",
"in",
"runs... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | Optimize1qGates.compose_u3 | Return a triple theta, phi, lambda for the product.
u3(theta, phi, lambda)
= u3(theta1, phi1, lambda1).u3(theta2, phi2, lambda2)
= Rz(phi1).Ry(theta1).Rz(lambda1+phi2).Ry(theta2).Rz(lambda2)
= Rz(phi1).Rz(phi').Ry(theta').Rz(lambda').Rz(lambda2)
= u3(theta', phi1 + p... | qiskit/transpiler/passes/optimize_1q_gates.py | def compose_u3(theta1, phi1, lambda1, theta2, phi2, lambda2):
"""Return a triple theta, phi, lambda for the product.
u3(theta, phi, lambda)
= u3(theta1, phi1, lambda1).u3(theta2, phi2, lambda2)
= Rz(phi1).Ry(theta1).Rz(lambda1+phi2).Ry(theta2).Rz(lambda2)
= Rz(phi1).Rz(... | def compose_u3(theta1, phi1, lambda1, theta2, phi2, lambda2):
"""Return a triple theta, phi, lambda for the product.
u3(theta, phi, lambda)
= u3(theta1, phi1, lambda1).u3(theta2, phi2, lambda2)
= Rz(phi1).Ry(theta1).Rz(lambda1+phi2).Ry(theta2).Rz(lambda2)
= Rz(phi1).Rz(... | [
"Return",
"a",
"triple",
"theta",
"phi",
"lambda",
"for",
"the",
"product",
"."
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/transpiler/passes/optimize_1q_gates.py#L194-L209 | [
"def",
"compose_u3",
"(",
"theta1",
",",
"phi1",
",",
"lambda1",
",",
"theta2",
",",
"phi2",
",",
"lambda2",
")",
":",
"# Careful with the factor of two in yzy_to_zyz",
"thetap",
",",
"phip",
",",
"lambdap",
"=",
"Optimize1qGates",
".",
"yzy_to_zyz",
"(",
"(",
... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | Optimize1qGates.yzy_to_zyz | Express a Y.Z.Y single qubit gate as a Z.Y.Z gate.
Solve the equation
.. math::
Ry(theta1).Rz(xi).Ry(theta2) = Rz(phi).Ry(theta).Rz(lambda)
for theta, phi, and lambda.
Return a solution theta, phi, and lambda. | qiskit/transpiler/passes/optimize_1q_gates.py | def yzy_to_zyz(xi, theta1, theta2, eps=1e-9): # pylint: disable=invalid-name
"""Express a Y.Z.Y single qubit gate as a Z.Y.Z gate.
Solve the equation
.. math::
Ry(theta1).Rz(xi).Ry(theta2) = Rz(phi).Ry(theta).Rz(lambda)
for theta, phi, and lambda.
Return a solution ... | def yzy_to_zyz(xi, theta1, theta2, eps=1e-9): # pylint: disable=invalid-name
"""Express a Y.Z.Y single qubit gate as a Z.Y.Z gate.
Solve the equation
.. math::
Ry(theta1).Rz(xi).Ry(theta2) = Rz(phi).Ry(theta).Rz(lambda)
for theta, phi, and lambda.
Return a solution ... | [
"Express",
"a",
"Y",
".",
"Z",
".",
"Y",
"single",
"qubit",
"gate",
"as",
"a",
"Z",
".",
"Y",
".",
"Z",
"gate",
"."
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/transpiler/passes/optimize_1q_gates.py#L212-L235 | [
"def",
"yzy_to_zyz",
"(",
"xi",
",",
"theta1",
",",
"theta2",
",",
"eps",
"=",
"1e-9",
")",
":",
"# pylint: disable=invalid-name",
"quaternion_yzy",
"=",
"quaternion_from_euler",
"(",
"[",
"theta1",
",",
"xi",
",",
"theta2",
"]",
",",
"'yzy'",
")",
"euler",
... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | FullAncillaAllocation.run | Extend the layout with new (physical qubit, virtual qubit) pairs.
The dag signals which virtual qubits are already in the circuit.
This pass will allocate new virtual qubits such that no collision occurs
(i.e. Layout bijectivity is preserved)
The coupling_map and layout together determ... | qiskit/transpiler/passes/mapping/full_ancilla_allocation.py | def run(self, dag):
"""
Extend the layout with new (physical qubit, virtual qubit) pairs.
The dag signals which virtual qubits are already in the circuit.
This pass will allocate new virtual qubits such that no collision occurs
(i.e. Layout bijectivity is preserved)
The... | def run(self, dag):
"""
Extend the layout with new (physical qubit, virtual qubit) pairs.
The dag signals which virtual qubits are already in the circuit.
This pass will allocate new virtual qubits such that no collision occurs
(i.e. Layout bijectivity is preserved)
The... | [
"Extend",
"the",
"layout",
"with",
"new",
"(",
"physical",
"qubit",
"virtual",
"qubit",
")",
"pairs",
"."
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/transpiler/passes/mapping/full_ancilla_allocation.py#L41-L83 | [
"def",
"run",
"(",
"self",
",",
"dag",
")",
":",
"self",
".",
"layout",
"=",
"self",
".",
"layout",
"or",
"self",
".",
"property_set",
".",
"get",
"(",
"'layout'",
")",
"if",
"self",
".",
"layout",
"is",
"None",
":",
"raise",
"TranspilerError",
"(",
... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | _validate_input_state | Validates the input to state visualization functions.
Args:
quantum_state (ndarray): Input state / density matrix.
Returns:
rho: A 2d numpy array for the density matrix.
Raises:
VisualizationError: Invalid input. | qiskit/visualization/utils.py | def _validate_input_state(quantum_state):
"""Validates the input to state visualization functions.
Args:
quantum_state (ndarray): Input state / density matrix.
Returns:
rho: A 2d numpy array for the density matrix.
Raises:
VisualizationError: Invalid input.
"""
rho = np.... | def _validate_input_state(quantum_state):
"""Validates the input to state visualization functions.
Args:
quantum_state (ndarray): Input state / density matrix.
Returns:
rho: A 2d numpy array for the density matrix.
Raises:
VisualizationError: Invalid input.
"""
rho = np.... | [
"Validates",
"the",
"input",
"to",
"state",
"visualization",
"functions",
"."
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/visualization/utils.py#L16-L37 | [
"def",
"_validate_input_state",
"(",
"quantum_state",
")",
":",
"rho",
"=",
"np",
".",
"asarray",
"(",
"quantum_state",
")",
"if",
"rho",
".",
"ndim",
"==",
"1",
":",
"rho",
"=",
"np",
".",
"outer",
"(",
"rho",
",",
"np",
".",
"conj",
"(",
"rho",
"... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | _trim | Trim a PIL image and remove white space. | qiskit/visualization/utils.py | def _trim(image):
"""Trim a PIL image and remove white space."""
background = PIL.Image.new(image.mode, image.size, image.getpixel((0, 0)))
diff = PIL.ImageChops.difference(image, background)
diff = PIL.ImageChops.add(diff, diff, 2.0, -100)
bbox = diff.getbbox()
if bbox:
image = image.cr... | def _trim(image):
"""Trim a PIL image and remove white space."""
background = PIL.Image.new(image.mode, image.size, image.getpixel((0, 0)))
diff = PIL.ImageChops.difference(image, background)
diff = PIL.ImageChops.add(diff, diff, 2.0, -100)
bbox = diff.getbbox()
if bbox:
image = image.cr... | [
"Trim",
"a",
"PIL",
"image",
"and",
"remove",
"white",
"space",
"."
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/visualization/utils.py#L40-L48 | [
"def",
"_trim",
"(",
"image",
")",
":",
"background",
"=",
"PIL",
".",
"Image",
".",
"new",
"(",
"image",
".",
"mode",
",",
"image",
".",
"size",
",",
"image",
".",
"getpixel",
"(",
"(",
"0",
",",
"0",
")",
")",
")",
"diff",
"=",
"PIL",
".",
... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | _get_layered_instructions | Given a circuit, return a tuple (qregs, cregs, ops) where
qregs and cregs are the quantum and classical registers
in order (based on reverse_bits) and ops is a list
of DAG nodes which type is "operation".
Args:
circuit (QuantumCircuit): From where the information is extracted.
reverse_bi... | qiskit/visualization/utils.py | def _get_layered_instructions(circuit, reverse_bits=False, justify=None):
"""
Given a circuit, return a tuple (qregs, cregs, ops) where
qregs and cregs are the quantum and classical registers
in order (based on reverse_bits) and ops is a list
of DAG nodes which type is "operation".
Args:
... | def _get_layered_instructions(circuit, reverse_bits=False, justify=None):
"""
Given a circuit, return a tuple (qregs, cregs, ops) where
qregs and cregs are the quantum and classical registers
in order (based on reverse_bits) and ops is a list
of DAG nodes which type is "operation".
Args:
... | [
"Given",
"a",
"circuit",
"return",
"a",
"tuple",
"(",
"qregs",
"cregs",
"ops",
")",
"where",
"qregs",
"and",
"cregs",
"are",
"the",
"quantum",
"and",
"classical",
"registers",
"in",
"order",
"(",
"based",
"on",
"reverse_bits",
")",
"and",
"ops",
"is",
"a... | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/visualization/utils.py#L51-L175 | [
"def",
"_get_layered_instructions",
"(",
"circuit",
",",
"reverse_bits",
"=",
"False",
",",
"justify",
"=",
"None",
")",
":",
"if",
"justify",
":",
"justify",
"=",
"justify",
".",
"lower",
"(",
")",
"# default to left",
"justify",
"=",
"justify",
"if",
"just... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | _get_gate_span | Get the list of qubits drawing this gate would cover | qiskit/visualization/utils.py | def _get_gate_span(qregs, instruction):
"""Get the list of qubits drawing this gate would cover"""
min_index = len(qregs)
max_index = 0
for qreg in instruction.qargs:
index = qregs.index(qreg)
if index < min_index:
min_index = index
if index > max_index:
... | def _get_gate_span(qregs, instruction):
"""Get the list of qubits drawing this gate would cover"""
min_index = len(qregs)
max_index = 0
for qreg in instruction.qargs:
index = qregs.index(qreg)
if index < min_index:
min_index = index
if index > max_index:
... | [
"Get",
"the",
"list",
"of",
"qubits",
"drawing",
"this",
"gate",
"would",
"cover"
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/visualization/utils.py#L178-L194 | [
"def",
"_get_gate_span",
"(",
"qregs",
",",
"instruction",
")",
":",
"min_index",
"=",
"len",
"(",
"qregs",
")",
"max_index",
"=",
"0",
"for",
"qreg",
"in",
"instruction",
".",
"qargs",
":",
"index",
"=",
"qregs",
".",
"index",
"(",
"qreg",
")",
"if",
... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | circuit_to_instruction | Build an ``Instruction`` object from a ``QuantumCircuit``.
The instruction is anonymous (not tied to a named quantum register),
and so can be inserted into another circuit. The instruction will
have the same string name as the circuit.
Args:
circuit (QuantumCircuit): the input circuit.
Re... | qiskit/converters/circuit_to_instruction.py | def circuit_to_instruction(circuit):
"""Build an ``Instruction`` object from a ``QuantumCircuit``.
The instruction is anonymous (not tied to a named quantum register),
and so can be inserted into another circuit. The instruction will
have the same string name as the circuit.
Args:
circuit ... | def circuit_to_instruction(circuit):
"""Build an ``Instruction`` object from a ``QuantumCircuit``.
The instruction is anonymous (not tied to a named quantum register),
and so can be inserted into another circuit. The instruction will
have the same string name as the circuit.
Args:
circuit ... | [
"Build",
"an",
"Instruction",
"object",
"from",
"a",
"QuantumCircuit",
"."
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/converters/circuit_to_instruction.py#L15-L60 | [
"def",
"circuit_to_instruction",
"(",
"circuit",
")",
":",
"instruction",
"=",
"Instruction",
"(",
"name",
"=",
"circuit",
".",
"name",
",",
"num_qubits",
"=",
"sum",
"(",
"[",
"qreg",
".",
"size",
"for",
"qreg",
"in",
"circuit",
".",
"qregs",
"]",
")",
... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | DenseLayout.run | Pick a convenient layout depending on the best matching
qubit connectivity, and set the property `layout`.
Args:
dag (DAGCircuit): DAG to find layout for.
Raises:
TranspilerError: if dag wider than self.coupling_map | qiskit/transpiler/passes/mapping/dense_layout.py | def run(self, dag):
"""
Pick a convenient layout depending on the best matching
qubit connectivity, and set the property `layout`.
Args:
dag (DAGCircuit): DAG to find layout for.
Raises:
TranspilerError: if dag wider than self.coupling_map
"""
... | def run(self, dag):
"""
Pick a convenient layout depending on the best matching
qubit connectivity, and set the property `layout`.
Args:
dag (DAGCircuit): DAG to find layout for.
Raises:
TranspilerError: if dag wider than self.coupling_map
"""
... | [
"Pick",
"a",
"convenient",
"layout",
"depending",
"on",
"the",
"best",
"matching",
"qubit",
"connectivity",
"and",
"set",
"the",
"property",
"layout",
"."
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/transpiler/passes/mapping/dense_layout.py#L45-L66 | [
"def",
"run",
"(",
"self",
",",
"dag",
")",
":",
"num_dag_qubits",
"=",
"sum",
"(",
"[",
"qreg",
".",
"size",
"for",
"qreg",
"in",
"dag",
".",
"qregs",
".",
"values",
"(",
")",
"]",
")",
"if",
"num_dag_qubits",
">",
"self",
".",
"coupling_map",
"."... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | DenseLayout._best_subset | Computes the qubit mapping with the best connectivity.
Args:
n_qubits (int): Number of subset qubits to consider.
Returns:
ndarray: Array of qubits to use for best connectivity mapping. | qiskit/transpiler/passes/mapping/dense_layout.py | def _best_subset(self, n_qubits):
"""Computes the qubit mapping with the best connectivity.
Args:
n_qubits (int): Number of subset qubits to consider.
Returns:
ndarray: Array of qubits to use for best connectivity mapping.
"""
if n_qubits == 1:
... | def _best_subset(self, n_qubits):
"""Computes the qubit mapping with the best connectivity.
Args:
n_qubits (int): Number of subset qubits to consider.
Returns:
ndarray: Array of qubits to use for best connectivity mapping.
"""
if n_qubits == 1:
... | [
"Computes",
"the",
"qubit",
"mapping",
"with",
"the",
"best",
"connectivity",
"."
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/transpiler/passes/mapping/dense_layout.py#L68-L121 | [
"def",
"_best_subset",
"(",
"self",
",",
"n_qubits",
")",
":",
"if",
"n_qubits",
"==",
"1",
":",
"return",
"np",
".",
"array",
"(",
"[",
"0",
"]",
")",
"device_qubits",
"=",
"self",
".",
"coupling_map",
".",
"size",
"(",
")",
"cmap",
"=",
"np",
"."... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | Kraus.is_cptp | Return True if completely-positive trace-preserving. | qiskit/quantum_info/operators/channel/kraus.py | def is_cptp(self, atol=None, rtol=None):
"""Return True if completely-positive trace-preserving."""
if self._data[1] is not None:
return False
if atol is None:
atol = self._atol
if rtol is None:
rtol = self._rtol
accum = 0j
for op in se... | def is_cptp(self, atol=None, rtol=None):
"""Return True if completely-positive trace-preserving."""
if self._data[1] is not None:
return False
if atol is None:
atol = self._atol
if rtol is None:
rtol = self._rtol
accum = 0j
for op in se... | [
"Return",
"True",
"if",
"completely",
"-",
"positive",
"trace",
"-",
"preserving",
"."
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/quantum_info/operators/channel/kraus.py#L166-L177 | [
"def",
"is_cptp",
"(",
"self",
",",
"atol",
"=",
"None",
",",
"rtol",
"=",
"None",
")",
":",
"if",
"self",
".",
"_data",
"[",
"1",
"]",
"is",
"not",
"None",
":",
"return",
"False",
"if",
"atol",
"is",
"None",
":",
"atol",
"=",
"self",
".",
"_at... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | Kraus.conjugate | Return the conjugate of the QuantumChannel. | qiskit/quantum_info/operators/channel/kraus.py | def conjugate(self):
"""Return the conjugate of the QuantumChannel."""
kraus_l, kraus_r = self._data
kraus_l = [k.conj() for k in kraus_l]
if kraus_r is not None:
kraus_r = [k.conj() for k in kraus_r]
return Kraus((kraus_l, kraus_r), self.input_dims(), self.output_dim... | def conjugate(self):
"""Return the conjugate of the QuantumChannel."""
kraus_l, kraus_r = self._data
kraus_l = [k.conj() for k in kraus_l]
if kraus_r is not None:
kraus_r = [k.conj() for k in kraus_r]
return Kraus((kraus_l, kraus_r), self.input_dims(), self.output_dim... | [
"Return",
"the",
"conjugate",
"of",
"the",
"QuantumChannel",
"."
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/quantum_info/operators/channel/kraus.py#L179-L185 | [
"def",
"conjugate",
"(",
"self",
")",
":",
"kraus_l",
",",
"kraus_r",
"=",
"self",
".",
"_data",
"kraus_l",
"=",
"[",
"k",
".",
"conj",
"(",
")",
"for",
"k",
"in",
"kraus_l",
"]",
"if",
"kraus_r",
"is",
"not",
"None",
":",
"kraus_r",
"=",
"[",
"k... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | Kraus.transpose | Return the transpose of the QuantumChannel. | qiskit/quantum_info/operators/channel/kraus.py | def transpose(self):
"""Return the transpose of the QuantumChannel."""
kraus_l, kraus_r = self._data
kraus_l = [k.T for k in kraus_l]
if kraus_r is not None:
kraus_r = [k.T for k in kraus_r]
return Kraus((kraus_l, kraus_r),
input_dims=self.output_... | def transpose(self):
"""Return the transpose of the QuantumChannel."""
kraus_l, kraus_r = self._data
kraus_l = [k.T for k in kraus_l]
if kraus_r is not None:
kraus_r = [k.T for k in kraus_r]
return Kraus((kraus_l, kraus_r),
input_dims=self.output_... | [
"Return",
"the",
"transpose",
"of",
"the",
"QuantumChannel",
"."
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/quantum_info/operators/channel/kraus.py#L187-L195 | [
"def",
"transpose",
"(",
"self",
")",
":",
"kraus_l",
",",
"kraus_r",
"=",
"self",
".",
"_data",
"kraus_l",
"=",
"[",
"k",
".",
"T",
"for",
"k",
"in",
"kraus_l",
"]",
"if",
"kraus_r",
"is",
"not",
"None",
":",
"kraus_r",
"=",
"[",
"k",
".",
"T",
... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | Kraus.compose | Return the composition channel self∘other.
Args:
other (QuantumChannel): a quantum channel subclass.
qargs (list): a list of subsystem positions to compose other on.
front (bool): If False compose in standard order other(self(input))
otherwise compo... | qiskit/quantum_info/operators/channel/kraus.py | def compose(self, other, qargs=None, front=False):
"""Return the composition channel self∘other.
Args:
other (QuantumChannel): a quantum channel subclass.
qargs (list): a list of subsystem positions to compose other on.
front (bool): If False compose in standard orde... | def compose(self, other, qargs=None, front=False):
"""Return the composition channel self∘other.
Args:
other (QuantumChannel): a quantum channel subclass.
qargs (list): a list of subsystem positions to compose other on.
front (bool): If False compose in standard orde... | [
"Return",
"the",
"composition",
"channel",
"self∘other",
"."
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/quantum_info/operators/channel/kraus.py#L197-L248 | [
"def",
"compose",
"(",
"self",
",",
"other",
",",
"qargs",
"=",
"None",
",",
"front",
"=",
"False",
")",
":",
"if",
"qargs",
"is",
"not",
"None",
":",
"return",
"Kraus",
"(",
"SuperOp",
"(",
"self",
")",
".",
"compose",
"(",
"other",
",",
"qargs",
... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | Kraus.power | The matrix power of the channel.
Args:
n (int): compute the matrix power of the superoperator matrix.
Returns:
Kraus: the matrix power of the SuperOp converted to a Kraus channel.
Raises:
QiskitError: if the input and output dimensions of the
Qu... | qiskit/quantum_info/operators/channel/kraus.py | def power(self, n):
"""The matrix power of the channel.
Args:
n (int): compute the matrix power of the superoperator matrix.
Returns:
Kraus: the matrix power of the SuperOp converted to a Kraus channel.
Raises:
QiskitError: if the input and output d... | def power(self, n):
"""The matrix power of the channel.
Args:
n (int): compute the matrix power of the superoperator matrix.
Returns:
Kraus: the matrix power of the SuperOp converted to a Kraus channel.
Raises:
QiskitError: if the input and output d... | [
"The",
"matrix",
"power",
"of",
"the",
"channel",
"."
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/quantum_info/operators/channel/kraus.py#L250-L265 | [
"def",
"power",
"(",
"self",
",",
"n",
")",
":",
"if",
"n",
">",
"0",
":",
"return",
"super",
"(",
")",
".",
"power",
"(",
"n",
")",
"return",
"Kraus",
"(",
"SuperOp",
"(",
"self",
")",
".",
"power",
"(",
"n",
")",
")"
] | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | Kraus.multiply | Return the QuantumChannel self + other.
Args:
other (complex): a complex number.
Returns:
Kraus: the scalar multiplication other * self as a Kraus object.
Raises:
QiskitError: if other is not a valid scalar. | qiskit/quantum_info/operators/channel/kraus.py | def multiply(self, other):
"""Return the QuantumChannel self + other.
Args:
other (complex): a complex number.
Returns:
Kraus: the scalar multiplication other * self as a Kraus object.
Raises:
QiskitError: if other is not a valid scalar.
"""... | def multiply(self, other):
"""Return the QuantumChannel self + other.
Args:
other (complex): a complex number.
Returns:
Kraus: the scalar multiplication other * self as a Kraus object.
Raises:
QiskitError: if other is not a valid scalar.
"""... | [
"Return",
"the",
"QuantumChannel",
"self",
"+",
"other",
"."
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/quantum_info/operators/channel/kraus.py#L333-L359 | [
"def",
"multiply",
"(",
"self",
",",
"other",
")",
":",
"if",
"not",
"isinstance",
"(",
"other",
",",
"Number",
")",
":",
"raise",
"QiskitError",
"(",
"\"other is not a number\"",
")",
"# If the number is complex we need to convert to general",
"# kraus channel so we mu... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | Kraus._evolve | Evolve a quantum state by the QuantumChannel.
Args:
state (QuantumState): The input statevector or density matrix.
qargs (list): a list of QuantumState subsystem positions to apply
the operator on.
Returns:
QuantumState: the output quantum... | qiskit/quantum_info/operators/channel/kraus.py | def _evolve(self, state, qargs=None):
"""Evolve a quantum state by the QuantumChannel.
Args:
state (QuantumState): The input statevector or density matrix.
qargs (list): a list of QuantumState subsystem positions to apply
the operator on.
Retu... | def _evolve(self, state, qargs=None):
"""Evolve a quantum state by the QuantumChannel.
Args:
state (QuantumState): The input statevector or density matrix.
qargs (list): a list of QuantumState subsystem positions to apply
the operator on.
Retu... | [
"Evolve",
"a",
"quantum",
"state",
"by",
"the",
"QuantumChannel",
"."
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/quantum_info/operators/channel/kraus.py#L361-L397 | [
"def",
"_evolve",
"(",
"self",
",",
"state",
",",
"qargs",
"=",
"None",
")",
":",
"# If subsystem evolution we use the SuperOp representation",
"if",
"qargs",
"is",
"not",
"None",
":",
"return",
"SuperOp",
"(",
"self",
")",
".",
"_evolve",
"(",
"state",
",",
... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | Kraus._tensor_product | Return the tensor product channel.
Args:
other (QuantumChannel): a quantum channel subclass.
reverse (bool): If False return self ⊗ other, if True return
if True return (other ⊗ self) [Default: False
Returns:
Kraus: the tensor product chan... | qiskit/quantum_info/operators/channel/kraus.py | def _tensor_product(self, other, reverse=False):
"""Return the tensor product channel.
Args:
other (QuantumChannel): a quantum channel subclass.
reverse (bool): If False return self ⊗ other, if True return
if True return (other ⊗ self) [Default: False... | def _tensor_product(self, other, reverse=False):
"""Return the tensor product channel.
Args:
other (QuantumChannel): a quantum channel subclass.
reverse (bool): If False return self ⊗ other, if True return
if True return (other ⊗ self) [Default: False... | [
"Return",
"the",
"tensor",
"product",
"channel",
"."
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/quantum_info/operators/channel/kraus.py#L399-L439 | [
"def",
"_tensor_product",
"(",
"self",
",",
"other",
",",
"reverse",
"=",
"False",
")",
":",
"# Convert other to Kraus",
"if",
"not",
"isinstance",
"(",
"other",
",",
"Kraus",
")",
":",
"other",
"=",
"Kraus",
"(",
"other",
")",
"# Get tensor matrix",
"ka_l",... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | functional_pulse | A decorator for generating SamplePulse from python callable.
Args:
func (callable): A function describing pulse envelope.
Raises:
PulseError: when invalid function is specified. | qiskit/pulse/commands/pulse_decorators.py | def functional_pulse(func):
"""A decorator for generating SamplePulse from python callable.
Args:
func (callable): A function describing pulse envelope.
Raises:
PulseError: when invalid function is specified.
"""
@functools.wraps(func)
def to_pulse(duration, *args, name=None, **k... | def functional_pulse(func):
"""A decorator for generating SamplePulse from python callable.
Args:
func (callable): A function describing pulse envelope.
Raises:
PulseError: when invalid function is specified.
"""
@functools.wraps(func)
def to_pulse(duration, *args, name=None, **k... | [
"A",
"decorator",
"for",
"generating",
"SamplePulse",
"from",
"python",
"callable",
".",
"Args",
":",
"func",
"(",
"callable",
")",
":",
"A",
"function",
"describing",
"pulse",
"envelope",
".",
"Raises",
":",
"PulseError",
":",
"when",
"invalid",
"function",
... | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/pulse/commands/pulse_decorators.py#L21-L37 | [
"def",
"functional_pulse",
"(",
"func",
")",
":",
"@",
"functools",
".",
"wraps",
"(",
"func",
")",
"def",
"to_pulse",
"(",
"duration",
",",
"*",
"args",
",",
"name",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"\"\"\"Return SamplePulse.\"\"\"",
"if"... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | BinaryOp.real | Return the correspond floating point number. | qiskit/qasm/node/binaryop.py | def real(self, nested_scope=None):
"""Return the correspond floating point number."""
operation = self.children[0].operation()
lhs = self.children[1].real(nested_scope)
rhs = self.children[2].real(nested_scope)
return operation(lhs, rhs) | def real(self, nested_scope=None):
"""Return the correspond floating point number."""
operation = self.children[0].operation()
lhs = self.children[1].real(nested_scope)
rhs = self.children[2].real(nested_scope)
return operation(lhs, rhs) | [
"Return",
"the",
"correspond",
"floating",
"point",
"number",
"."
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/qasm/node/binaryop.py#L38-L43 | [
"def",
"real",
"(",
"self",
",",
"nested_scope",
"=",
"None",
")",
":",
"operation",
"=",
"self",
".",
"children",
"[",
"0",
"]",
".",
"operation",
"(",
")",
"lhs",
"=",
"self",
".",
"children",
"[",
"1",
"]",
".",
"real",
"(",
"nested_scope",
")",... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | BinaryOp.sym | Return the correspond symbolic number. | qiskit/qasm/node/binaryop.py | def sym(self, nested_scope=None):
"""Return the correspond symbolic number."""
operation = self.children[0].operation()
lhs = self.children[1].sym(nested_scope)
rhs = self.children[2].sym(nested_scope)
return operation(lhs, rhs) | def sym(self, nested_scope=None):
"""Return the correspond symbolic number."""
operation = self.children[0].operation()
lhs = self.children[1].sym(nested_scope)
rhs = self.children[2].sym(nested_scope)
return operation(lhs, rhs) | [
"Return",
"the",
"correspond",
"symbolic",
"number",
"."
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/qasm/node/binaryop.py#L45-L50 | [
"def",
"sym",
"(",
"self",
",",
"nested_scope",
"=",
"None",
")",
":",
"operation",
"=",
"self",
".",
"children",
"[",
"0",
"]",
".",
"operation",
"(",
")",
"lhs",
"=",
"self",
".",
"children",
"[",
"1",
"]",
".",
"sym",
"(",
"nested_scope",
")",
... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | barrier | Apply barrier to circuit.
If qargs is None, applies to all the qbits.
Args is a list of QuantumRegister or single qubits.
For QuantumRegister, applies barrier to all the qubits in that register. | qiskit/extensions/standard/barrier.py | def barrier(self, *qargs):
"""Apply barrier to circuit.
If qargs is None, applies to all the qbits.
Args is a list of QuantumRegister or single qubits.
For QuantumRegister, applies barrier to all the qubits in that register."""
qubits = []
qargs = _convert_to_bits(qargs, [qbit for qreg in self.... | def barrier(self, *qargs):
"""Apply barrier to circuit.
If qargs is None, applies to all the qbits.
Args is a list of QuantumRegister or single qubits.
For QuantumRegister, applies barrier to all the qubits in that register."""
qubits = []
qargs = _convert_to_bits(qargs, [qbit for qreg in self.... | [
"Apply",
"barrier",
"to",
"circuit",
".",
"If",
"qargs",
"is",
"None",
"applies",
"to",
"all",
"the",
"qbits",
".",
"Args",
"is",
"a",
"list",
"of",
"QuantumRegister",
"or",
"single",
"qubits",
".",
"For",
"QuantumRegister",
"applies",
"barrier",
"to",
"al... | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/extensions/standard/barrier.py#L30-L53 | [
"def",
"barrier",
"(",
"self",
",",
"*",
"qargs",
")",
":",
"qubits",
"=",
"[",
"]",
"qargs",
"=",
"_convert_to_bits",
"(",
"qargs",
",",
"[",
"qbit",
"for",
"qreg",
"in",
"self",
".",
"qregs",
"for",
"qbit",
"in",
"qreg",
"]",
")",
"if",
"not",
... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | average_data | Compute the mean value of an diagonal observable.
Takes in a diagonal observable in dictionary, list or matrix format and then
calculates the sum_i value(i) P(i) where value(i) is the value of the
observable for state i.
Args:
counts (dict): a dict of outcomes from an experiment
observ... | qiskit/quantum_info/analyzation/average.py | def average_data(counts, observable):
"""Compute the mean value of an diagonal observable.
Takes in a diagonal observable in dictionary, list or matrix format and then
calculates the sum_i value(i) P(i) where value(i) is the value of the
observable for state i.
Args:
counts (dict): a dict ... | def average_data(counts, observable):
"""Compute the mean value of an diagonal observable.
Takes in a diagonal observable in dictionary, list or matrix format and then
calculates the sum_i value(i) P(i) where value(i) is the value of the
observable for state i.
Args:
counts (dict): a dict ... | [
"Compute",
"the",
"mean",
"value",
"of",
"an",
"diagonal",
"observable",
"."
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/quantum_info/analyzation/average.py#L13-L38 | [
"def",
"average_data",
"(",
"counts",
",",
"observable",
")",
":",
"if",
"not",
"isinstance",
"(",
"observable",
",",
"dict",
")",
":",
"observable",
"=",
"make_dict_observable",
"(",
"observable",
")",
"temp",
"=",
"0",
"tot",
"=",
"sum",
"(",
"counts",
... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | AstInterpreter._process_bit_id | Process an Id or IndexedId node as a bit or register type.
Return a list of tuples (Register,index). | qiskit/converters/ast_to_dag.py | def _process_bit_id(self, node):
"""Process an Id or IndexedId node as a bit or register type.
Return a list of tuples (Register,index).
"""
# pylint: disable=inconsistent-return-statements
reg = None
if node.name in self.dag.qregs:
reg = self.dag.qregs[node.... | def _process_bit_id(self, node):
"""Process an Id or IndexedId node as a bit or register type.
Return a list of tuples (Register,index).
"""
# pylint: disable=inconsistent-return-statements
reg = None
if node.name in self.dag.qregs:
reg = self.dag.qregs[node.... | [
"Process",
"an",
"Id",
"or",
"IndexedId",
"node",
"as",
"a",
"bit",
"or",
"register",
"type",
"."
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/converters/ast_to_dag.py#L89-L120 | [
"def",
"_process_bit_id",
"(",
"self",
",",
"node",
")",
":",
"# pylint: disable=inconsistent-return-statements",
"reg",
"=",
"None",
"if",
"node",
".",
"name",
"in",
"self",
".",
"dag",
".",
"qregs",
":",
"reg",
"=",
"self",
".",
"dag",
".",
"qregs",
"[",... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | AstInterpreter._process_custom_unitary | Process a custom unitary node. | qiskit/converters/ast_to_dag.py | def _process_custom_unitary(self, node):
"""Process a custom unitary node."""
name = node.name
if node.arguments is not None:
args = self._process_node(node.arguments)
else:
args = []
bits = [self._process_bit_id(node_element)
for node_elem... | def _process_custom_unitary(self, node):
"""Process a custom unitary node."""
name = node.name
if node.arguments is not None:
args = self._process_node(node.arguments)
else:
args = []
bits = [self._process_bit_id(node_element)
for node_elem... | [
"Process",
"a",
"custom",
"unitary",
"node",
"."
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/converters/ast_to_dag.py#L122-L151 | [
"def",
"_process_custom_unitary",
"(",
"self",
",",
"node",
")",
":",
"name",
"=",
"node",
".",
"name",
"if",
"node",
".",
"arguments",
"is",
"not",
"None",
":",
"args",
"=",
"self",
".",
"_process_node",
"(",
"node",
".",
"arguments",
")",
"else",
":"... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | AstInterpreter._process_gate | Process a gate node.
If opaque is True, process the node as an opaque gate node. | qiskit/converters/ast_to_dag.py | def _process_gate(self, node, opaque=False):
"""Process a gate node.
If opaque is True, process the node as an opaque gate node.
"""
self.gates[node.name] = {}
de_gate = self.gates[node.name]
de_gate["print"] = True # default
de_gate["opaque"] = opaque
d... | def _process_gate(self, node, opaque=False):
"""Process a gate node.
If opaque is True, process the node as an opaque gate node.
"""
self.gates[node.name] = {}
de_gate = self.gates[node.name]
de_gate["print"] = True # default
de_gate["opaque"] = opaque
d... | [
"Process",
"a",
"gate",
"node",
"."
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/converters/ast_to_dag.py#L153-L172 | [
"def",
"_process_gate",
"(",
"self",
",",
"node",
",",
"opaque",
"=",
"False",
")",
":",
"self",
".",
"gates",
"[",
"node",
".",
"name",
"]",
"=",
"{",
"}",
"de_gate",
"=",
"self",
".",
"gates",
"[",
"node",
".",
"name",
"]",
"de_gate",
"[",
"\"p... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | AstInterpreter._process_cnot | Process a CNOT gate node. | qiskit/converters/ast_to_dag.py | def _process_cnot(self, node):
"""Process a CNOT gate node."""
id0 = self._process_bit_id(node.children[0])
id1 = self._process_bit_id(node.children[1])
if not(len(id0) == len(id1) or len(id0) == 1 or len(id1) == 1):
raise QiskitError("internal error: qreg size mismatch",
... | def _process_cnot(self, node):
"""Process a CNOT gate node."""
id0 = self._process_bit_id(node.children[0])
id1 = self._process_bit_id(node.children[1])
if not(len(id0) == len(id1) or len(id0) == 1 or len(id1) == 1):
raise QiskitError("internal error: qreg size mismatch",
... | [
"Process",
"a",
"CNOT",
"gate",
"node",
"."
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/converters/ast_to_dag.py#L174-L188 | [
"def",
"_process_cnot",
"(",
"self",
",",
"node",
")",
":",
"id0",
"=",
"self",
".",
"_process_bit_id",
"(",
"node",
".",
"children",
"[",
"0",
"]",
")",
"id1",
"=",
"self",
".",
"_process_bit_id",
"(",
"node",
".",
"children",
"[",
"1",
"]",
")",
... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | AstInterpreter._process_measure | Process a measurement node. | qiskit/converters/ast_to_dag.py | def _process_measure(self, node):
"""Process a measurement node."""
id0 = self._process_bit_id(node.children[0])
id1 = self._process_bit_id(node.children[1])
if len(id0) != len(id1):
raise QiskitError("internal error: reg size mismatch",
"line=%s... | def _process_measure(self, node):
"""Process a measurement node."""
id0 = self._process_bit_id(node.children[0])
id1 = self._process_bit_id(node.children[1])
if len(id0) != len(id1):
raise QiskitError("internal error: reg size mismatch",
"line=%s... | [
"Process",
"a",
"measurement",
"node",
"."
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/converters/ast_to_dag.py#L190-L198 | [
"def",
"_process_measure",
"(",
"self",
",",
"node",
")",
":",
"id0",
"=",
"self",
".",
"_process_bit_id",
"(",
"node",
".",
"children",
"[",
"0",
"]",
")",
"id1",
"=",
"self",
".",
"_process_bit_id",
"(",
"node",
".",
"children",
"[",
"1",
"]",
")",... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | AstInterpreter._process_if | Process an if node. | qiskit/converters/ast_to_dag.py | def _process_if(self, node):
"""Process an if node."""
creg_name = node.children[0].name
creg = self.dag.cregs[creg_name]
cval = node.children[1].value
self.condition = (creg, cval)
self._process_node(node.children[2])
self.condition = None | def _process_if(self, node):
"""Process an if node."""
creg_name = node.children[0].name
creg = self.dag.cregs[creg_name]
cval = node.children[1].value
self.condition = (creg, cval)
self._process_node(node.children[2])
self.condition = None | [
"Process",
"an",
"if",
"node",
"."
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/converters/ast_to_dag.py#L200-L207 | [
"def",
"_process_if",
"(",
"self",
",",
"node",
")",
":",
"creg_name",
"=",
"node",
".",
"children",
"[",
"0",
"]",
".",
"name",
"creg",
"=",
"self",
".",
"dag",
".",
"cregs",
"[",
"creg_name",
"]",
"cval",
"=",
"node",
".",
"children",
"[",
"1",
... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | AstInterpreter._process_node | Carry out the action associated with a node. | qiskit/converters/ast_to_dag.py | def _process_node(self, node):
"""Carry out the action associated with a node."""
if node.type == "program":
self._process_children(node)
elif node.type == "qreg":
qreg = QuantumRegister(node.index, node.name)
self.dag.add_qreg(qreg)
elif node.type =... | def _process_node(self, node):
"""Carry out the action associated with a node."""
if node.type == "program":
self._process_children(node)
elif node.type == "qreg":
qreg = QuantumRegister(node.index, node.name)
self.dag.add_qreg(qreg)
elif node.type =... | [
"Carry",
"out",
"the",
"action",
"associated",
"with",
"a",
"node",
"."
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/converters/ast_to_dag.py#L214-L304 | [
"def",
"_process_node",
"(",
"self",
",",
"node",
")",
":",
"if",
"node",
".",
"type",
"==",
"\"program\"",
":",
"self",
".",
"_process_children",
"(",
"node",
")",
"elif",
"node",
".",
"type",
"==",
"\"qreg\"",
":",
"qreg",
"=",
"QuantumRegister",
"(",
... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | AstInterpreter._create_dag_op | Create a DAG node out of a parsed AST op node.
Args:
name (str): operation name to apply to the dag.
params (list): op parameters
qargs (list(QuantumRegister, int)): qubits to attach to
Raises:
QiskitError: if encountering a non-basis opaque gate | qiskit/converters/ast_to_dag.py | def _create_dag_op(self, name, params, qargs):
"""
Create a DAG node out of a parsed AST op node.
Args:
name (str): operation name to apply to the dag.
params (list): op parameters
qargs (list(QuantumRegister, int)): qubits to attach to
Raises:
... | def _create_dag_op(self, name, params, qargs):
"""
Create a DAG node out of a parsed AST op node.
Args:
name (str): operation name to apply to the dag.
params (list): op parameters
qargs (list(QuantumRegister, int)): qubits to attach to
Raises:
... | [
"Create",
"a",
"DAG",
"node",
"out",
"of",
"a",
"parsed",
"AST",
"op",
"node",
"."
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/converters/ast_to_dag.py#L306-L377 | [
"def",
"_create_dag_op",
"(",
"self",
",",
"name",
",",
"params",
",",
"qargs",
")",
":",
"if",
"name",
"==",
"\"u0\"",
":",
"op_class",
"=",
"U0Gate",
"elif",
"name",
"==",
"\"u1\"",
":",
"op_class",
"=",
"U1Gate",
"elif",
"name",
"==",
"\"u2\"",
":",... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | Measure.qasm | Return the corresponding OPENQASM string. | qiskit/qasm/node/measure.py | def qasm(self, prec=15):
"""Return the corresponding OPENQASM string."""
return "measure " + self.children[0].qasm(prec) + " -> " + \
self.children[1].qasm(prec) + ";" | def qasm(self, prec=15):
"""Return the corresponding OPENQASM string."""
return "measure " + self.children[0].qasm(prec) + " -> " + \
self.children[1].qasm(prec) + ";" | [
"Return",
"the",
"corresponding",
"OPENQASM",
"string",
"."
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/qasm/node/measure.py#L24-L27 | [
"def",
"qasm",
"(",
"self",
",",
"prec",
"=",
"15",
")",
":",
"return",
"\"measure \"",
"+",
"self",
".",
"children",
"[",
"0",
"]",
".",
"qasm",
"(",
"prec",
")",
"+",
"\" -> \"",
"+",
"self",
".",
"children",
"[",
"1",
"]",
".",
"qasm",
"(",
... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | Schedule.ch_duration | Return duration of supplied channels.
Args:
*channels: Supplied channels | qiskit/pulse/schedule.py | def ch_duration(self, *channels: List[Channel]) -> int:
"""Return duration of supplied channels.
Args:
*channels: Supplied channels
"""
return self.timeslots.ch_duration(*channels) | def ch_duration(self, *channels: List[Channel]) -> int:
"""Return duration of supplied channels.
Args:
*channels: Supplied channels
"""
return self.timeslots.ch_duration(*channels) | [
"Return",
"duration",
"of",
"supplied",
"channels",
"."
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/pulse/schedule.py#L100-L106 | [
"def",
"ch_duration",
"(",
"self",
",",
"*",
"channels",
":",
"List",
"[",
"Channel",
"]",
")",
"->",
"int",
":",
"return",
"self",
".",
"timeslots",
".",
"ch_duration",
"(",
"*",
"channels",
")"
] | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | Schedule.ch_start_time | Return minimum start time for supplied channels.
Args:
*channels: Supplied channels | qiskit/pulse/schedule.py | def ch_start_time(self, *channels: List[Channel]) -> int:
"""Return minimum start time for supplied channels.
Args:
*channels: Supplied channels
"""
return self.timeslots.ch_start_time(*channels) | def ch_start_time(self, *channels: List[Channel]) -> int:
"""Return minimum start time for supplied channels.
Args:
*channels: Supplied channels
"""
return self.timeslots.ch_start_time(*channels) | [
"Return",
"minimum",
"start",
"time",
"for",
"supplied",
"channels",
"."
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/pulse/schedule.py#L108-L114 | [
"def",
"ch_start_time",
"(",
"self",
",",
"*",
"channels",
":",
"List",
"[",
"Channel",
"]",
")",
"->",
"int",
":",
"return",
"self",
".",
"timeslots",
".",
"ch_start_time",
"(",
"*",
"channels",
")"
] | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | Schedule.ch_stop_time | Return maximum start time for supplied channels.
Args:
*channels: Supplied channels | qiskit/pulse/schedule.py | def ch_stop_time(self, *channels: List[Channel]) -> int:
"""Return maximum start time for supplied channels.
Args:
*channels: Supplied channels
"""
return self.timeslots.ch_stop_time(*channels) | def ch_stop_time(self, *channels: List[Channel]) -> int:
"""Return maximum start time for supplied channels.
Args:
*channels: Supplied channels
"""
return self.timeslots.ch_stop_time(*channels) | [
"Return",
"maximum",
"start",
"time",
"for",
"supplied",
"channels",
"."
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/pulse/schedule.py#L116-L122 | [
"def",
"ch_stop_time",
"(",
"self",
",",
"*",
"channels",
":",
"List",
"[",
"Channel",
"]",
")",
"->",
"int",
":",
"return",
"self",
".",
"timeslots",
".",
"ch_stop_time",
"(",
"*",
"channels",
")"
] | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | Schedule._instructions | Iterable for flattening Schedule tree.
Args:
time: Shifted time due to parent
Yields:
Tuple[int, ScheduleComponent]: Tuple containing time `ScheduleComponent` starts
at and the flattened `ScheduleComponent`. | qiskit/pulse/schedule.py | def _instructions(self, time: int = 0) -> Iterable[Tuple[int, 'Instruction']]:
"""Iterable for flattening Schedule tree.
Args:
time: Shifted time due to parent
Yields:
Tuple[int, ScheduleComponent]: Tuple containing time `ScheduleComponent` starts
at and... | def _instructions(self, time: int = 0) -> Iterable[Tuple[int, 'Instruction']]:
"""Iterable for flattening Schedule tree.
Args:
time: Shifted time due to parent
Yields:
Tuple[int, ScheduleComponent]: Tuple containing time `ScheduleComponent` starts
at and... | [
"Iterable",
"for",
"flattening",
"Schedule",
"tree",
"."
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/pulse/schedule.py#L124-L135 | [
"def",
"_instructions",
"(",
"self",
",",
"time",
":",
"int",
"=",
"0",
")",
"->",
"Iterable",
"[",
"Tuple",
"[",
"int",
",",
"'Instruction'",
"]",
"]",
":",
"for",
"insert_time",
",",
"child_sched",
"in",
"self",
".",
"children",
":",
"yield",
"from",... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | IndexedId.to_string | Print with indent. | qiskit/qasm/node/indexedid.py | def to_string(self, indent):
"""Print with indent."""
ind = indent * ' '
print(ind, 'indexed_id', self.name, self.index) | def to_string(self, indent):
"""Print with indent."""
ind = indent * ' '
print(ind, 'indexed_id', self.name, self.index) | [
"Print",
"with",
"indent",
"."
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/qasm/node/indexedid.py#L31-L34 | [
"def",
"to_string",
"(",
"self",
",",
"indent",
")",
":",
"ind",
"=",
"indent",
"*",
"' '",
"print",
"(",
"ind",
",",
"'indexed_id'",
",",
"self",
".",
"name",
",",
"self",
".",
"index",
")"
] | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | ModelTypeValidator.check_type | Validates a value against the correct type of the field.
It calls ``_expected_types`` to get a list of valid types.
Subclasses can do one of the following:
1. They can override the ``valid_types`` property with a tuple with
the expected types for this field.
2. Th... | qiskit/validation/base.py | def check_type(self, value, attr, data):
"""Validates a value against the correct type of the field.
It calls ``_expected_types`` to get a list of valid types.
Subclasses can do one of the following:
1. They can override the ``valid_types`` property with a tuple with
t... | def check_type(self, value, attr, data):
"""Validates a value against the correct type of the field.
It calls ``_expected_types`` to get a list of valid types.
Subclasses can do one of the following:
1. They can override the ``valid_types`` property with a tuple with
t... | [
"Validates",
"a",
"value",
"against",
"the",
"correct",
"type",
"of",
"the",
"field",
"."
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/validation/base.py#L45-L68 | [
"def",
"check_type",
"(",
"self",
",",
"value",
",",
"attr",
",",
"data",
")",
":",
"expected_types",
"=",
"self",
".",
"_expected_types",
"(",
")",
"if",
"not",
"isinstance",
"(",
"value",
",",
"expected_types",
")",
":",
"raise",
"self",
".",
"_not_exp... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | BaseSchema.dump_additional_data | Include unknown fields after dumping.
Unknown fields are added with no processing at all.
Args:
valid_data (dict or list): data collected and returned by ``dump()``.
many (bool): if True, data and original_data are a list.
original_data (object or list): object pass... | qiskit/validation/base.py | def dump_additional_data(self, valid_data, many, original_data):
"""Include unknown fields after dumping.
Unknown fields are added with no processing at all.
Args:
valid_data (dict or list): data collected and returned by ``dump()``.
many (bool): if True, data and origi... | def dump_additional_data(self, valid_data, many, original_data):
"""Include unknown fields after dumping.
Unknown fields are added with no processing at all.
Args:
valid_data (dict or list): data collected and returned by ``dump()``.
many (bool): if True, data and origi... | [
"Include",
"unknown",
"fields",
"after",
"dumping",
"."
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/validation/base.py#L105-L131 | [
"def",
"dump_additional_data",
"(",
"self",
",",
"valid_data",
",",
"many",
",",
"original_data",
")",
":",
"if",
"many",
":",
"for",
"i",
",",
"_",
"in",
"enumerate",
"(",
"valid_data",
")",
":",
"additional_keys",
"=",
"set",
"(",
"original_data",
"[",
... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | BaseSchema.load_additional_data | Include unknown fields after load.
Unknown fields are added with no processing at all.
Args:
valid_data (dict or list): validated data returned by ``load()``.
many (bool): if True, data and original_data are a list.
original_data (dict or list): data passed to ``loa... | qiskit/validation/base.py | def load_additional_data(self, valid_data, many, original_data):
"""Include unknown fields after load.
Unknown fields are added with no processing at all.
Args:
valid_data (dict or list): validated data returned by ``load()``.
many (bool): if True, data and original_dat... | def load_additional_data(self, valid_data, many, original_data):
"""Include unknown fields after load.
Unknown fields are added with no processing at all.
Args:
valid_data (dict or list): validated data returned by ``load()``.
many (bool): if True, data and original_dat... | [
"Include",
"unknown",
"fields",
"after",
"load",
"."
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/validation/base.py#L134-L160 | [
"def",
"load_additional_data",
"(",
"self",
",",
"valid_data",
",",
"many",
",",
"original_data",
")",
":",
"if",
"many",
":",
"for",
"i",
",",
"_",
"in",
"enumerate",
"(",
"valid_data",
")",
":",
"additional_keys",
"=",
"set",
"(",
"original_data",
"[",
... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | _SchemaBinder._create_validation_schema | Create a patched Schema for validating models.
Model validation is not part of Marshmallow. Schemas have a ``validate``
method but this delegates execution on ``load`` and discards the result.
Similarly, ``load`` will call ``_deserialize`` on every field in the
schema.
This fun... | qiskit/validation/base.py | def _create_validation_schema(schema_cls):
"""Create a patched Schema for validating models.
Model validation is not part of Marshmallow. Schemas have a ``validate``
method but this delegates execution on ``load`` and discards the result.
Similarly, ``load`` will call ``_deserialize`` o... | def _create_validation_schema(schema_cls):
"""Create a patched Schema for validating models.
Model validation is not part of Marshmallow. Schemas have a ``validate``
method but this delegates execution on ``load`` and discards the result.
Similarly, ``load`` will call ``_deserialize`` o... | [
"Create",
"a",
"patched",
"Schema",
"for",
"validating",
"models",
"."
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/validation/base.py#L201-L224 | [
"def",
"_create_validation_schema",
"(",
"schema_cls",
")",
":",
"validation_schema",
"=",
"schema_cls",
"(",
")",
"for",
"_",
",",
"field",
"in",
"validation_schema",
".",
"fields",
".",
"items",
"(",
")",
":",
"if",
"isinstance",
"(",
"field",
",",
"ModelT... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | _SchemaBinder._validate | Validate the internal representation of the instance. | qiskit/validation/base.py | def _validate(instance):
"""Validate the internal representation of the instance."""
try:
_ = instance.schema.validate(instance.to_dict())
except ValidationError as ex:
raise ModelValidationError(
ex.messages, ex.field_names, ex.fields, ex.data, **ex.kwarg... | def _validate(instance):
"""Validate the internal representation of the instance."""
try:
_ = instance.schema.validate(instance.to_dict())
except ValidationError as ex:
raise ModelValidationError(
ex.messages, ex.field_names, ex.fields, ex.data, **ex.kwarg... | [
"Validate",
"the",
"internal",
"representation",
"of",
"the",
"instance",
"."
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/validation/base.py#L227-L233 | [
"def",
"_validate",
"(",
"instance",
")",
":",
"try",
":",
"_",
"=",
"instance",
".",
"schema",
".",
"validate",
"(",
"instance",
".",
"to_dict",
"(",
")",
")",
"except",
"ValidationError",
"as",
"ex",
":",
"raise",
"ModelValidationError",
"(",
"ex",
"."... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | _SchemaBinder._validate_after_init | Add validation after instantiation. | qiskit/validation/base.py | def _validate_after_init(init_method):
"""Add validation after instantiation."""
@wraps(init_method)
def _decorated(self, **kwargs):
try:
_ = self.shallow_schema.validate(kwargs)
except ValidationError as ex:
raise ModelValidationError(
... | def _validate_after_init(init_method):
"""Add validation after instantiation."""
@wraps(init_method)
def _decorated(self, **kwargs):
try:
_ = self.shallow_schema.validate(kwargs)
except ValidationError as ex:
raise ModelValidationError(
... | [
"Add",
"validation",
"after",
"instantiation",
"."
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/validation/base.py#L236-L249 | [
"def",
"_validate_after_init",
"(",
"init_method",
")",
":",
"@",
"wraps",
"(",
"init_method",
")",
"def",
"_decorated",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"try",
":",
"_",
"=",
"self",
".",
"shallow_schema",
".",
"validate",
"(",
"kwargs",
... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | BaseModel.to_dict | Serialize the model into a Python dict of simple types.
Note that this method requires that the model is bound with
``@bind_schema``. | qiskit/validation/base.py | def to_dict(self):
"""Serialize the model into a Python dict of simple types.
Note that this method requires that the model is bound with
``@bind_schema``.
"""
try:
data, _ = self.schema.dump(self)
except ValidationError as ex:
raise ModelValidati... | def to_dict(self):
"""Serialize the model into a Python dict of simple types.
Note that this method requires that the model is bound with
``@bind_schema``.
"""
try:
data, _ = self.schema.dump(self)
except ValidationError as ex:
raise ModelValidati... | [
"Serialize",
"the",
"model",
"into",
"a",
"Python",
"dict",
"of",
"simple",
"types",
"."
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/validation/base.py#L320-L332 | [
"def",
"to_dict",
"(",
"self",
")",
":",
"try",
":",
"data",
",",
"_",
"=",
"self",
".",
"schema",
".",
"dump",
"(",
"self",
")",
"except",
"ValidationError",
"as",
"ex",
":",
"raise",
"ModelValidationError",
"(",
"ex",
".",
"messages",
",",
"ex",
".... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | BaseModel.from_dict | Deserialize a dict of simple types into an instance of this class.
Note that this method requires that the model is bound with
``@bind_schema``. | qiskit/validation/base.py | def from_dict(cls, dict_):
"""Deserialize a dict of simple types into an instance of this class.
Note that this method requires that the model is bound with
``@bind_schema``.
"""
try:
data, _ = cls.schema.load(dict_)
except ValidationError as ex:
... | def from_dict(cls, dict_):
"""Deserialize a dict of simple types into an instance of this class.
Note that this method requires that the model is bound with
``@bind_schema``.
"""
try:
data, _ = cls.schema.load(dict_)
except ValidationError as ex:
... | [
"Deserialize",
"a",
"dict",
"of",
"simple",
"types",
"into",
"an",
"instance",
"of",
"this",
"class",
"."
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/validation/base.py#L335-L347 | [
"def",
"from_dict",
"(",
"cls",
",",
"dict_",
")",
":",
"try",
":",
"data",
",",
"_",
"=",
"cls",
".",
"schema",
".",
"load",
"(",
"dict_",
")",
"except",
"ValidationError",
"as",
"ex",
":",
"raise",
"ModelValidationError",
"(",
"ex",
".",
"messages",
... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | qft | n-qubit QFT on q in circ. | qiskit/tools/qi/qi.py | def qft(circ, q, n):
"""n-qubit QFT on q in circ."""
for j in range(n):
for k in range(j):
circ.cu1(math.pi / float(2**(j - k)), q[j], q[k])
circ.h(q[j]) | def qft(circ, q, n):
"""n-qubit QFT on q in circ."""
for j in range(n):
for k in range(j):
circ.cu1(math.pi / float(2**(j - k)), q[j], q[k])
circ.h(q[j]) | [
"n",
"-",
"qubit",
"QFT",
"on",
"q",
"in",
"circ",
"."
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/tools/qi/qi.py#L35-L40 | [
"def",
"qft",
"(",
"circ",
",",
"q",
",",
"n",
")",
":",
"for",
"j",
"in",
"range",
"(",
"n",
")",
":",
"for",
"k",
"in",
"range",
"(",
"j",
")",
":",
"circ",
".",
"cu1",
"(",
"math",
".",
"pi",
"/",
"float",
"(",
"2",
"**",
"(",
"j",
"... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | partial_trace | Partial trace over subsystems of multi-partite matrix.
Note that subsystems are ordered as rho012 = rho0(x)rho1(x)rho2.
Args:
state (matrix_like): a matrix NxN
trace_systems (list(int)): a list of subsystems (starting from 0) to
trace over.
dimensions ... | qiskit/tools/qi/qi.py | def partial_trace(state, trace_systems, dimensions=None, reverse=True):
"""
Partial trace over subsystems of multi-partite matrix.
Note that subsystems are ordered as rho012 = rho0(x)rho1(x)rho2.
Args:
state (matrix_like): a matrix NxN
trace_systems (list(int)): a list of subsystems (s... | def partial_trace(state, trace_systems, dimensions=None, reverse=True):
"""
Partial trace over subsystems of multi-partite matrix.
Note that subsystems are ordered as rho012 = rho0(x)rho1(x)rho2.
Args:
state (matrix_like): a matrix NxN
trace_systems (list(int)): a list of subsystems (s... | [
"Partial",
"trace",
"over",
"subsystems",
"of",
"multi",
"-",
"partite",
"matrix",
"."
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/tools/qi/qi.py#L48-L92 | [
"def",
"partial_trace",
"(",
"state",
",",
"trace_systems",
",",
"dimensions",
"=",
"None",
",",
"reverse",
"=",
"True",
")",
":",
"state",
"=",
"np",
".",
"array",
"(",
"state",
")",
"# convert op to density matrix",
"if",
"dimensions",
"is",
"None",
":",
... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | __partial_trace_vec | Partial trace over subsystems of multi-partite vector.
Args:
vec (vector_like): complex vector N
trace_systems (list(int)): a list of subsystems (starting from 0) to
trace over.
dimensions (list(int)): a list of the dimensions of the subsystems.
... | qiskit/tools/qi/qi.py | def __partial_trace_vec(vec, trace_systems, dimensions, reverse=True):
"""
Partial trace over subsystems of multi-partite vector.
Args:
vec (vector_like): complex vector N
trace_systems (list(int)): a list of subsystems (starting from 0) to
trace over.
... | def __partial_trace_vec(vec, trace_systems, dimensions, reverse=True):
"""
Partial trace over subsystems of multi-partite vector.
Args:
vec (vector_like): complex vector N
trace_systems (list(int)): a list of subsystems (starting from 0) to
trace over.
... | [
"Partial",
"trace",
"over",
"subsystems",
"of",
"multi",
"-",
"partite",
"vector",
"."
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/tools/qi/qi.py#L95-L123 | [
"def",
"__partial_trace_vec",
"(",
"vec",
",",
"trace_systems",
",",
"dimensions",
",",
"reverse",
"=",
"True",
")",
":",
"# trace sys positions",
"if",
"reverse",
":",
"dimensions",
"=",
"dimensions",
"[",
":",
":",
"-",
"1",
"]",
"trace_systems",
"=",
"len... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | __partial_trace_mat | Partial trace over subsystems of multi-partite matrix.
Note that subsystems are ordered as rho012 = rho0(x)rho1(x)rho2.
Args:
mat (matrix_like): a matrix NxN.
trace_systems (list(int)): a list of subsystems (starting from 0) to
trace over.
dimensions (... | qiskit/tools/qi/qi.py | def __partial_trace_mat(mat, trace_systems, dimensions, reverse=True):
"""
Partial trace over subsystems of multi-partite matrix.
Note that subsystems are ordered as rho012 = rho0(x)rho1(x)rho2.
Args:
mat (matrix_like): a matrix NxN.
trace_systems (list(int)): a list of subsystems (sta... | def __partial_trace_mat(mat, trace_systems, dimensions, reverse=True):
"""
Partial trace over subsystems of multi-partite matrix.
Note that subsystems are ordered as rho012 = rho0(x)rho1(x)rho2.
Args:
mat (matrix_like): a matrix NxN.
trace_systems (list(int)): a list of subsystems (sta... | [
"Partial",
"trace",
"over",
"subsystems",
"of",
"multi",
"-",
"partite",
"matrix",
"."
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/tools/qi/qi.py#L126-L171 | [
"def",
"__partial_trace_mat",
"(",
"mat",
",",
"trace_systems",
",",
"dimensions",
",",
"reverse",
"=",
"True",
")",
":",
"trace_systems",
"=",
"sorted",
"(",
"trace_systems",
",",
"reverse",
"=",
"True",
")",
"for",
"j",
"in",
"trace_systems",
":",
"# Parti... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | vectorize | Flatten an operator to a vector in a specified basis.
Args:
density_matrix (ndarray): a density matrix.
method (str): the method of vectorization. Allowed values are
- 'col' (default) flattens to column-major vector.
- 'row' flattens to row-major vector.
- 'pauli... | qiskit/tools/qi/qi.py | def vectorize(density_matrix, method='col'):
"""Flatten an operator to a vector in a specified basis.
Args:
density_matrix (ndarray): a density matrix.
method (str): the method of vectorization. Allowed values are
- 'col' (default) flattens to column-major vector.
- 'row... | def vectorize(density_matrix, method='col'):
"""Flatten an operator to a vector in a specified basis.
Args:
density_matrix (ndarray): a density matrix.
method (str): the method of vectorization. Allowed values are
- 'col' (default) flattens to column-major vector.
- 'row... | [
"Flatten",
"an",
"operator",
"to",
"a",
"vector",
"in",
"a",
"specified",
"basis",
"."
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/tools/qi/qi.py#L174-L207 | [
"def",
"vectorize",
"(",
"density_matrix",
",",
"method",
"=",
"'col'",
")",
":",
"density_matrix",
"=",
"np",
".",
"array",
"(",
"density_matrix",
")",
"if",
"method",
"==",
"'col'",
":",
"return",
"density_matrix",
".",
"flatten",
"(",
"order",
"=",
"'F'... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | devectorize | Devectorize a vectorized square matrix.
Args:
vectorized_mat (ndarray): a vectorized density matrix.
method (str): the method of devectorization. Allowed values are
- 'col' (default): flattens to column-major vector.
- 'row': flattens to row-major vector.
- 'paul... | qiskit/tools/qi/qi.py | def devectorize(vectorized_mat, method='col'):
"""Devectorize a vectorized square matrix.
Args:
vectorized_mat (ndarray): a vectorized density matrix.
method (str): the method of devectorization. Allowed values are
- 'col' (default): flattens to column-major vector.
- 'r... | def devectorize(vectorized_mat, method='col'):
"""Devectorize a vectorized square matrix.
Args:
vectorized_mat (ndarray): a vectorized density matrix.
method (str): the method of devectorization. Allowed values are
- 'col' (default): flattens to column-major vector.
- 'r... | [
"Devectorize",
"a",
"vectorized",
"square",
"matrix",
"."
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/tools/qi/qi.py#L210-L246 | [
"def",
"devectorize",
"(",
"vectorized_mat",
",",
"method",
"=",
"'col'",
")",
":",
"vectorized_mat",
"=",
"np",
".",
"array",
"(",
"vectorized_mat",
")",
"dimension",
"=",
"int",
"(",
"np",
".",
"sqrt",
"(",
"vectorized_mat",
".",
"size",
")",
")",
"if"... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | choi_to_rauli | Convert a Choi-matrix to a Pauli-basis superoperator.
Note that this function assumes that the Choi-matrix
is defined in the standard column-stacking convention
and is normalized to have trace 1. For a channel E this
is defined as: choi = (I \\otimes E)(bell_state).
The resulting 'rauli' R acts on... | qiskit/tools/qi/qi.py | def choi_to_rauli(choi, order=1):
"""
Convert a Choi-matrix to a Pauli-basis superoperator.
Note that this function assumes that the Choi-matrix
is defined in the standard column-stacking convention
and is normalized to have trace 1. For a channel E this
is defined as: choi = (I \\otimes E)(bel... | def choi_to_rauli(choi, order=1):
"""
Convert a Choi-matrix to a Pauli-basis superoperator.
Note that this function assumes that the Choi-matrix
is defined in the standard column-stacking convention
and is normalized to have trace 1. For a channel E this
is defined as: choi = (I \\otimes E)(bel... | [
"Convert",
"a",
"Choi",
"-",
"matrix",
"to",
"a",
"Pauli",
"-",
"basis",
"superoperator",
"."
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/tools/qi/qi.py#L249-L287 | [
"def",
"choi_to_rauli",
"(",
"choi",
",",
"order",
"=",
"1",
")",
":",
"if",
"order",
"==",
"0",
":",
"order",
"=",
"'weight'",
"elif",
"order",
"==",
"1",
":",
"order",
"=",
"'tensor'",
"# get number of qubits'",
"num_qubits",
"=",
"int",
"(",
"np",
"... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | chop | Truncate small values of a complex array.
Args:
array (array_like): array to truncte small values.
epsilon (float): threshold.
Returns:
np.array: A new operator with small values set to zero. | qiskit/tools/qi/qi.py | def chop(array, epsilon=1e-10):
"""
Truncate small values of a complex array.
Args:
array (array_like): array to truncte small values.
epsilon (float): threshold.
Returns:
np.array: A new operator with small values set to zero.
"""
ret = np.array(array)
if np.isrea... | def chop(array, epsilon=1e-10):
"""
Truncate small values of a complex array.
Args:
array (array_like): array to truncte small values.
epsilon (float): threshold.
Returns:
np.array: A new operator with small values set to zero.
"""
ret = np.array(array)
if np.isrea... | [
"Truncate",
"small",
"values",
"of",
"a",
"complex",
"array",
"."
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/tools/qi/qi.py#L290-L308 | [
"def",
"chop",
"(",
"array",
",",
"epsilon",
"=",
"1e-10",
")",
":",
"ret",
"=",
"np",
".",
"array",
"(",
"array",
")",
"if",
"np",
".",
"isrealobj",
"(",
"ret",
")",
":",
"ret",
"[",
"abs",
"(",
"ret",
")",
"<",
"epsilon",
"]",
"=",
"0.0",
"... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | outer | Construct the outer product of two vectors.
The second vector argument is optional, if absent the projector
of the first vector will be returned.
Args:
vector1 (ndarray): the first vector.
vector2 (ndarray): the (optional) second vector.
Returns:
np.array: The matrix |v1><v2|. | qiskit/tools/qi/qi.py | def outer(vector1, vector2=None):
"""
Construct the outer product of two vectors.
The second vector argument is optional, if absent the projector
of the first vector will be returned.
Args:
vector1 (ndarray): the first vector.
vector2 (ndarray): the (optional) second vector.
R... | def outer(vector1, vector2=None):
"""
Construct the outer product of two vectors.
The second vector argument is optional, if absent the projector
of the first vector will be returned.
Args:
vector1 (ndarray): the first vector.
vector2 (ndarray): the (optional) second vector.
R... | [
"Construct",
"the",
"outer",
"product",
"of",
"two",
"vectors",
"."
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/tools/qi/qi.py#L311-L330 | [
"def",
"outer",
"(",
"vector1",
",",
"vector2",
"=",
"None",
")",
":",
"if",
"vector2",
"is",
"None",
":",
"vector2",
"=",
"np",
".",
"array",
"(",
"vector1",
")",
".",
"conj",
"(",
")",
"else",
":",
"vector2",
"=",
"np",
".",
"array",
"(",
"vect... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | random_unitary_matrix | Deprecated in 0.8+ | qiskit/tools/qi/qi.py | def random_unitary_matrix(dim, seed=None):
"""Deprecated in 0.8+
"""
warnings.warn('The random_unitary_matrix() function in qiskit.tools.qi has been '
'deprecated and will be removed in the future. Instead use '
'the function in qiskit.quantum_info.random',
... | def random_unitary_matrix(dim, seed=None):
"""Deprecated in 0.8+
"""
warnings.warn('The random_unitary_matrix() function in qiskit.tools.qi has been '
'deprecated and will be removed in the future. Instead use '
'the function in qiskit.quantum_info.random',
... | [
"Deprecated",
"in",
"0",
".",
"8",
"+"
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/tools/qi/qi.py#L337-L344 | [
"def",
"random_unitary_matrix",
"(",
"dim",
",",
"seed",
"=",
"None",
")",
":",
"warnings",
".",
"warn",
"(",
"'The random_unitary_matrix() function in qiskit.tools.qi has been '",
"'deprecated and will be removed in the future. Instead use '",
"'the function in qiskit.quantum_info.r... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | random_density_matrix | Deprecated in 0.8+ | qiskit/tools/qi/qi.py | def random_density_matrix(length, rank=None, method='Hilbert-Schmidt', seed=None):
"""Deprecated in 0.8+
"""
warnings.warn('The random_density_matrix() function in qiskit.tools.qi has been '
'deprecated and will be removed in the future. Instead use '
'the function in qis... | def random_density_matrix(length, rank=None, method='Hilbert-Schmidt', seed=None):
"""Deprecated in 0.8+
"""
warnings.warn('The random_density_matrix() function in qiskit.tools.qi has been '
'deprecated and will be removed in the future. Instead use '
'the function in qis... | [
"Deprecated",
"in",
"0",
".",
"8",
"+"
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/tools/qi/qi.py#L347-L354 | [
"def",
"random_density_matrix",
"(",
"length",
",",
"rank",
"=",
"None",
",",
"method",
"=",
"'Hilbert-Schmidt'",
",",
"seed",
"=",
"None",
")",
":",
"warnings",
".",
"warn",
"(",
"'The random_density_matrix() function in qiskit.tools.qi has been '",
"'deprecated and wi... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | concurrence | Calculate the concurrence.
Args:
state (np.array): a quantum state (1x4 array) or a density matrix (4x4
array)
Returns:
float: concurrence.
Raises:
Exception: if attempted on more than two qubits. | qiskit/tools/qi/qi.py | def concurrence(state):
"""Calculate the concurrence.
Args:
state (np.array): a quantum state (1x4 array) or a density matrix (4x4
array)
Returns:
float: concurrence.
Raises:
Exception: if attempted on more than two qubits.
"""
rho = np.array(st... | def concurrence(state):
"""Calculate the concurrence.
Args:
state (np.array): a quantum state (1x4 array) or a density matrix (4x4
array)
Returns:
float: concurrence.
Raises:
Exception: if attempted on more than two qubits.
"""
rho = np.array(st... | [
"Calculate",
"the",
"concurrence",
"."
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/tools/qi/qi.py#L377-L398 | [
"def",
"concurrence",
"(",
"state",
")",
":",
"rho",
"=",
"np",
".",
"array",
"(",
"state",
")",
"if",
"rho",
".",
"ndim",
"==",
"1",
":",
"rho",
"=",
"outer",
"(",
"state",
")",
"if",
"len",
"(",
"state",
")",
"!=",
"4",
":",
"raise",
"Excepti... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | shannon_entropy | Compute the Shannon entropy of a probability vector.
The shannon entropy of a probability vector pv is defined as
$H(pv) = - \\sum_j pv[j] log_b (pv[j])$ where $0 log_b 0 = 0$.
Args:
pvec (array_like): a probability vector.
base (int): the base of the logarith
Returns:
float: ... | qiskit/tools/qi/qi.py | def shannon_entropy(pvec, base=2):
"""
Compute the Shannon entropy of a probability vector.
The shannon entropy of a probability vector pv is defined as
$H(pv) = - \\sum_j pv[j] log_b (pv[j])$ where $0 log_b 0 = 0$.
Args:
pvec (array_like): a probability vector.
base (int): the bas... | def shannon_entropy(pvec, base=2):
"""
Compute the Shannon entropy of a probability vector.
The shannon entropy of a probability vector pv is defined as
$H(pv) = - \\sum_j pv[j] log_b (pv[j])$ where $0 log_b 0 = 0$.
Args:
pvec (array_like): a probability vector.
base (int): the bas... | [
"Compute",
"the",
"Shannon",
"entropy",
"of",
"a",
"probability",
"vector",
"."
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/tools/qi/qi.py#L401-L430 | [
"def",
"shannon_entropy",
"(",
"pvec",
",",
"base",
"=",
"2",
")",
":",
"# pylint: disable=missing-docstring",
"if",
"base",
"==",
"2",
":",
"def",
"logfn",
"(",
"x",
")",
":",
"return",
"-",
"x",
"*",
"np",
".",
"log2",
"(",
"x",
")",
"elif",
"base"... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | entropy | Compute the von-Neumann entropy of a quantum state.
Args:
state (array_like): a density matrix or state vector.
Returns:
float: The von-Neumann entropy S(rho). | qiskit/tools/qi/qi.py | def entropy(state):
"""
Compute the von-Neumann entropy of a quantum state.
Args:
state (array_like): a density matrix or state vector.
Returns:
float: The von-Neumann entropy S(rho).
"""
rho = np.array(state)
if rho.ndim == 1:
return 0
evals = np.maximum(np.li... | def entropy(state):
"""
Compute the von-Neumann entropy of a quantum state.
Args:
state (array_like): a density matrix or state vector.
Returns:
float: The von-Neumann entropy S(rho).
"""
rho = np.array(state)
if rho.ndim == 1:
return 0
evals = np.maximum(np.li... | [
"Compute",
"the",
"von",
"-",
"Neumann",
"entropy",
"of",
"a",
"quantum",
"state",
"."
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/tools/qi/qi.py#L433-L448 | [
"def",
"entropy",
"(",
"state",
")",
":",
"rho",
"=",
"np",
".",
"array",
"(",
"state",
")",
"if",
"rho",
".",
"ndim",
"==",
"1",
":",
"return",
"0",
"evals",
"=",
"np",
".",
"maximum",
"(",
"np",
".",
"linalg",
".",
"eigvalsh",
"(",
"state",
"... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | mutual_information | Compute the mutual information of a bipartite state.
Args:
state (array_like): a bipartite state-vector or density-matrix.
d0 (int): dimension of the first subsystem.
d1 (int or None): dimension of the second subsystem.
Returns:
float: The mutual information S(rho_A) + S(rho_B)... | qiskit/tools/qi/qi.py | def mutual_information(state, d0, d1=None):
"""
Compute the mutual information of a bipartite state.
Args:
state (array_like): a bipartite state-vector or density-matrix.
d0 (int): dimension of the first subsystem.
d1 (int or None): dimension of the second subsystem.
Returns:
... | def mutual_information(state, d0, d1=None):
"""
Compute the mutual information of a bipartite state.
Args:
state (array_like): a bipartite state-vector or density-matrix.
d0 (int): dimension of the first subsystem.
d1 (int or None): dimension of the second subsystem.
Returns:
... | [
"Compute",
"the",
"mutual",
"information",
"of",
"a",
"bipartite",
"state",
"."
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/tools/qi/qi.py#L451-L468 | [
"def",
"mutual_information",
"(",
"state",
",",
"d0",
",",
"d1",
"=",
"None",
")",
":",
"if",
"d1",
"is",
"None",
":",
"d1",
"=",
"int",
"(",
"len",
"(",
"state",
")",
"/",
"d0",
")",
"mi",
"=",
"entropy",
"(",
"partial_trace",
"(",
"state",
",",... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | entanglement_of_formation | Compute the entanglement of formation of quantum state.
The input quantum state must be either a bipartite state vector, or a
2-qubit density matrix.
Args:
state (array_like): (N) array_like or (4,4) array_like, a
bipartite quantum state.
d0 (int): the dimension of the first su... | qiskit/tools/qi/qi.py | def entanglement_of_formation(state, d0, d1=None):
"""
Compute the entanglement of formation of quantum state.
The input quantum state must be either a bipartite state vector, or a
2-qubit density matrix.
Args:
state (array_like): (N) array_like or (4,4) array_like, a
bipartite... | def entanglement_of_formation(state, d0, d1=None):
"""
Compute the entanglement of formation of quantum state.
The input quantum state must be either a bipartite state vector, or a
2-qubit density matrix.
Args:
state (array_like): (N) array_like or (4,4) array_like, a
bipartite... | [
"Compute",
"the",
"entanglement",
"of",
"formation",
"of",
"quantum",
"state",
"."
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/tools/qi/qi.py#L471-L504 | [
"def",
"entanglement_of_formation",
"(",
"state",
",",
"d0",
",",
"d1",
"=",
"None",
")",
":",
"state",
"=",
"np",
".",
"array",
"(",
"state",
")",
"if",
"d1",
"is",
"None",
":",
"d1",
"=",
"int",
"(",
"len",
"(",
"state",
")",
"/",
"d0",
")",
... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | __eof_qubit | Compute the Entanglement of Formation of a 2-qubit density matrix.
Args:
rho ((array_like): (4,4) array_like, input density matrix.
Returns:
float: The entanglement of formation. | qiskit/tools/qi/qi.py | def __eof_qubit(rho):
"""
Compute the Entanglement of Formation of a 2-qubit density matrix.
Args:
rho ((array_like): (4,4) array_like, input density matrix.
Returns:
float: The entanglement of formation.
"""
c = concurrence(rho)
c = 0.5 + 0.5 * np.sqrt(1 - c * c)
retur... | def __eof_qubit(rho):
"""
Compute the Entanglement of Formation of a 2-qubit density matrix.
Args:
rho ((array_like): (4,4) array_like, input density matrix.
Returns:
float: The entanglement of formation.
"""
c = concurrence(rho)
c = 0.5 + 0.5 * np.sqrt(1 - c * c)
retur... | [
"Compute",
"the",
"Entanglement",
"of",
"Formation",
"of",
"a",
"2",
"-",
"qubit",
"density",
"matrix",
"."
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/tools/qi/qi.py#L507-L519 | [
"def",
"__eof_qubit",
"(",
"rho",
")",
":",
"c",
"=",
"concurrence",
"(",
"rho",
")",
"c",
"=",
"0.5",
"+",
"0.5",
"*",
"np",
".",
"sqrt",
"(",
"1",
"-",
"c",
"*",
"c",
")",
"return",
"shannon_entropy",
"(",
"[",
"c",
",",
"1",
"-",
"c",
"]",... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | union | Create a union (and also shift if desired) of all input `Schedule`s.
Args:
*schedules: Schedules to take the union of
name: Name of the new schedule. Defaults to first element of `schedules` | qiskit/pulse/ops.py | def union(*schedules: List[Union[ScheduleComponent, Tuple[int, ScheduleComponent]]],
name: str = None) -> Schedule:
"""Create a union (and also shift if desired) of all input `Schedule`s.
Args:
*schedules: Schedules to take the union of
name: Name of the new schedule. Defaults to firs... | def union(*schedules: List[Union[ScheduleComponent, Tuple[int, ScheduleComponent]]],
name: str = None) -> Schedule:
"""Create a union (and also shift if desired) of all input `Schedule`s.
Args:
*schedules: Schedules to take the union of
name: Name of the new schedule. Defaults to firs... | [
"Create",
"a",
"union",
"(",
"and",
"also",
"shift",
"if",
"desired",
")",
"of",
"all",
"input",
"Schedule",
"s",
"."
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/pulse/ops.py#L22-L36 | [
"def",
"union",
"(",
"*",
"schedules",
":",
"List",
"[",
"Union",
"[",
"ScheduleComponent",
",",
"Tuple",
"[",
"int",
",",
"ScheduleComponent",
"]",
"]",
"]",
",",
"name",
":",
"str",
"=",
"None",
")",
"->",
"Schedule",
":",
"if",
"name",
"is",
"None... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | flatten | Create a flattened schedule.
Args:
schedule: Schedules to flatten
name: Name of the new schedule. Defaults to first element of `schedules` | qiskit/pulse/ops.py | def flatten(schedule: ScheduleComponent, name: str = None) -> Schedule:
"""Create a flattened schedule.
Args:
schedule: Schedules to flatten
name: Name of the new schedule. Defaults to first element of `schedules`
"""
if name is None:
name = schedule.name
return Schedule(*s... | def flatten(schedule: ScheduleComponent, name: str = None) -> Schedule:
"""Create a flattened schedule.
Args:
schedule: Schedules to flatten
name: Name of the new schedule. Defaults to first element of `schedules`
"""
if name is None:
name = schedule.name
return Schedule(*s... | [
"Create",
"a",
"flattened",
"schedule",
"."
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/pulse/ops.py#L41-L51 | [
"def",
"flatten",
"(",
"schedule",
":",
"ScheduleComponent",
",",
"name",
":",
"str",
"=",
"None",
")",
"->",
"Schedule",
":",
"if",
"name",
"is",
"None",
":",
"name",
"=",
"schedule",
".",
"name",
"return",
"Schedule",
"(",
"*",
"schedule",
".",
"inst... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | shift | Return schedule shifted by `time`.
Args:
schedule: The schedule to shift
time: The time to shift by
name: Name of shifted schedule. Defaults to name of `schedule` | qiskit/pulse/ops.py | def shift(schedule: ScheduleComponent, time: int, name: str = None) -> Schedule:
"""Return schedule shifted by `time`.
Args:
schedule: The schedule to shift
time: The time to shift by
name: Name of shifted schedule. Defaults to name of `schedule`
"""
if name is None:
nam... | def shift(schedule: ScheduleComponent, time: int, name: str = None) -> Schedule:
"""Return schedule shifted by `time`.
Args:
schedule: The schedule to shift
time: The time to shift by
name: Name of shifted schedule. Defaults to name of `schedule`
"""
if name is None:
nam... | [
"Return",
"schedule",
"shifted",
"by",
"time",
"."
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/pulse/ops.py#L54-L64 | [
"def",
"shift",
"(",
"schedule",
":",
"ScheduleComponent",
",",
"time",
":",
"int",
",",
"name",
":",
"str",
"=",
"None",
")",
"->",
"Schedule",
":",
"if",
"name",
"is",
"None",
":",
"name",
"=",
"schedule",
".",
"name",
"return",
"union",
"(",
"(",
... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | insert | Return a new schedule with the `child` schedule inserted into the `parent` at `start_time`.
Args:
parent: Schedule to be inserted into
time: Time to be inserted defined with respect to `parent`
child: Schedule to insert
name: Name of the new schedule. Defaults to name of parent | qiskit/pulse/ops.py | def insert(parent: ScheduleComponent, time: int, child: ScheduleComponent,
name: str = None) -> Schedule:
"""Return a new schedule with the `child` schedule inserted into the `parent` at `start_time`.
Args:
parent: Schedule to be inserted into
time: Time to be inserted defined with r... | def insert(parent: ScheduleComponent, time: int, child: ScheduleComponent,
name: str = None) -> Schedule:
"""Return a new schedule with the `child` schedule inserted into the `parent` at `start_time`.
Args:
parent: Schedule to be inserted into
time: Time to be inserted defined with r... | [
"Return",
"a",
"new",
"schedule",
"with",
"the",
"child",
"schedule",
"inserted",
"into",
"the",
"parent",
"at",
"start_time",
"."
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/pulse/ops.py#L67-L77 | [
"def",
"insert",
"(",
"parent",
":",
"ScheduleComponent",
",",
"time",
":",
"int",
",",
"child",
":",
"ScheduleComponent",
",",
"name",
":",
"str",
"=",
"None",
")",
"->",
"Schedule",
":",
"return",
"union",
"(",
"parent",
",",
"(",
"time",
",",
"child... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | append | r"""Return a new schedule with by appending `child` to `parent` at
the last time of the `parent` schedule's channels
over the intersection of the parent and child schedule's channels.
$t = \textrm{max}({x.stop\_time |x \in parent.channels \cap child.channels})$
Args:
parent: The sched... | qiskit/pulse/ops.py | def append(parent: ScheduleComponent, child: ScheduleComponent,
name: str = None) -> Schedule:
r"""Return a new schedule with by appending `child` to `parent` at
the last time of the `parent` schedule's channels
over the intersection of the parent and child schedule's channels.
$t =... | def append(parent: ScheduleComponent, child: ScheduleComponent,
name: str = None) -> Schedule:
r"""Return a new schedule with by appending `child` to `parent` at
the last time of the `parent` schedule's channels
over the intersection of the parent and child schedule's channels.
$t =... | [
"r",
"Return",
"a",
"new",
"schedule",
"with",
"by",
"appending",
"child",
"to",
"parent",
"at",
"the",
"last",
"time",
"of",
"the",
"parent",
"schedule",
"s",
"channels",
"over",
"the",
"intersection",
"of",
"the",
"parent",
"and",
"child",
"schedule",
"s... | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/pulse/ops.py#L80-L95 | [
"def",
"append",
"(",
"parent",
":",
"ScheduleComponent",
",",
"child",
":",
"ScheduleComponent",
",",
"name",
":",
"str",
"=",
"None",
")",
"->",
"Schedule",
":",
"common_channels",
"=",
"set",
"(",
"parent",
".",
"channels",
")",
"&",
"set",
"(",
"chil... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | u3 | Apply u3 to q. | qiskit/extensions/standard/u3.py | def u3(self, theta, phi, lam, q):
"""Apply u3 to q."""
return self.append(U3Gate(theta, phi, lam), [q], []) | def u3(self, theta, phi, lam, q):
"""Apply u3 to q."""
return self.append(U3Gate(theta, phi, lam), [q], []) | [
"Apply",
"u3",
"to",
"q",
"."
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/extensions/standard/u3.py#L62-L64 | [
"def",
"u3",
"(",
"self",
",",
"theta",
",",
"phi",
",",
"lam",
",",
"q",
")",
":",
"return",
"self",
".",
"append",
"(",
"U3Gate",
"(",
"theta",
",",
"phi",
",",
"lam",
")",
",",
"[",
"q",
"]",
",",
"[",
"]",
")"
] | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | BaseBackend.status | Return backend status.
Returns:
BackendStatus: the status of the backend. | qiskit/providers/basebackend.py | def status(self):
"""Return backend status.
Returns:
BackendStatus: the status of the backend.
"""
return BackendStatus(backend_name=self.name(),
backend_version=__version__,
operational=True,
... | def status(self):
"""Return backend status.
Returns:
BackendStatus: the status of the backend.
"""
return BackendStatus(backend_name=self.name(),
backend_version=__version__,
operational=True,
... | [
"Return",
"backend",
"status",
"."
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/providers/basebackend.py#L71-L81 | [
"def",
"status",
"(",
"self",
")",
":",
"return",
"BackendStatus",
"(",
"backend_name",
"=",
"self",
".",
"name",
"(",
")",
",",
"backend_version",
"=",
"__version__",
",",
"operational",
"=",
"True",
",",
"pending_jobs",
"=",
"0",
",",
"status_msg",
"=",
... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | BaseProgressBar.start | Start the progress bar.
Parameters:
iterations (int): Number of iterations. | qiskit/tools/events/progressbar.py | def start(self, iterations):
"""Start the progress bar.
Parameters:
iterations (int): Number of iterations.
"""
self.touched = True
self.iter = int(iterations)
self.t_start = time.time() | def start(self, iterations):
"""Start the progress bar.
Parameters:
iterations (int): Number of iterations.
"""
self.touched = True
self.iter = int(iterations)
self.t_start = time.time() | [
"Start",
"the",
"progress",
"bar",
"."
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/tools/events/progressbar.py#L60-L68 | [
"def",
"start",
"(",
"self",
",",
"iterations",
")",
":",
"self",
".",
"touched",
"=",
"True",
"self",
".",
"iter",
"=",
"int",
"(",
"iterations",
")",
"self",
".",
"t_start",
"=",
"time",
".",
"time",
"(",
")"
] | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | BaseProgressBar.time_remaining_est | Estimate the remaining time left.
Parameters:
completed_iter (int): Number of iterations completed.
Returns:
est_time: Estimated time remaining. | qiskit/tools/events/progressbar.py | def time_remaining_est(self, completed_iter):
"""Estimate the remaining time left.
Parameters:
completed_iter (int): Number of iterations completed.
Returns:
est_time: Estimated time remaining.
"""
if completed_iter:
t_r_est = (time.time() - ... | def time_remaining_est(self, completed_iter):
"""Estimate the remaining time left.
Parameters:
completed_iter (int): Number of iterations completed.
Returns:
est_time: Estimated time remaining.
"""
if completed_iter:
t_r_est = (time.time() - ... | [
"Estimate",
"the",
"remaining",
"time",
"left",
"."
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/tools/events/progressbar.py#L83-L101 | [
"def",
"time_remaining_est",
"(",
"self",
",",
"completed_iter",
")",
":",
"if",
"completed_iter",
":",
"t_r_est",
"=",
"(",
"time",
".",
"time",
"(",
")",
"-",
"self",
".",
"t_start",
")",
"/",
"completed_iter",
"*",
"(",
"self",
".",
"iter",
"-",
"co... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | CommutativeCancellation.run | Run the CommutativeCancellation pass on a dag
Args:
dag (DAGCircuit): the DAG to be optimized.
Returns:
DAGCircuit: the optimized DAG.
Raises:
TranspilerError: when the 1 qubit rotation gates are not found | qiskit/transpiler/passes/commutative_cancellation.py | def run(self, dag):
"""Run the CommutativeCancellation pass on a dag
Args:
dag (DAGCircuit): the DAG to be optimized.
Returns:
DAGCircuit: the optimized DAG.
Raises:
TranspilerError: when the 1 qubit rotation gates are not found
"""
... | def run(self, dag):
"""Run the CommutativeCancellation pass on a dag
Args:
dag (DAGCircuit): the DAG to be optimized.
Returns:
DAGCircuit: the optimized DAG.
Raises:
TranspilerError: when the 1 qubit rotation gates are not found
"""
... | [
"Run",
"the",
"CommutativeCancellation",
"pass",
"on",
"a",
"dag"
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/transpiler/passes/commutative_cancellation.py#L33-L110 | [
"def",
"run",
"(",
"self",
",",
"dag",
")",
":",
"q_gate_list",
"=",
"[",
"'cx'",
",",
"'cy'",
",",
"'cz'",
",",
"'h'",
",",
"'x'",
",",
"'y'",
",",
"'z'",
"]",
"# Gate sets to be cancelled",
"cancellation_sets",
"=",
"defaultdict",
"(",
"lambda",
":",
... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | _experiments_to_circuits | Return a list of QuantumCircuit object(s) from a qobj
Args:
qobj (Qobj): The Qobj object to convert to QuantumCircuits
Returns:
list: A list of QuantumCircuit objects from the qobj | qiskit/compiler/disassembler.py | def _experiments_to_circuits(qobj):
"""Return a list of QuantumCircuit object(s) from a qobj
Args:
qobj (Qobj): The Qobj object to convert to QuantumCircuits
Returns:
list: A list of QuantumCircuit objects from the qobj
"""
if qobj.experiments:
circuits = []
for x i... | def _experiments_to_circuits(qobj):
"""Return a list of QuantumCircuit object(s) from a qobj
Args:
qobj (Qobj): The Qobj object to convert to QuantumCircuits
Returns:
list: A list of QuantumCircuit objects from the qobj
"""
if qobj.experiments:
circuits = []
for x i... | [
"Return",
"a",
"list",
"of",
"QuantumCircuit",
"object",
"(",
"s",
")",
"from",
"a",
"qobj"
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/compiler/disassembler.py#L18-L78 | [
"def",
"_experiments_to_circuits",
"(",
"qobj",
")",
":",
"if",
"qobj",
".",
"experiments",
":",
"circuits",
"=",
"[",
"]",
"for",
"x",
"in",
"qobj",
".",
"experiments",
":",
"quantum_registers",
"=",
"[",
"QuantumRegister",
"(",
"i",
"[",
"1",
"]",
",",... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | disassemble | Dissasemble a qobj and return the circuits, run_config, and user header
Args:
qobj (Qobj): The input qobj object to dissasemble
Returns:
circuits (list): A list of quantum circuits
run_config (dict): The dist of the run config
user_qobj_header (dict): The dict of any user header... | qiskit/compiler/disassembler.py | def disassemble(qobj):
"""Dissasemble a qobj and return the circuits, run_config, and user header
Args:
qobj (Qobj): The input qobj object to dissasemble
Returns:
circuits (list): A list of quantum circuits
run_config (dict): The dist of the run config
user_qobj_header (dict... | def disassemble(qobj):
"""Dissasemble a qobj and return the circuits, run_config, and user header
Args:
qobj (Qobj): The input qobj object to dissasemble
Returns:
circuits (list): A list of quantum circuits
run_config (dict): The dist of the run config
user_qobj_header (dict... | [
"Dissasemble",
"a",
"qobj",
"and",
"return",
"the",
"circuits",
"run_config",
"and",
"user",
"header"
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/compiler/disassembler.py#L81-L96 | [
"def",
"disassemble",
"(",
"qobj",
")",
":",
"run_config",
"=",
"qobj",
".",
"config",
".",
"to_dict",
"(",
")",
"user_qobj_header",
"=",
"qobj",
".",
"header",
".",
"to_dict",
"(",
")",
"circuits",
"=",
"_experiments_to_circuits",
"(",
"qobj",
")",
"retur... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | hamming_distance | Calculate the Hamming distance between two bit strings
Args:
str1 (str): First string.
str2 (str): Second string.
Returns:
int: Distance between strings.
Raises:
VisualizationError: Strings not same length | qiskit/visualization/counts_visualization.py | def hamming_distance(str1, str2):
"""Calculate the Hamming distance between two bit strings
Args:
str1 (str): First string.
str2 (str): Second string.
Returns:
int: Distance between strings.
Raises:
VisualizationError: Strings not same length
"""
if len(str1) != ... | def hamming_distance(str1, str2):
"""Calculate the Hamming distance between two bit strings
Args:
str1 (str): First string.
str2 (str): Second string.
Returns:
int: Distance between strings.
Raises:
VisualizationError: Strings not same length
"""
if len(str1) != ... | [
"Calculate",
"the",
"Hamming",
"distance",
"between",
"two",
"bit",
"strings"
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/visualization/counts_visualization.py#L25-L38 | [
"def",
"hamming_distance",
"(",
"str1",
",",
"str2",
")",
":",
"if",
"len",
"(",
"str1",
")",
"!=",
"len",
"(",
"str2",
")",
":",
"raise",
"VisualizationError",
"(",
"'Strings not same length.'",
")",
"return",
"sum",
"(",
"s1",
"!=",
"s2",
"for",
"s1",
... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | plot_histogram | Plot a histogram of data.
Args:
data (list or dict): This is either a list of dictionaries or a single
dict containing the values to represent (ex {'001': 130})
figsize (tuple): Figure size in inches.
color (list or str): String or list of strings for histogram bar colors.
... | qiskit/visualization/counts_visualization.py | def plot_histogram(data, figsize=(7, 5), color=None, number_to_keep=None,
sort='asc', target_string=None,
legend=None, bar_labels=True, title=None):
"""Plot a histogram of data.
Args:
data (list or dict): This is either a list of dictionaries or a single
... | def plot_histogram(data, figsize=(7, 5), color=None, number_to_keep=None,
sort='asc', target_string=None,
legend=None, bar_labels=True, title=None):
"""Plot a histogram of data.
Args:
data (list or dict): This is either a list of dictionaries or a single
... | [
"Plot",
"a",
"histogram",
"of",
"data",
"."
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/visualization/counts_visualization.py#L45-L184 | [
"def",
"plot_histogram",
"(",
"data",
",",
"figsize",
"=",
"(",
"7",
",",
"5",
")",
",",
"color",
"=",
"None",
",",
"number_to_keep",
"=",
"None",
",",
"sort",
"=",
"'asc'",
",",
"target_string",
"=",
"None",
",",
"legend",
"=",
"None",
",",
"bar_lab... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | quaternion_from_axis_rotation | Return quaternion for rotation about given axis.
Args:
angle (float): Angle in radians.
axis (str): Axis for rotation
Returns:
Quaternion: Quaternion for axis rotation.
Raises:
ValueError: Invalid input axis. | qiskit/quantum_info/operators/quaternion.py | def quaternion_from_axis_rotation(angle, axis):
"""Return quaternion for rotation about given axis.
Args:
angle (float): Angle in radians.
axis (str): Axis for rotation
Returns:
Quaternion: Quaternion for axis rotation.
Raises:
ValueError: Invalid input axis.
"""
... | def quaternion_from_axis_rotation(angle, axis):
"""Return quaternion for rotation about given axis.
Args:
angle (float): Angle in radians.
axis (str): Axis for rotation
Returns:
Quaternion: Quaternion for axis rotation.
Raises:
ValueError: Invalid input axis.
"""
... | [
"Return",
"quaternion",
"for",
"rotation",
"about",
"given",
"axis",
"."
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/quantum_info/operators/quaternion.py#L104-L128 | [
"def",
"quaternion_from_axis_rotation",
"(",
"angle",
",",
"axis",
")",
":",
"out",
"=",
"np",
".",
"zeros",
"(",
"4",
",",
"dtype",
"=",
"float",
")",
"if",
"axis",
"==",
"'x'",
":",
"out",
"[",
"1",
"]",
"=",
"1",
"elif",
"axis",
"==",
"'y'",
"... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | quaternion_from_euler | Generate a quaternion from a set of Euler angles.
Args:
angles (array_like): Array of Euler angles.
order (str): Order of Euler rotations. 'yzy' is default.
Returns:
Quaternion: Quaternion representation of Euler rotation. | qiskit/quantum_info/operators/quaternion.py | def quaternion_from_euler(angles, order='yzy'):
"""Generate a quaternion from a set of Euler angles.
Args:
angles (array_like): Array of Euler angles.
order (str): Order of Euler rotations. 'yzy' is default.
Returns:
Quaternion: Quaternion representation of Euler rotation.
"""... | def quaternion_from_euler(angles, order='yzy'):
"""Generate a quaternion from a set of Euler angles.
Args:
angles (array_like): Array of Euler angles.
order (str): Order of Euler rotations. 'yzy' is default.
Returns:
Quaternion: Quaternion representation of Euler rotation.
"""... | [
"Generate",
"a",
"quaternion",
"from",
"a",
"set",
"of",
"Euler",
"angles",
"."
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/quantum_info/operators/quaternion.py#L131-L146 | [
"def",
"quaternion_from_euler",
"(",
"angles",
",",
"order",
"=",
"'yzy'",
")",
":",
"angles",
"=",
"np",
".",
"asarray",
"(",
"angles",
",",
"dtype",
"=",
"float",
")",
"quat",
"=",
"quaternion_from_axis_rotation",
"(",
"angles",
"[",
"0",
"]",
",",
"or... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | Quaternion.normalize | Normalizes a Quaternion to unit length
so that it represents a valid rotation.
Args:
inplace (bool): Do an inplace normalization.
Returns:
Quaternion: Normalized quaternion. | qiskit/quantum_info/operators/quaternion.py | def normalize(self, inplace=False):
"""Normalizes a Quaternion to unit length
so that it represents a valid rotation.
Args:
inplace (bool): Do an inplace normalization.
Returns:
Quaternion: Normalized quaternion.
"""
if inplace:
nrm =... | def normalize(self, inplace=False):
"""Normalizes a Quaternion to unit length
so that it represents a valid rotation.
Args:
inplace (bool): Do an inplace normalization.
Returns:
Quaternion: Normalized quaternion.
"""
if inplace:
nrm =... | [
"Normalizes",
"a",
"Quaternion",
"to",
"unit",
"length",
"so",
"that",
"it",
"represents",
"a",
"valid",
"rotation",
"."
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/quantum_info/operators/quaternion.py#L49-L66 | [
"def",
"normalize",
"(",
"self",
",",
"inplace",
"=",
"False",
")",
":",
"if",
"inplace",
":",
"nrm",
"=",
"self",
".",
"norm",
"(",
")",
"self",
".",
"data",
"/=",
"nrm",
"return",
"None",
"nrm",
"=",
"self",
".",
"norm",
"(",
")",
"data_copy",
... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | Quaternion.to_matrix | Converts a unit-length quaternion to a rotation matrix.
Returns:
ndarray: Rotation matrix. | qiskit/quantum_info/operators/quaternion.py | def to_matrix(self):
"""Converts a unit-length quaternion to a rotation matrix.
Returns:
ndarray: Rotation matrix.
"""
w, x, y, z = self.normalize().data # pylint: disable=C0103
mat = np.array([
[1-2*y**2-2*z**2, 2*x*y-2*z*w, 2*x*z+2*y*w],
[2... | def to_matrix(self):
"""Converts a unit-length quaternion to a rotation matrix.
Returns:
ndarray: Rotation matrix.
"""
w, x, y, z = self.normalize().data # pylint: disable=C0103
mat = np.array([
[1-2*y**2-2*z**2, 2*x*y-2*z*w, 2*x*z+2*y*w],
[2... | [
"Converts",
"a",
"unit",
"-",
"length",
"quaternion",
"to",
"a",
"rotation",
"matrix",
"."
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/quantum_info/operators/quaternion.py#L68-L80 | [
"def",
"to_matrix",
"(",
"self",
")",
":",
"w",
",",
"x",
",",
"y",
",",
"z",
"=",
"self",
".",
"normalize",
"(",
")",
".",
"data",
"# pylint: disable=C0103",
"mat",
"=",
"np",
".",
"array",
"(",
"[",
"[",
"1",
"-",
"2",
"*",
"y",
"**",
"2",
... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | Quaternion.to_zyz | Converts a unit-length quaternion to a sequence
of ZYZ Euler angles.
Returns:
ndarray: Array of Euler angles. | qiskit/quantum_info/operators/quaternion.py | def to_zyz(self):
"""Converts a unit-length quaternion to a sequence
of ZYZ Euler angles.
Returns:
ndarray: Array of Euler angles.
"""
mat = self.to_matrix()
euler = np.zeros(3, dtype=float)
if mat[2, 2] < 1:
if mat[2, 2] > -1:
... | def to_zyz(self):
"""Converts a unit-length quaternion to a sequence
of ZYZ Euler angles.
Returns:
ndarray: Array of Euler angles.
"""
mat = self.to_matrix()
euler = np.zeros(3, dtype=float)
if mat[2, 2] < 1:
if mat[2, 2] > -1:
... | [
"Converts",
"a",
"unit",
"-",
"length",
"quaternion",
"to",
"a",
"sequence",
"of",
"ZYZ",
"Euler",
"angles",
"."
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/quantum_info/operators/quaternion.py#L82-L101 | [
"def",
"to_zyz",
"(",
"self",
")",
":",
"mat",
"=",
"self",
".",
"to_matrix",
"(",
")",
"euler",
"=",
"np",
".",
"zeros",
"(",
"3",
",",
"dtype",
"=",
"float",
")",
"if",
"mat",
"[",
"2",
",",
"2",
"]",
"<",
"1",
":",
"if",
"mat",
"[",
"2",... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | process_data | Prepare received data for representation.
Args:
data (dict): values to represent (ex. {'001' : 130})
number_to_keep (int): number of elements to show individually.
Returns:
dict: processed data to show. | qiskit/visualization/interactive/iplot_histogram.py | def process_data(data, number_to_keep):
""" Prepare received data for representation.
Args:
data (dict): values to represent (ex. {'001' : 130})
number_to_keep (int): number of elements to show individually.
Returns:
dict: processed data to show.
"""
re... | def process_data(data, number_to_keep):
""" Prepare received data for representation.
Args:
data (dict): values to represent (ex. {'001' : 130})
number_to_keep (int): number of elements to show individually.
Returns:
dict: processed data to show.
"""
re... | [
"Prepare",
"received",
"data",
"for",
"representation",
"."
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/visualization/interactive/iplot_histogram.py#L26-L50 | [
"def",
"process_data",
"(",
"data",
",",
"number_to_keep",
")",
":",
"result",
"=",
"dict",
"(",
")",
"if",
"number_to_keep",
"!=",
"0",
":",
"data_temp",
"=",
"dict",
"(",
"Counter",
"(",
"data",
")",
".",
"most_common",
"(",
"number_to_keep",
")",
")",... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | iplot_histogram | Create a histogram representation.
Graphical representation of the input array using a vertical bars
style graph.
Args:
data (list or dict): This is either a list of dicts or a single
dict containing the values to represent (ex. {'001' : 130})
figsize (... | qiskit/visualization/interactive/iplot_histogram.py | def iplot_histogram(data, figsize=None, number_to_keep=None,
sort='asc', legend=None):
""" Create a histogram representation.
Graphical representation of the input array using a vertical bars
style graph.
Args:
data (list or dict): This is either a list of ... | def iplot_histogram(data, figsize=None, number_to_keep=None,
sort='asc', legend=None):
""" Create a histogram representation.
Graphical representation of the input array using a vertical bars
style graph.
Args:
data (list or dict): This is either a list of ... | [
"Create",
"a",
"histogram",
"representation",
"."
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/visualization/interactive/iplot_histogram.py#L53-L141 | [
"def",
"iplot_histogram",
"(",
"data",
",",
"figsize",
"=",
"None",
",",
"number_to_keep",
"=",
"None",
",",
"sort",
"=",
"'asc'",
",",
"legend",
"=",
"None",
")",
":",
"# HTML",
"html_template",
"=",
"Template",
"(",
"\"\"\"\n <p>\n <div id=\"histogra... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | InstructionParameter.check_type | Customize check_type for handling containers. | qiskit/validation/fields/custom.py | def check_type(self, value, attr, data):
"""Customize check_type for handling containers."""
# Check the type in the standard way first, in order to fail quickly
# in case of invalid values.
root_value = super(InstructionParameter, self).check_type(
value, attr, data)
... | def check_type(self, value, attr, data):
"""Customize check_type for handling containers."""
# Check the type in the standard way first, in order to fail quickly
# in case of invalid values.
root_value = super(InstructionParameter, self).check_type(
value, attr, data)
... | [
"Customize",
"check_type",
"for",
"handling",
"containers",
"."
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/validation/fields/custom.py#L113-L124 | [
"def",
"check_type",
"(",
"self",
",",
"value",
",",
"attr",
",",
"data",
")",
":",
"# Check the type in the standard way first, in order to fail quickly",
"# in case of invalid values.",
"root_value",
"=",
"super",
"(",
"InstructionParameter",
",",
"self",
")",
".",
"c... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | Register.check_range | Check that j is a valid index into self. | qiskit/circuit/register.py | def check_range(self, j):
"""Check that j is a valid index into self."""
if isinstance(j, int):
if j < 0 or j >= self.size:
raise QiskitIndexError("register index out of range")
elif isinstance(j, slice):
if j.start < 0 or j.stop >= self.size or (j... | def check_range(self, j):
"""Check that j is a valid index into self."""
if isinstance(j, int):
if j < 0 or j >= self.size:
raise QiskitIndexError("register index out of range")
elif isinstance(j, slice):
if j.start < 0 or j.stop >= self.size or (j... | [
"Check",
"that",
"j",
"is",
"a",
"valid",
"index",
"into",
"self",
"."
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/circuit/register.py#L57-L65 | [
"def",
"check_range",
"(",
"self",
",",
"j",
")",
":",
"if",
"isinstance",
"(",
"j",
",",
"int",
")",
":",
"if",
"j",
"<",
"0",
"or",
"j",
">=",
"self",
".",
"size",
":",
"raise",
"QiskitIndexError",
"(",
"\"register index out of range\"",
")",
"elif",... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | Node.to_string | Print with indent. | qiskit/qasm/node/node.py | def to_string(self, indent):
"""Print with indent."""
ind = indent * ' '
if self.root:
print(ind, self.type, '---', self.root)
else:
print(ind, self.type)
indent = indent + 3
ind = indent * ' '
for children in self.children:
if ... | def to_string(self, indent):
"""Print with indent."""
ind = indent * ' '
if self.root:
print(ind, self.type, '---', self.root)
else:
print(ind, self.type)
indent = indent + 3
ind = indent * ' '
for children in self.children:
if ... | [
"Print",
"with",
"indent",
"."
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/qasm/node/node.py#L34-L54 | [
"def",
"to_string",
"(",
"self",
",",
"indent",
")",
":",
"ind",
"=",
"indent",
"*",
"' '",
"if",
"self",
".",
"root",
":",
"print",
"(",
"ind",
",",
"self",
".",
"type",
",",
"'---'",
",",
"self",
".",
"root",
")",
"else",
":",
"print",
"(",
"... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | Gate.assemble | Assemble a QasmQobjInstruction | qiskit/circuit/gate.py | def assemble(self):
"""Assemble a QasmQobjInstruction"""
instruction = super().assemble()
if self.label:
instruction.label = self.label
return instruction | def assemble(self):
"""Assemble a QasmQobjInstruction"""
instruction = super().assemble()
if self.label:
instruction.label = self.label
return instruction | [
"Assemble",
"a",
"QasmQobjInstruction"
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/circuit/gate.py#L41-L46 | [
"def",
"assemble",
"(",
"self",
")",
":",
"instruction",
"=",
"super",
"(",
")",
".",
"assemble",
"(",
")",
"if",
"self",
".",
"label",
":",
"instruction",
".",
"label",
"=",
"self",
".",
"label",
"return",
"instruction"
] | d4f58d903bc96341b816f7c35df936d6421267d1 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.