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
purity
Calculate the purity of a quantum state. Args: state (ndarray): a quantum state Returns: float: purity.
qiskit/quantum_info/states/states.py
def purity(state): """Calculate the purity of a quantum state. Args: state (ndarray): a quantum state Returns: float: purity. """ rho = np.array(state) if rho.ndim == 1: return 1.0 return np.real(np.trace(rho.dot(rho)))
def purity(state): """Calculate the purity of a quantum state. Args: state (ndarray): a quantum state Returns: float: purity. """ rho = np.array(state) if rho.ndim == 1: return 1.0 return np.real(np.trace(rho.dot(rho)))
[ "Calculate", "the", "purity", "of", "a", "quantum", "state", "." ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/quantum_info/states/states.py#L60-L71
[ "def", "purity", "(", "state", ")", ":", "rho", "=", "np", ".", "array", "(", "state", ")", "if", "rho", ".", "ndim", "==", "1", ":", "return", "1.0", "return", "np", ".", "real", "(", "np", ".", "trace", "(", "rho", ".", "dot", "(", "rho", "...
d4f58d903bc96341b816f7c35df936d6421267d1
test
Gate.qasm
Return the corresponding OPENQASM string.
qiskit/qasm/node/gate.py
def qasm(self, prec=15): """Return the corresponding OPENQASM string.""" string = "gate " + self.name if self.arguments is not None: string += "(" + self.arguments.qasm(prec) + ")" string += " " + self.bitlist.qasm(prec) + "\n" string += "{\n" + self.body.qasm(prec) +...
def qasm(self, prec=15): """Return the corresponding OPENQASM string.""" string = "gate " + self.name if self.arguments is not None: string += "(" + self.arguments.qasm(prec) + ")" string += " " + self.bitlist.qasm(prec) + "\n" string += "{\n" + self.body.qasm(prec) +...
[ "Return", "the", "corresponding", "OPENQASM", "string", "." ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/qasm/node/gate.py#L53-L60
[ "def", "qasm", "(", "self", ",", "prec", "=", "15", ")", ":", "string", "=", "\"gate \"", "+", "self", ".", "name", "if", "self", ".", "arguments", "is", "not", "None", ":", "string", "+=", "\"(\"", "+", "self", ".", "arguments", ".", "qasm", "(", ...
d4f58d903bc96341b816f7c35df936d6421267d1
test
CommutationAnalysis.run
Run the pass on the DAG, and write the discovered commutation relations into the property_set.
qiskit/transpiler/passes/commutation_analysis.py
def run(self, dag): """ Run the pass on the DAG, and write the discovered commutation relations into the property_set. """ # Initiate the commutation set self.property_set['commutation_set'] = defaultdict(list) # Build a dictionary to keep track of the gates on e...
def run(self, dag): """ Run the pass on the DAG, and write the discovered commutation relations into the property_set. """ # Initiate the commutation set self.property_set['commutation_set'] = defaultdict(list) # Build a dictionary to keep track of the gates on e...
[ "Run", "the", "pass", "on", "the", "DAG", "and", "write", "the", "discovered", "commutation", "relations", "into", "the", "property_set", "." ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/transpiler/passes/commutation_analysis.py#L38-L76
[ "def", "run", "(", "self", ",", "dag", ")", ":", "# Initiate the commutation set", "self", ".", "property_set", "[", "'commutation_set'", "]", "=", "defaultdict", "(", "list", ")", "# Build a dictionary to keep track of the gates on each qubit", "for", "wire", "in", "...
d4f58d903bc96341b816f7c35df936d6421267d1
test
backend_widget
Creates a backend widget.
qiskit/tools/jupyter/backend_overview.py
def backend_widget(backend): """Creates a backend widget. """ config = backend.configuration().to_dict() props = backend.properties().to_dict() name = widgets.HTML(value="<h4>{name}</h4>".format(name=backend.name()), layout=widgets.Layout()) n_qubits = config['n_qubits'...
def backend_widget(backend): """Creates a backend widget. """ config = backend.configuration().to_dict() props = backend.properties().to_dict() name = widgets.HTML(value="<h4>{name}</h4>".format(name=backend.name()), layout=widgets.Layout()) n_qubits = config['n_qubits'...
[ "Creates", "a", "backend", "widget", "." ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/tools/jupyter/backend_overview.py#L112-L167
[ "def", "backend_widget", "(", "backend", ")", ":", "config", "=", "backend", ".", "configuration", "(", ")", ".", "to_dict", "(", ")", "props", "=", "backend", ".", "properties", "(", ")", ".", "to_dict", "(", ")", "name", "=", "widgets", ".", "HTML", ...
d4f58d903bc96341b816f7c35df936d6421267d1
test
update_backend_info
Updates the monitor info Called from another thread.
qiskit/tools/jupyter/backend_overview.py
def update_backend_info(self, interval=60): """Updates the monitor info Called from another thread. """ my_thread = threading.currentThread() current_interval = 0 started = False all_dead = False stati = [None]*len(self._backends) while getattr(my_thread, "do_run", True) and not all_...
def update_backend_info(self, interval=60): """Updates the monitor info Called from another thread. """ my_thread = threading.currentThread() current_interval = 0 started = False all_dead = False stati = [None]*len(self._backends) while getattr(my_thread, "do_run", True) and not all_...
[ "Updates", "the", "monitor", "info", "Called", "from", "another", "thread", "." ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/tools/jupyter/backend_overview.py#L170-L224
[ "def", "update_backend_info", "(", "self", ",", "interval", "=", "60", ")", ":", "my_thread", "=", "threading", ".", "currentThread", "(", ")", "current_interval", "=", "0", "started", "=", "False", "all_dead", "=", "False", "stati", "=", "[", "None", "]",...
d4f58d903bc96341b816f7c35df936d6421267d1
test
generate_jobs_pending_widget
Generates a jobs_pending progress bar widget.
qiskit/tools/jupyter/backend_overview.py
def generate_jobs_pending_widget(): """Generates a jobs_pending progress bar widget. """ pbar = widgets.IntProgress( value=0, min=0, max=50, description='', orientation='horizontal', layout=widgets.Layout(max_width='180px')) pbar.style.bar_color = '#71cddd' p...
def generate_jobs_pending_widget(): """Generates a jobs_pending progress bar widget. """ pbar = widgets.IntProgress( value=0, min=0, max=50, description='', orientation='horizontal', layout=widgets.Layout(max_width='180px')) pbar.style.bar_color = '#71cddd' p...
[ "Generates", "a", "jobs_pending", "progress", "bar", "widget", "." ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/tools/jupyter/backend_overview.py#L227-L257
[ "def", "generate_jobs_pending_widget", "(", ")", ":", "pbar", "=", "widgets", ".", "IntProgress", "(", "value", "=", "0", ",", "min", "=", "0", ",", "max", "=", "50", ",", "description", "=", "''", ",", "orientation", "=", "'horizontal'", ",", "layout", ...
d4f58d903bc96341b816f7c35df936d6421267d1
test
CXDirection.run
Flips the cx nodes to match the directed coupling map. Args: dag (DAGCircuit): DAG to map. Returns: DAGCircuit: The rearranged dag for the coupling map Raises: TranspilerError: If the circuit cannot be mapped just by flipping the cx nodes.
qiskit/transpiler/passes/mapping/cx_direction.py
def run(self, dag): """ Flips the cx nodes to match the directed coupling map. Args: dag (DAGCircuit): DAG to map. Returns: DAGCircuit: The rearranged dag for the coupling map Raises: TranspilerError: If the circuit cannot be mapped just by fl...
def run(self, dag): """ Flips the cx nodes to match the directed coupling map. Args: dag (DAGCircuit): DAG to map. Returns: DAGCircuit: The rearranged dag for the coupling map Raises: TranspilerError: If the circuit cannot be mapped just by fl...
[ "Flips", "the", "cx", "nodes", "to", "match", "the", "directed", "coupling", "map", ".", "Args", ":", "dag", "(", "DAGCircuit", ")", ":", "DAG", "to", "map", ".", "Returns", ":", "DAGCircuit", ":", "The", "rearranged", "dag", "for", "the", "coupling", ...
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/transpiler/passes/mapping/cx_direction.py#L44-L95
[ "def", "run", "(", "self", ",", "dag", ")", ":", "new_dag", "=", "DAGCircuit", "(", ")", "if", "self", ".", "layout", "is", "None", ":", "# LegacySwap renames the register in the DAG and does not match the property set", "self", ".", "layout", "=", "Layout", ".", ...
d4f58d903bc96341b816f7c35df936d6421267d1
test
CXCancellation.run
Run one pass of cx cancellation on the circuit Args: dag (DAGCircuit): the directed acyclic graph to run on. Returns: DAGCircuit: Transformed DAG.
qiskit/transpiler/passes/cx_cancellation.py
def run(self, dag): """ Run one pass of cx cancellation on the circuit Args: dag (DAGCircuit): the directed acyclic graph to run on. Returns: DAGCircuit: Transformed DAG. """ cx_runs = dag.collect_runs(["cx"]) for cx_run in cx_runs: ...
def run(self, dag): """ Run one pass of cx cancellation on the circuit Args: dag (DAGCircuit): the directed acyclic graph to run on. Returns: DAGCircuit: Transformed DAG. """ cx_runs = dag.collect_runs(["cx"]) for cx_run in cx_runs: ...
[ "Run", "one", "pass", "of", "cx", "cancellation", "on", "the", "circuit" ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/transpiler/passes/cx_cancellation.py#L16-L49
[ "def", "run", "(", "self", ",", "dag", ")", ":", "cx_runs", "=", "dag", ".", "collect_runs", "(", "[", "\"cx\"", "]", ")", "for", "cx_run", "in", "cx_runs", ":", "# Partition the cx_run into chunks with equal gate arguments", "partition", "=", "[", "]", "chunk...
d4f58d903bc96341b816f7c35df936d6421267d1
test
BaseProvider.get_backend
Return a single backend matching the specified filtering. Args: name (str): name of the backend. **kwargs (dict): dict used for filtering. Returns: BaseBackend: a backend matching the filtering. Raises: QiskitBackendNotFoundError: if no backend ...
qiskit/providers/baseprovider.py
def get_backend(self, name=None, **kwargs): """Return a single backend matching the specified filtering. Args: name (str): name of the backend. **kwargs (dict): dict used for filtering. Returns: BaseBackend: a backend matching the filtering. Raises:...
def get_backend(self, name=None, **kwargs): """Return a single backend matching the specified filtering. Args: name (str): name of the backend. **kwargs (dict): dict used for filtering. Returns: BaseBackend: a backend matching the filtering. Raises:...
[ "Return", "a", "single", "backend", "matching", "the", "specified", "filtering", "." ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/providers/baseprovider.py#L28-L48
[ "def", "get_backend", "(", "self", ",", "name", "=", "None", ",", "*", "*", "kwargs", ")", ":", "backends", "=", "self", ".", "backends", "(", "name", ",", "*", "*", "kwargs", ")", "if", "len", "(", "backends", ")", ">", "1", ":", "raise", "Qiski...
d4f58d903bc96341b816f7c35df936d6421267d1
test
Choi._bipartite_shape
Return the shape for bipartite matrix
qiskit/quantum_info/operators/channel/choi.py
def _bipartite_shape(self): """Return the shape for bipartite matrix""" return (self._input_dim, self._output_dim, self._input_dim, self._output_dim)
def _bipartite_shape(self): """Return the shape for bipartite matrix""" return (self._input_dim, self._output_dim, self._input_dim, self._output_dim)
[ "Return", "the", "shape", "for", "bipartite", "matrix" ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/quantum_info/operators/channel/choi.py#L113-L116
[ "def", "_bipartite_shape", "(", "self", ")", ":", "return", "(", "self", ".", "_input_dim", ",", "self", ".", "_output_dim", ",", "self", ".", "_input_dim", ",", "self", ".", "_output_dim", ")" ]
d4f58d903bc96341b816f7c35df936d6421267d1
test
Choi.conjugate
Return the conjugate of the QuantumChannel.
qiskit/quantum_info/operators/channel/choi.py
def conjugate(self): """Return the conjugate of the QuantumChannel.""" return Choi(np.conj(self._data), self.input_dims(), self.output_dims())
def conjugate(self): """Return the conjugate of the QuantumChannel.""" return Choi(np.conj(self._data), self.input_dims(), self.output_dims())
[ "Return", "the", "conjugate", "of", "the", "QuantumChannel", "." ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/quantum_info/operators/channel/choi.py#L118-L120
[ "def", "conjugate", "(", "self", ")", ":", "return", "Choi", "(", "np", ".", "conj", "(", "self", ".", "_data", ")", ",", "self", ".", "input_dims", "(", ")", ",", "self", ".", "output_dims", "(", ")", ")" ]
d4f58d903bc96341b816f7c35df936d6421267d1
test
Choi.transpose
Return the transpose of the QuantumChannel.
qiskit/quantum_info/operators/channel/choi.py
def transpose(self): """Return the transpose of the QuantumChannel.""" # Make bipartite matrix d_in, d_out = self.dim data = np.reshape(self._data, (d_in, d_out, d_in, d_out)) # Swap input and output indicies on bipartite matrix data = np.transpose(data, (1, 0, 3, 2)) ...
def transpose(self): """Return the transpose of the QuantumChannel.""" # Make bipartite matrix d_in, d_out = self.dim data = np.reshape(self._data, (d_in, d_out, d_in, d_out)) # Swap input and output indicies on bipartite matrix data = np.transpose(data, (1, 0, 3, 2)) ...
[ "Return", "the", "transpose", "of", "the", "QuantumChannel", "." ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/quantum_info/operators/channel/choi.py#L122-L132
[ "def", "transpose", "(", "self", ")", ":", "# Make bipartite matrix", "d_in", ",", "d_out", "=", "self", ".", "dim", "data", "=", "np", ".", "reshape", "(", "self", ".", "_data", ",", "(", "d_in", ",", "d_out", ",", "d_in", ",", "d_out", ")", ")", ...
d4f58d903bc96341b816f7c35df936d6421267d1
test
Choi.compose
Return the composition channel self∘other. Args: other (QuantumChannel): a quantum channel. qargs (list): a list of subsystem positions to compose other on. front (bool): If False compose in standard order other(self(input)) otherwise compose in rev...
qiskit/quantum_info/operators/channel/choi.py
def compose(self, other, qargs=None, front=False): """Return the composition channel self∘other. Args: other (QuantumChannel): a quantum channel. qargs (list): a list of subsystem positions to compose other on. front (bool): If False compose in standard order other(s...
def compose(self, other, qargs=None, front=False): """Return the composition channel self∘other. Args: other (QuantumChannel): a quantum channel. qargs (list): a list of subsystem positions to compose other on. front (bool): If False compose in standard order other(s...
[ "Return", "the", "composition", "channel", "self∘other", "." ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/quantum_info/operators/channel/choi.py#L134-L185
[ "def", "compose", "(", "self", ",", "other", ",", "qargs", "=", "None", ",", "front", "=", "False", ")", ":", "if", "qargs", "is", "not", "None", ":", "return", "Choi", "(", "SuperOp", "(", "self", ")", ".", "compose", "(", "other", ",", "qargs", ...
d4f58d903bc96341b816f7c35df936d6421267d1
test
Choi.power
The matrix power of the channel. Args: n (int): compute the matrix power of the superoperator matrix. Returns: Choi: the matrix power of the SuperOp converted to a Choi channel. Raises: QiskitError: if the input and output dimensions of the Quan...
qiskit/quantum_info/operators/channel/choi.py
def power(self, n): """The matrix power of the channel. Args: n (int): compute the matrix power of the superoperator matrix. Returns: Choi: the matrix power of the SuperOp converted to a Choi channel. Raises: QiskitError: if the input and output dim...
def power(self, n): """The matrix power of the channel. Args: n (int): compute the matrix power of the superoperator matrix. Returns: Choi: the matrix power of the SuperOp converted to a Choi channel. Raises: QiskitError: if the input and output dim...
[ "The", "matrix", "power", "of", "the", "channel", "." ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/quantum_info/operators/channel/choi.py#L187-L202
[ "def", "power", "(", "self", ",", "n", ")", ":", "if", "n", ">", "0", ":", "return", "super", "(", ")", ".", "power", "(", "n", ")", "return", "Choi", "(", "SuperOp", "(", "self", ")", ".", "power", "(", "n", ")", ")" ]
d4f58d903bc96341b816f7c35df936d6421267d1
test
Choi._evolve
Evolve a quantum state by the QuantumChannel. Args: state (QuantumState): The input statevector or density matrix. qargs (list): a list of QuantumState subsystem positions to apply the operator on. Returns: DensityMatrix: the output quantu...
qiskit/quantum_info/operators/channel/choi.py
def _evolve(self, state, qargs=None): """Evolve a quantum state by the QuantumChannel. Args: state (QuantumState): The input statevector or density matrix. qargs (list): a list of QuantumState subsystem positions to apply the operator on. Retu...
def _evolve(self, state, qargs=None): """Evolve a quantum state by the QuantumChannel. Args: state (QuantumState): The input statevector or density matrix. qargs (list): a list of QuantumState subsystem positions to apply the operator on. Retu...
[ "Evolve", "a", "quantum", "state", "by", "the", "QuantumChannel", "." ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/quantum_info/operators/channel/choi.py#L288-L313
[ "def", "_evolve", "(", "self", ",", "state", ",", "qargs", "=", "None", ")", ":", "# If subsystem evolution we use the SuperOp representation", "if", "qargs", "is", "not", "None", ":", "return", "SuperOp", "(", "self", ")", ".", "_evolve", "(", "state", ",", ...
d4f58d903bc96341b816f7c35df936d6421267d1
test
Choi._tensor_product
Return the tensor product channel. Args: other (QuantumChannel): a quantum channel. reverse (bool): If False return self ⊗ other, if True return if True return (other ⊗ self) [Default: False Returns: Choi: the tensor product channel as a C...
qiskit/quantum_info/operators/channel/choi.py
def _tensor_product(self, other, reverse=False): """Return the tensor product channel. Args: other (QuantumChannel): a quantum channel. reverse (bool): If False return self ⊗ other, if True return if True return (other ⊗ self) [Default: False ...
def _tensor_product(self, other, reverse=False): """Return the tensor product channel. Args: other (QuantumChannel): a quantum channel. reverse (bool): If False return self ⊗ other, if True return if True return (other ⊗ self) [Default: False ...
[ "Return", "the", "tensor", "product", "channel", "." ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/quantum_info/operators/channel/choi.py#L315-L348
[ "def", "_tensor_product", "(", "self", ",", "other", ",", "reverse", "=", "False", ")", ":", "# Convert other to Choi", "if", "not", "isinstance", "(", "other", ",", "Choi", ")", ":", "other", "=", "Choi", "(", "other", ")", "if", "reverse", ":", "input_...
d4f58d903bc96341b816f7c35df936d6421267d1
test
_get_register_specs
Get the number and size of unique registers from bit_labels list. Args: bit_labels (list): this list is of the form:: [['reg1', 0], ['reg1', 1], ['reg2', 0]] which indicates a register named "reg1" of size 2 and a register named "reg2" of size 1. This is the ...
qiskit/visualization/latex.py
def _get_register_specs(bit_labels): """Get the number and size of unique registers from bit_labels list. Args: bit_labels (list): this list is of the form:: [['reg1', 0], ['reg1', 1], ['reg2', 0]] which indicates a register named "reg1" of size 2 and a register na...
def _get_register_specs(bit_labels): """Get the number and size of unique registers from bit_labels list. Args: bit_labels (list): this list is of the form:: [['reg1', 0], ['reg1', 1], ['reg2', 0]] which indicates a register named "reg1" of size 2 and a register na...
[ "Get", "the", "number", "and", "size", "of", "unique", "registers", "from", "bit_labels", "list", "." ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/visualization/latex.py#L748-L766
[ "def", "_get_register_specs", "(", "bit_labels", ")", ":", "it", "=", "itertools", ".", "groupby", "(", "bit_labels", ",", "operator", ".", "itemgetter", "(", "0", ")", ")", "for", "register_name", ",", "sub_it", "in", "it", ":", "yield", "register_name", ...
d4f58d903bc96341b816f7c35df936d6421267d1
test
_truncate_float
Truncate long floats Args: matchobj (re.Match): contains original float format_str (str): format specifier Returns: str: returns truncated float
qiskit/visualization/latex.py
def _truncate_float(matchobj, format_str='0.2g'): """Truncate long floats Args: matchobj (re.Match): contains original float format_str (str): format specifier Returns: str: returns truncated float """ if matchobj.group(0): return format(float(matchobj.group(0)), form...
def _truncate_float(matchobj, format_str='0.2g'): """Truncate long floats Args: matchobj (re.Match): contains original float format_str (str): format specifier Returns: str: returns truncated float """ if matchobj.group(0): return format(float(matchobj.group(0)), form...
[ "Truncate", "long", "floats" ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/visualization/latex.py#L769-L780
[ "def", "_truncate_float", "(", "matchobj", ",", "format_str", "=", "'0.2g'", ")", ":", "if", "matchobj", ".", "group", "(", "0", ")", ":", "return", "format", "(", "float", "(", "matchobj", ".", "group", "(", "0", ")", ")", ",", "format_str", ")", "r...
d4f58d903bc96341b816f7c35df936d6421267d1
test
QCircuitImage.latex
Return LaTeX string representation of circuit. This method uses the LaTeX Qconfig package to create a graphical representation of the circuit. Returns: string: for writing to a LaTeX file.
qiskit/visualization/latex.py
def latex(self, aliases=None): """Return LaTeX string representation of circuit. This method uses the LaTeX Qconfig package to create a graphical representation of the circuit. Returns: string: for writing to a LaTeX file. """ self._initialize_latex_array(al...
def latex(self, aliases=None): """Return LaTeX string representation of circuit. This method uses the LaTeX Qconfig package to create a graphical representation of the circuit. Returns: string: for writing to a LaTeX file. """ self._initialize_latex_array(al...
[ "Return", "LaTeX", "string", "representation", "of", "circuit", "." ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/visualization/latex.py#L119-L179
[ "def", "latex", "(", "self", ",", "aliases", "=", "None", ")", ":", "self", ".", "_initialize_latex_array", "(", "aliases", ")", "self", ".", "_build_latex_array", "(", "aliases", ")", "header_1", "=", "r\"\"\"% \\documentclass[preview]{standalone}\n% If the image is ...
d4f58d903bc96341b816f7c35df936d6421267d1
test
QCircuitImage._get_image_depth
Get depth information for the circuit. Returns: int: number of columns in the circuit int: total size of columns in the circuit
qiskit/visualization/latex.py
def _get_image_depth(self): """Get depth information for the circuit. Returns: int: number of columns in the circuit int: total size of columns in the circuit """ max_column_widths = [] for layer in self.ops: # store the max width for the l...
def _get_image_depth(self): """Get depth information for the circuit. Returns: int: number of columns in the circuit int: total size of columns in the circuit """ max_column_widths = [] for layer in self.ops: # store the max width for the l...
[ "Get", "depth", "information", "for", "the", "circuit", "." ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/visualization/latex.py#L208-L251
[ "def", "_get_image_depth", "(", "self", ")", ":", "max_column_widths", "=", "[", "]", "for", "layer", "in", "self", ".", "ops", ":", "# store the max width for the layer", "current_max", "=", "0", "for", "op", "in", "layer", ":", "# update current op width", "ar...
d4f58d903bc96341b816f7c35df936d6421267d1
test
QCircuitImage._get_beamer_page
Get height, width & scale attributes for the beamer page. Returns: tuple: (height, width, scale) desirable page attributes
qiskit/visualization/latex.py
def _get_beamer_page(self): """Get height, width & scale attributes for the beamer page. Returns: tuple: (height, width, scale) desirable page attributes """ # PIL python package limits image size to around a quarter gigabyte # this means the beamer image should be l...
def _get_beamer_page(self): """Get height, width & scale attributes for the beamer page. Returns: tuple: (height, width, scale) desirable page attributes """ # PIL python package limits image size to around a quarter gigabyte # this means the beamer image should be l...
[ "Get", "height", "width", "&", "scale", "attributes", "for", "the", "beamer", "page", "." ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/visualization/latex.py#L253-L285
[ "def", "_get_beamer_page", "(", "self", ")", ":", "# PIL python package limits image size to around a quarter gigabyte", "# this means the beamer image should be limited to < 50000", "# if you want to avoid a \"warning\" too, set it to < 25000", "PIL_limit", "=", "40000", "# the beamer latex...
d4f58d903bc96341b816f7c35df936d6421267d1
test
QCircuitImage._build_latex_array
Returns an array of strings containing \\LaTeX for this circuit. If aliases is not None, aliases contains a dict mapping the current qubits in the circuit to new qubit names. We will deduce the register names and sizes from aliases.
qiskit/visualization/latex.py
def _build_latex_array(self, aliases=None): """Returns an array of strings containing \\LaTeX for this circuit. If aliases is not None, aliases contains a dict mapping the current qubits in the circuit to new qubit names. We will deduce the register names and sizes from aliases. ...
def _build_latex_array(self, aliases=None): """Returns an array of strings containing \\LaTeX for this circuit. If aliases is not None, aliases contains a dict mapping the current qubits in the circuit to new qubit names. We will deduce the register names and sizes from aliases. ...
[ "Returns", "an", "array", "of", "strings", "containing", "\\\\", "LaTeX", "for", "this", "circuit", "." ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/visualization/latex.py#L294-L716
[ "def", "_build_latex_array", "(", "self", ",", "aliases", "=", "None", ")", ":", "columns", "=", "1", "# Rename qregs if necessary", "if", "aliases", ":", "qregdata", "=", "{", "}", "for", "q", "in", "aliases", ".", "values", "(", ")", ":", "if", "q", ...
d4f58d903bc96341b816f7c35df936d6421267d1
test
QCircuitImage._get_qubit_index
Get the index number for a quantum bit Args: qubit (tuple): The tuple of the bit of the form (register_name, bit_number) Returns: int: The index in the bit list Raises: VisualizationError: If the bit isn't found
qiskit/visualization/latex.py
def _get_qubit_index(self, qubit): """Get the index number for a quantum bit Args: qubit (tuple): The tuple of the bit of the form (register_name, bit_number) Returns: int: The index in the bit list Raises: VisualizationError: If the bi...
def _get_qubit_index(self, qubit): """Get the index number for a quantum bit Args: qubit (tuple): The tuple of the bit of the form (register_name, bit_number) Returns: int: The index in the bit list Raises: VisualizationError: If the bi...
[ "Get", "the", "index", "number", "for", "a", "quantum", "bit", "Args", ":", "qubit", "(", "tuple", ")", ":", "The", "tuple", "of", "the", "bit", "of", "the", "form", "(", "register_name", "bit_number", ")", "Returns", ":", "int", ":", "The", "index", ...
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/visualization/latex.py#L718-L734
[ "def", "_get_qubit_index", "(", "self", ",", "qubit", ")", ":", "for", "i", ",", "bit", "in", "enumerate", "(", "self", ".", "qubit_list", ")", ":", "if", "qubit", "==", "bit", ":", "qindex", "=", "i", "break", "else", ":", "raise", "exceptions", "."...
d4f58d903bc96341b816f7c35df936d6421267d1
test
_load_schema
Loads the QObj schema for use in future validations. Caches schema in _SCHEMAS module attribute. Args: file_path(str): Path to schema. name(str): Given name for schema. Defaults to file_path filename without schema. Return: schema(dict): Loaded schema.
qiskit/validation/jsonschema/schema_validation.py
def _load_schema(file_path, name=None): """Loads the QObj schema for use in future validations. Caches schema in _SCHEMAS module attribute. Args: file_path(str): Path to schema. name(str): Given name for schema. Defaults to file_path filename without schema. Return: sc...
def _load_schema(file_path, name=None): """Loads the QObj schema for use in future validations. Caches schema in _SCHEMAS module attribute. Args: file_path(str): Path to schema. name(str): Given name for schema. Defaults to file_path filename without schema. Return: sc...
[ "Loads", "the", "QObj", "schema", "for", "use", "in", "future", "validations", "." ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/validation/jsonschema/schema_validation.py#L33-L52
[ "def", "_load_schema", "(", "file_path", ",", "name", "=", "None", ")", ":", "if", "name", "is", "None", ":", "# filename without extension", "name", "=", "os", ".", "path", ".", "splitext", "(", "os", ".", "path", ".", "basename", "(", "file_path", ")",...
d4f58d903bc96341b816f7c35df936d6421267d1
test
_get_validator
Generate validator for JSON schema. Args: name (str): Name for validator. Will be validator key in `_VALIDATORS` dict. schema (dict): JSON schema `dict`. If not provided searches for schema in `_SCHEMAS`. check_schema (bool): Verify schema is valid. validator...
qiskit/validation/jsonschema/schema_validation.py
def _get_validator(name, schema=None, check_schema=True, validator_class=None, **validator_kwargs): """Generate validator for JSON schema. Args: name (str): Name for validator. Will be validator key in `_VALIDATORS` dict. schema (dict): JSON schema `dict`. If not ...
def _get_validator(name, schema=None, check_schema=True, validator_class=None, **validator_kwargs): """Generate validator for JSON schema. Args: name (str): Name for validator. Will be validator key in `_VALIDATORS` dict. schema (dict): JSON schema `dict`. If not ...
[ "Generate", "validator", "for", "JSON", "schema", "." ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/validation/jsonschema/schema_validation.py#L55-L97
[ "def", "_get_validator", "(", "name", ",", "schema", "=", "None", ",", "check_schema", "=", "True", ",", "validator_class", "=", "None", ",", "*", "*", "validator_kwargs", ")", ":", "if", "schema", "is", "None", ":", "try", ":", "schema", "=", "_SCHEMAS"...
d4f58d903bc96341b816f7c35df936d6421267d1
test
_load_schemas_and_validators
Load all default schemas into `_SCHEMAS`.
qiskit/validation/jsonschema/schema_validation.py
def _load_schemas_and_validators(): """Load all default schemas into `_SCHEMAS`.""" schema_base_path = os.path.join(os.path.dirname(__file__), '../..') for name, path in _DEFAULT_SCHEMA_PATHS.items(): _load_schema(os.path.join(schema_base_path, path), name) _get_validator(name)
def _load_schemas_and_validators(): """Load all default schemas into `_SCHEMAS`.""" schema_base_path = os.path.join(os.path.dirname(__file__), '../..') for name, path in _DEFAULT_SCHEMA_PATHS.items(): _load_schema(os.path.join(schema_base_path, path), name) _get_validator(name)
[ "Load", "all", "default", "schemas", "into", "_SCHEMAS", "." ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/validation/jsonschema/schema_validation.py#L100-L105
[ "def", "_load_schemas_and_validators", "(", ")", ":", "schema_base_path", "=", "os", ".", "path", ".", "join", "(", "os", ".", "path", ".", "dirname", "(", "__file__", ")", ",", "'../..'", ")", "for", "name", ",", "path", "in", "_DEFAULT_SCHEMA_PATHS", "."...
d4f58d903bc96341b816f7c35df936d6421267d1
test
validate_json_against_schema
Validates JSON dict against a schema. Args: json_dict (dict): JSON to be validated. schema (dict or str): JSON schema dictionary or the name of one of the standards schemas in Qiskit to validate against it. The list of standard schemas is: ``backend_configuration``, ...
qiskit/validation/jsonschema/schema_validation.py
def validate_json_against_schema(json_dict, schema, err_msg=None): """Validates JSON dict against a schema. Args: json_dict (dict): JSON to be validated. schema (dict or str): JSON schema dictionary or the name of one of the standards schemas in Qisk...
def validate_json_against_schema(json_dict, schema, err_msg=None): """Validates JSON dict against a schema. Args: json_dict (dict): JSON to be validated. schema (dict or str): JSON schema dictionary or the name of one of the standards schemas in Qisk...
[ "Validates", "JSON", "dict", "against", "a", "schema", "." ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/validation/jsonschema/schema_validation.py#L112-L145
[ "def", "validate_json_against_schema", "(", "json_dict", ",", "schema", ",", "err_msg", "=", "None", ")", ":", "try", ":", "if", "isinstance", "(", "schema", ",", "str", ")", ":", "schema_name", "=", "schema", "schema", "=", "_SCHEMAS", "[", "schema_name", ...
d4f58d903bc96341b816f7c35df936d6421267d1
test
_format_causes
Return a cascading explanation of the validation error. Returns a cascading explanation of the validation error in the form of:: <validator> failed @ <subfield_path> because of: <validator> failed @ <subfield_path> because of: ... <validator> failed @ <subfield_path...
qiskit/validation/jsonschema/schema_validation.py
def _format_causes(err, level=0): """Return a cascading explanation of the validation error. Returns a cascading explanation of the validation error in the form of:: <validator> failed @ <subfield_path> because of: <validator> failed @ <subfield_path> because of: ... ...
def _format_causes(err, level=0): """Return a cascading explanation of the validation error. Returns a cascading explanation of the validation error in the form of:: <validator> failed @ <subfield_path> because of: <validator> failed @ <subfield_path> because of: ... ...
[ "Return", "a", "cascading", "explanation", "of", "the", "validation", "error", "." ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/validation/jsonschema/schema_validation.py#L148-L211
[ "def", "_format_causes", "(", "err", ",", "level", "=", "0", ")", ":", "lines", "=", "[", "]", "def", "_print", "(", "string", ",", "offset", "=", "0", ")", ":", "lines", ".", "append", "(", "_pad", "(", "string", ",", "offset", "=", "offset", ")...
d4f58d903bc96341b816f7c35df936d6421267d1
test
IdList.qasm
Return the corresponding OPENQASM string.
qiskit/qasm/node/idlist.py
def qasm(self, prec=15): """Return the corresponding OPENQASM string.""" return ",".join([self.children[j].qasm(prec) for j in range(self.size())])
def qasm(self, prec=15): """Return the corresponding OPENQASM string.""" return ",".join([self.children[j].qasm(prec) for j in range(self.size())])
[ "Return", "the", "corresponding", "OPENQASM", "string", "." ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/qasm/node/idlist.py#L27-L30
[ "def", "qasm", "(", "self", ",", "prec", "=", "15", ")", ":", "return", "\",\"", ".", "join", "(", "[", "self", ".", "children", "[", "j", "]", ".", "qasm", "(", "prec", ")", "for", "j", "in", "range", "(", "self", ".", "size", "(", ")", ")",...
d4f58d903bc96341b816f7c35df936d6421267d1
test
majority
Majority gate.
examples/python/rippleadd.py
def majority(p, a, b, c): """Majority gate.""" p.cx(c, b) p.cx(c, a) p.ccx(a, b, c)
def majority(p, a, b, c): """Majority gate.""" p.cx(c, b) p.cx(c, a) p.ccx(a, b, c)
[ "Majority", "gate", "." ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/examples/python/rippleadd.py#L40-L44
[ "def", "majority", "(", "p", ",", "a", ",", "b", ",", "c", ")", ":", "p", ".", "cx", "(", "c", ",", "b", ")", "p", ".", "cx", "(", "c", ",", "a", ")", "p", ".", "ccx", "(", "a", ",", "b", ",", "c", ")" ]
d4f58d903bc96341b816f7c35df936d6421267d1
test
unmajority
Unmajority gate.
examples/python/rippleadd.py
def unmajority(p, a, b, c): """Unmajority gate.""" p.ccx(a, b, c) p.cx(c, a) p.cx(a, b)
def unmajority(p, a, b, c): """Unmajority gate.""" p.ccx(a, b, c) p.cx(c, a) p.cx(a, b)
[ "Unmajority", "gate", "." ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/examples/python/rippleadd.py#L47-L51
[ "def", "unmajority", "(", "p", ",", "a", ",", "b", ",", "c", ")", ":", "p", ".", "ccx", "(", "a", ",", "b", ",", "c", ")", "p", ".", "cx", "(", "c", ",", "a", ")", "p", ".", "cx", "(", "a", ",", "b", ")" ]
d4f58d903bc96341b816f7c35df936d6421267d1
test
MergeAdjacentBarriers._collect_potential_merges
Returns a dict of DAGNode : Barrier objects, where the barrier needs to be inserted where the corresponding DAGNode appears in the main DAG
qiskit/transpiler/passes/merge_adjacent_barriers.py
def _collect_potential_merges(dag, barriers): """ Returns a dict of DAGNode : Barrier objects, where the barrier needs to be inserted where the corresponding DAGNode appears in the main DAG """ # if only got 1 or 0 barriers then can't merge if len(barriers) < 2: ...
def _collect_potential_merges(dag, barriers): """ Returns a dict of DAGNode : Barrier objects, where the barrier needs to be inserted where the corresponding DAGNode appears in the main DAG """ # if only got 1 or 0 barriers then can't merge if len(barriers) < 2: ...
[ "Returns", "a", "dict", "of", "DAGNode", ":", "Barrier", "objects", "where", "the", "barrier", "needs", "to", "be", "inserted", "where", "the", "corresponding", "DAGNode", "appears", "in", "the", "main", "DAG" ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/transpiler/passes/merge_adjacent_barriers.py#L76-L143
[ "def", "_collect_potential_merges", "(", "dag", ",", "barriers", ")", ":", "# if only got 1 or 0 barriers then can't merge", "if", "len", "(", "barriers", ")", "<", "2", ":", "return", "None", "# mapping from the node that will be the main barrier to the", "# barrier object t...
d4f58d903bc96341b816f7c35df936d6421267d1
test
circuit_drawer
Draw a quantum circuit to different formats (set by output parameter): 0. text: ASCII art TextDrawing that can be printed in the console. 1. latex: high-quality images, but heavy external software dependencies 2. matplotlib: purely in Python with no external dependencies Args: circuit (QuantumC...
qiskit/visualization/circuit_visualization.py
def circuit_drawer(circuit, scale=0.7, filename=None, style=None, output='text', interactive=False, line_length=None, plot_barriers=True, reverse_bits=False, ...
def circuit_drawer(circuit, scale=0.7, filename=None, style=None, output='text', interactive=False, line_length=None, plot_barriers=True, reverse_bits=False, ...
[ "Draw", "a", "quantum", "circuit", "to", "different", "formats", "(", "set", "by", "output", "parameter", ")", ":", "0", ".", "text", ":", "ASCII", "art", "TextDrawing", "that", "can", "be", "printed", "in", "the", "console", ".", "1", ".", "latex", ":...
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/visualization/circuit_visualization.py#L36-L204
[ "def", "circuit_drawer", "(", "circuit", ",", "scale", "=", "0.7", ",", "filename", "=", "None", ",", "style", "=", "None", ",", "output", "=", "'text'", ",", "interactive", "=", "False", ",", "line_length", "=", "None", ",", "plot_barriers", "=", "True"...
d4f58d903bc96341b816f7c35df936d6421267d1
test
_text_circuit_drawer
Draws a circuit using ascii art. Args: circuit (QuantumCircuit): Input circuit filename (str): optional filename to write the result line_length (int): Optional. Breaks the circuit drawing to this length. This useful when the drawing does not fit in the console. If ...
qiskit/visualization/circuit_visualization.py
def _text_circuit_drawer(circuit, filename=None, line_length=None, reverse_bits=False, plotbarriers=True, justify=None, vertically_compressed=True): """ Draws a circuit using ascii art. Args: circuit (QuantumCircuit): Input circuit filename (str): optional filename t...
def _text_circuit_drawer(circuit, filename=None, line_length=None, reverse_bits=False, plotbarriers=True, justify=None, vertically_compressed=True): """ Draws a circuit using ascii art. Args: circuit (QuantumCircuit): Input circuit filename (str): optional filename t...
[ "Draws", "a", "circuit", "using", "ascii", "art", ".", "Args", ":", "circuit", "(", "QuantumCircuit", ")", ":", "Input", "circuit", "filename", "(", "str", ")", ":", "optional", "filename", "to", "write", "the", "result", "line_length", "(", "int", ")", ...
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/visualization/circuit_visualization.py#L284-L315
[ "def", "_text_circuit_drawer", "(", "circuit", ",", "filename", "=", "None", ",", "line_length", "=", "None", ",", "reverse_bits", "=", "False", ",", "plotbarriers", "=", "True", ",", "justify", "=", "None", ",", "vertically_compressed", "=", "True", ")", ":...
d4f58d903bc96341b816f7c35df936d6421267d1
test
_latex_circuit_drawer
Draw a quantum circuit based on latex (Qcircuit package) Requires version >=2.6.0 of the qcircuit LaTeX package. Args: circuit (QuantumCircuit): a quantum circuit scale (float): scaling factor filename (str): file path to save image to style (dict or str): dictionary of style o...
qiskit/visualization/circuit_visualization.py
def _latex_circuit_drawer(circuit, scale=0.7, filename=None, style=None, plot_barriers=True, reverse_bits=False, justify=None): """Draw a quantum circuit based ...
def _latex_circuit_drawer(circuit, scale=0.7, filename=None, style=None, plot_barriers=True, reverse_bits=False, justify=None): """Draw a quantum circuit based ...
[ "Draw", "a", "quantum", "circuit", "based", "on", "latex", "(", "Qcircuit", "package", ")" ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/visualization/circuit_visualization.py#L323-L398
[ "def", "_latex_circuit_drawer", "(", "circuit", ",", "scale", "=", "0.7", ",", "filename", "=", "None", ",", "style", "=", "None", ",", "plot_barriers", "=", "True", ",", "reverse_bits", "=", "False", ",", "justify", "=", "None", ")", ":", "tmpfilename", ...
d4f58d903bc96341b816f7c35df936d6421267d1
test
_generate_latex_source
Convert QuantumCircuit to LaTeX string. Args: circuit (QuantumCircuit): input circuit scale (float): image scaling filename (str): optional filename to write latex style (dict or str): dictionary of style or file name of style file reverse_bits (bool): When set to True rever...
qiskit/visualization/circuit_visualization.py
def _generate_latex_source(circuit, filename=None, scale=0.7, style=None, reverse_bits=False, plot_barriers=True, justify=None): """Convert QuantumCircuit to LaTeX string. Args: circuit (QuantumCircuit): input circuit scale (float): image sc...
def _generate_latex_source(circuit, filename=None, scale=0.7, style=None, reverse_bits=False, plot_barriers=True, justify=None): """Convert QuantumCircuit to LaTeX string. Args: circuit (QuantumCircuit): input circuit scale (float): image sc...
[ "Convert", "QuantumCircuit", "to", "LaTeX", "string", "." ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/visualization/circuit_visualization.py#L401-L433
[ "def", "_generate_latex_source", "(", "circuit", ",", "filename", "=", "None", ",", "scale", "=", "0.7", ",", "style", "=", "None", ",", "reverse_bits", "=", "False", ",", "plot_barriers", "=", "True", ",", "justify", "=", "None", ")", ":", "qregs", ",",...
d4f58d903bc96341b816f7c35df936d6421267d1
test
_matplotlib_circuit_drawer
Draw a quantum circuit based on matplotlib. If `%matplotlib inline` is invoked in a Jupyter notebook, it visualizes a circuit inline. We recommend `%config InlineBackend.figure_format = 'svg'` for the inline visualization. Args: circuit (QuantumCircuit): a quantum circuit scale (float): sca...
qiskit/visualization/circuit_visualization.py
def _matplotlib_circuit_drawer(circuit, scale=0.7, filename=None, style=None, plot_barriers=True, reverse_bits=False, justify=None): ...
def _matplotlib_circuit_drawer(circuit, scale=0.7, filename=None, style=None, plot_barriers=True, reverse_bits=False, justify=None): ...
[ "Draw", "a", "quantum", "circuit", "based", "on", "matplotlib", ".", "If", "%matplotlib", "inline", "is", "invoked", "in", "a", "Jupyter", "notebook", "it", "visualizes", "a", "circuit", "inline", ".", "We", "recommend", "%config", "InlineBackend", ".", "figur...
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/visualization/circuit_visualization.py#L441-L475
[ "def", "_matplotlib_circuit_drawer", "(", "circuit", ",", "scale", "=", "0.7", ",", "filename", "=", "None", ",", "style", "=", "None", ",", "plot_barriers", "=", "True", ",", "reverse_bits", "=", "False", ",", "justify", "=", "None", ")", ":", "qregs", ...
d4f58d903bc96341b816f7c35df936d6421267d1
test
random_state
Return a random quantum state from the uniform (Haar) measure on state space. Args: dim (int): the dim of the state spaxe seed (int): Optional. To set a random seed. Returns: ndarray: state(2**num) a random quantum state.
qiskit/quantum_info/random/utils.py
def random_state(dim, seed=None): """ Return a random quantum state from the uniform (Haar) measure on state space. Args: dim (int): the dim of the state spaxe seed (int): Optional. To set a random seed. Returns: ndarray: state(2**num) a random quantum state. """ i...
def random_state(dim, seed=None): """ Return a random quantum state from the uniform (Haar) measure on state space. Args: dim (int): the dim of the state spaxe seed (int): Optional. To set a random seed. Returns: ndarray: state(2**num) a random quantum state. """ i...
[ "Return", "a", "random", "quantum", "state", "from", "the", "uniform", "(", "Haar", ")", "measure", "on", "state", "space", "." ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/quantum_info/random/utils.py#L23-L44
[ "def", "random_state", "(", "dim", ",", "seed", "=", "None", ")", ":", "if", "seed", "is", "None", ":", "seed", "=", "np", ".", "random", ".", "randint", "(", "0", ",", "np", ".", "iinfo", "(", "np", ".", "int32", ")", ".", "max", ")", "rng", ...
d4f58d903bc96341b816f7c35df936d6421267d1
test
random_unitary
Return a random dim x dim unitary Operator from the Haar measure. Args: dim (int): the dim of the state space. seed (int): Optional. To set a random seed. Returns: Operator: (dim, dim) unitary operator. Raises: QiskitError: if dim is not a positive power of 2.
qiskit/quantum_info/random/utils.py
def random_unitary(dim, seed=None): """ Return a random dim x dim unitary Operator from the Haar measure. Args: dim (int): the dim of the state space. seed (int): Optional. To set a random seed. Returns: Operator: (dim, dim) unitary operator. Raises: QiskitError: i...
def random_unitary(dim, seed=None): """ Return a random dim x dim unitary Operator from the Haar measure. Args: dim (int): the dim of the state space. seed (int): Optional. To set a random seed. Returns: Operator: (dim, dim) unitary operator. Raises: QiskitError: i...
[ "Return", "a", "random", "dim", "x", "dim", "unitary", "Operator", "from", "the", "Haar", "measure", "." ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/quantum_info/random/utils.py#L47-L78
[ "def", "random_unitary", "(", "dim", ",", "seed", "=", "None", ")", ":", "if", "dim", "==", "0", "or", "not", "math", ".", "log2", "(", "dim", ")", ".", "is_integer", "(", ")", ":", "raise", "QiskitError", "(", "\"Desired unitary dimension not a positive p...
d4f58d903bc96341b816f7c35df936d6421267d1
test
random_density_matrix
Generate a random density matrix rho. Args: length (int): the length of the density matrix. rank (int or None): the rank of the density matrix. The default value is full-rank. method (string): the method to use. 'Hilbert-Schmidt': sample rho from the Hilbert-Schmidt ...
qiskit/quantum_info/random/utils.py
def random_density_matrix(length, rank=None, method='Hilbert-Schmidt', seed=None): """ Generate a random density matrix rho. Args: length (int): the length of the density matrix. rank (int or None): the rank of the density matrix. The default value is full-rank. method (...
def random_density_matrix(length, rank=None, method='Hilbert-Schmidt', seed=None): """ Generate a random density matrix rho. Args: length (int): the length of the density matrix. rank (int or None): the rank of the density matrix. The default value is full-rank. method (...
[ "Generate", "a", "random", "density", "matrix", "rho", "." ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/quantum_info/random/utils.py#L82-L104
[ "def", "random_density_matrix", "(", "length", ",", "rank", "=", "None", ",", "method", "=", "'Hilbert-Schmidt'", ",", "seed", "=", "None", ")", ":", "if", "method", "==", "'Hilbert-Schmidt'", ":", "return", "__random_density_hs", "(", "length", ",", "rank", ...
d4f58d903bc96341b816f7c35df936d6421267d1
test
__ginibre_matrix
Return a normally distributed complex random matrix. Args: nrow (int): number of rows in output matrix. ncol (int): number of columns in output matrix. seed (int): Optional. To set a random seed. Returns: ndarray: A complex rectangular matrix where each real and imaginary ...
qiskit/quantum_info/random/utils.py
def __ginibre_matrix(nrow, ncol=None, seed=None): """ Return a normally distributed complex random matrix. Args: nrow (int): number of rows in output matrix. ncol (int): number of columns in output matrix. seed (int): Optional. To set a random seed. Returns: ndarray: A c...
def __ginibre_matrix(nrow, ncol=None, seed=None): """ Return a normally distributed complex random matrix. Args: nrow (int): number of rows in output matrix. ncol (int): number of columns in output matrix. seed (int): Optional. To set a random seed. Returns: ndarray: A c...
[ "Return", "a", "normally", "distributed", "complex", "random", "matrix", "." ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/quantum_info/random/utils.py#L107-L125
[ "def", "__ginibre_matrix", "(", "nrow", ",", "ncol", "=", "None", ",", "seed", "=", "None", ")", ":", "if", "ncol", "is", "None", ":", "ncol", "=", "nrow", "if", "seed", "is", "not", "None", ":", "np", ".", "random", ".", "seed", "(", "seed", ")"...
d4f58d903bc96341b816f7c35df936d6421267d1
test
__random_density_hs
Generate a random density matrix from the Hilbert-Schmidt metric. Args: N (int): the length of the density matrix. rank (int or None): the rank of the density matrix. The default value is full-rank. seed (int): Optional. To set a random seed. Returns: ndarray: rho (N...
qiskit/quantum_info/random/utils.py
def __random_density_hs(N, rank=None, seed=None): """ Generate a random density matrix from the Hilbert-Schmidt metric. Args: N (int): the length of the density matrix. rank (int or None): the rank of the density matrix. The default value is full-rank. seed (int): Option...
def __random_density_hs(N, rank=None, seed=None): """ Generate a random density matrix from the Hilbert-Schmidt metric. Args: N (int): the length of the density matrix. rank (int or None): the rank of the density matrix. The default value is full-rank. seed (int): Option...
[ "Generate", "a", "random", "density", "matrix", "from", "the", "Hilbert", "-", "Schmidt", "metric", "." ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/quantum_info/random/utils.py#L128-L142
[ "def", "__random_density_hs", "(", "N", ",", "rank", "=", "None", ",", "seed", "=", "None", ")", ":", "G", "=", "__ginibre_matrix", "(", "N", ",", "rank", ",", "seed", ")", "G", "=", "G", ".", "dot", "(", "G", ".", "conj", "(", ")", ".", "T", ...
d4f58d903bc96341b816f7c35df936d6421267d1
test
__random_density_bures
Generate a random density matrix from the Bures metric. Args: N (int): the length of the density matrix. rank (int or None): the rank of the density matrix. The default value is full-rank. seed (int): Optional. To set a random seed. Returns: ndarray: rho (N,N) a dens...
qiskit/quantum_info/random/utils.py
def __random_density_bures(N, rank=None, seed=None): """ Generate a random density matrix from the Bures metric. Args: N (int): the length of the density matrix. rank (int or None): the rank of the density matrix. The default value is full-rank. seed (int): Optional. To ...
def __random_density_bures(N, rank=None, seed=None): """ Generate a random density matrix from the Bures metric. Args: N (int): the length of the density matrix. rank (int or None): the rank of the density matrix. The default value is full-rank. seed (int): Optional. To ...
[ "Generate", "a", "random", "density", "matrix", "from", "the", "Bures", "metric", "." ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/quantum_info/random/utils.py#L145-L160
[ "def", "__random_density_bures", "(", "N", ",", "rank", "=", "None", ",", "seed", "=", "None", ")", ":", "P", "=", "np", ".", "eye", "(", "N", ")", "+", "random_unitary", "(", "N", ")", ".", "data", "G", "=", "P", ".", "dot", "(", "__ginibre_matr...
d4f58d903bc96341b816f7c35df936d6421267d1
test
GateBody.qasm
Return the corresponding OPENQASM string.
qiskit/qasm/node/gatebody.py
def qasm(self, prec=15): """Return the corresponding OPENQASM string.""" string = "" for children in self.children: string += " " + children.qasm(prec) + "\n" return string
def qasm(self, prec=15): """Return the corresponding OPENQASM string.""" string = "" for children in self.children: string += " " + children.qasm(prec) + "\n" return string
[ "Return", "the", "corresponding", "OPENQASM", "string", "." ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/qasm/node/gatebody.py#L24-L29
[ "def", "qasm", "(", "self", ",", "prec", "=", "15", ")", ":", "string", "=", "\"\"", "for", "children", "in", "self", ".", "children", ":", "string", "+=", "\" \"", "+", "children", ".", "qasm", "(", "prec", ")", "+", "\"\\n\"", "return", "string" ]
d4f58d903bc96341b816f7c35df936d6421267d1
test
GateBody.calls
Return a list of custom gate names in this gate body.
qiskit/qasm/node/gatebody.py
def calls(self): """Return a list of custom gate names in this gate body.""" lst = [] for children in self.children: if children.type == "custom_unitary": lst.append(children.name) return lst
def calls(self): """Return a list of custom gate names in this gate body.""" lst = [] for children in self.children: if children.type == "custom_unitary": lst.append(children.name) return lst
[ "Return", "a", "list", "of", "custom", "gate", "names", "in", "this", "gate", "body", "." ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/qasm/node/gatebody.py#L31-L37
[ "def", "calls", "(", "self", ")", ":", "lst", "=", "[", "]", "for", "children", "in", "self", ".", "children", ":", "if", "children", ".", "type", "==", "\"custom_unitary\"", ":", "lst", ".", "append", "(", "children", ".", "name", ")", "return", "ls...
d4f58d903bc96341b816f7c35df936d6421267d1
test
Real.qasm
Return the corresponding OPENQASM string.
qiskit/qasm/node/real.py
def qasm(self, prec=15): """Return the corresponding OPENQASM string.""" if self.value == pi: return "pi" return ccode(self.value, precision=prec)
def qasm(self, prec=15): """Return the corresponding OPENQASM string.""" if self.value == pi: return "pi" return ccode(self.value, precision=prec)
[ "Return", "the", "corresponding", "OPENQASM", "string", "." ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/qasm/node/real.py#L32-L37
[ "def", "qasm", "(", "self", ",", "prec", "=", "15", ")", ":", "if", "self", ".", "value", "==", "pi", ":", "return", "\"pi\"", "return", "ccode", "(", "self", ".", "value", ",", "precision", "=", "prec", ")" ]
d4f58d903bc96341b816f7c35df936d6421267d1
test
SdgGate._define
gate sdg a { u1(-pi/2) a; }
qiskit/extensions/standard/s.py
def _define(self): """ gate sdg a { u1(-pi/2) a; } """ definition = [] q = QuantumRegister(1, "q") rule = [ (U1Gate(-pi/2), [q[0]], []) ] for inst in rule: definition.append(inst) self.definition = definition
def _define(self): """ gate sdg a { u1(-pi/2) a; } """ definition = [] q = QuantumRegister(1, "q") rule = [ (U1Gate(-pi/2), [q[0]], []) ] for inst in rule: definition.append(inst) self.definition = definition
[ "gate", "sdg", "a", "{", "u1", "(", "-", "pi", "/", "2", ")", "a", ";", "}" ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/extensions/standard/s.py#L60-L71
[ "def", "_define", "(", "self", ")", ":", "definition", "=", "[", "]", "q", "=", "QuantumRegister", "(", "1", ",", "\"q\"", ")", "rule", "=", "[", "(", "U1Gate", "(", "-", "pi", "/", "2", ")", ",", "[", "q", "[", "0", "]", "]", ",", "[", "]"...
d4f58d903bc96341b816f7c35df936d6421267d1
test
Chi.compose
Return the composition channel self∘other. Args: other (QuantumChannel): a quantum channel. qargs (list): a list of subsystem positions to compose other on. front (bool): If False compose in standard order other(self(input)) otherwise compose in rev...
qiskit/quantum_info/operators/channel/chi.py
def compose(self, other, qargs=None, front=False): """Return the composition channel self∘other. Args: other (QuantumChannel): a quantum channel. qargs (list): a list of subsystem positions to compose other on. front (bool): If False compose in standard order other(s...
def compose(self, other, qargs=None, front=False): """Return the composition channel self∘other. Args: other (QuantumChannel): a quantum channel. qargs (list): a list of subsystem positions to compose other on. front (bool): If False compose in standard order other(s...
[ "Return", "the", "composition", "channel", "self∘other", "." ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/quantum_info/operators/channel/chi.py#L136-L169
[ "def", "compose", "(", "self", ",", "other", ",", "qargs", "=", "None", ",", "front", "=", "False", ")", ":", "if", "qargs", "is", "not", "None", ":", "return", "Chi", "(", "SuperOp", "(", "self", ")", ".", "compose", "(", "other", ",", "qargs", ...
d4f58d903bc96341b816f7c35df936d6421267d1
test
Chi.power
The matrix power of the channel. Args: n (int): compute the matrix power of the superoperator matrix. Returns: Chi: the matrix power of the SuperOp converted to a Chi channel. Raises: QiskitError: if the input and output dimensions of the Quantu...
qiskit/quantum_info/operators/channel/chi.py
def power(self, n): """The matrix power of the channel. Args: n (int): compute the matrix power of the superoperator matrix. Returns: Chi: the matrix power of the SuperOp converted to a Chi channel. Raises: QiskitError: if the input and output dimen...
def power(self, n): """The matrix power of the channel. Args: n (int): compute the matrix power of the superoperator matrix. Returns: Chi: the matrix power of the SuperOp converted to a Chi channel. Raises: QiskitError: if the input and output dimen...
[ "The", "matrix", "power", "of", "the", "channel", "." ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/quantum_info/operators/channel/chi.py#L171-L186
[ "def", "power", "(", "self", ",", "n", ")", ":", "if", "n", ">", "0", ":", "return", "super", "(", ")", ".", "power", "(", "n", ")", "return", "Chi", "(", "SuperOp", "(", "self", ")", ".", "power", "(", "n", ")", ")" ]
d4f58d903bc96341b816f7c35df936d6421267d1
test
Chi.add
Return the QuantumChannel self + other. Args: other (QuantumChannel): a quantum channel. Returns: Chi: the linear addition self + other as a Chi object. Raises: QiskitError: if other is not a QuantumChannel subclass, or has incompatible dimensio...
qiskit/quantum_info/operators/channel/chi.py
def add(self, other): """Return the QuantumChannel self + other. Args: other (QuantumChannel): a quantum channel. Returns: Chi: the linear addition self + other as a Chi object. Raises: QiskitError: if other is not a QuantumChannel subclass, or ...
def add(self, other): """Return the QuantumChannel self + other. Args: other (QuantumChannel): a quantum channel. Returns: Chi: the linear addition self + other as a Chi object. Raises: QiskitError: if other is not a QuantumChannel subclass, or ...
[ "Return", "the", "QuantumChannel", "self", "+", "other", "." ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/quantum_info/operators/channel/chi.py#L216-L234
[ "def", "add", "(", "self", ",", "other", ")", ":", "if", "not", "isinstance", "(", "other", ",", "Chi", ")", ":", "other", "=", "Chi", "(", "other", ")", "if", "self", ".", "dim", "!=", "other", ".", "dim", ":", "raise", "QiskitError", "(", "\"ot...
d4f58d903bc96341b816f7c35df936d6421267d1
test
Chi.multiply
Return the QuantumChannel self + other. Args: other (complex): a complex number. Returns: Chi: the scalar multiplication other * self as a Chi object. Raises: QiskitError: if other is not a valid scalar.
qiskit/quantum_info/operators/channel/chi.py
def multiply(self, other): """Return the QuantumChannel self + other. Args: other (complex): a complex number. Returns: Chi: the scalar multiplication other * self as a Chi object. Raises: QiskitError: if other is not a valid scalar. """ ...
def multiply(self, other): """Return the QuantumChannel self + other. Args: other (complex): a complex number. Returns: Chi: the scalar multiplication other * self as a Chi object. Raises: QiskitError: if other is not a valid scalar. """ ...
[ "Return", "the", "QuantumChannel", "self", "+", "other", "." ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/quantum_info/operators/channel/chi.py#L256-L270
[ "def", "multiply", "(", "self", ",", "other", ")", ":", "if", "not", "isinstance", "(", "other", ",", "Number", ")", ":", "raise", "QiskitError", "(", "\"other is not a number\"", ")", "return", "Chi", "(", "other", "*", "self", ".", "_data", ",", "self"...
d4f58d903bc96341b816f7c35df936d6421267d1
test
Chi._tensor_product
Return the tensor product channel. Args: other (QuantumChannel): a quantum channel. reverse (bool): If False return self ⊗ other, if True return if True return (other ⊗ self) [Default: False Returns: Chi: the tensor product channel as a Ch...
qiskit/quantum_info/operators/channel/chi.py
def _tensor_product(self, other, reverse=False): """Return the tensor product channel. Args: other (QuantumChannel): a quantum channel. reverse (bool): If False return self ⊗ other, if True return if True return (other ⊗ self) [Default: False ...
def _tensor_product(self, other, reverse=False): """Return the tensor product channel. Args: other (QuantumChannel): a quantum channel. reverse (bool): If False return self ⊗ other, if True return if True return (other ⊗ self) [Default: False ...
[ "Return", "the", "tensor", "product", "channel", "." ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/quantum_info/operators/channel/chi.py#L285-L308
[ "def", "_tensor_product", "(", "self", ",", "other", ",", "reverse", "=", "False", ")", ":", "if", "not", "isinstance", "(", "other", ",", "Chi", ")", ":", "other", "=", "Chi", "(", "other", ")", "if", "reverse", ":", "input_dims", "=", "self", ".", ...
d4f58d903bc96341b816f7c35df936d6421267d1
test
SuperOp.conjugate
Return the conjugate of the QuantumChannel.
qiskit/quantum_info/operators/channel/superop.py
def conjugate(self): """Return the conjugate of the QuantumChannel.""" return SuperOp( np.conj(self._data), self.input_dims(), self.output_dims())
def conjugate(self): """Return the conjugate of the QuantumChannel.""" return SuperOp( np.conj(self._data), self.input_dims(), self.output_dims())
[ "Return", "the", "conjugate", "of", "the", "QuantumChannel", "." ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/quantum_info/operators/channel/superop.py#L117-L120
[ "def", "conjugate", "(", "self", ")", ":", "return", "SuperOp", "(", "np", ".", "conj", "(", "self", ".", "_data", ")", ",", "self", ".", "input_dims", "(", ")", ",", "self", ".", "output_dims", "(", ")", ")" ]
d4f58d903bc96341b816f7c35df936d6421267d1
test
SuperOp.transpose
Return the transpose of the QuantumChannel.
qiskit/quantum_info/operators/channel/superop.py
def transpose(self): """Return the transpose of the QuantumChannel.""" return SuperOp( np.transpose(self._data), input_dims=self.output_dims(), output_dims=self.input_dims())
def transpose(self): """Return the transpose of the QuantumChannel.""" return SuperOp( np.transpose(self._data), input_dims=self.output_dims(), output_dims=self.input_dims())
[ "Return", "the", "transpose", "of", "the", "QuantumChannel", "." ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/quantum_info/operators/channel/superop.py#L122-L127
[ "def", "transpose", "(", "self", ")", ":", "return", "SuperOp", "(", "np", ".", "transpose", "(", "self", ".", "_data", ")", ",", "input_dims", "=", "self", ".", "output_dims", "(", ")", ",", "output_dims", "=", "self", ".", "input_dims", "(", ")", "...
d4f58d903bc96341b816f7c35df936d6421267d1
test
SuperOp.compose
Return the composition channel self∘other. Args: other (QuantumChannel): a quantum channel. qargs (list): a list of subsystem positions to compose other on. front (bool): If False compose in standard order other(self(input)) otherwise compose in rev...
qiskit/quantum_info/operators/channel/superop.py
def compose(self, other, qargs=None, front=False): """Return the composition channel self∘other. Args: other (QuantumChannel): a quantum channel. qargs (list): a list of subsystem positions to compose other on. front (bool): If False compose in standard order other(s...
def compose(self, other, qargs=None, front=False): """Return the composition channel self∘other. Args: other (QuantumChannel): a quantum channel. qargs (list): a list of subsystem positions to compose other on. front (bool): If False compose in standard order other(s...
[ "Return", "the", "composition", "channel", "self∘other", "." ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/quantum_info/operators/channel/superop.py#L129-L171
[ "def", "compose", "(", "self", ",", "other", ",", "qargs", "=", "None", ",", "front", "=", "False", ")", ":", "# Convert other to SuperOp", "if", "not", "isinstance", "(", "other", ",", "SuperOp", ")", ":", "other", "=", "SuperOp", "(", "other", ")", "...
d4f58d903bc96341b816f7c35df936d6421267d1
test
SuperOp.power
Return the compose of a QuantumChannel with itself n times. Args: n (int): compute the matrix power of the superoperator matrix. Returns: SuperOp: the n-times composition channel as a SuperOp object. Raises: QiskitError: if the input and output dimensions o...
qiskit/quantum_info/operators/channel/superop.py
def power(self, n): """Return the compose of a QuantumChannel with itself n times. Args: n (int): compute the matrix power of the superoperator matrix. Returns: SuperOp: the n-times composition channel as a SuperOp object. Raises: QiskitError: if th...
def power(self, n): """Return the compose of a QuantumChannel with itself n times. Args: n (int): compute the matrix power of the superoperator matrix. Returns: SuperOp: the n-times composition channel as a SuperOp object. Raises: QiskitError: if th...
[ "Return", "the", "compose", "of", "a", "QuantumChannel", "with", "itself", "n", "times", "." ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/quantum_info/operators/channel/superop.py#L173-L194
[ "def", "power", "(", "self", ",", "n", ")", ":", "if", "not", "isinstance", "(", "n", ",", "(", "int", ",", "np", ".", "integer", ")", ")", ":", "raise", "QiskitError", "(", "\"Can only power with integer powers.\"", ")", "if", "self", ".", "_input_dim",...
d4f58d903bc96341b816f7c35df936d6421267d1
test
SuperOp.add
Return the QuantumChannel self + other. Args: other (QuantumChannel): a quantum channel. Returns: SuperOp: the linear addition self + other as a SuperOp object. Raises: QiskitError: if other cannot be converted to a channel or has incompatible d...
qiskit/quantum_info/operators/channel/superop.py
def add(self, other): """Return the QuantumChannel self + other. Args: other (QuantumChannel): a quantum channel. Returns: SuperOp: the linear addition self + other as a SuperOp object. Raises: QiskitError: if other cannot be converted to a channel ...
def add(self, other): """Return the QuantumChannel self + other. Args: other (QuantumChannel): a quantum channel. Returns: SuperOp: the linear addition self + other as a SuperOp object. Raises: QiskitError: if other cannot be converted to a channel ...
[ "Return", "the", "QuantumChannel", "self", "+", "other", "." ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/quantum_info/operators/channel/superop.py#L226-L245
[ "def", "add", "(", "self", ",", "other", ")", ":", "# Convert other to SuperOp", "if", "not", "isinstance", "(", "other", ",", "SuperOp", ")", ":", "other", "=", "SuperOp", "(", "other", ")", "if", "self", ".", "dim", "!=", "other", ".", "dim", ":", ...
d4f58d903bc96341b816f7c35df936d6421267d1
test
SuperOp.multiply
Return the QuantumChannel self + other. Args: other (complex): a complex number. Returns: SuperOp: the scalar multiplication other * self as a SuperOp object. Raises: QiskitError: if other is not a valid scalar.
qiskit/quantum_info/operators/channel/superop.py
def multiply(self, other): """Return the QuantumChannel self + other. Args: other (complex): a complex number. Returns: SuperOp: the scalar multiplication other * self as a SuperOp object. Raises: QiskitError: if other is not a valid scalar. ...
def multiply(self, other): """Return the QuantumChannel self + other. Args: other (complex): a complex number. Returns: SuperOp: the scalar multiplication other * self as a SuperOp object. Raises: QiskitError: if other is not a valid scalar. ...
[ "Return", "the", "QuantumChannel", "self", "+", "other", "." ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/quantum_info/operators/channel/superop.py#L268-L283
[ "def", "multiply", "(", "self", ",", "other", ")", ":", "if", "not", "isinstance", "(", "other", ",", "Number", ")", ":", "raise", "QiskitError", "(", "\"other is not a number\"", ")", "return", "SuperOp", "(", "other", "*", "self", ".", "_data", ",", "s...
d4f58d903bc96341b816f7c35df936d6421267d1
test
SuperOp._evolve
Evolve a quantum state by the QuantumChannel. Args: state (QuantumState): The input statevector or density matrix. qargs (list): a list of QuantumState subsystem positions to apply the operator on. Returns: DensityMatrix: the output quantu...
qiskit/quantum_info/operators/channel/superop.py
def _evolve(self, state, qargs=None): """Evolve a quantum state by the QuantumChannel. Args: state (QuantumState): The input statevector or density matrix. qargs (list): a list of QuantumState subsystem positions to apply the operator on. Retu...
def _evolve(self, state, qargs=None): """Evolve a quantum state by the QuantumChannel. Args: state (QuantumState): The input statevector or density matrix. qargs (list): a list of QuantumState subsystem positions to apply the operator on. Retu...
[ "Evolve", "a", "quantum", "state", "by", "the", "QuantumChannel", "." ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/quantum_info/operators/channel/superop.py#L285-L314
[ "def", "_evolve", "(", "self", ",", "state", ",", "qargs", "=", "None", ")", ":", "state", "=", "self", ".", "_format_state", "(", "state", ",", "density_matrix", "=", "True", ")", "if", "qargs", "is", "None", ":", "if", "state", ".", "shape", "[", ...
d4f58d903bc96341b816f7c35df936d6421267d1
test
SuperOp._compose_subsystem
Return the composition channel.
qiskit/quantum_info/operators/channel/superop.py
def _compose_subsystem(self, other, qargs, front=False): """Return the composition channel.""" # Compute tensor contraction indices from qargs input_dims = list(self.input_dims()) output_dims = list(self.output_dims()) if front: num_indices = len(self.input_dims()) ...
def _compose_subsystem(self, other, qargs, front=False): """Return the composition channel.""" # Compute tensor contraction indices from qargs input_dims = list(self.input_dims()) output_dims = list(self.output_dims()) if front: num_indices = len(self.input_dims()) ...
[ "Return", "the", "composition", "channel", "." ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/quantum_info/operators/channel/superop.py#L316-L346
[ "def", "_compose_subsystem", "(", "self", ",", "other", ",", "qargs", ",", "front", "=", "False", ")", ":", "# Compute tensor contraction indices from qargs", "input_dims", "=", "list", "(", "self", ".", "input_dims", "(", ")", ")", "output_dims", "=", "list", ...
d4f58d903bc96341b816f7c35df936d6421267d1
test
SuperOp._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/channel/superop.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/channel/superop.py#L348-L378
[ "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
SuperOp._instruction_to_superop
Convert a QuantumCircuit or Instruction to a SuperOp.
qiskit/quantum_info/operators/channel/superop.py
def _instruction_to_superop(cls, instruction): """Convert a QuantumCircuit or Instruction to a SuperOp.""" # Convert circuit to an instruction if isinstance(instruction, QuantumCircuit): instruction = instruction.to_instruction() # Initialize an identity superoperator of the ...
def _instruction_to_superop(cls, instruction): """Convert a QuantumCircuit or Instruction to a SuperOp.""" # Convert circuit to an instruction if isinstance(instruction, QuantumCircuit): instruction = instruction.to_instruction() # Initialize an identity superoperator of the ...
[ "Convert", "a", "QuantumCircuit", "or", "Instruction", "to", "a", "SuperOp", "." ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/quantum_info/operators/channel/superop.py#L416-L425
[ "def", "_instruction_to_superop", "(", "cls", ",", "instruction", ")", ":", "# Convert circuit to an instruction", "if", "isinstance", "(", "instruction", ",", "QuantumCircuit", ")", ":", "instruction", "=", "instruction", ".", "to_instruction", "(", ")", "# Initializ...
d4f58d903bc96341b816f7c35df936d6421267d1
test
SuperOp._append_instruction
Update the current Operator by apply an instruction.
qiskit/quantum_info/operators/channel/superop.py
def _append_instruction(self, obj, qargs=None): """Update the current Operator by apply an instruction.""" if isinstance(obj, Instruction): chan = None if obj.name == 'reset': # For superoperator evolution we can simulate a reset as # a non-unitary...
def _append_instruction(self, obj, qargs=None): """Update the current Operator by apply an instruction.""" if isinstance(obj, Instruction): chan = None if obj.name == 'reset': # For superoperator evolution we can simulate a reset as # a non-unitary...
[ "Update", "the", "current", "Operator", "by", "apply", "an", "instruction", "." ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/quantum_info/operators/channel/superop.py#L427-L472
[ "def", "_append_instruction", "(", "self", ",", "obj", ",", "qargs", "=", "None", ")", ":", "if", "isinstance", "(", "obj", ",", "Instruction", ")", ":", "chan", "=", "None", "if", "obj", ".", "name", "==", "'reset'", ":", "# For superoperator evolution we...
d4f58d903bc96341b816f7c35df936d6421267d1
test
BarrierBeforeFinalMeasurements.run
Return a circuit with a barrier before last measurements.
qiskit/transpiler/passes/mapping/barrier_before_final_measurements.py
def run(self, dag): """Return a circuit with a barrier before last measurements.""" # Collect DAG nodes which are followed only by barriers or other measures. final_op_types = ['measure', 'barrier'] final_ops = [] for candidate_node in dag.named_nodes(*final_op_types): ...
def run(self, dag): """Return a circuit with a barrier before last measurements.""" # Collect DAG nodes which are followed only by barriers or other measures. final_op_types = ['measure', 'barrier'] final_ops = [] for candidate_node in dag.named_nodes(*final_op_types): ...
[ "Return", "a", "circuit", "with", "a", "barrier", "before", "last", "measurements", "." ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/transpiler/passes/mapping/barrier_before_final_measurements.py#L25-L76
[ "def", "run", "(", "self", ",", "dag", ")", ":", "# Collect DAG nodes which are followed only by barriers or other measures.", "final_op_types", "=", "[", "'measure'", ",", "'barrier'", "]", "final_ops", "=", "[", "]", "for", "candidate_node", "in", "dag", ".", "nam...
d4f58d903bc96341b816f7c35df936d6421267d1
test
circuits_to_qobj
Convert a list of circuits into a qobj. Args: circuits (list[QuantumCircuits] or QuantumCircuit): circuits to compile qobj_header (QobjHeader): header to pass to the results qobj_id (int): TODO: delete after qiskit-terra 0.8 backend_name (str): TODO: delete after qiskit-terra 0.8 ...
qiskit/converters/circuits_to_qobj.py
def circuits_to_qobj(circuits, qobj_header=None, qobj_id=None, backend_name=None, config=None, shots=None, max_credits=None, basis_gates=None, coupling_map=None, seed=None, memory=None): """Convert a list of circuits into a qobj. ...
def circuits_to_qobj(circuits, qobj_header=None, qobj_id=None, backend_name=None, config=None, shots=None, max_credits=None, basis_gates=None, coupling_map=None, seed=None, memory=None): """Convert a list of circuits into a qobj. ...
[ "Convert", "a", "list", "of", "circuits", "into", "a", "qobj", "." ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/converters/circuits_to_qobj.py#L15-L60
[ "def", "circuits_to_qobj", "(", "circuits", ",", "qobj_header", "=", "None", ",", "qobj_id", "=", "None", ",", "backend_name", "=", "None", ",", "config", "=", "None", ",", "shots", "=", "None", ",", "max_credits", "=", "None", ",", "basis_gates", "=", "...
d4f58d903bc96341b816f7c35df936d6421267d1
test
Unroll3qOrMore.run
Expand 3+ qubit gates using their decomposition rules. Args: dag(DAGCircuit): input dag Returns: DAGCircuit: output dag with maximum node degrees of 2 Raises: QiskitError: if a 3q+ gate is not decomposable
qiskit/transpiler/passes/unroll_3q_or_more.py
def run(self, dag): """Expand 3+ qubit gates using their decomposition rules. Args: dag(DAGCircuit): input dag Returns: DAGCircuit: output dag with maximum node degrees of 2 Raises: QiskitError: if a 3q+ gate is not decomposable """ fo...
def run(self, dag): """Expand 3+ qubit gates using their decomposition rules. Args: dag(DAGCircuit): input dag Returns: DAGCircuit: output dag with maximum node degrees of 2 Raises: QiskitError: if a 3q+ gate is not decomposable """ fo...
[ "Expand", "3", "+", "qubit", "gates", "using", "their", "decomposition", "rules", "." ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/transpiler/passes/unroll_3q_or_more.py#L21-L47
[ "def", "run", "(", "self", ",", "dag", ")", ":", "for", "node", "in", "dag", ".", "threeQ_or_more_gates", "(", ")", ":", "# TODO: allow choosing other possible decompositions", "rule", "=", "node", ".", "op", ".", "definition", "if", "not", "rule", ":", "rai...
d4f58d903bc96341b816f7c35df936d6421267d1
test
Decompose.run
Expand a given gate into its decomposition. Args: dag(DAGCircuit): input dag Returns: DAGCircuit: output dag where gate was expanded.
qiskit/transpiler/passes/decompose.py
def run(self, dag): """Expand a given gate into its decomposition. Args: dag(DAGCircuit): input dag Returns: DAGCircuit: output dag where gate was expanded. """ # Walk through the DAG and expand each non-basis node for node in dag.op_nodes(self.ga...
def run(self, dag): """Expand a given gate into its decomposition. Args: dag(DAGCircuit): input dag Returns: DAGCircuit: output dag where gate was expanded. """ # Walk through the DAG and expand each non-basis node for node in dag.op_nodes(self.ga...
[ "Expand", "a", "given", "gate", "into", "its", "decomposition", "." ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/transpiler/passes/decompose.py#L27-L51
[ "def", "run", "(", "self", ",", "dag", ")", ":", "# Walk through the DAG and expand each non-basis node", "for", "node", "in", "dag", ".", "op_nodes", "(", "self", ".", "gate", ")", ":", "# opaque or built-in gates are not decomposable", "if", "not", "node", ".", ...
d4f58d903bc96341b816f7c35df936d6421267d1
test
unitary
Apply u2 to q.
qiskit/extensions/unitary.py
def unitary(self, obj, qubits, label=None): """Apply u2 to q.""" if isinstance(qubits, QuantumRegister): qubits = qubits[:] return self.append(UnitaryGate(obj, label=label), qubits, [])
def unitary(self, obj, qubits, label=None): """Apply u2 to q.""" if isinstance(qubits, QuantumRegister): qubits = qubits[:] return self.append(UnitaryGate(obj, label=label), qubits, [])
[ "Apply", "u2", "to", "q", "." ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/extensions/unitary.py#L102-L106
[ "def", "unitary", "(", "self", ",", "obj", ",", "qubits", ",", "label", "=", "None", ")", ":", "if", "isinstance", "(", "qubits", ",", "QuantumRegister", ")", ":", "qubits", "=", "qubits", "[", ":", "]", "return", "self", ".", "append", "(", "Unitary...
d4f58d903bc96341b816f7c35df936d6421267d1
test
UnitaryGate._define
Calculate a subcircuit that implements this unitary.
qiskit/extensions/unitary.py
def _define(self): """Calculate a subcircuit that implements this unitary.""" if self.num_qubits == 1: q = QuantumRegister(1, "q") angles = euler_angles_1q(self.to_matrix()) self.definition = [(U3Gate(*angles), [q[0]], [])] if self.num_qubits == 2: ...
def _define(self): """Calculate a subcircuit that implements this unitary.""" if self.num_qubits == 1: q = QuantumRegister(1, "q") angles = euler_angles_1q(self.to_matrix()) self.definition = [(U3Gate(*angles), [q[0]], [])] if self.num_qubits == 2: ...
[ "Calculate", "a", "subcircuit", "that", "implements", "this", "unitary", "." ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/extensions/unitary.py#L92-L99
[ "def", "_define", "(", "self", ")", ":", "if", "self", ".", "num_qubits", "==", "1", ":", "q", "=", "QuantumRegister", "(", "1", ",", "\"q\"", ")", "angles", "=", "euler_angles_1q", "(", "self", ".", "to_matrix", "(", ")", ")", "self", ".", "definiti...
d4f58d903bc96341b816f7c35df936d6421267d1
test
Nested.check_type
Validate if the value is of the type of the schema's model. Assumes the nested schema is a ``BaseSchema``.
qiskit/validation/fields/containers.py
def check_type(self, value, attr, data): """Validate if the value is of the type of the schema's model. Assumes the nested schema is a ``BaseSchema``. """ if self.many and not is_collection(value): raise self._not_expected_type( value, Iterable, fields=[self]...
def check_type(self, value, attr, data): """Validate if the value is of the type of the schema's model. Assumes the nested schema is a ``BaseSchema``. """ if self.many and not is_collection(value): raise self._not_expected_type( value, Iterable, fields=[self]...
[ "Validate", "if", "the", "value", "is", "of", "the", "type", "of", "the", "schema", "s", "model", "." ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/validation/fields/containers.py#L26-L49
[ "def", "check_type", "(", "self", ",", "value", ",", "attr", ",", "data", ")", ":", "if", "self", ".", "many", "and", "not", "is_collection", "(", "value", ")", ":", "raise", "self", ".", "_not_expected_type", "(", "value", ",", "Iterable", ",", "field...
d4f58d903bc96341b816f7c35df936d6421267d1
test
List.check_type
Validate if it's a list of valid item-field values. Check if each element in the list can be validated by the item-field passed during construction.
qiskit/validation/fields/containers.py
def check_type(self, value, attr, data): """Validate if it's a list of valid item-field values. Check if each element in the list can be validated by the item-field passed during construction. """ super().check_type(value, attr, data) errors = [] for idx, v in e...
def check_type(self, value, attr, data): """Validate if it's a list of valid item-field values. Check if each element in the list can be validated by the item-field passed during construction. """ super().check_type(value, attr, data) errors = [] for idx, v in e...
[ "Validate", "if", "it", "s", "a", "list", "of", "valid", "item", "-", "field", "values", "." ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/validation/fields/containers.py#L58-L76
[ "def", "check_type", "(", "self", ",", "value", ",", "attr", ",", "data", ")", ":", "super", "(", ")", ".", "check_type", "(", "value", ",", "attr", ",", "data", ")", "errors", "=", "[", "]", "for", "idx", ",", "v", "in", "enumerate", "(", "value...
d4f58d903bc96341b816f7c35df936d6421267d1
test
dag_drawer
Plot the directed acyclic graph (dag) to represent operation dependencies in a quantum circuit. Note this function leverages `pydot <https://github.com/erocarrera/pydot>`_ (via `nxpd <https://github.com/chebee7i/nxpd`_) to generate the graph, which means that having `Graphviz <https://www.graphviz....
qiskit/visualization/dag_visualization.py
def dag_drawer(dag, scale=0.7, filename=None, style='color'): """Plot the directed acyclic graph (dag) to represent operation dependencies in a quantum circuit. Note this function leverages `pydot <https://github.com/erocarrera/pydot>`_ (via `nxpd <https://github.com/chebee7i/nxpd`_) to generate th...
def dag_drawer(dag, scale=0.7, filename=None, style='color'): """Plot the directed acyclic graph (dag) to represent operation dependencies in a quantum circuit. Note this function leverages `pydot <https://github.com/erocarrera/pydot>`_ (via `nxpd <https://github.com/chebee7i/nxpd`_) to generate th...
[ "Plot", "the", "directed", "acyclic", "graph", "(", "dag", ")", "to", "represent", "operation", "dependencies", "in", "a", "quantum", "circuit", "." ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/visualization/dag_visualization.py#L18-L83
[ "def", "dag_drawer", "(", "dag", ",", "scale", "=", "0.7", ",", "filename", "=", "None", ",", "style", "=", "'color'", ")", ":", "try", ":", "import", "nxpd", "import", "pydot", "# pylint: disable=unused-import", "except", "ImportError", ":", "raise", "Impor...
d4f58d903bc96341b816f7c35df936d6421267d1
test
BaseOperator._atol
Set the absolute tolerence parameter for float comparisons.
qiskit/quantum_info/operators/base_operator.py
def _atol(self, atol): """Set the absolute tolerence parameter for float comparisons.""" # NOTE: that this overrides the class value so applies to all # instances of the class. max_tol = self.__class__.MAX_TOL if atol < 0: raise QiskitError("Invalid atol: must be non-...
def _atol(self, atol): """Set the absolute tolerence parameter for float comparisons.""" # NOTE: that this overrides the class value so applies to all # instances of the class. max_tol = self.__class__.MAX_TOL if atol < 0: raise QiskitError("Invalid atol: must be non-...
[ "Set", "the", "absolute", "tolerence", "parameter", "for", "float", "comparisons", "." ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/quantum_info/operators/base_operator.py#L75-L85
[ "def", "_atol", "(", "self", ",", "atol", ")", ":", "# NOTE: that this overrides the class value so applies to all", "# instances of the class.", "max_tol", "=", "self", ".", "__class__", ".", "MAX_TOL", "if", "atol", "<", "0", ":", "raise", "QiskitError", "(", "\"I...
d4f58d903bc96341b816f7c35df936d6421267d1
test
BaseOperator._rtol
Set the relative tolerence parameter for float comparisons.
qiskit/quantum_info/operators/base_operator.py
def _rtol(self, rtol): """Set the relative tolerence parameter for float comparisons.""" # NOTE: that this overrides the class value so applies to all # instances of the class. max_tol = self.__class__.MAX_TOL if rtol < 0: raise QiskitError("Invalid rtol: must be non-...
def _rtol(self, rtol): """Set the relative tolerence parameter for float comparisons.""" # NOTE: that this overrides the class value so applies to all # instances of the class. max_tol = self.__class__.MAX_TOL if rtol < 0: raise QiskitError("Invalid rtol: must be non-...
[ "Set", "the", "relative", "tolerence", "parameter", "for", "float", "comparisons", "." ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/quantum_info/operators/base_operator.py#L93-L103
[ "def", "_rtol", "(", "self", ",", "rtol", ")", ":", "# NOTE: that this overrides the class value so applies to all", "# instances of the class.", "max_tol", "=", "self", ".", "__class__", ".", "MAX_TOL", "if", "rtol", "<", "0", ":", "raise", "QiskitError", "(", "\"I...
d4f58d903bc96341b816f7c35df936d6421267d1
test
BaseOperator._reshape
Reshape input and output dimensions of operator. Arg: input_dims (tuple): new subsystem input dimensions. output_dims (tuple): new subsystem output dimensions. Returns: Operator: returns self with reshaped input and output dimensions. Raises: Qi...
qiskit/quantum_info/operators/base_operator.py
def _reshape(self, input_dims=None, output_dims=None): """Reshape input and output dimensions of operator. Arg: input_dims (tuple): new subsystem input dimensions. output_dims (tuple): new subsystem output dimensions. Returns: Operator: returns self with res...
def _reshape(self, input_dims=None, output_dims=None): """Reshape input and output dimensions of operator. Arg: input_dims (tuple): new subsystem input dimensions. output_dims (tuple): new subsystem output dimensions. Returns: Operator: returns self with res...
[ "Reshape", "input", "and", "output", "dimensions", "of", "operator", "." ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/quantum_info/operators/base_operator.py#L105-L131
[ "def", "_reshape", "(", "self", ",", "input_dims", "=", "None", ",", "output_dims", "=", "None", ")", ":", "if", "input_dims", "is", "not", "None", ":", "if", "np", ".", "product", "(", "input_dims", ")", "!=", "self", ".", "_input_dim", ":", "raise", ...
d4f58d903bc96341b816f7c35df936d6421267d1
test
BaseOperator.input_dims
Return tuple of input dimension for specified subsystems.
qiskit/quantum_info/operators/base_operator.py
def input_dims(self, qargs=None): """Return tuple of input dimension for specified subsystems.""" if qargs is None: return self._input_dims return tuple(self._input_dims[i] for i in qargs)
def input_dims(self, qargs=None): """Return tuple of input dimension for specified subsystems.""" if qargs is None: return self._input_dims return tuple(self._input_dims[i] for i in qargs)
[ "Return", "tuple", "of", "input", "dimension", "for", "specified", "subsystems", "." ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/quantum_info/operators/base_operator.py#L133-L137
[ "def", "input_dims", "(", "self", ",", "qargs", "=", "None", ")", ":", "if", "qargs", "is", "None", ":", "return", "self", ".", "_input_dims", "return", "tuple", "(", "self", ".", "_input_dims", "[", "i", "]", "for", "i", "in", "qargs", ")" ]
d4f58d903bc96341b816f7c35df936d6421267d1
test
BaseOperator.output_dims
Return tuple of output dimension for specified subsystems.
qiskit/quantum_info/operators/base_operator.py
def output_dims(self, qargs=None): """Return tuple of output dimension for specified subsystems.""" if qargs is None: return self._output_dims return tuple(self._output_dims[i] for i in qargs)
def output_dims(self, qargs=None): """Return tuple of output dimension for specified subsystems.""" if qargs is None: return self._output_dims return tuple(self._output_dims[i] for i in qargs)
[ "Return", "tuple", "of", "output", "dimension", "for", "specified", "subsystems", "." ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/quantum_info/operators/base_operator.py#L139-L143
[ "def", "output_dims", "(", "self", ",", "qargs", "=", "None", ")", ":", "if", "qargs", "is", "None", ":", "return", "self", ".", "_output_dims", "return", "tuple", "(", "self", ".", "_output_dims", "[", "i", "]", "for", "i", "in", "qargs", ")" ]
d4f58d903bc96341b816f7c35df936d6421267d1
test
BaseOperator.copy
Make a copy of current operator.
qiskit/quantum_info/operators/base_operator.py
def copy(self): """Make a copy of current operator.""" # pylint: disable=no-value-for-parameter # The constructor of subclasses from raw data should be a copy return self.__class__(self.data, self.input_dims(), self.output_dims())
def copy(self): """Make a copy of current operator.""" # pylint: disable=no-value-for-parameter # The constructor of subclasses from raw data should be a copy return self.__class__(self.data, self.input_dims(), self.output_dims())
[ "Make", "a", "copy", "of", "current", "operator", "." ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/quantum_info/operators/base_operator.py#L145-L149
[ "def", "copy", "(", "self", ")", ":", "# pylint: disable=no-value-for-parameter", "# The constructor of subclasses from raw data should be a copy", "return", "self", ".", "__class__", "(", "self", ".", "data", ",", "self", ".", "input_dims", "(", ")", ",", "self", "."...
d4f58d903bc96341b816f7c35df936d6421267d1
test
BaseOperator.power
Return the compose of a operator with itself n times. Args: n (int): the number of times to compose with self (n>0). Returns: BaseOperator: the n-times composed operator. Raises: QiskitError: if the input and output dimensions of the operator ar...
qiskit/quantum_info/operators/base_operator.py
def power(self, n): """Return the compose of a operator with itself n times. Args: n (int): the number of times to compose with self (n>0). Returns: BaseOperator: the n-times composed operator. Raises: QiskitError: if the input and output dimensions...
def power(self, n): """Return the compose of a operator with itself n times. Args: n (int): the number of times to compose with self (n>0). Returns: BaseOperator: the n-times composed operator. Raises: QiskitError: if the input and output dimensions...
[ "Return", "the", "compose", "of", "a", "operator", "with", "itself", "n", "times", "." ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/quantum_info/operators/base_operator.py#L195-L217
[ "def", "power", "(", "self", ",", "n", ")", ":", "# NOTE: if a subclass can have negative or non-integer powers", "# this method should be overriden in that class.", "if", "not", "isinstance", "(", "n", ",", "(", "int", ",", "np", ".", "integer", ")", ")", "or", "n"...
d4f58d903bc96341b816f7c35df936d6421267d1
test
BaseOperator._automatic_dims
Check if input dimension corresponds to qubit subsystems.
qiskit/quantum_info/operators/base_operator.py
def _automatic_dims(cls, dims, size): """Check if input dimension corresponds to qubit subsystems.""" if dims is None: dims = size elif np.product(dims) != size: raise QiskitError("dimensions do not match size.") if isinstance(dims, (int, np.integer)): ...
def _automatic_dims(cls, dims, size): """Check if input dimension corresponds to qubit subsystems.""" if dims is None: dims = size elif np.product(dims) != size: raise QiskitError("dimensions do not match size.") if isinstance(dims, (int, np.integer)): ...
[ "Check", "if", "input", "dimension", "corresponds", "to", "qubit", "subsystems", "." ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/quantum_info/operators/base_operator.py#L315-L326
[ "def", "_automatic_dims", "(", "cls", ",", "dims", ",", "size", ")", ":", "if", "dims", "is", "None", ":", "dims", "=", "size", "elif", "np", ".", "product", "(", "dims", ")", "!=", "size", ":", "raise", "QiskitError", "(", "\"dimensions do not match siz...
d4f58d903bc96341b816f7c35df936d6421267d1
test
BaseOperator._einsum_matmul
Perform a contraction using Numpy.einsum Args: tensor (np.array): a vector or matrix reshaped to a rank-N tensor. mat (np.array): a matrix reshaped to a rank-2M tensor. indices (list): tensor indices to contract with mat. shift (int): shift for indicies of tensor...
qiskit/quantum_info/operators/base_operator.py
def _einsum_matmul(cls, tensor, mat, indices, shift=0, right_mul=False): """Perform a contraction using Numpy.einsum Args: tensor (np.array): a vector or matrix reshaped to a rank-N tensor. mat (np.array): a matrix reshaped to a rank-2M tensor. indices (list): tensor...
def _einsum_matmul(cls, tensor, mat, indices, shift=0, right_mul=False): """Perform a contraction using Numpy.einsum Args: tensor (np.array): a vector or matrix reshaped to a rank-N tensor. mat (np.array): a matrix reshaped to a rank-2M tensor. indices (list): tensor...
[ "Perform", "a", "contraction", "using", "Numpy", ".", "einsum" ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/quantum_info/operators/base_operator.py#L329-L362
[ "def", "_einsum_matmul", "(", "cls", ",", "tensor", ",", "mat", ",", "indices", ",", "shift", "=", "0", ",", "right_mul", "=", "False", ")", ":", "rank", "=", "tensor", ".", "ndim", "rank_mat", "=", "mat", ".", "ndim", "if", "rank_mat", "%", "2", "...
d4f58d903bc96341b816f7c35df936d6421267d1
test
BasePolyField._deserialize
Override ``_deserialize`` for customizing the exception raised.
qiskit/validation/fields/polymorphic.py
def _deserialize(self, value, attr, data): """Override ``_deserialize`` for customizing the exception raised.""" try: return super()._deserialize(value, attr, data) except ValidationError as ex: if 'deserialization_schema_selector' in ex.messages[0]: ex.me...
def _deserialize(self, value, attr, data): """Override ``_deserialize`` for customizing the exception raised.""" try: return super()._deserialize(value, attr, data) except ValidationError as ex: if 'deserialization_schema_selector' in ex.messages[0]: ex.me...
[ "Override", "_deserialize", "for", "customizing", "the", "exception", "raised", "." ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/validation/fields/polymorphic.py#L61-L68
[ "def", "_deserialize", "(", "self", ",", "value", ",", "attr", ",", "data", ")", ":", "try", ":", "return", "super", "(", ")", ".", "_deserialize", "(", "value", ",", "attr", ",", "data", ")", "except", "ValidationError", "as", "ex", ":", "if", "'des...
d4f58d903bc96341b816f7c35df936d6421267d1
test
BasePolyField._serialize
Override ``_serialize`` for customizing the exception raised.
qiskit/validation/fields/polymorphic.py
def _serialize(self, value, key, obj): """Override ``_serialize`` for customizing the exception raised.""" try: return super()._serialize(value, key, obj) except TypeError as ex: if 'serialization_schema_selector' in str(ex): raise ValidationError('Data fr...
def _serialize(self, value, key, obj): """Override ``_serialize`` for customizing the exception raised.""" try: return super()._serialize(value, key, obj) except TypeError as ex: if 'serialization_schema_selector' in str(ex): raise ValidationError('Data fr...
[ "Override", "_serialize", "for", "customizing", "the", "exception", "raised", "." ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/validation/fields/polymorphic.py#L70-L77
[ "def", "_serialize", "(", "self", ",", "value", ",", "key", ",", "obj", ")", ":", "try", ":", "return", "super", "(", ")", ".", "_serialize", "(", "value", ",", "key", ",", "obj", ")", "except", "TypeError", "as", "ex", ":", "if", "'serialization_sch...
d4f58d903bc96341b816f7c35df936d6421267d1
test
ByType.check_type
Check if at least one of the possible choices validates the value. Possible choices are assumed to be ``ModelTypeValidator`` fields.
qiskit/validation/fields/polymorphic.py
def check_type(self, value, attr, data): """Check if at least one of the possible choices validates the value. Possible choices are assumed to be ``ModelTypeValidator`` fields. """ for field in self.choices: if isinstance(field, ModelTypeValidator): try: ...
def check_type(self, value, attr, data): """Check if at least one of the possible choices validates the value. Possible choices are assumed to be ``ModelTypeValidator`` fields. """ for field in self.choices: if isinstance(field, ModelTypeValidator): try: ...
[ "Check", "if", "at", "least", "one", "of", "the", "possible", "choices", "validates", "the", "value", "." ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/validation/fields/polymorphic.py#L229-L243
[ "def", "check_type", "(", "self", ",", "value", ",", "attr", ",", "data", ")", ":", "for", "field", "in", "self", ".", "choices", ":", "if", "isinstance", "(", "field", ",", "ModelTypeValidator", ")", ":", "try", ":", "return", "field", ".", "check_typ...
d4f58d903bc96341b816f7c35df936d6421267d1
test
state_fidelity
Return the state fidelity between two quantum states. Either input may be a state vector, or a density matrix. The state fidelity (F) for two density matrices is defined as:: F(rho1, rho2) = Tr[sqrt(sqrt(rho1).rho2.sqrt(rho1))] ^ 2 For a pure state and mixed state the fidelity is given by:: ...
qiskit/quantum_info/states/measures.py
def state_fidelity(state1, state2): """Return the state fidelity between two quantum states. Either input may be a state vector, or a density matrix. The state fidelity (F) for two density matrices is defined as:: F(rho1, rho2) = Tr[sqrt(sqrt(rho1).rho2.sqrt(rho1))] ^ 2 For a pure state and m...
def state_fidelity(state1, state2): """Return the state fidelity between two quantum states. Either input may be a state vector, or a density matrix. The state fidelity (F) for two density matrices is defined as:: F(rho1, rho2) = Tr[sqrt(sqrt(rho1).rho2.sqrt(rho1))] ^ 2 For a pure state and m...
[ "Return", "the", "state", "fidelity", "between", "two", "quantum", "states", "." ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/quantum_info/states/measures.py#L20-L60
[ "def", "state_fidelity", "(", "state1", ",", "state2", ")", ":", "# convert input to numpy arrays", "s1", "=", "np", ".", "array", "(", "state1", ")", "s2", "=", "np", ".", "array", "(", "state2", ")", "# fidelity of two state vectors", "if", "s1", ".", "ndi...
d4f58d903bc96341b816f7c35df936d6421267d1
test
_funm_svd
Apply real scalar function to singular values of a matrix. Args: a (array_like): (N, N) Matrix at which to evaluate the function. func (callable): Callable object that evaluates a scalar function f. Returns: ndarray: funm (N, N) Value of the matrix function specified by func ev...
qiskit/quantum_info/states/measures.py
def _funm_svd(a, func): """Apply real scalar function to singular values of a matrix. Args: a (array_like): (N, N) Matrix at which to evaluate the function. func (callable): Callable object that evaluates a scalar function f. Returns: ndarray: funm (N, N) Value of the matrix functi...
def _funm_svd(a, func): """Apply real scalar function to singular values of a matrix. Args: a (array_like): (N, N) Matrix at which to evaluate the function. func (callable): Callable object that evaluates a scalar function f. Returns: ndarray: funm (N, N) Value of the matrix functi...
[ "Apply", "real", "scalar", "function", "to", "singular", "values", "of", "a", "matrix", "." ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/quantum_info/states/measures.py#L63-L76
[ "def", "_funm_svd", "(", "a", ",", "func", ")", ":", "U", ",", "s", ",", "Vh", "=", "la", ".", "svd", "(", "a", ",", "lapack_driver", "=", "'gesvd'", ")", "S", "=", "np", ".", "diag", "(", "func", "(", "s", ")", ")", "return", "U", ".", "do...
d4f58d903bc96341b816f7c35df936d6421267d1
test
CheckMap.run
If `dag` is mapped to `coupling_map`, the property `is_swap_mapped` is set to True (or to False otherwise). Args: dag (DAGCircuit): DAG to map.
qiskit/transpiler/passes/mapping/check_map.py
def run(self, dag): """ If `dag` is mapped to `coupling_map`, the property `is_swap_mapped` is set to True (or to False otherwise). Args: dag (DAGCircuit): DAG to map. """ if self.layout is None: if self.property_set["layout"]: sel...
def run(self, dag): """ If `dag` is mapped to `coupling_map`, the property `is_swap_mapped` is set to True (or to False otherwise). Args: dag (DAGCircuit): DAG to map. """ if self.layout is None: if self.property_set["layout"]: sel...
[ "If", "dag", "is", "mapped", "to", "coupling_map", "the", "property", "is_swap_mapped", "is", "set", "to", "True", "(", "or", "to", "False", "otherwise", ")", "." ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/transpiler/passes/mapping/check_map.py#L34-L56
[ "def", "run", "(", "self", ",", "dag", ")", ":", "if", "self", ".", "layout", "is", "None", ":", "if", "self", ".", "property_set", "[", "\"layout\"", "]", ":", "self", ".", "layout", "=", "self", ".", "property_set", "[", "\"layout\"", "]", "else", ...
d4f58d903bc96341b816f7c35df936d6421267d1
test
snapshot
Take a statevector snapshot of the internal simulator representation. Works on all qubits, and prevents reordering (like barrier). For other types of snapshots use the Snapshot extension directly. Args: label (str): a snapshot label to report the result snapshot_type (str): the type of the...
qiskit/extensions/simulator/snapshot.py
def snapshot(self, label, snapshot_type='statevector', qubits=None, params=None): """Take a statevector snapshot of the internal simulator representation. Works on all qubits, and prevents reordering (like barrier). For other types of snapshots use the Sn...
def snapshot(self, label, snapshot_type='statevector', qubits=None, params=None): """Take a statevector snapshot of the internal simulator representation. Works on all qubits, and prevents reordering (like barrier). For other types of snapshots use the Sn...
[ "Take", "a", "statevector", "snapshot", "of", "the", "internal", "simulator", "representation", ".", "Works", "on", "all", "qubits", "and", "prevents", "reordering", "(", "like", "barrier", ")", "." ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/extensions/simulator/snapshot.py#L87-L138
[ "def", "snapshot", "(", "self", ",", "label", ",", "snapshot_type", "=", "'statevector'", ",", "qubits", "=", "None", ",", "params", "=", "None", ")", ":", "# Convert label to string for backwards compatibility", "if", "not", "isinstance", "(", "label", ",", "st...
d4f58d903bc96341b816f7c35df936d6421267d1
test
Snapshot.assemble
Assemble a QasmQobjInstruction
qiskit/extensions/simulator/snapshot.py
def assemble(self): """Assemble a QasmQobjInstruction""" instruction = super().assemble() instruction.label = self._label instruction.snapshot_type = self._snapshot_type return instruction
def assemble(self): """Assemble a QasmQobjInstruction""" instruction = super().assemble() instruction.label = self._label instruction.snapshot_type = self._snapshot_type return instruction
[ "Assemble", "a", "QasmQobjInstruction" ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/extensions/simulator/snapshot.py#L49-L54
[ "def", "assemble", "(", "self", ")", ":", "instruction", "=", "super", "(", ")", ".", "assemble", "(", ")", "instruction", ".", "label", "=", "self", ".", "_label", "instruction", ".", "snapshot_type", "=", "self", ".", "_snapshot_type", "return", "instruc...
d4f58d903bc96341b816f7c35df936d6421267d1
test
Snapshot.inverse
Special case. Return self.
qiskit/extensions/simulator/snapshot.py
def inverse(self): """Special case. Return self.""" return Snapshot(self.num_qubits, self.num_clbits, self.params[0], self.params[1])
def inverse(self): """Special case. Return self.""" return Snapshot(self.num_qubits, self.num_clbits, self.params[0], self.params[1])
[ "Special", "case", ".", "Return", "self", "." ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/extensions/simulator/snapshot.py#L56-L59
[ "def", "inverse", "(", "self", ")", ":", "return", "Snapshot", "(", "self", ".", "num_qubits", ",", "self", ".", "num_clbits", ",", "self", ".", "params", "[", "0", "]", ",", "self", ".", "params", "[", "1", "]", ")" ]
d4f58d903bc96341b816f7c35df936d6421267d1
test
Snapshot.label
Set snapshot label to name Args: name (str or None): label to assign unitary Raises: TypeError: name is not string or None.
qiskit/extensions/simulator/snapshot.py
def label(self, name): """Set snapshot label to name Args: name (str or None): label to assign unitary Raises: TypeError: name is not string or None. """ if isinstance(name, str): self._label = name else: raise TypeError('...
def label(self, name): """Set snapshot label to name Args: name (str or None): label to assign unitary Raises: TypeError: name is not string or None. """ if isinstance(name, str): self._label = name else: raise TypeError('...
[ "Set", "snapshot", "label", "to", "name" ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/extensions/simulator/snapshot.py#L72-L84
[ "def", "label", "(", "self", ",", "name", ")", ":", "if", "isinstance", "(", "name", ",", "str", ")", ":", "self", ".", "_label", "=", "name", "else", ":", "raise", "TypeError", "(", "'label expects a string'", ")" ]
d4f58d903bc96341b816f7c35df936d6421267d1
test
QuantumChannel.is_cptp
Return True if completely-positive trace-preserving (CPTP).
qiskit/quantum_info/operators/channel/quantum_channel.py
def is_cptp(self, atol=None, rtol=None): """Return True if completely-positive trace-preserving (CPTP).""" choi = _to_choi(self.rep, self._data, *self.dim) return self._is_cp_helper(choi, atol, rtol) and self._is_tp_helper( choi, atol, rtol)
def is_cptp(self, atol=None, rtol=None): """Return True if completely-positive trace-preserving (CPTP).""" choi = _to_choi(self.rep, self._data, *self.dim) return self._is_cp_helper(choi, atol, rtol) and self._is_tp_helper( choi, atol, rtol)
[ "Return", "True", "if", "completely", "-", "positive", "trace", "-", "preserving", "(", "CPTP", ")", "." ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/quantum_info/operators/channel/quantum_channel.py#L28-L32
[ "def", "is_cptp", "(", "self", ",", "atol", "=", "None", ",", "rtol", "=", "None", ")", ":", "choi", "=", "_to_choi", "(", "self", ".", "rep", ",", "self", ".", "_data", ",", "*", "self", ".", "dim", ")", "return", "self", ".", "_is_cp_helper", "...
d4f58d903bc96341b816f7c35df936d6421267d1
test
QuantumChannel.is_tp
Test if a channel is completely-positive (CP)
qiskit/quantum_info/operators/channel/quantum_channel.py
def is_tp(self, atol=None, rtol=None): """Test if a channel is completely-positive (CP)""" choi = _to_choi(self.rep, self._data, *self.dim) return self._is_tp_helper(choi, atol, rtol)
def is_tp(self, atol=None, rtol=None): """Test if a channel is completely-positive (CP)""" choi = _to_choi(self.rep, self._data, *self.dim) return self._is_tp_helper(choi, atol, rtol)
[ "Test", "if", "a", "channel", "is", "completely", "-", "positive", "(", "CP", ")" ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/quantum_info/operators/channel/quantum_channel.py#L34-L37
[ "def", "is_tp", "(", "self", ",", "atol", "=", "None", ",", "rtol", "=", "None", ")", ":", "choi", "=", "_to_choi", "(", "self", ".", "rep", ",", "self", ".", "_data", ",", "*", "self", ".", "dim", ")", "return", "self", ".", "_is_tp_helper", "("...
d4f58d903bc96341b816f7c35df936d6421267d1
test
QuantumChannel.is_cp
Test if Choi-matrix is completely-positive (CP)
qiskit/quantum_info/operators/channel/quantum_channel.py
def is_cp(self, atol=None, rtol=None): """Test if Choi-matrix is completely-positive (CP)""" choi = _to_choi(self.rep, self._data, *self.dim) return self._is_cp_helper(choi, atol, rtol)
def is_cp(self, atol=None, rtol=None): """Test if Choi-matrix is completely-positive (CP)""" choi = _to_choi(self.rep, self._data, *self.dim) return self._is_cp_helper(choi, atol, rtol)
[ "Test", "if", "Choi", "-", "matrix", "is", "completely", "-", "positive", "(", "CP", ")" ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/quantum_info/operators/channel/quantum_channel.py#L39-L42
[ "def", "is_cp", "(", "self", ",", "atol", "=", "None", ",", "rtol", "=", "None", ")", ":", "choi", "=", "_to_choi", "(", "self", ".", "rep", ",", "self", ".", "_data", ",", "*", "self", ".", "dim", ")", "return", "self", ".", "_is_cp_helper", "("...
d4f58d903bc96341b816f7c35df936d6421267d1
test
QuantumChannel.is_unitary
Return True if QuantumChannel is a unitary channel.
qiskit/quantum_info/operators/channel/quantum_channel.py
def is_unitary(self, atol=None, rtol=None): """Return True if QuantumChannel is a unitary channel.""" try: op = self.to_operator() return op.is_unitary(atol=atol, rtol=rtol) except QiskitError: return False
def is_unitary(self, atol=None, rtol=None): """Return True if QuantumChannel is a unitary channel.""" try: op = self.to_operator() return op.is_unitary(atol=atol, rtol=rtol) except QiskitError: return False
[ "Return", "True", "if", "QuantumChannel", "is", "a", "unitary", "channel", "." ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/quantum_info/operators/channel/quantum_channel.py#L44-L50
[ "def", "is_unitary", "(", "self", ",", "atol", "=", "None", ",", "rtol", "=", "None", ")", ":", "try", ":", "op", "=", "self", ".", "to_operator", "(", ")", "return", "op", ".", "is_unitary", "(", "atol", "=", "atol", ",", "rtol", "=", "rtol", ")...
d4f58d903bc96341b816f7c35df936d6421267d1
test
QuantumChannel.to_operator
Try to convert channel to a unitary representation Operator.
qiskit/quantum_info/operators/channel/quantum_channel.py
def to_operator(self): """Try to convert channel to a unitary representation Operator.""" mat = _to_operator(self.rep, self._data, *self.dim) return Operator(mat, self.input_dims(), self.output_dims())
def to_operator(self): """Try to convert channel to a unitary representation Operator.""" mat = _to_operator(self.rep, self._data, *self.dim) return Operator(mat, self.input_dims(), self.output_dims())
[ "Try", "to", "convert", "channel", "to", "a", "unitary", "representation", "Operator", "." ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/quantum_info/operators/channel/quantum_channel.py#L52-L55
[ "def", "to_operator", "(", "self", ")", ":", "mat", "=", "_to_operator", "(", "self", ".", "rep", ",", "self", ".", "_data", ",", "*", "self", ".", "dim", ")", "return", "Operator", "(", "mat", ",", "self", ".", "input_dims", "(", ")", ",", "self",...
d4f58d903bc96341b816f7c35df936d6421267d1
test
QuantumChannel.to_instruction
Convert to a Kraus or UnitaryGate circuit instruction. If the channel is unitary it will be added as a unitary gate, otherwise it will be added as a kraus simulator instruction. Returns: Instruction: A kraus instruction for the channel. Raises: QiskitError: if ...
qiskit/quantum_info/operators/channel/quantum_channel.py
def to_instruction(self): """Convert to a Kraus or UnitaryGate circuit instruction. If the channel is unitary it will be added as a unitary gate, otherwise it will be added as a kraus simulator instruction. Returns: Instruction: A kraus instruction for the channel. ...
def to_instruction(self): """Convert to a Kraus or UnitaryGate circuit instruction. If the channel is unitary it will be added as a unitary gate, otherwise it will be added as a kraus simulator instruction. Returns: Instruction: A kraus instruction for the channel. ...
[ "Convert", "to", "a", "Kraus", "or", "UnitaryGate", "circuit", "instruction", "." ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/quantum_info/operators/channel/quantum_channel.py#L57-L88
[ "def", "to_instruction", "(", "self", ")", ":", "from", "qiskit", ".", "circuit", ".", "instruction", "import", "Instruction", "# Check if input is an N-qubit CPTP channel.", "n_qubits", "=", "int", "(", "np", ".", "log2", "(", "self", ".", "_input_dim", ")", ")...
d4f58d903bc96341b816f7c35df936d6421267d1
test
QuantumChannel._is_cp_helper
Test if a channel is completely-positive (CP)
qiskit/quantum_info/operators/channel/quantum_channel.py
def _is_cp_helper(self, choi, atol, rtol): """Test if a channel is completely-positive (CP)""" if atol is None: atol = self._atol if rtol is None: rtol = self._rtol return is_positive_semidefinite_matrix(choi, rtol=rtol, atol=atol)
def _is_cp_helper(self, choi, atol, rtol): """Test if a channel is completely-positive (CP)""" if atol is None: atol = self._atol if rtol is None: rtol = self._rtol return is_positive_semidefinite_matrix(choi, rtol=rtol, atol=atol)
[ "Test", "if", "a", "channel", "is", "completely", "-", "positive", "(", "CP", ")" ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/quantum_info/operators/channel/quantum_channel.py#L90-L96
[ "def", "_is_cp_helper", "(", "self", ",", "choi", ",", "atol", ",", "rtol", ")", ":", "if", "atol", "is", "None", ":", "atol", "=", "self", ".", "_atol", "if", "rtol", "is", "None", ":", "rtol", "=", "self", ".", "_rtol", "return", "is_positive_semid...
d4f58d903bc96341b816f7c35df936d6421267d1
test
QuantumChannel._is_tp_helper
Test if Choi-matrix is trace-preserving (TP)
qiskit/quantum_info/operators/channel/quantum_channel.py
def _is_tp_helper(self, choi, atol, rtol): """Test if Choi-matrix is trace-preserving (TP)""" if atol is None: atol = self._atol if rtol is None: rtol = self._rtol # Check if the partial trace is the identity matrix d_in, d_out = self.dim mat = np....
def _is_tp_helper(self, choi, atol, rtol): """Test if Choi-matrix is trace-preserving (TP)""" if atol is None: atol = self._atol if rtol is None: rtol = self._rtol # Check if the partial trace is the identity matrix d_in, d_out = self.dim mat = np....
[ "Test", "if", "Choi", "-", "matrix", "is", "trace", "-", "preserving", "(", "TP", ")" ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/quantum_info/operators/channel/quantum_channel.py#L98-L108
[ "def", "_is_tp_helper", "(", "self", ",", "choi", ",", "atol", ",", "rtol", ")", ":", "if", "atol", "is", "None", ":", "atol", "=", "self", ".", "_atol", "if", "rtol", "is", "None", ":", "rtol", "=", "self", ".", "_rtol", "# Check if the partial trace ...
d4f58d903bc96341b816f7c35df936d6421267d1
test
QuantumChannel._format_state
Format input state so it is statevector or density matrix
qiskit/quantum_info/operators/channel/quantum_channel.py
def _format_state(self, state, density_matrix=False): """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.') # Flatt...
def _format_state(self, state, density_matrix=False): """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.') # Flatt...
[ "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/channel/quantum_channel.py#L110-L127
[ "def", "_format_state", "(", "self", ",", "state", ",", "density_matrix", "=", "False", ")", ":", "state", "=", "np", ".", "array", "(", "state", ")", "shape", "=", "state", ".", "shape", "ndim", "=", "state", ".", "ndim", "if", "ndim", ">", "2", "...
d4f58d903bc96341b816f7c35df936d6421267d1