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 | QasmSimulatorPy._add_qasm_reset | Apply a reset instruction to a qubit.
Args:
qubit (int): the qubit being rest
This is done by doing a simulating a measurement
outcome and projecting onto the outcome state while
renormalizing. | qiskit/providers/basicaer/qasm_simulator.py | def _add_qasm_reset(self, qubit):
"""Apply a reset instruction to a qubit.
Args:
qubit (int): the qubit being rest
This is done by doing a simulating a measurement
outcome and projecting onto the outcome state while
renormalizing.
"""
# get measure o... | def _add_qasm_reset(self, qubit):
"""Apply a reset instruction to a qubit.
Args:
qubit (int): the qubit being rest
This is done by doing a simulating a measurement
outcome and projecting onto the outcome state while
renormalizing.
"""
# get measure o... | [
"Apply",
"a",
"reset",
"instruction",
"to",
"a",
"qubit",
"."
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/providers/basicaer/qasm_simulator.py#L251-L269 | [
"def",
"_add_qasm_reset",
"(",
"self",
",",
"qubit",
")",
":",
"# get measure outcome",
"outcome",
",",
"probability",
"=",
"self",
".",
"_get_measure_outcome",
"(",
"qubit",
")",
"# update quantum state",
"if",
"outcome",
"==",
"'0'",
":",
"update",
"=",
"[",
... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | QasmSimulatorPy._validate_initial_statevector | Validate an initial statevector | qiskit/providers/basicaer/qasm_simulator.py | def _validate_initial_statevector(self):
"""Validate an initial statevector"""
# If initial statevector isn't set we don't need to validate
if self._initial_statevector is None:
return
# Check statevector is correct length for number of qubits
length = len(self._initi... | def _validate_initial_statevector(self):
"""Validate an initial statevector"""
# If initial statevector isn't set we don't need to validate
if self._initial_statevector is None:
return
# Check statevector is correct length for number of qubits
length = len(self._initi... | [
"Validate",
"an",
"initial",
"statevector"
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/providers/basicaer/qasm_simulator.py#L271-L281 | [
"def",
"_validate_initial_statevector",
"(",
"self",
")",
":",
"# If initial statevector isn't set we don't need to validate",
"if",
"self",
".",
"_initial_statevector",
"is",
"None",
":",
"return",
"# Check statevector is correct length for number of qubits",
"length",
"=",
"len... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | QasmSimulatorPy._set_options | Set the backend options for all experiments in a qobj | qiskit/providers/basicaer/qasm_simulator.py | def _set_options(self, qobj_config=None, backend_options=None):
"""Set the backend options for all experiments in a qobj"""
# Reset default options
self._initial_statevector = self.DEFAULT_OPTIONS["initial_statevector"]
self._chop_threshold = self.DEFAULT_OPTIONS["chop_threshold"]
... | def _set_options(self, qobj_config=None, backend_options=None):
"""Set the backend options for all experiments in a qobj"""
# Reset default options
self._initial_statevector = self.DEFAULT_OPTIONS["initial_statevector"]
self._chop_threshold = self.DEFAULT_OPTIONS["chop_threshold"]
... | [
"Set",
"the",
"backend",
"options",
"for",
"all",
"experiments",
"in",
"a",
"qobj"
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/providers/basicaer/qasm_simulator.py#L283-L310 | [
"def",
"_set_options",
"(",
"self",
",",
"qobj_config",
"=",
"None",
",",
"backend_options",
"=",
"None",
")",
":",
"# Reset default options",
"self",
".",
"_initial_statevector",
"=",
"self",
".",
"DEFAULT_OPTIONS",
"[",
"\"initial_statevector\"",
"]",
"self",
".... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | QasmSimulatorPy._initialize_statevector | Set the initial statevector for simulation | qiskit/providers/basicaer/qasm_simulator.py | def _initialize_statevector(self):
"""Set the initial statevector for simulation"""
if self._initial_statevector is None:
# Set to default state of all qubits in |0>
self._statevector = np.zeros(2 ** self._number_of_qubits,
dtype=complex)
... | def _initialize_statevector(self):
"""Set the initial statevector for simulation"""
if self._initial_statevector is None:
# Set to default state of all qubits in |0>
self._statevector = np.zeros(2 ** self._number_of_qubits,
dtype=complex)
... | [
"Set",
"the",
"initial",
"statevector",
"for",
"simulation"
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/providers/basicaer/qasm_simulator.py#L312-L323 | [
"def",
"_initialize_statevector",
"(",
"self",
")",
":",
"if",
"self",
".",
"_initial_statevector",
"is",
"None",
":",
"# Set to default state of all qubits in |0>",
"self",
".",
"_statevector",
"=",
"np",
".",
"zeros",
"(",
"2",
"**",
"self",
".",
"_number_of_qub... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | QasmSimulatorPy._get_statevector | Return the current statevector in JSON Result spec format | qiskit/providers/basicaer/qasm_simulator.py | def _get_statevector(self):
"""Return the current statevector in JSON Result spec format"""
vec = np.reshape(self._statevector, 2 ** self._number_of_qubits)
# Expand complex numbers
vec = np.stack([vec.real, vec.imag], axis=1)
# Truncate small values
vec[abs(vec) < self._... | def _get_statevector(self):
"""Return the current statevector in JSON Result spec format"""
vec = np.reshape(self._statevector, 2 ** self._number_of_qubits)
# Expand complex numbers
vec = np.stack([vec.real, vec.imag], axis=1)
# Truncate small values
vec[abs(vec) < self._... | [
"Return",
"the",
"current",
"statevector",
"in",
"JSON",
"Result",
"spec",
"format"
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/providers/basicaer/qasm_simulator.py#L325-L332 | [
"def",
"_get_statevector",
"(",
"self",
")",
":",
"vec",
"=",
"np",
".",
"reshape",
"(",
"self",
".",
"_statevector",
",",
"2",
"**",
"self",
".",
"_number_of_qubits",
")",
"# Expand complex numbers",
"vec",
"=",
"np",
".",
"stack",
"(",
"[",
"vec",
".",... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | QasmSimulatorPy._validate_measure_sampling | Determine if measure sampling is allowed for an experiment
Args:
experiment (QobjExperiment): a qobj experiment. | qiskit/providers/basicaer/qasm_simulator.py | def _validate_measure_sampling(self, experiment):
"""Determine if measure sampling is allowed for an experiment
Args:
experiment (QobjExperiment): a qobj experiment.
"""
# If shots=1 we should disable measure sampling.
# This is also required for statevector simulato... | def _validate_measure_sampling(self, experiment):
"""Determine if measure sampling is allowed for an experiment
Args:
experiment (QobjExperiment): a qobj experiment.
"""
# If shots=1 we should disable measure sampling.
# This is also required for statevector simulato... | [
"Determine",
"if",
"measure",
"sampling",
"is",
"allowed",
"for",
"an",
"experiment"
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/providers/basicaer/qasm_simulator.py#L334-L372 | [
"def",
"_validate_measure_sampling",
"(",
"self",
",",
"experiment",
")",
":",
"# If shots=1 we should disable measure sampling.",
"# This is also required for statevector simulator to return the",
"# correct final statevector without silently dropping final measurements.",
"if",
"self",
"... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | QasmSimulatorPy.run | Run qobj asynchronously.
Args:
qobj (Qobj): payload of the experiment
backend_options (dict): backend options
Returns:
BasicAerJob: derived from BaseJob
Additional Information:
backend_options: Is a dict of options for the backend. It may contai... | qiskit/providers/basicaer/qasm_simulator.py | def run(self, qobj, backend_options=None):
"""Run qobj asynchronously.
Args:
qobj (Qobj): payload of the experiment
backend_options (dict): backend options
Returns:
BasicAerJob: derived from BaseJob
Additional Information:
backend_option... | def run(self, qobj, backend_options=None):
"""Run qobj asynchronously.
Args:
qobj (Qobj): payload of the experiment
backend_options (dict): backend options
Returns:
BasicAerJob: derived from BaseJob
Additional Information:
backend_option... | [
"Run",
"qobj",
"asynchronously",
"."
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/providers/basicaer/qasm_simulator.py#L374-L404 | [
"def",
"run",
"(",
"self",
",",
"qobj",
",",
"backend_options",
"=",
"None",
")",
":",
"self",
".",
"_set_options",
"(",
"qobj_config",
"=",
"qobj",
".",
"config",
",",
"backend_options",
"=",
"backend_options",
")",
"job_id",
"=",
"str",
"(",
"uuid",
".... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | QasmSimulatorPy._run_job | Run experiments in qobj
Args:
job_id (str): unique id for the job.
qobj (Qobj): job description
Returns:
Result: Result object | qiskit/providers/basicaer/qasm_simulator.py | def _run_job(self, job_id, qobj):
"""Run experiments in qobj
Args:
job_id (str): unique id for the job.
qobj (Qobj): job description
Returns:
Result: Result object
"""
self._validate(qobj)
result_list = []
self._shots = qobj.c... | def _run_job(self, job_id, qobj):
"""Run experiments in qobj
Args:
job_id (str): unique id for the job.
qobj (Qobj): job description
Returns:
Result: Result object
"""
self._validate(qobj)
result_list = []
self._shots = qobj.c... | [
"Run",
"experiments",
"in",
"qobj"
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/providers/basicaer/qasm_simulator.py#L406-L435 | [
"def",
"_run_job",
"(",
"self",
",",
"job_id",
",",
"qobj",
")",
":",
"self",
".",
"_validate",
"(",
"qobj",
")",
"result_list",
"=",
"[",
"]",
"self",
".",
"_shots",
"=",
"qobj",
".",
"config",
".",
"shots",
"self",
".",
"_memory",
"=",
"getattr",
... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | QasmSimulatorPy.run_experiment | Run an experiment (circuit) and return a single experiment result.
Args:
experiment (QobjExperiment): experiment from qobj experiments list
Returns:
dict: A result dictionary which looks something like::
{
"name": name of this experiment (obtai... | qiskit/providers/basicaer/qasm_simulator.py | def run_experiment(self, experiment):
"""Run an experiment (circuit) and return a single experiment result.
Args:
experiment (QobjExperiment): experiment from qobj experiments list
Returns:
dict: A result dictionary which looks something like::
{
... | def run_experiment(self, experiment):
"""Run an experiment (circuit) and return a single experiment result.
Args:
experiment (QobjExperiment): experiment from qobj experiments list
Returns:
dict: A result dictionary which looks something like::
{
... | [
"Run",
"an",
"experiment",
"(",
"circuit",
")",
"and",
"return",
"a",
"single",
"experiment",
"result",
"."
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/providers/basicaer/qasm_simulator.py#L437-L620 | [
"def",
"run_experiment",
"(",
"self",
",",
"experiment",
")",
":",
"start",
"=",
"time",
".",
"time",
"(",
")",
"self",
".",
"_number_of_qubits",
"=",
"experiment",
".",
"config",
".",
"n_qubits",
"self",
".",
"_number_of_cmembits",
"=",
"experiment",
".",
... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | QasmSimulatorPy._validate | Semantic validations of the qobj which cannot be done via schemas. | qiskit/providers/basicaer/qasm_simulator.py | def _validate(self, qobj):
"""Semantic validations of the qobj which cannot be done via schemas."""
n_qubits = qobj.config.n_qubits
max_qubits = self.configuration().n_qubits
if n_qubits > max_qubits:
raise BasicAerError('Number of qubits {} '.format(n_qubits) +
... | def _validate(self, qobj):
"""Semantic validations of the qobj which cannot be done via schemas."""
n_qubits = qobj.config.n_qubits
max_qubits = self.configuration().n_qubits
if n_qubits > max_qubits:
raise BasicAerError('Number of qubits {} '.format(n_qubits) +
... | [
"Semantic",
"validations",
"of",
"the",
"qobj",
"which",
"cannot",
"be",
"done",
"via",
"schemas",
"."
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/providers/basicaer/qasm_simulator.py#L622-L637 | [
"def",
"_validate",
"(",
"self",
",",
"qobj",
")",
":",
"n_qubits",
"=",
"qobj",
".",
"config",
".",
"n_qubits",
"max_qubits",
"=",
"self",
".",
"configuration",
"(",
")",
".",
"n_qubits",
"if",
"n_qubits",
">",
"max_qubits",
":",
"raise",
"BasicAerError",... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | UnitarySimulatorPy._add_unitary_single | Apply an arbitrary 1-qubit unitary matrix.
Args:
gate (matrix_like): a single qubit gate matrix
qubit (int): the qubit to apply gate to | qiskit/providers/basicaer/unitary_simulator.py | def _add_unitary_single(self, gate, qubit):
"""Apply an arbitrary 1-qubit unitary matrix.
Args:
gate (matrix_like): a single qubit gate matrix
qubit (int): the qubit to apply gate to
"""
# Convert to complex rank-2 tensor
gate_tensor = np.array(gate, dtyp... | def _add_unitary_single(self, gate, qubit):
"""Apply an arbitrary 1-qubit unitary matrix.
Args:
gate (matrix_like): a single qubit gate matrix
qubit (int): the qubit to apply gate to
"""
# Convert to complex rank-2 tensor
gate_tensor = np.array(gate, dtyp... | [
"Apply",
"an",
"arbitrary",
"1",
"-",
"qubit",
"unitary",
"matrix",
"."
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/providers/basicaer/unitary_simulator.py#L110-L123 | [
"def",
"_add_unitary_single",
"(",
"self",
",",
"gate",
",",
"qubit",
")",
":",
"# Convert to complex rank-2 tensor",
"gate_tensor",
"=",
"np",
".",
"array",
"(",
"gate",
",",
"dtype",
"=",
"complex",
")",
"# Compute einsum index string for 1-qubit matrix multiplication... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | UnitarySimulatorPy._add_unitary_two | Apply a two-qubit unitary matrix.
Args:
gate (matrix_like): a the two-qubit gate matrix
qubit0 (int): gate qubit-0
qubit1 (int): gate qubit-1 | qiskit/providers/basicaer/unitary_simulator.py | def _add_unitary_two(self, gate, qubit0, qubit1):
"""Apply a two-qubit unitary matrix.
Args:
gate (matrix_like): a the two-qubit gate matrix
qubit0 (int): gate qubit-0
qubit1 (int): gate qubit-1
"""
# Convert to complex rank-4 tensor
gate_ten... | def _add_unitary_two(self, gate, qubit0, qubit1):
"""Apply a two-qubit unitary matrix.
Args:
gate (matrix_like): a the two-qubit gate matrix
qubit0 (int): gate qubit-0
qubit1 (int): gate qubit-1
"""
# Convert to complex rank-4 tensor
gate_ten... | [
"Apply",
"a",
"two",
"-",
"qubit",
"unitary",
"matrix",
"."
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/providers/basicaer/unitary_simulator.py#L125-L142 | [
"def",
"_add_unitary_two",
"(",
"self",
",",
"gate",
",",
"qubit0",
",",
"qubit1",
")",
":",
"# Convert to complex rank-4 tensor",
"gate_tensor",
"=",
"np",
".",
"reshape",
"(",
"np",
".",
"array",
"(",
"gate",
",",
"dtype",
"=",
"complex",
")",
",",
"4",
... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | UnitarySimulatorPy._validate_initial_unitary | Validate an initial unitary matrix | qiskit/providers/basicaer/unitary_simulator.py | def _validate_initial_unitary(self):
"""Validate an initial unitary matrix"""
# If initial unitary isn't set we don't need to validate
if self._initial_unitary is None:
return
# Check unitary is correct length for number of qubits
shape = np.shape(self._initial_unitar... | def _validate_initial_unitary(self):
"""Validate an initial unitary matrix"""
# If initial unitary isn't set we don't need to validate
if self._initial_unitary is None:
return
# Check unitary is correct length for number of qubits
shape = np.shape(self._initial_unitar... | [
"Validate",
"an",
"initial",
"unitary",
"matrix"
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/providers/basicaer/unitary_simulator.py#L144-L155 | [
"def",
"_validate_initial_unitary",
"(",
"self",
")",
":",
"# If initial unitary isn't set we don't need to validate",
"if",
"self",
".",
"_initial_unitary",
"is",
"None",
":",
"return",
"# Check unitary is correct length for number of qubits",
"shape",
"=",
"np",
".",
"shape... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | UnitarySimulatorPy._set_options | Set the backend options for all experiments in a qobj | qiskit/providers/basicaer/unitary_simulator.py | def _set_options(self, qobj_config=None, backend_options=None):
"""Set the backend options for all experiments in a qobj"""
# Reset default options
self._initial_unitary = self.DEFAULT_OPTIONS["initial_unitary"]
self._chop_threshold = self.DEFAULT_OPTIONS["chop_threshold"]
if bac... | def _set_options(self, qobj_config=None, backend_options=None):
"""Set the backend options for all experiments in a qobj"""
# Reset default options
self._initial_unitary = self.DEFAULT_OPTIONS["initial_unitary"]
self._chop_threshold = self.DEFAULT_OPTIONS["chop_threshold"]
if bac... | [
"Set",
"the",
"backend",
"options",
"for",
"all",
"experiments",
"in",
"a",
"qobj"
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/providers/basicaer/unitary_simulator.py#L157-L191 | [
"def",
"_set_options",
"(",
"self",
",",
"qobj_config",
"=",
"None",
",",
"backend_options",
"=",
"None",
")",
":",
"# Reset default options",
"self",
".",
"_initial_unitary",
"=",
"self",
".",
"DEFAULT_OPTIONS",
"[",
"\"initial_unitary\"",
"]",
"self",
".",
"_c... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | UnitarySimulatorPy._initialize_unitary | Set the initial unitary for simulation | qiskit/providers/basicaer/unitary_simulator.py | def _initialize_unitary(self):
"""Set the initial unitary for simulation"""
self._validate_initial_unitary()
if self._initial_unitary is None:
# Set to identity matrix
self._unitary = np.eye(2 ** self._number_of_qubits,
dtype=complex)
... | def _initialize_unitary(self):
"""Set the initial unitary for simulation"""
self._validate_initial_unitary()
if self._initial_unitary is None:
# Set to identity matrix
self._unitary = np.eye(2 ** self._number_of_qubits,
dtype=complex)
... | [
"Set",
"the",
"initial",
"unitary",
"for",
"simulation"
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/providers/basicaer/unitary_simulator.py#L193-L204 | [
"def",
"_initialize_unitary",
"(",
"self",
")",
":",
"self",
".",
"_validate_initial_unitary",
"(",
")",
"if",
"self",
".",
"_initial_unitary",
"is",
"None",
":",
"# Set to identity matrix",
"self",
".",
"_unitary",
"=",
"np",
".",
"eye",
"(",
"2",
"**",
"se... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | UnitarySimulatorPy._get_unitary | Return the current unitary in JSON Result spec format | qiskit/providers/basicaer/unitary_simulator.py | def _get_unitary(self):
"""Return the current unitary in JSON Result spec format"""
unitary = np.reshape(self._unitary, 2 * [2 ** self._number_of_qubits])
# Expand complex numbers
unitary = np.stack((unitary.real, unitary.imag), axis=-1)
# Truncate small values
unitary[ab... | def _get_unitary(self):
"""Return the current unitary in JSON Result spec format"""
unitary = np.reshape(self._unitary, 2 * [2 ** self._number_of_qubits])
# Expand complex numbers
unitary = np.stack((unitary.real, unitary.imag), axis=-1)
# Truncate small values
unitary[ab... | [
"Return",
"the",
"current",
"unitary",
"in",
"JSON",
"Result",
"spec",
"format"
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/providers/basicaer/unitary_simulator.py#L206-L213 | [
"def",
"_get_unitary",
"(",
"self",
")",
":",
"unitary",
"=",
"np",
".",
"reshape",
"(",
"self",
".",
"_unitary",
",",
"2",
"*",
"[",
"2",
"**",
"self",
".",
"_number_of_qubits",
"]",
")",
"# Expand complex numbers",
"unitary",
"=",
"np",
".",
"stack",
... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | UnitarySimulatorPy._run_job | Run experiments in qobj.
Args:
job_id (str): unique id for the job.
qobj (Qobj): job description
Returns:
Result: Result object | qiskit/providers/basicaer/unitary_simulator.py | def _run_job(self, job_id, qobj):
"""Run experiments in qobj.
Args:
job_id (str): unique id for the job.
qobj (Qobj): job description
Returns:
Result: Result object
"""
self._validate(qobj)
result_list = []
start = time.time()... | def _run_job(self, job_id, qobj):
"""Run experiments in qobj.
Args:
job_id (str): unique id for the job.
qobj (Qobj): job description
Returns:
Result: Result object
"""
self._validate(qobj)
result_list = []
start = time.time()... | [
"Run",
"experiments",
"in",
"qobj",
"."
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/providers/basicaer/unitary_simulator.py#L257-L283 | [
"def",
"_run_job",
"(",
"self",
",",
"job_id",
",",
"qobj",
")",
":",
"self",
".",
"_validate",
"(",
"qobj",
")",
"result_list",
"=",
"[",
"]",
"start",
"=",
"time",
".",
"time",
"(",
")",
"for",
"experiment",
"in",
"qobj",
".",
"experiments",
":",
... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | UnitarySimulatorPy.run_experiment | Run an experiment (circuit) and return a single experiment result.
Args:
experiment (QobjExperiment): experiment from qobj experiments list
Returns:
dict: A result dictionary which looks something like::
{
"name": name of this experiment (obtain... | qiskit/providers/basicaer/unitary_simulator.py | def run_experiment(self, experiment):
"""Run an experiment (circuit) and return a single experiment result.
Args:
experiment (QobjExperiment): experiment from qobj experiments list
Returns:
dict: A result dictionary which looks something like::
{
... | def run_experiment(self, experiment):
"""Run an experiment (circuit) and return a single experiment result.
Args:
experiment (QobjExperiment): experiment from qobj experiments list
Returns:
dict: A result dictionary which looks something like::
{
... | [
"Run",
"an",
"experiment",
"(",
"circuit",
")",
"and",
"return",
"a",
"single",
"experiment",
"result",
"."
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/providers/basicaer/unitary_simulator.py#L285-L350 | [
"def",
"run_experiment",
"(",
"self",
",",
"experiment",
")",
":",
"start",
"=",
"time",
".",
"time",
"(",
")",
"self",
".",
"_number_of_qubits",
"=",
"experiment",
".",
"header",
".",
"n_qubits",
"# Validate the dimension of initial unitary if set",
"self",
".",
... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | UnitarySimulatorPy._validate | Semantic validations of the qobj which cannot be done via schemas.
Some of these may later move to backend schemas.
1. No shots
2. No measurements in the middle | qiskit/providers/basicaer/unitary_simulator.py | def _validate(self, qobj):
"""Semantic validations of the qobj which cannot be done via schemas.
Some of these may later move to backend schemas.
1. No shots
2. No measurements in the middle
"""
n_qubits = qobj.config.n_qubits
max_qubits = self.configuration().n_q... | def _validate(self, qobj):
"""Semantic validations of the qobj which cannot be done via schemas.
Some of these may later move to backend schemas.
1. No shots
2. No measurements in the middle
"""
n_qubits = qobj.config.n_qubits
max_qubits = self.configuration().n_q... | [
"Semantic",
"validations",
"of",
"the",
"qobj",
"which",
"cannot",
"be",
"done",
"via",
"schemas",
".",
"Some",
"of",
"these",
"may",
"later",
"move",
"to",
"backend",
"schemas",
".",
"1",
".",
"No",
"shots",
"2",
".",
"No",
"measurements",
"in",
"the",
... | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/providers/basicaer/unitary_simulator.py#L352-L379 | [
"def",
"_validate",
"(",
"self",
",",
"qobj",
")",
":",
"n_qubits",
"=",
"qobj",
".",
"config",
".",
"n_qubits",
"max_qubits",
"=",
"self",
".",
"configuration",
"(",
")",
".",
"n_qubits",
"if",
"n_qubits",
">",
"max_qubits",
":",
"raise",
"BasicAerError",... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | _is_bit | Determine if obj is a bit | qiskit/circuit/decorators.py | def _is_bit(obj):
"""Determine if obj is a bit"""
# If there is a bit type this could be replaced by isinstance.
if isinstance(obj, tuple) and len(obj) == 2:
if isinstance(obj[0], Register) and isinstance(obj[1], int) and obj[1] < len(obj[0]):
return True
return False | def _is_bit(obj):
"""Determine if obj is a bit"""
# If there is a bit type this could be replaced by isinstance.
if isinstance(obj, tuple) and len(obj) == 2:
if isinstance(obj[0], Register) and isinstance(obj[1], int) and obj[1] < len(obj[0]):
return True
return False | [
"Determine",
"if",
"obj",
"is",
"a",
"bit"
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/circuit/decorators.py#L21-L27 | [
"def",
"_is_bit",
"(",
"obj",
")",
":",
"# If there is a bit type this could be replaced by isinstance.",
"if",
"isinstance",
"(",
"obj",
",",
"tuple",
")",
"and",
"len",
"(",
"obj",
")",
"==",
"2",
":",
"if",
"isinstance",
"(",
"obj",
"[",
"0",
"]",
",",
... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | _convert_to_bits | Recursively converts the integers, tuples and ranges in a_list
for a qu/clbit from the bits. E.g. bits[item_in_a_list] | qiskit/circuit/decorators.py | def _convert_to_bits(a_list, bits):
""" Recursively converts the integers, tuples and ranges in a_list
for a qu/clbit from the bits. E.g. bits[item_in_a_list]"""
new_list = []
for item in a_list:
if isinstance(item, (int, slice)):
# eg. circuit.h(2)
# eg. circuit.h(slice(... | def _convert_to_bits(a_list, bits):
""" Recursively converts the integers, tuples and ranges in a_list
for a qu/clbit from the bits. E.g. bits[item_in_a_list]"""
new_list = []
for item in a_list:
if isinstance(item, (int, slice)):
# eg. circuit.h(2)
# eg. circuit.h(slice(... | [
"Recursively",
"converts",
"the",
"integers",
"tuples",
"and",
"ranges",
"in",
"a_list",
"for",
"a",
"qu",
"/",
"clbit",
"from",
"the",
"bits",
".",
"E",
".",
"g",
".",
"bits",
"[",
"item_in_a_list",
"]"
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/circuit/decorators.py#L30-L50 | [
"def",
"_convert_to_bits",
"(",
"a_list",
",",
"bits",
")",
":",
"new_list",
"=",
"[",
"]",
"for",
"item",
"in",
"a_list",
":",
"if",
"isinstance",
"(",
"item",
",",
"(",
"int",
",",
"slice",
")",
")",
":",
"# eg. circuit.h(2)",
"# eg. circuit.h(slice(0, 2... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | _to_bits | Convert gate arguments to [qu|cl]bits from integers, slices, ranges, etc.
For example circuit.h(0) -> circuit.h(QuantumRegister(2)[0]) | qiskit/circuit/decorators.py | def _to_bits(nqbits, ncbits=0, func=None):
"""Convert gate arguments to [qu|cl]bits from integers, slices, ranges, etc.
For example circuit.h(0) -> circuit.h(QuantumRegister(2)[0]) """
if func is None:
return functools.partial(_to_bits, nqbits, ncbits)
@functools.wraps(func)
def wrapper(sel... | def _to_bits(nqbits, ncbits=0, func=None):
"""Convert gate arguments to [qu|cl]bits from integers, slices, ranges, etc.
For example circuit.h(0) -> circuit.h(QuantumRegister(2)[0]) """
if func is None:
return functools.partial(_to_bits, nqbits, ncbits)
@functools.wraps(func)
def wrapper(sel... | [
"Convert",
"gate",
"arguments",
"to",
"[",
"qu|cl",
"]",
"bits",
"from",
"integers",
"slices",
"ranges",
"etc",
".",
"For",
"example",
"circuit",
".",
"h",
"(",
"0",
")",
"-",
">",
"circuit",
".",
"h",
"(",
"QuantumRegister",
"(",
"2",
")",
"[",
"0",... | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/circuit/decorators.py#L53-L73 | [
"def",
"_to_bits",
"(",
"nqbits",
",",
"ncbits",
"=",
"0",
",",
"func",
"=",
"None",
")",
":",
"if",
"func",
"is",
"None",
":",
"return",
"functools",
".",
"partial",
"(",
"_to_bits",
",",
"nqbits",
",",
"ncbits",
")",
"@",
"functools",
".",
"wraps",... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | _op_expand | Decorator for expanding an operation across a whole register or register subset.
Args:
n_bits (int): the number of register bit arguments the decorated function takes
func (function): used for decorators with keyword args
broadcastable (list(bool)): list of bool for which register args can b... | qiskit/circuit/decorators.py | def _op_expand(n_bits, func=None, broadcastable=None):
"""Decorator for expanding an operation across a whole register or register subset.
Args:
n_bits (int): the number of register bit arguments the decorated function takes
func (function): used for decorators with keyword args
broadcas... | def _op_expand(n_bits, func=None, broadcastable=None):
"""Decorator for expanding an operation across a whole register or register subset.
Args:
n_bits (int): the number of register bit arguments the decorated function takes
func (function): used for decorators with keyword args
broadcas... | [
"Decorator",
"for",
"expanding",
"an",
"operation",
"across",
"a",
"whole",
"register",
"or",
"register",
"subset",
".",
"Args",
":",
"n_bits",
"(",
"int",
")",
":",
"the",
"number",
"of",
"register",
"bit",
"arguments",
"the",
"decorated",
"function",
"take... | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/circuit/decorators.py#L76-L138 | [
"def",
"_op_expand",
"(",
"n_bits",
",",
"func",
"=",
"None",
",",
"broadcastable",
"=",
"None",
")",
":",
"if",
"func",
"is",
"None",
":",
"return",
"functools",
".",
"partial",
"(",
"_op_expand",
",",
"n_bits",
",",
"broadcastable",
"=",
"broadcastable",... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | U1Gate.to_matrix | Return a Numpy.array for the U3 gate. | qiskit/extensions/standard/u1.py | def to_matrix(self):
"""Return a Numpy.array for the U3 gate."""
lam = self.params[0]
lam = float(lam)
return numpy.array([[1, 0], [0, numpy.exp(1j * lam)]], dtype=complex) | def to_matrix(self):
"""Return a Numpy.array for the U3 gate."""
lam = self.params[0]
lam = float(lam)
return numpy.array([[1, 0], [0, numpy.exp(1j * lam)]], dtype=complex) | [
"Return",
"a",
"Numpy",
".",
"array",
"for",
"the",
"U3",
"gate",
"."
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/extensions/standard/u1.py#L43-L47 | [
"def",
"to_matrix",
"(",
"self",
")",
":",
"lam",
"=",
"self",
".",
"params",
"[",
"0",
"]",
"lam",
"=",
"float",
"(",
"lam",
")",
"return",
"numpy",
".",
"array",
"(",
"[",
"[",
"1",
",",
"0",
"]",
",",
"[",
"0",
",",
"numpy",
".",
"exp",
... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | TrivialLayout.run | Pick a layout by assigning n circuit qubits to device qubits 0, .., n-1.
Args:
dag (DAGCircuit): DAG to find layout for.
Raises:
TranspilerError: if dag wider than self.coupling_map | qiskit/transpiler/passes/mapping/trivial_layout.py | def run(self, dag):
"""
Pick a layout by assigning n circuit qubits to device qubits 0, .., n-1.
Args:
dag (DAGCircuit): DAG to find layout for.
Raises:
TranspilerError: if dag wider than self.coupling_map
"""
num_dag_qubits = sum([qreg.size for ... | def run(self, dag):
"""
Pick a layout by assigning n circuit qubits to device qubits 0, .., n-1.
Args:
dag (DAGCircuit): DAG to find layout for.
Raises:
TranspilerError: if dag wider than self.coupling_map
"""
num_dag_qubits = sum([qreg.size for ... | [
"Pick",
"a",
"layout",
"by",
"assigning",
"n",
"circuit",
"qubits",
"to",
"device",
"qubits",
"0",
"..",
"n",
"-",
"1",
"."
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/transpiler/passes/mapping/trivial_layout.py#L40-L53 | [
"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 | Interval.has_overlap | Check if self has overlap with `interval`.
Args:
interval: interval to be examined
Returns:
bool: True if self has overlap with `interval` otherwise False | qiskit/pulse/timeslots.py | def has_overlap(self, interval: 'Interval') -> bool:
"""Check if self has overlap with `interval`.
Args:
interval: interval to be examined
Returns:
bool: True if self has overlap with `interval` otherwise False
"""
if self.begin < interval.end and interv... | def has_overlap(self, interval: 'Interval') -> bool:
"""Check if self has overlap with `interval`.
Args:
interval: interval to be examined
Returns:
bool: True if self has overlap with `interval` otherwise False
"""
if self.begin < interval.end and interv... | [
"Check",
"if",
"self",
"has",
"overlap",
"with",
"interval",
"."
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/pulse/timeslots.py#L59-L70 | [
"def",
"has_overlap",
"(",
"self",
",",
"interval",
":",
"'Interval'",
")",
"->",
"bool",
":",
"if",
"self",
".",
"begin",
"<",
"interval",
".",
"end",
"and",
"interval",
".",
"begin",
"<",
"self",
".",
"end",
":",
"return",
"True",
"return",
"False"
] | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | Interval.shift | Return a new interval shifted by `time` from self
Args:
time: time to be shifted
Returns:
Interval: interval shifted by `time` | qiskit/pulse/timeslots.py | def shift(self, time: int) -> 'Interval':
"""Return a new interval shifted by `time` from self
Args:
time: time to be shifted
Returns:
Interval: interval shifted by `time`
"""
return Interval(self._begin + time, self._end + time) | def shift(self, time: int) -> 'Interval':
"""Return a new interval shifted by `time` from self
Args:
time: time to be shifted
Returns:
Interval: interval shifted by `time`
"""
return Interval(self._begin + time, self._end + time) | [
"Return",
"a",
"new",
"interval",
"shifted",
"by",
"time",
"from",
"self"
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/pulse/timeslots.py#L72-L81 | [
"def",
"shift",
"(",
"self",
",",
"time",
":",
"int",
")",
"->",
"'Interval'",
":",
"return",
"Interval",
"(",
"self",
".",
"_begin",
"+",
"time",
",",
"self",
".",
"_end",
"+",
"time",
")"
] | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | Timeslot.shift | Return a new Timeslot shifted by `time`.
Args:
time: time to be shifted | qiskit/pulse/timeslots.py | def shift(self, time: int) -> 'Timeslot':
"""Return a new Timeslot shifted by `time`.
Args:
time: time to be shifted
"""
return Timeslot(self.interval.shift(time), self.channel) | def shift(self, time: int) -> 'Timeslot':
"""Return a new Timeslot shifted by `time`.
Args:
time: time to be shifted
"""
return Timeslot(self.interval.shift(time), self.channel) | [
"Return",
"a",
"new",
"Timeslot",
"shifted",
"by",
"time",
"."
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/pulse/timeslots.py#L114-L120 | [
"def",
"shift",
"(",
"self",
",",
"time",
":",
"int",
")",
"->",
"'Timeslot'",
":",
"return",
"Timeslot",
"(",
"self",
".",
"interval",
".",
"shift",
"(",
"time",
")",
",",
"self",
".",
"channel",
")"
] | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | TimeslotCollection.ch_start_time | Return earliest start time in this collection.
Args:
*channels: Channels over which to obtain start_time. | qiskit/pulse/timeslots.py | def ch_start_time(self, *channels: List[Channel]) -> int:
"""Return earliest start time in this collection.
Args:
*channels: Channels over which to obtain start_time.
"""
intervals = list(itertools.chain(*(self._table[chan] for chan in channels
... | def ch_start_time(self, *channels: List[Channel]) -> int:
"""Return earliest start time in this collection.
Args:
*channels: Channels over which to obtain start_time.
"""
intervals = list(itertools.chain(*(self._table[chan] for chan in channels
... | [
"Return",
"earliest",
"start",
"time",
"in",
"this",
"collection",
"."
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/pulse/timeslots.py#L179-L189 | [
"def",
"ch_start_time",
"(",
"self",
",",
"*",
"channels",
":",
"List",
"[",
"Channel",
"]",
")",
"->",
"int",
":",
"intervals",
"=",
"list",
"(",
"itertools",
".",
"chain",
"(",
"*",
"(",
"self",
".",
"_table",
"[",
"chan",
"]",
"for",
"chan",
"in... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | TimeslotCollection.ch_stop_time | Return maximum time of timeslots over all channels.
Args:
*channels: Channels over which to obtain stop time. | qiskit/pulse/timeslots.py | def ch_stop_time(self, *channels: List[Channel]) -> int:
"""Return maximum time of timeslots over all channels.
Args:
*channels: Channels over which to obtain stop time.
"""
intervals = list(itertools.chain(*(self._table[chan] for chan in channels
... | def ch_stop_time(self, *channels: List[Channel]) -> int:
"""Return maximum time of timeslots over all channels.
Args:
*channels: Channels over which to obtain stop time.
"""
intervals = list(itertools.chain(*(self._table[chan] for chan in channels
... | [
"Return",
"maximum",
"time",
"of",
"timeslots",
"over",
"all",
"channels",
"."
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/pulse/timeslots.py#L191-L201 | [
"def",
"ch_stop_time",
"(",
"self",
",",
"*",
"channels",
":",
"List",
"[",
"Channel",
"]",
")",
"->",
"int",
":",
"intervals",
"=",
"list",
"(",
"itertools",
".",
"chain",
"(",
"*",
"(",
"self",
".",
"_table",
"[",
"chan",
"]",
"for",
"chan",
"in"... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | TimeslotCollection.is_mergeable_with | Return if self is mergeable with `timeslots`.
Args:
timeslots: TimeslotCollection to be checked | qiskit/pulse/timeslots.py | def is_mergeable_with(self, timeslots: 'TimeslotCollection') -> bool:
"""Return if self is mergeable with `timeslots`.
Args:
timeslots: TimeslotCollection to be checked
"""
for slot in timeslots.timeslots:
for interval in self._table[slot.channel]:
... | def is_mergeable_with(self, timeslots: 'TimeslotCollection') -> bool:
"""Return if self is mergeable with `timeslots`.
Args:
timeslots: TimeslotCollection to be checked
"""
for slot in timeslots.timeslots:
for interval in self._table[slot.channel]:
... | [
"Return",
"if",
"self",
"is",
"mergeable",
"with",
"timeslots",
"."
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/pulse/timeslots.py#L211-L221 | [
"def",
"is_mergeable_with",
"(",
"self",
",",
"timeslots",
":",
"'TimeslotCollection'",
")",
"->",
"bool",
":",
"for",
"slot",
"in",
"timeslots",
".",
"timeslots",
":",
"for",
"interval",
"in",
"self",
".",
"_table",
"[",
"slot",
".",
"channel",
"]",
":",
... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | TimeslotCollection.merged | Return a new TimeslotCollection merged with a specified `timeslots`
Args:
timeslots: TimeslotCollection to be merged | qiskit/pulse/timeslots.py | def merged(self, timeslots: 'TimeslotCollection') -> 'TimeslotCollection':
"""Return a new TimeslotCollection merged with a specified `timeslots`
Args:
timeslots: TimeslotCollection to be merged
"""
slots = [Timeslot(slot.interval, slot.channel) for slot in self.timeslots]
... | def merged(self, timeslots: 'TimeslotCollection') -> 'TimeslotCollection':
"""Return a new TimeslotCollection merged with a specified `timeslots`
Args:
timeslots: TimeslotCollection to be merged
"""
slots = [Timeslot(slot.interval, slot.channel) for slot in self.timeslots]
... | [
"Return",
"a",
"new",
"TimeslotCollection",
"merged",
"with",
"a",
"specified",
"timeslots"
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/pulse/timeslots.py#L223-L231 | [
"def",
"merged",
"(",
"self",
",",
"timeslots",
":",
"'TimeslotCollection'",
")",
"->",
"'TimeslotCollection'",
":",
"slots",
"=",
"[",
"Timeslot",
"(",
"slot",
".",
"interval",
",",
"slot",
".",
"channel",
")",
"for",
"slot",
"in",
"self",
".",
"timeslots... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | TimeslotCollection.shift | Return a new TimeslotCollection shifted by `time`.
Args:
time: time to be shifted by | qiskit/pulse/timeslots.py | def shift(self, time: int) -> 'TimeslotCollection':
"""Return a new TimeslotCollection shifted by `time`.
Args:
time: time to be shifted by
"""
slots = [Timeslot(slot.interval.shift(time), slot.channel) for slot in self.timeslots]
return TimeslotCollection(*slots) | def shift(self, time: int) -> 'TimeslotCollection':
"""Return a new TimeslotCollection shifted by `time`.
Args:
time: time to be shifted by
"""
slots = [Timeslot(slot.interval.shift(time), slot.channel) for slot in self.timeslots]
return TimeslotCollection(*slots) | [
"Return",
"a",
"new",
"TimeslotCollection",
"shifted",
"by",
"time",
"."
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/pulse/timeslots.py#L233-L240 | [
"def",
"shift",
"(",
"self",
",",
"time",
":",
"int",
")",
"->",
"'TimeslotCollection'",
":",
"slots",
"=",
"[",
"Timeslot",
"(",
"slot",
".",
"interval",
".",
"shift",
"(",
"time",
")",
",",
"slot",
".",
"channel",
")",
"for",
"slot",
"in",
"self",
... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | External.real | Return the correspond floating point number. | qiskit/qasm/node/external.py | def real(self, nested_scope=None):
"""Return the correspond floating point number."""
op = self.children[0].name
expr = self.children[1]
dispatch = {
'sin': sympy.sin,
'cos': sympy.cos,
'tan': sympy.tan,
'asin': sympy.asin,
'aco... | def real(self, nested_scope=None):
"""Return the correspond floating point number."""
op = self.children[0].name
expr = self.children[1]
dispatch = {
'sin': sympy.sin,
'cos': sympy.cos,
'tan': sympy.tan,
'asin': sympy.asin,
'aco... | [
"Return",
"the",
"correspond",
"floating",
"point",
"number",
"."
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/qasm/node/external.py#L39-L58 | [
"def",
"real",
"(",
"self",
",",
"nested_scope",
"=",
"None",
")",
":",
"op",
"=",
"self",
".",
"children",
"[",
"0",
"]",
".",
"name",
"expr",
"=",
"self",
".",
"children",
"[",
"1",
"]",
"dispatch",
"=",
"{",
"'sin'",
":",
"sympy",
".",
"sin",
... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | CIFailureReporter.report | Report on GitHub that the specified branch is failing to build at
the specified commit. The method will open an issue indicating that
the branch is failing. If there is an issue already open, it will add a
comment avoiding to report twice about the same failure.
Args:
branch... | tools/report_ci_failure.py | def report(self, branch, commit, infourl=None):
"""Report on GitHub that the specified branch is failing to build at
the specified commit. The method will open an issue indicating that
the branch is failing. If there is an issue already open, it will add a
comment avoiding to report twic... | def report(self, branch, commit, infourl=None):
"""Report on GitHub that the specified branch is failing to build at
the specified commit. The method will open an issue indicating that
the branch is failing. If there is an issue already open, it will add a
comment avoiding to report twic... | [
"Report",
"on",
"GitHub",
"that",
"the",
"specified",
"branch",
"is",
"failing",
"to",
"build",
"at",
"the",
"specified",
"commit",
".",
"The",
"method",
"will",
"open",
"an",
"issue",
"indicating",
"that",
"the",
"branch",
"is",
"failing",
".",
"If",
"the... | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/tools/report_ci_failure.py#L33-L49 | [
"def",
"report",
"(",
"self",
",",
"branch",
",",
"commit",
",",
"infourl",
"=",
"None",
")",
":",
"issue_number",
"=",
"self",
".",
"_get_report_issue_number",
"(",
")",
"if",
"issue_number",
":",
"self",
".",
"_report_as_comment",
"(",
"issue_number",
",",... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | process_data | Sort rho data | qiskit/visualization/interactive/iplot_paulivec.py | def process_data(rho):
""" Sort rho data """
result = dict()
num = int(np.log2(len(rho)))
labels = list(map(lambda x: x.to_label(), pauli_group(num)))
values = list(map(lambda x: np.real(np.trace(np.dot(x.to_matrix(), rho))),
pauli_group(num)))
for position, label in enum... | def process_data(rho):
""" Sort rho data """
result = dict()
num = int(np.log2(len(rho)))
labels = list(map(lambda x: x.to_label(), pauli_group(num)))
values = list(map(lambda x: np.real(np.trace(np.dot(x.to_matrix(), rho))),
pauli_group(num)))
for position, label in enum... | [
"Sort",
"rho",
"data"
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/visualization/interactive/iplot_paulivec.py#L25-L36 | [
"def",
"process_data",
"(",
"rho",
")",
":",
"result",
"=",
"dict",
"(",
")",
"num",
"=",
"int",
"(",
"np",
".",
"log2",
"(",
"len",
"(",
"rho",
")",
")",
")",
"labels",
"=",
"list",
"(",
"map",
"(",
"lambda",
"x",
":",
"x",
".",
"to_label",
... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | iplot_state_paulivec | Create a paulivec representation.
Graphical representation of the input array.
Args:
rho (array): State vector or density matrix.
figsize (tuple): Figure size in pixels.
slider (bool): activate slider
show_legend (bool): show legend of graph content | qiskit/visualization/interactive/iplot_paulivec.py | def iplot_state_paulivec(rho, figsize=None, slider=False, show_legend=False):
""" Create a paulivec representation.
Graphical representation of the input array.
Args:
rho (array): State vector or density matrix.
figsize (tuple): Figure size in pixels.
slider (bo... | def iplot_state_paulivec(rho, figsize=None, slider=False, show_legend=False):
""" Create a paulivec representation.
Graphical representation of the input array.
Args:
rho (array): State vector or density matrix.
figsize (tuple): Figure size in pixels.
slider (bo... | [
"Create",
"a",
"paulivec",
"representation",
"."
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/visualization/interactive/iplot_paulivec.py#L39-L103 | [
"def",
"iplot_state_paulivec",
"(",
"rho",
",",
"figsize",
"=",
"None",
",",
"slider",
"=",
"False",
",",
"show_legend",
"=",
"False",
")",
":",
"# HTML",
"html_template",
"=",
"Template",
"(",
"\"\"\"\n <p>\n <div id=\"paulivec_$divNumber\"></div>\n </p>\n... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | iplot_state | Plot the quantum state.
Args:
quantum_state (ndarray): statevector or density matrix
representation of a quantum state.
method (str): Plotting method to use.
figsize (tuple): Figure size in pixels.
Raises:
VisualizationError: if the input is not... | qiskit/visualization/interactive/iplot_state.py | def iplot_state(quantum_state, method='city', figsize=None):
"""Plot the quantum state.
Args:
quantum_state (ndarray): statevector or density matrix
representation of a quantum state.
method (str): Plotting method to use.
figsize (tuple): Figure size in ... | def iplot_state(quantum_state, method='city', figsize=None):
"""Plot the quantum state.
Args:
quantum_state (ndarray): statevector or density matrix
representation of a quantum state.
method (str): Plotting method to use.
figsize (tuple): Figure size in ... | [
"Plot",
"the",
"quantum",
"state",
"."
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/visualization/interactive/iplot_state.py#L21-L50 | [
"def",
"iplot_state",
"(",
"quantum_state",
",",
"method",
"=",
"'city'",
",",
"figsize",
"=",
"None",
")",
":",
"warnings",
".",
"warn",
"(",
"\"iplot_state is deprecated, and will be removed in \\\n the 0.9 release. Use the iplot_state_ * functions \\\n ... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | rzz | Apply RZZ to circuit. | qiskit/extensions/standard/rzz.py | def rzz(self, theta, qubit1, qubit2):
"""Apply RZZ to circuit."""
return self.append(RZZGate(theta), [qubit1, qubit2], []) | def rzz(self, theta, qubit1, qubit2):
"""Apply RZZ to circuit."""
return self.append(RZZGate(theta), [qubit1, qubit2], []) | [
"Apply",
"RZZ",
"to",
"circuit",
"."
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/extensions/standard/rzz.py#L49-L51 | [
"def",
"rzz",
"(",
"self",
",",
"theta",
",",
"qubit1",
",",
"qubit2",
")",
":",
"return",
"self",
".",
"append",
"(",
"RZZGate",
"(",
"theta",
")",
",",
"[",
"qubit1",
",",
"qubit2",
"]",
",",
"[",
"]",
")"
] | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | cswap | Apply Fredkin to circuit. | qiskit/extensions/standard/cswap.py | def cswap(self, ctl, tgt1, tgt2):
"""Apply Fredkin to circuit."""
return self.append(FredkinGate(), [ctl, tgt1, tgt2], []) | def cswap(self, ctl, tgt1, tgt2):
"""Apply Fredkin to circuit."""
return self.append(FredkinGate(), [ctl, tgt1, tgt2], []) | [
"Apply",
"Fredkin",
"to",
"circuit",
"."
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/extensions/standard/cswap.py#L53-L55 | [
"def",
"cswap",
"(",
"self",
",",
"ctl",
",",
"tgt1",
",",
"tgt2",
")",
":",
"return",
"self",
".",
"append",
"(",
"FredkinGate",
"(",
")",
",",
"[",
"ctl",
",",
"tgt1",
",",
"tgt2",
"]",
",",
"[",
"]",
")"
] | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | FredkinGate._define | gate cswap a,b,c
{ cx c,b;
ccx a,b,c;
cx c,b;
} | qiskit/extensions/standard/cswap.py | def _define(self):
"""
gate cswap a,b,c
{ cx c,b;
ccx a,b,c;
cx c,b;
}
"""
definition = []
q = QuantumRegister(3, "q")
rule = [
(CnotGate(), [q[2], q[1]], []),
(ToffoliGate(), [q[0], q[1], q[2]], []),
... | def _define(self):
"""
gate cswap a,b,c
{ cx c,b;
ccx a,b,c;
cx c,b;
}
"""
definition = []
q = QuantumRegister(3, "q")
rule = [
(CnotGate(), [q[2], q[1]], []),
(ToffoliGate(), [q[0], q[1], q[2]], []),
... | [
"gate",
"cswap",
"a",
"b",
"c",
"{",
"cx",
"c",
"b",
";",
"ccx",
"a",
"b",
"c",
";",
"cx",
"c",
"b",
";",
"}"
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/extensions/standard/cswap.py#L27-L44 | [
"def",
"_define",
"(",
"self",
")",
":",
"definition",
"=",
"[",
"]",
"q",
"=",
"QuantumRegister",
"(",
"3",
",",
"\"q\"",
")",
"rule",
"=",
"[",
"(",
"CnotGate",
"(",
")",
",",
"[",
"q",
"[",
"2",
"]",
",",
"q",
"[",
"1",
"]",
"]",
",",
"[... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | NoiseAdaptiveLayout._initialize_backend_prop | Extract readout and CNOT errors and compute swap costs. | qiskit/transpiler/passes/mapping/noise_adaptive_layout.py | def _initialize_backend_prop(self):
"""
Extract readout and CNOT errors and compute swap costs.
"""
backend_prop = self.backend_prop
for ginfo in backend_prop.gates:
if ginfo.gate == 'cx':
for item in ginfo.parameters:
if item.name ... | def _initialize_backend_prop(self):
"""
Extract readout and CNOT errors and compute swap costs.
"""
backend_prop = self.backend_prop
for ginfo in backend_prop.gates:
if ginfo.gate == 'cx':
for item in ginfo.parameters:
if item.name ... | [
"Extract",
"readout",
"and",
"CNOT",
"errors",
"and",
"compute",
"swap",
"costs",
"."
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/transpiler/passes/mapping/noise_adaptive_layout.py#L79-L125 | [
"def",
"_initialize_backend_prop",
"(",
"self",
")",
":",
"backend_prop",
"=",
"self",
".",
"backend_prop",
"for",
"ginfo",
"in",
"backend_prop",
".",
"gates",
":",
"if",
"ginfo",
".",
"gate",
"==",
"'cx'",
":",
"for",
"item",
"in",
"ginfo",
".",
"paramete... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | NoiseAdaptiveLayout._create_program_graph | Program graph has virtual qubits as nodes.
Two nodes have an edge if the corresponding virtual qubits
participate in a 2-qubit gate. The edge is weighted by the
number of CNOTs between the pair. | qiskit/transpiler/passes/mapping/noise_adaptive_layout.py | def _create_program_graph(self, dag):
"""
Program graph has virtual qubits as nodes.
Two nodes have an edge if the corresponding virtual qubits
participate in a 2-qubit gate. The edge is weighted by the
number of CNOTs between the pair.
"""
idx = 0
for q i... | def _create_program_graph(self, dag):
"""
Program graph has virtual qubits as nodes.
Two nodes have an edge if the corresponding virtual qubits
participate in a 2-qubit gate. The edge is weighted by the
number of CNOTs between the pair.
"""
idx = 0
for q i... | [
"Program",
"graph",
"has",
"virtual",
"qubits",
"as",
"nodes",
".",
"Two",
"nodes",
"have",
"an",
"edge",
"if",
"the",
"corresponding",
"virtual",
"qubits",
"participate",
"in",
"a",
"2",
"-",
"qubit",
"gate",
".",
"The",
"edge",
"is",
"weighted",
"by",
... | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/transpiler/passes/mapping/noise_adaptive_layout.py#L133-L153 | [
"def",
"_create_program_graph",
"(",
"self",
",",
"dag",
")",
":",
"idx",
"=",
"0",
"for",
"q",
"in",
"dag",
".",
"qubits",
"(",
")",
":",
"self",
".",
"qarg_to_id",
"[",
"q",
"[",
"0",
"]",
".",
"name",
"+",
"str",
"(",
"q",
"[",
"1",
"]",
"... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | NoiseAdaptiveLayout._select_next_edge | If there is an edge with one endpoint mapped, return it.
Else return in the first edge | qiskit/transpiler/passes/mapping/noise_adaptive_layout.py | def _select_next_edge(self):
"""
If there is an edge with one endpoint mapped, return it.
Else return in the first edge
"""
for edge in self.pending_program_edges:
q1_mapped = edge[0] in self.prog2hw
q2_mapped = edge[1] in self.prog2hw
assert n... | def _select_next_edge(self):
"""
If there is an edge with one endpoint mapped, return it.
Else return in the first edge
"""
for edge in self.pending_program_edges:
q1_mapped = edge[0] in self.prog2hw
q2_mapped = edge[1] in self.prog2hw
assert n... | [
"If",
"there",
"is",
"an",
"edge",
"with",
"one",
"endpoint",
"mapped",
"return",
"it",
".",
"Else",
"return",
"in",
"the",
"first",
"edge"
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/transpiler/passes/mapping/noise_adaptive_layout.py#L155-L166 | [
"def",
"_select_next_edge",
"(",
"self",
")",
":",
"for",
"edge",
"in",
"self",
".",
"pending_program_edges",
":",
"q1_mapped",
"=",
"edge",
"[",
"0",
"]",
"in",
"self",
".",
"prog2hw",
"q2_mapped",
"=",
"edge",
"[",
"1",
"]",
"in",
"self",
".",
"prog2... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | NoiseAdaptiveLayout._select_best_remaining_cx | Select best remaining CNOT in the hardware for the next program edge. | qiskit/transpiler/passes/mapping/noise_adaptive_layout.py | def _select_best_remaining_cx(self):
"""
Select best remaining CNOT in the hardware for the next program edge.
"""
candidates = []
for gate in self.gate_list:
chk1 = gate[0] in self.available_hw_qubits
chk2 = gate[1] in self.available_hw_qubits
... | def _select_best_remaining_cx(self):
"""
Select best remaining CNOT in the hardware for the next program edge.
"""
candidates = []
for gate in self.gate_list:
chk1 = gate[0] in self.available_hw_qubits
chk2 = gate[1] in self.available_hw_qubits
... | [
"Select",
"best",
"remaining",
"CNOT",
"in",
"the",
"hardware",
"for",
"the",
"next",
"program",
"edge",
"."
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/transpiler/passes/mapping/noise_adaptive_layout.py#L168-L184 | [
"def",
"_select_best_remaining_cx",
"(",
"self",
")",
":",
"candidates",
"=",
"[",
"]",
"for",
"gate",
"in",
"self",
".",
"gate_list",
":",
"chk1",
"=",
"gate",
"[",
"0",
"]",
"in",
"self",
".",
"available_hw_qubits",
"chk2",
"=",
"gate",
"[",
"1",
"]"... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | NoiseAdaptiveLayout._select_best_remaining_qubit | Select the best remaining hardware qubit for the next program qubit. | qiskit/transpiler/passes/mapping/noise_adaptive_layout.py | def _select_best_remaining_qubit(self, prog_qubit):
"""
Select the best remaining hardware qubit for the next program qubit.
"""
reliab_store = {}
for hw_qubit in self.available_hw_qubits:
reliab = 1
for n in self.prog_graph.neighbors(prog_qubit):
... | def _select_best_remaining_qubit(self, prog_qubit):
"""
Select the best remaining hardware qubit for the next program qubit.
"""
reliab_store = {}
for hw_qubit in self.available_hw_qubits:
reliab = 1
for n in self.prog_graph.neighbors(prog_qubit):
... | [
"Select",
"the",
"best",
"remaining",
"hardware",
"qubit",
"for",
"the",
"next",
"program",
"qubit",
"."
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/transpiler/passes/mapping/noise_adaptive_layout.py#L186-L204 | [
"def",
"_select_best_remaining_qubit",
"(",
"self",
",",
"prog_qubit",
")",
":",
"reliab_store",
"=",
"{",
"}",
"for",
"hw_qubit",
"in",
"self",
".",
"available_hw_qubits",
":",
"reliab",
"=",
"1",
"for",
"n",
"in",
"self",
".",
"prog_graph",
".",
"neighbors... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | NoiseAdaptiveLayout.run | Main run method for the noise adaptive layout. | qiskit/transpiler/passes/mapping/noise_adaptive_layout.py | def run(self, dag):
"""Main run method for the noise adaptive layout."""
self._initialize_backend_prop()
num_qubits = self._create_program_graph(dag)
if num_qubits > len(self.swap_graph):
raise TranspilerError('Number of qubits greater than device.')
for end1, end2, _... | def run(self, dag):
"""Main run method for the noise adaptive layout."""
self._initialize_backend_prop()
num_qubits = self._create_program_graph(dag)
if num_qubits > len(self.swap_graph):
raise TranspilerError('Number of qubits greater than device.')
for end1, end2, _... | [
"Main",
"run",
"method",
"for",
"the",
"noise",
"adaptive",
"layout",
"."
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/transpiler/passes/mapping/noise_adaptive_layout.py#L206-L245 | [
"def",
"run",
"(",
"self",
",",
"dag",
")",
":",
"self",
".",
"_initialize_backend_prop",
"(",
")",
"num_qubits",
"=",
"self",
".",
"_create_program_graph",
"(",
"dag",
")",
"if",
"num_qubits",
">",
"len",
"(",
"self",
".",
"swap_graph",
")",
":",
"raise... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | CompositeGate.instruction_list | Return a list of instructions for this CompositeGate.
If the CompositeGate itself contains composites, call
this method recursively. | qiskit/circuit/compositegate.py | def instruction_list(self):
"""Return a list of instructions for this CompositeGate.
If the CompositeGate itself contains composites, call
this method recursively.
"""
instruction_list = []
for instruction in self.data:
if isinstance(instruction, CompositeGat... | def instruction_list(self):
"""Return a list of instructions for this CompositeGate.
If the CompositeGate itself contains composites, call
this method recursively.
"""
instruction_list = []
for instruction in self.data:
if isinstance(instruction, CompositeGat... | [
"Return",
"a",
"list",
"of",
"instructions",
"for",
"this",
"CompositeGate",
"."
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/circuit/compositegate.py#L34-L46 | [
"def",
"instruction_list",
"(",
"self",
")",
":",
"instruction_list",
"=",
"[",
"]",
"for",
"instruction",
"in",
"self",
".",
"data",
":",
"if",
"isinstance",
"(",
"instruction",
",",
"CompositeGate",
")",
":",
"instruction_list",
".",
"extend",
"(",
"instru... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | CompositeGate.inverse | Invert this gate. | qiskit/circuit/compositegate.py | def inverse(self):
"""Invert this gate."""
self.data = [gate.inverse() for gate in reversed(self.data)]
self.inverse_flag = not self.inverse_flag
return self | def inverse(self):
"""Invert this gate."""
self.data = [gate.inverse() for gate in reversed(self.data)]
self.inverse_flag = not self.inverse_flag
return self | [
"Invert",
"this",
"gate",
"."
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/circuit/compositegate.py#L70-L74 | [
"def",
"inverse",
"(",
"self",
")",
":",
"self",
".",
"data",
"=",
"[",
"gate",
".",
"inverse",
"(",
")",
"for",
"gate",
"in",
"reversed",
"(",
"self",
".",
"data",
")",
"]",
"self",
".",
"inverse_flag",
"=",
"not",
"self",
".",
"inverse_flag",
"re... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | CompositeGate.q_if | Add controls to this gate. | qiskit/circuit/compositegate.py | def q_if(self, *qregs):
"""Add controls to this gate."""
self.data = [gate.q_if(qregs) for gate in self.data]
return self | def q_if(self, *qregs):
"""Add controls to this gate."""
self.data = [gate.q_if(qregs) for gate in self.data]
return self | [
"Add",
"controls",
"to",
"this",
"gate",
"."
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/circuit/compositegate.py#L76-L79 | [
"def",
"q_if",
"(",
"self",
",",
"*",
"qregs",
")",
":",
"self",
".",
"data",
"=",
"[",
"gate",
".",
"q_if",
"(",
"qregs",
")",
"for",
"gate",
"in",
"self",
".",
"data",
"]",
"return",
"self"
] | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | CompositeGate.c_if | Add classical control register. | qiskit/circuit/compositegate.py | def c_if(self, classical, val):
"""Add classical control register."""
self.data = [gate.c_if(classical, val) for gate in self.data]
return self | def c_if(self, classical, val):
"""Add classical control register."""
self.data = [gate.c_if(classical, val) for gate in self.data]
return self | [
"Add",
"classical",
"control",
"register",
"."
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/circuit/compositegate.py#L81-L84 | [
"def",
"c_if",
"(",
"self",
",",
"classical",
",",
"val",
")",
":",
"self",
".",
"data",
"=",
"[",
"gate",
".",
"c_if",
"(",
"classical",
",",
"val",
")",
"for",
"gate",
"in",
"self",
".",
"data",
"]",
"return",
"self"
] | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | Operator.is_unitary | Return True if operator is a unitary matrix. | qiskit/quantum_info/operators/operator.py | def is_unitary(self, atol=None, rtol=None):
"""Return True if operator is a unitary matrix."""
if atol is None:
atol = self._atol
if rtol is None:
rtol = self._rtol
return is_unitary_matrix(self._data, rtol=rtol, atol=atol) | def is_unitary(self, atol=None, rtol=None):
"""Return True if operator is a unitary matrix."""
if atol is None:
atol = self._atol
if rtol is None:
rtol = self._rtol
return is_unitary_matrix(self._data, rtol=rtol, atol=atol) | [
"Return",
"True",
"if",
"operator",
"is",
"a",
"unitary",
"matrix",
"."
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/quantum_info/operators/operator.py#L89-L95 | [
"def",
"is_unitary",
"(",
"self",
",",
"atol",
"=",
"None",
",",
"rtol",
"=",
"None",
")",
":",
"if",
"atol",
"is",
"None",
":",
"atol",
"=",
"self",
".",
"_atol",
"if",
"rtol",
"is",
"None",
":",
"rtol",
"=",
"self",
".",
"_rtol",
"return",
"is_... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | Operator.conjugate | Return the conjugate of the operator. | qiskit/quantum_info/operators/operator.py | def conjugate(self):
"""Return the conjugate of the operator."""
return Operator(
np.conj(self.data), self.input_dims(), self.output_dims()) | def conjugate(self):
"""Return the conjugate of the operator."""
return Operator(
np.conj(self.data), self.input_dims(), self.output_dims()) | [
"Return",
"the",
"conjugate",
"of",
"the",
"operator",
"."
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/quantum_info/operators/operator.py#L106-L109 | [
"def",
"conjugate",
"(",
"self",
")",
":",
"return",
"Operator",
"(",
"np",
".",
"conj",
"(",
"self",
".",
"data",
")",
",",
"self",
".",
"input_dims",
"(",
")",
",",
"self",
".",
"output_dims",
"(",
")",
")"
] | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | Operator.transpose | Return the transpose of the operator. | qiskit/quantum_info/operators/operator.py | def transpose(self):
"""Return the transpose of the operator."""
return Operator(
np.transpose(self.data), self.input_dims(), self.output_dims()) | def transpose(self):
"""Return the transpose of the operator."""
return Operator(
np.transpose(self.data), self.input_dims(), self.output_dims()) | [
"Return",
"the",
"transpose",
"of",
"the",
"operator",
"."
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/quantum_info/operators/operator.py#L111-L114 | [
"def",
"transpose",
"(",
"self",
")",
":",
"return",
"Operator",
"(",
"np",
".",
"transpose",
"(",
"self",
".",
"data",
")",
",",
"self",
".",
"input_dims",
"(",
")",
",",
"self",
".",
"output_dims",
"(",
")",
")"
] | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | Operator.power | Return the matrix power of the operator.
Args:
n (int): the power to raise the matrix to.
Returns:
BaseOperator: the n-times composed operator.
Raises:
QiskitError: if the input and output dimensions of the operator
are not equal, or the power i... | qiskit/quantum_info/operators/operator.py | def power(self, n):
"""Return the matrix power of the operator.
Args:
n (int): the power to raise the matrix to.
Returns:
BaseOperator: the n-times composed operator.
Raises:
QiskitError: if the input and output dimensions of the operator
... | def power(self, n):
"""Return the matrix power of the operator.
Args:
n (int): the power to raise the matrix to.
Returns:
BaseOperator: the n-times composed operator.
Raises:
QiskitError: if the input and output dimensions of the operator
... | [
"Return",
"the",
"matrix",
"power",
"of",
"the",
"operator",
"."
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/quantum_info/operators/operator.py#L159-L180 | [
"def",
"power",
"(",
"self",
",",
"n",
")",
":",
"if",
"not",
"isinstance",
"(",
"n",
",",
"int",
")",
":",
"raise",
"QiskitError",
"(",
"\"Can only take integer powers of Operator.\"",
")",
"if",
"self",
".",
"input_dims",
"(",
")",
"!=",
"self",
".",
"... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | Operator.add | Return the operator self + other.
Args:
other (Operator): an operator object.
Returns:
Operator: the operator self + other.
Raises:
QiskitError: if other is not an operator, or has incompatible
dimensions. | qiskit/quantum_info/operators/operator.py | def add(self, other):
"""Return the operator self + other.
Args:
other (Operator): an operator object.
Returns:
Operator: the operator self + other.
Raises:
QiskitError: if other is not an operator, or has incompatible
dimensions.
... | def add(self, other):
"""Return the operator self + other.
Args:
other (Operator): an operator object.
Returns:
Operator: the operator self + other.
Raises:
QiskitError: if other is not an operator, or has incompatible
dimensions.
... | [
"Return",
"the",
"operator",
"self",
"+",
"other",
"."
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/quantum_info/operators/operator.py#L210-L228 | [
"def",
"add",
"(",
"self",
",",
"other",
")",
":",
"if",
"not",
"isinstance",
"(",
"other",
",",
"Operator",
")",
":",
"other",
"=",
"Operator",
"(",
"other",
")",
"if",
"self",
".",
"dim",
"!=",
"other",
".",
"dim",
":",
"raise",
"QiskitError",
"(... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | Operator.multiply | Return the operator self + other.
Args:
other (complex): a complex number.
Returns:
Operator: the operator other * self.
Raises:
QiskitError: if other is not a valid complex number. | qiskit/quantum_info/operators/operator.py | def multiply(self, other):
"""Return the operator self + other.
Args:
other (complex): a complex number.
Returns:
Operator: the operator other * self.
Raises:
QiskitError: if other is not a valid complex number.
"""
if not isinstance... | def multiply(self, other):
"""Return the operator self + other.
Args:
other (complex): a complex number.
Returns:
Operator: the operator other * self.
Raises:
QiskitError: if other is not a valid complex number.
"""
if not isinstance... | [
"Return",
"the",
"operator",
"self",
"+",
"other",
"."
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/quantum_info/operators/operator.py#L250-L265 | [
"def",
"multiply",
"(",
"self",
",",
"other",
")",
":",
"if",
"not",
"isinstance",
"(",
"other",
",",
"Number",
")",
":",
"raise",
"QiskitError",
"(",
"\"other is not a number\"",
")",
"return",
"Operator",
"(",
"other",
"*",
"self",
".",
"data",
",",
"s... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | Operator._shape | Return the tensor shape of the matrix operator | qiskit/quantum_info/operators/operator.py | def _shape(self):
"""Return the tensor shape of the matrix operator"""
return tuple(reversed(self.output_dims())) + tuple(
reversed(self.input_dims())) | def _shape(self):
"""Return the tensor shape of the matrix operator"""
return tuple(reversed(self.output_dims())) + tuple(
reversed(self.input_dims())) | [
"Return",
"the",
"tensor",
"shape",
"of",
"the",
"matrix",
"operator"
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/quantum_info/operators/operator.py#L268-L271 | [
"def",
"_shape",
"(",
"self",
")",
":",
"return",
"tuple",
"(",
"reversed",
"(",
"self",
".",
"output_dims",
"(",
")",
")",
")",
"+",
"tuple",
"(",
"reversed",
"(",
"self",
".",
"input_dims",
"(",
")",
")",
")"
] | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | Operator._evolve | Evolve a quantum state by the operator.
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 state... | qiskit/quantum_info/operators/operator.py | def _evolve(self, state, qargs=None):
"""Evolve a quantum state by the operator.
Args:
state (QuantumState): The input statevector or density matrix.
qargs (list): a list of QuantumState subsystem positions to apply
the operator on.
Returns:
... | def _evolve(self, state, qargs=None):
"""Evolve a quantum state by the operator.
Args:
state (QuantumState): The input statevector or density matrix.
qargs (list): a list of QuantumState subsystem positions to apply
the operator on.
Returns:
... | [
"Evolve",
"a",
"quantum",
"state",
"by",
"the",
"operator",
"."
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/quantum_info/operators/operator.py#L273-L301 | [
"def",
"_evolve",
"(",
"self",
",",
"state",
",",
"qargs",
"=",
"None",
")",
":",
"state",
"=",
"self",
".",
"_format_state",
"(",
"state",
")",
"if",
"qargs",
"is",
"None",
":",
"if",
"state",
".",
"shape",
"[",
"0",
"]",
"!=",
"self",
".",
"_in... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | Operator._evolve_subsystem | Evolve a quantum state by the operator.
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 state... | qiskit/quantum_info/operators/operator.py | def _evolve_subsystem(self, state, qargs):
"""Evolve a quantum state by the operator.
Args:
state (QuantumState): The input statevector or density matrix.
qargs (list): a list of QuantumState subsystem positions to apply
the operator on.
Retur... | def _evolve_subsystem(self, state, qargs):
"""Evolve a quantum state by the operator.
Args:
state (QuantumState): The input statevector or density matrix.
qargs (list): a list of QuantumState subsystem positions to apply
the operator on.
Retur... | [
"Evolve",
"a",
"quantum",
"state",
"by",
"the",
"operator",
"."
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/quantum_info/operators/operator.py#L359-L400 | [
"def",
"_evolve_subsystem",
"(",
"self",
",",
"state",
",",
"qargs",
")",
":",
"mat",
"=",
"np",
".",
"reshape",
"(",
"self",
".",
"data",
",",
"self",
".",
"_shape",
")",
"# Hack to assume state is a N-qubit state until a proper class for states",
"# is in place",
... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | Operator._format_state | Format input state so it is statevector or density matrix | qiskit/quantum_info/operators/operator.py | def _format_state(self, state):
"""Format input state so it is statevector or density matrix"""
state = np.array(state)
shape = state.shape
ndim = state.ndim
if ndim > 2:
raise QiskitError('Input state is not a vector or matrix.')
# Flatten column-vector to ve... | def _format_state(self, state):
"""Format input state so it is statevector or density matrix"""
state = np.array(state)
shape = state.shape
ndim = state.ndim
if ndim > 2:
raise QiskitError('Input state is not a vector or matrix.')
# Flatten column-vector to ve... | [
"Format",
"input",
"state",
"so",
"it",
"is",
"statevector",
"or",
"density",
"matrix"
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/quantum_info/operators/operator.py#L402-L416 | [
"def",
"_format_state",
"(",
"self",
",",
"state",
")",
":",
"state",
"=",
"np",
".",
"array",
"(",
"state",
")",
"shape",
"=",
"state",
".",
"shape",
"ndim",
"=",
"state",
".",
"ndim",
"if",
"ndim",
">",
"2",
":",
"raise",
"QiskitError",
"(",
"'In... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | Operator._instruction_to_operator | Convert a QuantumCircuit or Instruction to an Operator. | qiskit/quantum_info/operators/operator.py | def _instruction_to_operator(cls, instruction):
"""Convert a QuantumCircuit or Instruction to an Operator."""
# Convert circuit to an instruction
if isinstance(instruction, QuantumCircuit):
instruction = instruction.to_instruction()
# Initialize an identity operator of the co... | def _instruction_to_operator(cls, instruction):
"""Convert a QuantumCircuit or Instruction to an Operator."""
# Convert circuit to an instruction
if isinstance(instruction, QuantumCircuit):
instruction = instruction.to_instruction()
# Initialize an identity operator of the co... | [
"Convert",
"a",
"QuantumCircuit",
"or",
"Instruction",
"to",
"an",
"Operator",
"."
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/quantum_info/operators/operator.py#L419-L427 | [
"def",
"_instruction_to_operator",
"(",
"cls",
",",
"instruction",
")",
":",
"# Convert circuit to an instruction",
"if",
"isinstance",
"(",
"instruction",
",",
"QuantumCircuit",
")",
":",
"instruction",
"=",
"instruction",
".",
"to_instruction",
"(",
")",
"# Initiali... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | Operator._append_instruction | Update the current Operator by apply an instruction. | qiskit/quantum_info/operators/operator.py | def _append_instruction(self, obj, qargs=None):
"""Update the current Operator by apply an instruction."""
if isinstance(obj, Instruction):
mat = None
if hasattr(obj, 'to_matrix'):
# If instruction is a gate first we see if it has a
# `to_matrix` d... | def _append_instruction(self, obj, qargs=None):
"""Update the current Operator by apply an instruction."""
if isinstance(obj, Instruction):
mat = None
if hasattr(obj, 'to_matrix'):
# If instruction is a gate first we see if it has a
# `to_matrix` d... | [
"Update",
"the",
"current",
"Operator",
"by",
"apply",
"an",
"instruction",
"."
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/quantum_info/operators/operator.py#L429-L460 | [
"def",
"_append_instruction",
"(",
"self",
",",
"obj",
",",
"qargs",
"=",
"None",
")",
":",
"if",
"isinstance",
"(",
"obj",
",",
"Instruction",
")",
":",
"mat",
"=",
"None",
"if",
"hasattr",
"(",
"obj",
",",
"'to_matrix'",
")",
":",
"# If instruction is ... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | LegacySwap.run | Map a DAGCircuit onto a CouplingGraph using swap gates.
Args:
dag (DAGCircuit): input DAG circuit
Returns:
DAGCircuit: object containing a circuit equivalent to
circuit_graph that respects couplings in coupling_map, and
a layout dict mapping qubits of ci... | qiskit/transpiler/passes/mapping/legacy_swap.py | def run(self, dag):
"""Map a DAGCircuit onto a CouplingGraph using swap gates.
Args:
dag (DAGCircuit): input DAG circuit
Returns:
DAGCircuit: object containing a circuit equivalent to
circuit_graph that respects couplings in coupling_map, and
a l... | def run(self, dag):
"""Map a DAGCircuit onto a CouplingGraph using swap gates.
Args:
dag (DAGCircuit): input DAG circuit
Returns:
DAGCircuit: object containing a circuit equivalent to
circuit_graph that respects couplings in coupling_map, and
a l... | [
"Map",
"a",
"DAGCircuit",
"onto",
"a",
"CouplingGraph",
"using",
"swap",
"gates",
"."
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/transpiler/passes/mapping/legacy_swap.py#L53-L204 | [
"def",
"run",
"(",
"self",
",",
"dag",
")",
":",
"if",
"dag",
".",
"width",
"(",
")",
">",
"self",
".",
"coupling_map",
".",
"size",
"(",
")",
":",
"raise",
"TranspilerError",
"(",
"\"Not enough qubits in CouplingGraph\"",
")",
"# Schedule the input circuit",
... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | LegacySwap.layer_permutation | Find a swap circuit that implements a permutation for this layer.
The goal is to swap qubits such that qubits in the same two-qubit gates
are adjacent.
Based on Sergey Bravyi's algorithm.
The layer_partition is a list of (qu)bit lists and each qubit is a
tuple (qreg, index).
... | qiskit/transpiler/passes/mapping/legacy_swap.py | def layer_permutation(self, layer_partition, layout, qubit_subset):
"""Find a swap circuit that implements a permutation for this layer.
The goal is to swap qubits such that qubits in the same two-qubit gates
are adjacent.
Based on Sergey Bravyi's algorithm.
The layer_partitio... | def layer_permutation(self, layer_partition, layout, qubit_subset):
"""Find a swap circuit that implements a permutation for this layer.
The goal is to swap qubits such that qubits in the same two-qubit gates
are adjacent.
Based on Sergey Bravyi's algorithm.
The layer_partitio... | [
"Find",
"a",
"swap",
"circuit",
"that",
"implements",
"a",
"permutation",
"for",
"this",
"layer",
"."
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/transpiler/passes/mapping/legacy_swap.py#L206-L355 | [
"def",
"layer_permutation",
"(",
"self",
",",
"layer_partition",
",",
"layout",
",",
"qubit_subset",
")",
":",
"if",
"self",
".",
"seed",
"is",
"None",
":",
"self",
".",
"seed",
"=",
"np",
".",
"random",
".",
"randint",
"(",
"0",
",",
"np",
".",
"iin... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | LegacySwap.swap_mapper_layer_update | Update the QASM string for an iteration of swap_mapper.
i = layer number
first_layer = True if this is the first layer with multi-qubit gates
best_layout = layout returned from swap algorithm
best_d = depth returned from swap algorithm
best_circ = swap circuit returned from swap... | qiskit/transpiler/passes/mapping/legacy_swap.py | def swap_mapper_layer_update(self, i, first_layer, best_layout, best_d,
best_circ, layer_list):
"""Update the QASM string for an iteration of swap_mapper.
i = layer number
first_layer = True if this is the first layer with multi-qubit gates
best_layout =... | def swap_mapper_layer_update(self, i, first_layer, best_layout, best_d,
best_circ, layer_list):
"""Update the QASM string for an iteration of swap_mapper.
i = layer number
first_layer = True if this is the first layer with multi-qubit gates
best_layout =... | [
"Update",
"the",
"QASM",
"string",
"for",
"an",
"iteration",
"of",
"swap_mapper",
"."
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/transpiler/passes/mapping/legacy_swap.py#L357-L392 | [
"def",
"swap_mapper_layer_update",
"(",
"self",
",",
"i",
",",
"first_layer",
",",
"best_layout",
",",
"best_d",
",",
"best_circ",
",",
"layer_list",
")",
":",
"layout",
"=",
"best_layout",
"dagcircuit_output",
"=",
"DAGCircuit",
"(",
")",
"QR",
"=",
"QuantumR... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | Prefix.real | Return the correspond floating point number. | qiskit/qasm/node/prefix.py | def real(self, nested_scope=None):
"""Return the correspond floating point number."""
operation = self.children[0].operation()
expr = self.children[1].real(nested_scope)
return operation(expr) | def real(self, nested_scope=None):
"""Return the correspond floating point number."""
operation = self.children[0].operation()
expr = self.children[1].real(nested_scope)
return operation(expr) | [
"Return",
"the",
"correspond",
"floating",
"point",
"number",
"."
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/qasm/node/prefix.py#L36-L40 | [
"def",
"real",
"(",
"self",
",",
"nested_scope",
"=",
"None",
")",
":",
"operation",
"=",
"self",
".",
"children",
"[",
"0",
"]",
".",
"operation",
"(",
")",
"expr",
"=",
"self",
".",
"children",
"[",
"1",
"]",
".",
"real",
"(",
"nested_scope",
")"... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | Prefix.sym | Return the correspond symbolic number. | qiskit/qasm/node/prefix.py | def sym(self, nested_scope=None):
"""Return the correspond symbolic number."""
operation = self.children[0].operation()
expr = self.children[1].sym(nested_scope)
return operation(expr) | def sym(self, nested_scope=None):
"""Return the correspond symbolic number."""
operation = self.children[0].operation()
expr = self.children[1].sym(nested_scope)
return operation(expr) | [
"Return",
"the",
"correspond",
"symbolic",
"number",
"."
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/qasm/node/prefix.py#L42-L46 | [
"def",
"sym",
"(",
"self",
",",
"nested_scope",
"=",
"None",
")",
":",
"operation",
"=",
"self",
".",
"children",
"[",
"0",
"]",
".",
"operation",
"(",
")",
"expr",
"=",
"self",
".",
"children",
"[",
"1",
"]",
".",
"sym",
"(",
"nested_scope",
")",
... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | _separate_bitstring | Separate a bitstring according to the registers defined in the result header. | qiskit/result/postprocess.py | def _separate_bitstring(bitstring, creg_sizes):
"""Separate a bitstring according to the registers defined in the result header."""
substrings = []
running_index = 0
for _, size in reversed(creg_sizes):
substrings.append(bitstring[running_index: running_index + size])
running_index += si... | def _separate_bitstring(bitstring, creg_sizes):
"""Separate a bitstring according to the registers defined in the result header."""
substrings = []
running_index = 0
for _, size in reversed(creg_sizes):
substrings.append(bitstring[running_index: running_index + size])
running_index += si... | [
"Separate",
"a",
"bitstring",
"according",
"to",
"the",
"registers",
"defined",
"in",
"the",
"result",
"header",
"."
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/result/postprocess.py#L26-L33 | [
"def",
"_separate_bitstring",
"(",
"bitstring",
",",
"creg_sizes",
")",
":",
"substrings",
"=",
"[",
"]",
"running_index",
"=",
"0",
"for",
"_",
",",
"size",
"in",
"reversed",
"(",
"creg_sizes",
")",
":",
"substrings",
".",
"append",
"(",
"bitstring",
"[",... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | format_counts_memory | Format a single bitstring (memory) from a single shot experiment.
- The hexadecimals are expanded to bitstrings
- Spaces are inserted at register divisions.
Args:
shot_memory (str): result of a single experiment.
header (dict): the experiment header dictionary containing
usefu... | qiskit/result/postprocess.py | def format_counts_memory(shot_memory, header=None):
"""
Format a single bitstring (memory) from a single shot experiment.
- The hexadecimals are expanded to bitstrings
- Spaces are inserted at register divisions.
Args:
shot_memory (str): result of a single experiment.
header (dict... | def format_counts_memory(shot_memory, header=None):
"""
Format a single bitstring (memory) from a single shot experiment.
- The hexadecimals are expanded to bitstrings
- Spaces are inserted at register divisions.
Args:
shot_memory (str): result of a single experiment.
header (dict... | [
"Format",
"a",
"single",
"bitstring",
"(",
"memory",
")",
"from",
"a",
"single",
"shot",
"experiment",
"."
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/result/postprocess.py#L36-L64 | [
"def",
"format_counts_memory",
"(",
"shot_memory",
",",
"header",
"=",
"None",
")",
":",
"if",
"shot_memory",
".",
"startswith",
"(",
"'0x'",
")",
":",
"shot_memory",
"=",
"_hex_to_bin",
"(",
"shot_memory",
")",
"if",
"header",
":",
"creg_sizes",
"=",
"heade... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | _list_to_complex_array | Convert nested list of shape (..., 2) to complex numpy array with shape (...)
Args:
complex_list (list): List to convert.
Returns:
np.ndarray: Complex numpy aray
Raises:
QiskitError: If inner most array of input nested list is not of length 2. | qiskit/result/postprocess.py | def _list_to_complex_array(complex_list):
"""Convert nested list of shape (..., 2) to complex numpy array with shape (...)
Args:
complex_list (list): List to convert.
Returns:
np.ndarray: Complex numpy aray
Raises:
QiskitError: If inner most array of input nested list is not o... | def _list_to_complex_array(complex_list):
"""Convert nested list of shape (..., 2) to complex numpy array with shape (...)
Args:
complex_list (list): List to convert.
Returns:
np.ndarray: Complex numpy aray
Raises:
QiskitError: If inner most array of input nested list is not o... | [
"Convert",
"nested",
"list",
"of",
"shape",
"(",
"...",
"2",
")",
"to",
"complex",
"numpy",
"array",
"with",
"shape",
"(",
"...",
")"
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/result/postprocess.py#L67-L83 | [
"def",
"_list_to_complex_array",
"(",
"complex_list",
")",
":",
"arr",
"=",
"np",
".",
"asarray",
"(",
"complex_list",
",",
"dtype",
"=",
"np",
".",
"complex_",
")",
"if",
"not",
"arr",
".",
"shape",
"[",
"-",
"1",
"]",
"==",
"2",
":",
"raise",
"Qisk... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | format_level_0_memory | Format an experiment result memory object for measurement level 0.
Args:
memory (list): Memory from experiment with `meas_level==1`. `avg` or
`single` will be inferred from shape of result memory.
Returns:
np.ndarray: Measurement level 0 complex numpy array
Raises:
Qis... | qiskit/result/postprocess.py | def format_level_0_memory(memory):
""" Format an experiment result memory object for measurement level 0.
Args:
memory (list): Memory from experiment with `meas_level==1`. `avg` or
`single` will be inferred from shape of result memory.
Returns:
np.ndarray: Measurement level 0 c... | def format_level_0_memory(memory):
""" Format an experiment result memory object for measurement level 0.
Args:
memory (list): Memory from experiment with `meas_level==1`. `avg` or
`single` will be inferred from shape of result memory.
Returns:
np.ndarray: Measurement level 0 c... | [
"Format",
"an",
"experiment",
"result",
"memory",
"object",
"for",
"measurement",
"level",
"0",
"."
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/result/postprocess.py#L86-L104 | [
"def",
"format_level_0_memory",
"(",
"memory",
")",
":",
"formatted_memory",
"=",
"_list_to_complex_array",
"(",
"memory",
")",
"# infer meas_return from shape of returned data.",
"if",
"not",
"2",
"<=",
"len",
"(",
"formatted_memory",
".",
"shape",
")",
"<=",
"3",
... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | format_level_1_memory | Format an experiment result memory object for measurement level 1.
Args:
memory (list): Memory from experiment with `meas_level==1`. `avg` or
`single` will be inferred from shape of result memory.
Returns:
np.ndarray: Measurement level 1 complex numpy array
Raises:
Qis... | qiskit/result/postprocess.py | def format_level_1_memory(memory):
""" Format an experiment result memory object for measurement level 1.
Args:
memory (list): Memory from experiment with `meas_level==1`. `avg` or
`single` will be inferred from shape of result memory.
Returns:
np.ndarray: Measurement level 1 c... | def format_level_1_memory(memory):
""" Format an experiment result memory object for measurement level 1.
Args:
memory (list): Memory from experiment with `meas_level==1`. `avg` or
`single` will be inferred from shape of result memory.
Returns:
np.ndarray: Measurement level 1 c... | [
"Format",
"an",
"experiment",
"result",
"memory",
"object",
"for",
"measurement",
"level",
"1",
"."
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/result/postprocess.py#L107-L125 | [
"def",
"format_level_1_memory",
"(",
"memory",
")",
":",
"formatted_memory",
"=",
"_list_to_complex_array",
"(",
"memory",
")",
"# infer meas_return from shape of returned data.",
"if",
"not",
"1",
"<=",
"len",
"(",
"formatted_memory",
".",
"shape",
")",
"<=",
"2",
... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | format_level_2_memory | Format an experiment result memory object for measurement level 2.
Args:
memory (list): Memory from experiment with `meas_level==2` and `memory==True`.
header (dict): the experiment header dictionary containing
useful information for postprocessing.
Returns:
list[str]: List... | qiskit/result/postprocess.py | def format_level_2_memory(memory, header=None):
""" Format an experiment result memory object for measurement level 2.
Args:
memory (list): Memory from experiment with `meas_level==2` and `memory==True`.
header (dict): the experiment header dictionary containing
useful information f... | def format_level_2_memory(memory, header=None):
""" Format an experiment result memory object for measurement level 2.
Args:
memory (list): Memory from experiment with `meas_level==2` and `memory==True`.
header (dict): the experiment header dictionary containing
useful information f... | [
"Format",
"an",
"experiment",
"result",
"memory",
"object",
"for",
"measurement",
"level",
"2",
"."
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/result/postprocess.py#L128-L142 | [
"def",
"format_level_2_memory",
"(",
"memory",
",",
"header",
"=",
"None",
")",
":",
"memory_list",
"=",
"[",
"]",
"for",
"shot_memory",
"in",
"memory",
":",
"memory_list",
".",
"append",
"(",
"format_counts_memory",
"(",
"shot_memory",
",",
"header",
")",
"... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | format_counts | Format a single experiment result coming from backend to present
to the Qiskit user.
Args:
counts (dict): counts histogram of multiple shots
header (dict): the experiment header dictionary containing
useful information for postprocessing.
Returns:
dict: a formatted coun... | qiskit/result/postprocess.py | def format_counts(counts, header=None):
"""Format a single experiment result coming from backend to present
to the Qiskit user.
Args:
counts (dict): counts histogram of multiple shots
header (dict): the experiment header dictionary containing
useful information for postprocessin... | def format_counts(counts, header=None):
"""Format a single experiment result coming from backend to present
to the Qiskit user.
Args:
counts (dict): counts histogram of multiple shots
header (dict): the experiment header dictionary containing
useful information for postprocessin... | [
"Format",
"a",
"single",
"experiment",
"result",
"coming",
"from",
"backend",
"to",
"present",
"to",
"the",
"Qiskit",
"user",
"."
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/result/postprocess.py#L145-L161 | [
"def",
"format_counts",
"(",
"counts",
",",
"header",
"=",
"None",
")",
":",
"counts_dict",
"=",
"{",
"}",
"for",
"key",
",",
"val",
"in",
"counts",
".",
"items",
"(",
")",
":",
"key",
"=",
"format_counts_memory",
"(",
"key",
",",
"header",
")",
"cou... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | format_statevector | Format statevector coming from the backend to present to the Qiskit user.
Args:
vec (list): a list of [re, im] complex numbers.
decimals (int): the number of decimals in the statevector.
If None, no rounding is done.
Returns:
list[complex]: a list of python complex numbers. | qiskit/result/postprocess.py | def format_statevector(vec, decimals=None):
"""Format statevector coming from the backend to present to the Qiskit user.
Args:
vec (list): a list of [re, im] complex numbers.
decimals (int): the number of decimals in the statevector.
If None, no rounding is done.
Returns:
... | def format_statevector(vec, decimals=None):
"""Format statevector coming from the backend to present to the Qiskit user.
Args:
vec (list): a list of [re, im] complex numbers.
decimals (int): the number of decimals in the statevector.
If None, no rounding is done.
Returns:
... | [
"Format",
"statevector",
"coming",
"from",
"the",
"backend",
"to",
"present",
"to",
"the",
"Qiskit",
"user",
"."
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/result/postprocess.py#L164-L181 | [
"def",
"format_statevector",
"(",
"vec",
",",
"decimals",
"=",
"None",
")",
":",
"num_basis",
"=",
"len",
"(",
"vec",
")",
"vec_complex",
"=",
"np",
".",
"zeros",
"(",
"num_basis",
",",
"dtype",
"=",
"complex",
")",
"for",
"i",
"in",
"range",
"(",
"n... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | format_unitary | Format unitary coming from the backend to present to the Qiskit user.
Args:
mat (list[list]): a list of list of [re, im] complex numbers
decimals (int): the number of decimals in the statevector.
If None, no rounding is done.
Returns:
list[list[complex]]: a matrix of comple... | qiskit/result/postprocess.py | def format_unitary(mat, decimals=None):
"""Format unitary coming from the backend to present to the Qiskit user.
Args:
mat (list[list]): a list of list of [re, im] complex numbers
decimals (int): the number of decimals in the statevector.
If None, no rounding is done.
Returns:
... | def format_unitary(mat, decimals=None):
"""Format unitary coming from the backend to present to the Qiskit user.
Args:
mat (list[list]): a list of list of [re, im] complex numbers
decimals (int): the number of decimals in the statevector.
If None, no rounding is done.
Returns:
... | [
"Format",
"unitary",
"coming",
"from",
"the",
"backend",
"to",
"present",
"to",
"the",
"Qiskit",
"user",
"."
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/result/postprocess.py#L184-L199 | [
"def",
"format_unitary",
"(",
"mat",
",",
"decimals",
"=",
"None",
")",
":",
"num_basis",
"=",
"len",
"(",
"mat",
")",
"mat_complex",
"=",
"np",
".",
"zeros",
"(",
"(",
"num_basis",
",",
"num_basis",
")",
",",
"dtype",
"=",
"complex",
")",
"for",
"i"... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | requires_submit | Decorator to ensure that a submit has been performed before
calling the method.
Args:
func (callable): test function to be decorated.
Returns:
callable: the decorated function. | qiskit/providers/basicaer/basicaerjob.py | def requires_submit(func):
"""
Decorator to ensure that a submit has been performed before
calling the method.
Args:
func (callable): test function to be decorated.
Returns:
callable: the decorated function.
"""
@functools.wraps(func)
def _wrapper(self, *args, **kwargs)... | def requires_submit(func):
"""
Decorator to ensure that a submit has been performed before
calling the method.
Args:
func (callable): test function to be decorated.
Returns:
callable: the decorated function.
"""
@functools.wraps(func)
def _wrapper(self, *args, **kwargs)... | [
"Decorator",
"to",
"ensure",
"that",
"a",
"submit",
"has",
"been",
"performed",
"before",
"calling",
"the",
"method",
"."
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/providers/basicaer/basicaerjob.py#L21-L37 | [
"def",
"requires_submit",
"(",
"func",
")",
":",
"@",
"functools",
".",
"wraps",
"(",
"func",
")",
"def",
"_wrapper",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"self",
".",
"_future",
"is",
"None",
":",
"raise",
"JobEr... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | BasicAerJob.submit | Submit the job to the backend for execution.
Raises:
QobjValidationError: if the JSON serialization of the Qobj passed
during construction does not validate against the Qobj schema.
JobError: if trying to re-submit the job. | qiskit/providers/basicaer/basicaerjob.py | def submit(self):
"""Submit the job to the backend for execution.
Raises:
QobjValidationError: if the JSON serialization of the Qobj passed
during construction does not validate against the Qobj schema.
JobError: if trying to re-submit the job.
"""
i... | def submit(self):
"""Submit the job to the backend for execution.
Raises:
QobjValidationError: if the JSON serialization of the Qobj passed
during construction does not validate against the Qobj schema.
JobError: if trying to re-submit the job.
"""
i... | [
"Submit",
"the",
"job",
"to",
"the",
"backend",
"for",
"execution",
"."
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/providers/basicaer/basicaerjob.py#L58-L71 | [
"def",
"submit",
"(",
"self",
")",
":",
"if",
"self",
".",
"_future",
"is",
"not",
"None",
":",
"raise",
"JobError",
"(",
"\"We have already submitted the job!\"",
")",
"validate_qobj_against_schema",
"(",
"self",
".",
"_qobj",
")",
"self",
".",
"_future",
"="... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | BasicAerJob.status | Gets the status of the job by querying the Python's future
Returns:
qiskit.providers.JobStatus: The current JobStatus
Raises:
JobError: If the future is in unexpected state
concurrent.futures.TimeoutError: if timeout occurred. | qiskit/providers/basicaer/basicaerjob.py | def status(self):
"""Gets the status of the job by querying the Python's future
Returns:
qiskit.providers.JobStatus: The current JobStatus
Raises:
JobError: If the future is in unexpected state
concurrent.futures.TimeoutError: if timeout occurred.
""... | def status(self):
"""Gets the status of the job by querying the Python's future
Returns:
qiskit.providers.JobStatus: The current JobStatus
Raises:
JobError: If the future is in unexpected state
concurrent.futures.TimeoutError: if timeout occurred.
""... | [
"Gets",
"the",
"status",
"of",
"the",
"job",
"by",
"querying",
"the",
"Python",
"s",
"future"
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/providers/basicaer/basicaerjob.py#L98-L122 | [
"def",
"status",
"(",
"self",
")",
":",
"# The order is important here",
"if",
"self",
".",
"_future",
".",
"running",
"(",
")",
":",
"_status",
"=",
"JobStatus",
".",
"RUNNING",
"elif",
"self",
".",
"_future",
".",
"cancelled",
"(",
")",
":",
"_status",
... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | LoRange.includes | Whether `lo_freq` is within the `LoRange`.
Args:
lo_freq: LO frequency to be checked
Returns:
bool: True if lo_freq is included in this range, otherwise False | qiskit/pulse/channels/pulse_channels.py | def includes(self, lo_freq: float) -> bool:
"""Whether `lo_freq` is within the `LoRange`.
Args:
lo_freq: LO frequency to be checked
Returns:
bool: True if lo_freq is included in this range, otherwise False
"""
if self._lb <= lo_freq <= self._ub:
... | def includes(self, lo_freq: float) -> bool:
"""Whether `lo_freq` is within the `LoRange`.
Args:
lo_freq: LO frequency to be checked
Returns:
bool: True if lo_freq is included in this range, otherwise False
"""
if self._lb <= lo_freq <= self._ub:
... | [
"Whether",
"lo_freq",
"is",
"within",
"the",
"LoRange",
"."
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/pulse/channels/pulse_channels.py#L25-L36 | [
"def",
"includes",
"(",
"self",
",",
"lo_freq",
":",
"float",
")",
"->",
"bool",
":",
"if",
"self",
".",
"_lb",
"<=",
"lo_freq",
"<=",
"self",
".",
"_ub",
":",
"return",
"True",
"return",
"False"
] | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | iplot_bloch_multivector | Create a bloch sphere representation.
Graphical representation of the input array, using as much bloch
spheres as qubit are required.
Args:
rho (array): State vector or density matrix
figsize (tuple): Figure size in pixels. | qiskit/visualization/interactive/iplot_blochsphere.py | def iplot_bloch_multivector(rho, figsize=None):
""" Create a bloch sphere representation.
Graphical representation of the input array, using as much bloch
spheres as qubit are required.
Args:
rho (array): State vector or density matrix
figsize (tuple): Figure size i... | def iplot_bloch_multivector(rho, figsize=None):
""" Create a bloch sphere representation.
Graphical representation of the input array, using as much bloch
spheres as qubit are required.
Args:
rho (array): State vector or density matrix
figsize (tuple): Figure size i... | [
"Create",
"a",
"bloch",
"sphere",
"representation",
"."
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/visualization/interactive/iplot_blochsphere.py#L25-L105 | [
"def",
"iplot_bloch_multivector",
"(",
"rho",
",",
"figsize",
"=",
"None",
")",
":",
"# HTML",
"html_template",
"=",
"Template",
"(",
"\"\"\"\n <p>\n <div id=\"content_$divNumber\" style=\"position: absolute; z-index: 1;\">\n <div id=\"bloch_$divNumber\"></div>\n ... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | parallel_map | Parallel execution of a mapping of `values` to the function `task`. This
is functionally equivalent to::
result = [task(value, *task_args, **task_kwargs) for value in values]
On Windows this function defaults to a serial implementation to avoid the
overhead from spawning processes in Windows.
... | qiskit/tools/parallel.py | def parallel_map(task, values, task_args=tuple(), task_kwargs={}, # pylint: disable=W0102
num_processes=CPU_COUNT):
"""
Parallel execution of a mapping of `values` to the function `task`. This
is functionally equivalent to::
result = [task(value, *task_args, **task_kwargs) for val... | def parallel_map(task, values, task_args=tuple(), task_kwargs={}, # pylint: disable=W0102
num_processes=CPU_COUNT):
"""
Parallel execution of a mapping of `values` to the function `task`. This
is functionally equivalent to::
result = [task(value, *task_args, **task_kwargs) for val... | [
"Parallel",
"execution",
"of",
"a",
"mapping",
"of",
"values",
"to",
"the",
"function",
"task",
".",
"This",
"is",
"functionally",
"equivalent",
"to",
"::"
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/tools/parallel.py#L60-L137 | [
"def",
"parallel_map",
"(",
"task",
",",
"values",
",",
"task_args",
"=",
"tuple",
"(",
")",
",",
"task_kwargs",
"=",
"{",
"}",
",",
"# pylint: disable=W0102",
"num_processes",
"=",
"CPU_COUNT",
")",
":",
"if",
"len",
"(",
"values",
")",
"==",
"1",
":",
... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | LoConfigConverter.get_qubit_los | Embed default qubit LO frequencies from backend and format them to list object.
If configured lo frequency is the same as default, this method returns `None`.
Args:
user_lo_config (LoConfig): A dictionary of LOs to format.
Returns:
list: A list of qubit LOs.
Ra... | qiskit/qobj/converters/lo_config.py | def get_qubit_los(self, user_lo_config):
"""Embed default qubit LO frequencies from backend and format them to list object.
If configured lo frequency is the same as default, this method returns `None`.
Args:
user_lo_config (LoConfig): A dictionary of LOs to format.
Returns... | def get_qubit_los(self, user_lo_config):
"""Embed default qubit LO frequencies from backend and format them to list object.
If configured lo frequency is the same as default, this method returns `None`.
Args:
user_lo_config (LoConfig): A dictionary of LOs to format.
Returns... | [
"Embed",
"default",
"qubit",
"LO",
"frequencies",
"from",
"backend",
"and",
"format",
"them",
"to",
"list",
"object",
".",
"If",
"configured",
"lo",
"frequency",
"is",
"the",
"same",
"as",
"default",
"this",
"method",
"returns",
"None",
"."
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/qobj/converters/lo_config.py#L54-L77 | [
"def",
"get_qubit_los",
"(",
"self",
",",
"user_lo_config",
")",
":",
"try",
":",
"_q_los",
"=",
"self",
".",
"default_qubit_los",
".",
"copy",
"(",
")",
"except",
"KeyError",
":",
"raise",
"PulseError",
"(",
"'Qubit default frequencies not exist.'",
")",
"for",... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | LoConfigConverter.get_meas_los | Embed default meas LO frequencies from backend and format them to list object.
If configured lo frequency is the same as default, this method returns `None`.
Args:
user_lo_config (LoConfig): A dictionary of LOs to format.
Returns:
list: A list of meas LOs.
Rais... | qiskit/qobj/converters/lo_config.py | def get_meas_los(self, user_lo_config):
"""Embed default meas LO frequencies from backend and format them to list object.
If configured lo frequency is the same as default, this method returns `None`.
Args:
user_lo_config (LoConfig): A dictionary of LOs to format.
Returns:
... | def get_meas_los(self, user_lo_config):
"""Embed default meas LO frequencies from backend and format them to list object.
If configured lo frequency is the same as default, this method returns `None`.
Args:
user_lo_config (LoConfig): A dictionary of LOs to format.
Returns:
... | [
"Embed",
"default",
"meas",
"LO",
"frequencies",
"from",
"backend",
"and",
"format",
"them",
"to",
"list",
"object",
".",
"If",
"configured",
"lo",
"frequency",
"is",
"the",
"same",
"as",
"default",
"this",
"method",
"returns",
"None",
"."
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/qobj/converters/lo_config.py#L79-L102 | [
"def",
"get_meas_los",
"(",
"self",
",",
"user_lo_config",
")",
":",
"try",
":",
"_m_los",
"=",
"self",
".",
"default_meas_los",
".",
"copy",
"(",
")",
"except",
"KeyError",
":",
"raise",
"PulseError",
"(",
"'Default measurement frequencies not exist.'",
")",
"f... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | Unroller.run | Expand all op nodes to the given basis.
Args:
dag(DAGCircuit): input dag
Raises:
QiskitError: if unable to unroll given the basis due to undefined
decomposition rules (such as a bad basis) or excessive recursion.
Returns:
DAGCircuit: output unro... | qiskit/transpiler/passes/unroller.py | def run(self, dag):
"""Expand all op nodes to the given basis.
Args:
dag(DAGCircuit): input dag
Raises:
QiskitError: if unable to unroll given the basis due to undefined
decomposition rules (such as a bad basis) or excessive recursion.
Returns:
... | def run(self, dag):
"""Expand all op nodes to the given basis.
Args:
dag(DAGCircuit): input dag
Raises:
QiskitError: if unable to unroll given the basis due to undefined
decomposition rules (such as a bad basis) or excessive recursion.
Returns:
... | [
"Expand",
"all",
"op",
"nodes",
"to",
"the",
"given",
"basis",
"."
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/transpiler/passes/unroller.py#L29-L69 | [
"def",
"run",
"(",
"self",
",",
"dag",
")",
":",
"# Walk through the DAG and expand each non-basis node",
"for",
"node",
"in",
"dag",
".",
"op_nodes",
"(",
")",
":",
"basic_insts",
"=",
"[",
"'measure'",
",",
"'reset'",
",",
"'barrier'",
",",
"'snapshot'",
"]"... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | iplot_state_qsphere | Create a Q sphere representation.
Graphical representation of the input array, using a Q sphere for each
eigenvalue.
Args:
rho (array): State vector or density matrix.
figsize (tuple): Figure size in pixels. | qiskit/visualization/interactive/iplot_qsphere.py | def iplot_state_qsphere(rho, figsize=None):
""" Create a Q sphere representation.
Graphical representation of the input array, using a Q sphere for each
eigenvalue.
Args:
rho (array): State vector or density matrix.
figsize (tuple): Figure size in pixels.
"""
... | def iplot_state_qsphere(rho, figsize=None):
""" Create a Q sphere representation.
Graphical representation of the input array, using a Q sphere for each
eigenvalue.
Args:
rho (array): State vector or density matrix.
figsize (tuple): Figure size in pixels.
"""
... | [
"Create",
"a",
"Q",
"sphere",
"representation",
"."
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/visualization/interactive/iplot_qsphere.py#L31-L155 | [
"def",
"iplot_state_qsphere",
"(",
"rho",
",",
"figsize",
"=",
"None",
")",
":",
"# HTML",
"html_template",
"=",
"Template",
"(",
"\"\"\"\n <p>\n <div id=\"content_$divNumber\" style=\"position: absolute; z-index: 1;\">\n <div id=\"qsphere_$divNumber\"></div>\n ... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | n_choose_k | Return the number of combinations for n choose k.
Args:
n (int): the total number of options .
k (int): The number of elements.
Returns:
int: returns the binomial coefficient | qiskit/visualization/interactive/iplot_qsphere.py | def n_choose_k(n, k):
"""Return the number of combinations for n choose k.
Args:
n (int): the total number of options .
k (int): The number of elements.
Returns:
int: returns the binomial coefficient
"""
if n == 0:
return 0
return reduce(lambda x, y: x * y[0] / ... | def n_choose_k(n, k):
"""Return the number of combinations for n choose k.
Args:
n (int): the total number of options .
k (int): The number of elements.
Returns:
int: returns the binomial coefficient
"""
if n == 0:
return 0
return reduce(lambda x, y: x * y[0] / ... | [
"Return",
"the",
"number",
"of",
"combinations",
"for",
"n",
"choose",
"k",
"."
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/visualization/interactive/iplot_qsphere.py#L158-L172 | [
"def",
"n_choose_k",
"(",
"n",
",",
"k",
")",
":",
"if",
"n",
"==",
"0",
":",
"return",
"0",
"return",
"reduce",
"(",
"lambda",
"x",
",",
"y",
":",
"x",
"*",
"y",
"[",
"0",
"]",
"/",
"y",
"[",
"1",
"]",
",",
"zip",
"(",
"range",
"(",
"n",... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | bit_string_index | Return the index of a string of 0s and 1s. | qiskit/visualization/interactive/iplot_qsphere.py | def bit_string_index(text):
"""Return the index of a string of 0s and 1s."""
n = len(text)
k = text.count("1")
if text.count("0") != n - k:
raise VisualizationError("s must be a string of 0 and 1")
ones = [pos for pos, char in enumerate(text) if char == "1"]
return lex_index(n, k, ones) | def bit_string_index(text):
"""Return the index of a string of 0s and 1s."""
n = len(text)
k = text.count("1")
if text.count("0") != n - k:
raise VisualizationError("s must be a string of 0 and 1")
ones = [pos for pos, char in enumerate(text) if char == "1"]
return lex_index(n, k, ones) | [
"Return",
"the",
"index",
"of",
"a",
"string",
"of",
"0s",
"and",
"1s",
"."
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/visualization/interactive/iplot_qsphere.py#L175-L182 | [
"def",
"bit_string_index",
"(",
"text",
")",
":",
"n",
"=",
"len",
"(",
"text",
")",
"k",
"=",
"text",
".",
"count",
"(",
"\"1\"",
")",
"if",
"text",
".",
"count",
"(",
"\"0\"",
")",
"!=",
"n",
"-",
"k",
":",
"raise",
"VisualizationError",
"(",
"... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | lex_index | Return the lex index of a combination..
Args:
n (int): the total number of options .
k (int): The number of elements.
lst (list): list
Returns:
int: returns int index for lex order
Raises:
VisualizationError: if length of list is not equal to k | qiskit/visualization/interactive/iplot_qsphere.py | def lex_index(n, k, lst):
"""Return the lex index of a combination..
Args:
n (int): the total number of options .
k (int): The number of elements.
lst (list): list
Returns:
int: returns int index for lex order
Raises:
VisualizationError: if length of list is n... | def lex_index(n, k, lst):
"""Return the lex index of a combination..
Args:
n (int): the total number of options .
k (int): The number of elements.
lst (list): list
Returns:
int: returns int index for lex order
Raises:
VisualizationError: if length of list is n... | [
"Return",
"the",
"lex",
"index",
"of",
"a",
"combination",
".."
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/visualization/interactive/iplot_qsphere.py#L185-L203 | [
"def",
"lex_index",
"(",
"n",
",",
"k",
",",
"lst",
")",
":",
"if",
"len",
"(",
"lst",
")",
"!=",
"k",
":",
"raise",
"VisualizationError",
"(",
"\"list should have length k\"",
")",
"comb",
"=",
"list",
"(",
"map",
"(",
"lambda",
"x",
":",
"n",
"-",
... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | plot_state_hinton | Plot a hinton diagram for the quanum state.
Args:
rho (ndarray): Numpy array for state vector or density matrix.
title (str): a string that represents the plot title
figsize (tuple): Figure size in inches.
Returns:
matplotlib.Figure: The matplotlib.Figure of the visualization
... | qiskit/visualization/state_visualization.py | def plot_state_hinton(rho, title='', figsize=None):
"""Plot a hinton diagram for the quanum state.
Args:
rho (ndarray): Numpy array for state vector or density matrix.
title (str): a string that represents the plot title
figsize (tuple): Figure size in inches.
Returns:
matp... | def plot_state_hinton(rho, title='', figsize=None):
"""Plot a hinton diagram for the quanum state.
Args:
rho (ndarray): Numpy array for state vector or density matrix.
title (str): a string that represents the plot title
figsize (tuple): Figure size in inches.
Returns:
matp... | [
"Plot",
"a",
"hinton",
"diagram",
"for",
"the",
"quanum",
"state",
"."
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/visualization/state_visualization.py#L50-L121 | [
"def",
"plot_state_hinton",
"(",
"rho",
",",
"title",
"=",
"''",
",",
"figsize",
"=",
"None",
")",
":",
"if",
"not",
"HAS_MATPLOTLIB",
":",
"raise",
"ImportError",
"(",
"'Must have Matplotlib installed.'",
")",
"rho",
"=",
"_validate_input_state",
"(",
"rho",
... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | plot_bloch_vector | Plot the Bloch sphere.
Plot a sphere, axes, the Bloch vector, and its projections onto each axis.
Args:
bloch (list[double]): array of three elements where [<x>, <y>, <z>]
title (str): a string that represents the plot title
ax (matplotlib.Axes): An Axes to use for rendering the bloch ... | qiskit/visualization/state_visualization.py | def plot_bloch_vector(bloch, title="", ax=None, figsize=None):
"""Plot the Bloch sphere.
Plot a sphere, axes, the Bloch vector, and its projections onto each axis.
Args:
bloch (list[double]): array of three elements where [<x>, <y>, <z>]
title (str): a string that represents the plot title... | def plot_bloch_vector(bloch, title="", ax=None, figsize=None):
"""Plot the Bloch sphere.
Plot a sphere, axes, the Bloch vector, and its projections onto each axis.
Args:
bloch (list[double]): array of three elements where [<x>, <y>, <z>]
title (str): a string that represents the plot title... | [
"Plot",
"the",
"Bloch",
"sphere",
"."
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/visualization/state_visualization.py#L124-L153 | [
"def",
"plot_bloch_vector",
"(",
"bloch",
",",
"title",
"=",
"\"\"",
",",
"ax",
"=",
"None",
",",
"figsize",
"=",
"None",
")",
":",
"if",
"not",
"HAS_MATPLOTLIB",
":",
"raise",
"ImportError",
"(",
"'Must have Matplotlib installed.'",
")",
"if",
"figsize",
"i... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | plot_bloch_multivector | Plot the Bloch sphere.
Plot a sphere, axes, the Bloch vector, and its projections onto each axis.
Args:
rho (ndarray): Numpy array for state vector or density matrix.
title (str): a string that represents the plot title
figsize (tuple): Has no effect, here for compatibility only.
... | qiskit/visualization/state_visualization.py | def plot_bloch_multivector(rho, title='', figsize=None):
"""Plot the Bloch sphere.
Plot a sphere, axes, the Bloch vector, and its projections onto each axis.
Args:
rho (ndarray): Numpy array for state vector or density matrix.
title (str): a string that represents the plot title
fi... | def plot_bloch_multivector(rho, title='', figsize=None):
"""Plot the Bloch sphere.
Plot a sphere, axes, the Bloch vector, and its projections onto each axis.
Args:
rho (ndarray): Numpy array for state vector or density matrix.
title (str): a string that represents the plot title
fi... | [
"Plot",
"the",
"Bloch",
"sphere",
"."
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/visualization/state_visualization.py#L156-L192 | [
"def",
"plot_bloch_multivector",
"(",
"rho",
",",
"title",
"=",
"''",
",",
"figsize",
"=",
"None",
")",
":",
"if",
"not",
"HAS_MATPLOTLIB",
":",
"raise",
"ImportError",
"(",
"'Must have Matplotlib installed.'",
")",
"rho",
"=",
"_validate_input_state",
"(",
"rho... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | plot_state_city | Plot the cityscape of quantum state.
Plot two 3d bar graphs (two dimensional) of the real and imaginary
part of the density matrix rho.
Args:
rho (ndarray): Numpy array for state vector or density matrix.
title (str): a string that represents the plot title
figsize (tuple): Figure ... | qiskit/visualization/state_visualization.py | def plot_state_city(rho, title="", figsize=None, color=None,
alpha=1):
"""Plot the cityscape of quantum state.
Plot two 3d bar graphs (two dimensional) of the real and imaginary
part of the density matrix rho.
Args:
rho (ndarray): Numpy array for state vector or density mat... | def plot_state_city(rho, title="", figsize=None, color=None,
alpha=1):
"""Plot the cityscape of quantum state.
Plot two 3d bar graphs (two dimensional) of the real and imaginary
part of the density matrix rho.
Args:
rho (ndarray): Numpy array for state vector or density mat... | [
"Plot",
"the",
"cityscape",
"of",
"quantum",
"state",
"."
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/visualization/state_visualization.py#L195-L341 | [
"def",
"plot_state_city",
"(",
"rho",
",",
"title",
"=",
"\"\"",
",",
"figsize",
"=",
"None",
",",
"color",
"=",
"None",
",",
"alpha",
"=",
"1",
")",
":",
"if",
"not",
"HAS_MATPLOTLIB",
":",
"raise",
"ImportError",
"(",
"'Must have Matplotlib installed.'",
... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | plot_state_paulivec | Plot the paulivec representation of a quantum state.
Plot a bargraph of the mixed state rho over the pauli matrices
Args:
rho (ndarray): Numpy array for state vector or density matrix
title (str): a string that represents the plot title
figsize (tuple): Figure size in inches.
c... | qiskit/visualization/state_visualization.py | def plot_state_paulivec(rho, title="", figsize=None, color=None):
"""Plot the paulivec representation of a quantum state.
Plot a bargraph of the mixed state rho over the pauli matrices
Args:
rho (ndarray): Numpy array for state vector or density matrix
title (str): a string that represents... | def plot_state_paulivec(rho, title="", figsize=None, color=None):
"""Plot the paulivec representation of a quantum state.
Plot a bargraph of the mixed state rho over the pauli matrices
Args:
rho (ndarray): Numpy array for state vector or density matrix
title (str): a string that represents... | [
"Plot",
"the",
"paulivec",
"representation",
"of",
"a",
"quantum",
"state",
"."
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/visualization/state_visualization.py#L344-L390 | [
"def",
"plot_state_paulivec",
"(",
"rho",
",",
"title",
"=",
"\"\"",
",",
"figsize",
"=",
"None",
",",
"color",
"=",
"None",
")",
":",
"if",
"not",
"HAS_MATPLOTLIB",
":",
"raise",
"ImportError",
"(",
"'Must have Matplotlib installed.'",
")",
"rho",
"=",
"_va... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | bit_string_index | Return the index of a string of 0s and 1s. | qiskit/visualization/state_visualization.py | def bit_string_index(s):
"""Return the index of a string of 0s and 1s."""
n = len(s)
k = s.count("1")
if s.count("0") != n - k:
raise VisualizationError("s must be a string of 0 and 1")
ones = [pos for pos, char in enumerate(s) if char == "1"]
return lex_index(n, k, ones) | def bit_string_index(s):
"""Return the index of a string of 0s and 1s."""
n = len(s)
k = s.count("1")
if s.count("0") != n - k:
raise VisualizationError("s must be a string of 0 and 1")
ones = [pos for pos, char in enumerate(s) if char == "1"]
return lex_index(n, k, ones) | [
"Return",
"the",
"index",
"of",
"a",
"string",
"of",
"0s",
"and",
"1s",
"."
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/visualization/state_visualization.py#L431-L438 | [
"def",
"bit_string_index",
"(",
"s",
")",
":",
"n",
"=",
"len",
"(",
"s",
")",
"k",
"=",
"s",
".",
"count",
"(",
"\"1\"",
")",
"if",
"s",
".",
"count",
"(",
"\"0\"",
")",
"!=",
"n",
"-",
"k",
":",
"raise",
"VisualizationError",
"(",
"\"s must be ... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | phase_to_color_wheel | Map a phase of a complexnumber to a color in (r,g,b).
complex_number is phase is first mapped to angle in the range
[0, 2pi] and then to a color wheel with blue at zero phase. | qiskit/visualization/state_visualization.py | def phase_to_color_wheel(complex_number):
"""Map a phase of a complexnumber to a color in (r,g,b).
complex_number is phase is first mapped to angle in the range
[0, 2pi] and then to a color wheel with blue at zero phase.
"""
angles = np.angle(complex_number)
angle_round = int(((angles + 2 * np.... | def phase_to_color_wheel(complex_number):
"""Map a phase of a complexnumber to a color in (r,g,b).
complex_number is phase is first mapped to angle in the range
[0, 2pi] and then to a color wheel with blue at zero phase.
"""
angles = np.angle(complex_number)
angle_round = int(((angles + 2 * np.... | [
"Map",
"a",
"phase",
"of",
"a",
"complexnumber",
"to",
"a",
"color",
"in",
"(",
"r",
"g",
"b",
")",
"."
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/visualization/state_visualization.py#L441-L463 | [
"def",
"phase_to_color_wheel",
"(",
"complex_number",
")",
":",
"angles",
"=",
"np",
".",
"angle",
"(",
"complex_number",
")",
"angle_round",
"=",
"int",
"(",
"(",
"(",
"angles",
"+",
"2",
"*",
"np",
".",
"pi",
")",
"%",
"(",
"2",
"*",
"np",
".",
"... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | plot_state_qsphere | Plot the qsphere representation of a quantum state.
Args:
rho (ndarray): State vector or density matrix representation.
of quantum state.
figsize (tuple): Figure size in inches.
Returns:
Figure: A matplotlib figure instance.
Raises:
ImportError: Requires matplotlib... | qiskit/visualization/state_visualization.py | def plot_state_qsphere(rho, figsize=None):
"""Plot the qsphere representation of a quantum state.
Args:
rho (ndarray): State vector or density matrix representation.
of quantum state.
figsize (tuple): Figure size in inches.
Returns:
Figure: A matplotlib figure instance.
... | def plot_state_qsphere(rho, figsize=None):
"""Plot the qsphere representation of a quantum state.
Args:
rho (ndarray): State vector or density matrix representation.
of quantum state.
figsize (tuple): Figure size in inches.
Returns:
Figure: A matplotlib figure instance.
... | [
"Plot",
"the",
"qsphere",
"representation",
"of",
"a",
"quantum",
"state",
"."
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/visualization/state_visualization.py#L466-L586 | [
"def",
"plot_state_qsphere",
"(",
"rho",
",",
"figsize",
"=",
"None",
")",
":",
"if",
"not",
"HAS_MATPLOTLIB",
":",
"raise",
"ImportError",
"(",
"'Must have Matplotlib installed.'",
")",
"rho",
"=",
"_validate_input_state",
"(",
"rho",
")",
"if",
"figsize",
"is"... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | plot_state | Plot the quantum state.
Args:
quantum_state (ndarray): statevector or density matrix
representation of a quantum state.
method (str): Plotting method to use.
figsize (tuple): Figure size in inches,
Returns:
matplotlib.Figure: The matplotlib.Fig... | qiskit/visualization/state_visualization.py | def plot_state(quantum_state, method='city', figsize=None):
"""Plot the quantum state.
Args:
quantum_state (ndarray): statevector or density matrix
representation of a quantum state.
method (str): Plotting method to use.
figsize (tuple): Figure size in i... | def plot_state(quantum_state, method='city', figsize=None):
"""Plot the quantum state.
Args:
quantum_state (ndarray): statevector or density matrix
representation of a quantum state.
method (str): Plotting method to use.
figsize (tuple): Figure size in i... | [
"Plot",
"the",
"quantum",
"state",
"."
] | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/visualization/state_visualization.py#L589-L624 | [
"def",
"plot_state",
"(",
"quantum_state",
",",
"method",
"=",
"'city'",
",",
"figsize",
"=",
"None",
")",
":",
"if",
"not",
"HAS_MATPLOTLIB",
":",
"raise",
"ImportError",
"(",
"'Must have Matplotlib installed.'",
")",
"warnings",
".",
"warn",
"(",
"\"plot_state... | d4f58d903bc96341b816f7c35df936d6421267d1 |
test | generate_facecolors | Generates shaded facecolors for shaded bars.
This is here to work around a Matplotlib bug
where alpha does not work in Bar3D.
Args:
x (array_like): The x- coordinates of the anchor point of the bars.
y (array_like): The y- coordinates of the anchor point of the bars.
z (array_like): ... | qiskit/visualization/state_visualization.py | def generate_facecolors(x, y, z, dx, dy, dz, color):
"""Generates shaded facecolors for shaded bars.
This is here to work around a Matplotlib bug
where alpha does not work in Bar3D.
Args:
x (array_like): The x- coordinates of the anchor point of the bars.
y (array_like): The y- coordinat... | def generate_facecolors(x, y, z, dx, dy, dz, color):
"""Generates shaded facecolors for shaded bars.
This is here to work around a Matplotlib bug
where alpha does not work in Bar3D.
Args:
x (array_like): The x- coordinates of the anchor point of the bars.
y (array_like): The y- coordinat... | [
"Generates",
"shaded",
"facecolors",
"for",
"shaded",
"bars",
".",
"This",
"is",
"here",
"to",
"work",
"around",
"a",
"Matplotlib",
"bug",
"where",
"alpha",
"does",
"not",
"work",
"in",
"Bar3D",
".",
"Args",
":",
"x",
"(",
"array_like",
")",
":",
"The",
... | Qiskit/qiskit-terra | python | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/visualization/state_visualization.py#L627-L710 | [
"def",
"generate_facecolors",
"(",
"x",
",",
"y",
",",
"z",
",",
"dx",
",",
"dy",
",",
"dz",
",",
"color",
")",
":",
"cuboid",
"=",
"np",
".",
"array",
"(",
"[",
"# -z",
"(",
"(",
"0",
",",
"0",
",",
"0",
")",
",",
"(",
"0",
",",
"1",
","... | d4f58d903bc96341b816f7c35df936d6421267d1 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.