_id stringlengths 2 7 | title stringlengths 1 88 | partition stringclasses 3
values | text stringlengths 75 19.8k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q268400 | LoRange.includes | test | def includes(self, lo_freq: float) -> bool:
"""Whether `lo_freq` is within the `LoRange`.
Args:
lo_freq: LO frequency to be checked
Returns:
bool: True if lo_freq is included in this range, otherwise False
"""
if self._lb <= lo_freq <= self._ub:
... | python | {
"resource": ""
} |
q268401 | iplot_bloch_multivector | test | def iplot_bloch_multivector(rho, figsize=None):
""" Create a bloch sphere representation.
Graphical representation of the input array, using as much bloch
spheres as qubit are required.
Args:
rho (array): State vector or density matrix
figsize (tuple): Figure size i... | python | {
"resource": ""
} |
q268402 | LoConfigConverter.get_qubit_los | test | def get_qubit_los(self, user_lo_config):
"""Embed default qubit LO frequencies from backend and format them to list object.
If configured lo frequency is the same as default, this method returns `None`.
Args:
user_lo_config (LoConfig): A dictionary of LOs to format.
Returns... | python | {
"resource": ""
} |
q268403 | LoConfigConverter.get_meas_los | test | def get_meas_los(self, user_lo_config):
"""Embed default meas LO frequencies from backend and format them to list object.
If configured lo frequency is the same as default, this method returns `None`.
Args:
user_lo_config (LoConfig): A dictionary of LOs to format.
Returns:
... | python | {
"resource": ""
} |
q268404 | Unroller.run | test | def run(self, dag):
"""Expand all op nodes to the given basis.
Args:
dag(DAGCircuit): input dag
Raises:
QiskitError: if unable to unroll given the basis due to undefined
decomposition rules (such as a bad basis) or excessive recursion.
Returns:
... | python | {
"resource": ""
} |
q268405 | iplot_state_qsphere | test | def iplot_state_qsphere(rho, figsize=None):
""" Create a Q sphere representation.
Graphical representation of the input array, using a Q sphere for each
eigenvalue.
Args:
rho (array): State vector or density matrix.
figsize (tuple): Figure size in pixels.
"""
... | python | {
"resource": ""
} |
q268406 | n_choose_k | test | def n_choose_k(n, k):
"""Return the number of combinations for n choose k.
Args:
n (int): the total number of options .
k (int): The number of elements.
Returns:
int: returns the binomial coefficient
"""
if n == 0:
return 0
return reduce(lambda x, y: x * y[0] / ... | python | {
"resource": ""
} |
q268407 | lex_index | test | def lex_index(n, k, lst):
"""Return the lex index of a combination..
Args:
n (int): the total number of options .
k (int): The number of elements.
lst (list): list
Returns:
int: returns int index for lex order
Raises:
VisualizationError: if length of list is n... | python | {
"resource": ""
} |
q268408 | plot_state_paulivec | test | def plot_state_paulivec(rho, title="", figsize=None, color=None):
"""Plot the paulivec representation of a quantum state.
Plot a bargraph of the mixed state rho over the pauli matrices
Args:
rho (ndarray): Numpy array for state vector or density matrix
title (str): a string that represents... | python | {
"resource": ""
} |
q268409 | get_unique_backends | test | def get_unique_backends():
"""Gets the unique backends that are available.
Returns:
list: Unique available backends.
Raises:
QiskitError: No backends available.
"""
backends = IBMQ.backends()
unique_hardware_backends = []
unique_names = []
for back in backends:
... | python | {
"resource": ""
} |
q268410 | DAGNode.op | test | def op(self):
"""Returns the Instruction object corresponding to the op for the node else None"""
if 'type' not in self.data_dict or self.data_dict['type'] != 'op':
raise QiskitError("The node %s is not an op node" % (str(self)))
return self.data_dict.get('op') | python | {
"resource": ""
} |
q268411 | constant | test | def constant(duration: int, amp: complex, name: str = None) -> SamplePulse:
"""Generates constant-sampled `SamplePulse`.
Applies `left` sampling strategy to generate discrete pulse from continuous function.
Args:
duration: Duration of pulse. Must be greater than zero.
amp: Complex pulse am... | python | {
"resource": ""
} |
q268412 | zero | test | def zero(duration: int, name: str = None) -> SamplePulse:
"""Generates zero-sampled `SamplePulse`.
Args:
duration: Duration of pulse. Must be greater than zero.
name: Name of pulse.
"""
return _sampled_zero_pulse(duration, name=name) | python | {
"resource": ""
} |
q268413 | square | test | def square(duration: int, amp: complex, period: float = None,
phase: float = 0, name: str = None) -> SamplePulse:
"""Generates square wave `SamplePulse`.
Applies `left` sampling strategy to generate discrete pulse from continuous function.
Args:
duration: Duration of pulse. Must be grea... | python | {
"resource": ""
} |
q268414 | sawtooth | test | def sawtooth(duration: int, amp: complex, period: float = None,
phase: float = 0, name: str = None) -> SamplePulse:
"""Generates sawtooth wave `SamplePulse`.
Args:
duration: Duration of pulse. Must be greater than zero.
amp: Pulse amplitude. Wave range is [-amp, amp].
perio... | python | {
"resource": ""
} |
q268415 | triangle | test | def triangle(duration: int, amp: complex, period: float = None,
phase: float = 0, name: str = None) -> SamplePulse:
"""Generates triangle wave `SamplePulse`.
Applies `left` sampling strategy to generate discrete pulse from continuous function.
Args:
duration: Duration of pulse. Must b... | python | {
"resource": ""
} |
q268416 | cos | test | def cos(duration: int, amp: complex, freq: float = None,
phase: float = 0, name: str = None) -> SamplePulse:
"""Generates cosine wave `SamplePulse`.
Applies `left` sampling strategy to generate discrete pulse from continuous function.
Args:
duration: Duration of pulse. Must be greater than... | python | {
"resource": ""
} |
q268417 | sin | test | def sin(duration: int, amp: complex, freq: float = None,
phase: float = 0, name: str = None) -> SamplePulse:
"""Generates sine wave `SamplePulse`.
Args:
duration: Duration of pulse. Must be greater than zero.
amp: Pulse amplitude.
freq: Pulse frequency, units of 1/dt. If `None` ... | python | {
"resource": ""
} |
q268418 | gaussian | test | def gaussian(duration: int, amp: complex, sigma: float, name: str = None) -> SamplePulse:
r"""Generates unnormalized gaussian `SamplePulse`.
Centered at `duration/2` and zeroed at `t=-1` to prevent large initial discontinuity.
Applies `left` sampling strategy to generate discrete pulse from continuous fun... | python | {
"resource": ""
} |
q268419 | gaussian_deriv | test | def gaussian_deriv(duration: int, amp: complex, sigma: float, name: str = None) -> SamplePulse:
r"""Generates unnormalized gaussian derivative `SamplePulse`.
Applies `left` sampling strategy to generate discrete pulse from continuous function.
Args:
duration: Duration of pulse. Must be greater tha... | python | {
"resource": ""
} |
q268420 | gaussian_square | test | def gaussian_square(duration: int, amp: complex, sigma: float,
risefall: int, name: str = None) -> SamplePulse:
"""Generates gaussian square `SamplePulse`.
Centered at `duration/2` and zeroed at `t=-1` and `t=duration+1` to prevent
large initial/final discontinuities.
Applies `left... | python | {
"resource": ""
} |
q268421 | _GraphDist.dist_real | test | def dist_real(self):
"""Compute distance.
"""
x0, y0 = self.ax.transAxes.transform( # pylint: disable=invalid-name
(0, 0))
x1, y1 = self.ax.transAxes.transform( # pylint: disable=invalid-name
(1, 1))
value = x1 - x0 if self.x else y1 - y0
return ... | python | {
"resource": ""
} |
q268422 | Qreg.to_string | test | def to_string(self, indent):
"""Print the node data, with indent."""
ind = indent * ' '
print(ind, 'qreg')
self.children[0].to_string(indent + 3) | python | {
"resource": ""
} |
q268423 | BasicAerProvider._get_backend_instance | test | def _get_backend_instance(self, backend_cls):
"""
Return an instance of a backend from its class.
Args:
backend_cls (class): Backend class.
Returns:
BaseBackend: a backend instance.
Raises:
QiskitError: if the backend could not be instantiated... | python | {
"resource": ""
} |
q268424 | DAGCircuit.rename_register | test | def rename_register(self, regname, newname):
"""Rename a classical or quantum register throughout the circuit.
regname = existing register name string
newname = replacement register name string
"""
if regname == newname:
return
if newname in self.qregs or new... | python | {
"resource": ""
} |
q268425 | DAGCircuit.remove_all_ops_named | test | def remove_all_ops_named(self, opname):
"""Remove all operation nodes with the given name."""
for n in self.named_nodes(opname):
self.remove_op_node(n) | python | {
"resource": ""
} |
q268426 | DAGCircuit.add_qreg | test | def add_qreg(self, qreg):
"""Add all wires in a quantum register."""
if not isinstance(qreg, QuantumRegister):
raise DAGCircuitError("not a QuantumRegister instance.")
if qreg.name in self.qregs:
raise DAGCircuitError("duplicate register %s" % qreg.name)
self.qreg... | python | {
"resource": ""
} |
q268427 | DAGCircuit.add_creg | test | def add_creg(self, creg):
"""Add all wires in a classical register."""
if not isinstance(creg, ClassicalRegister):
raise DAGCircuitError("not a ClassicalRegister instance.")
if creg.name in self.cregs:
raise DAGCircuitError("duplicate register %s" % creg.name)
sel... | python | {
"resource": ""
} |
q268428 | DAGCircuit._add_wire | test | def _add_wire(self, wire):
"""Add a qubit or bit to the circuit.
Args:
wire (tuple): (Register,int) containing a register instance and index
This adds a pair of in and out nodes connected by an edge.
Raises:
DAGCircuitError: if trying to add duplicate wire
... | python | {
"resource": ""
} |
q268429 | DAGCircuit._check_condition | test | def _check_condition(self, name, condition):
"""Verify that the condition is valid.
Args:
name (string): used for error reporting
condition (tuple or None): a condition tuple (ClassicalRegister,int)
Raises:
DAGCircuitError: if conditioning on an invalid regi... | python | {
"resource": ""
} |
q268430 | DAGCircuit._bits_in_condition | test | def _bits_in_condition(self, cond):
"""Return a list of bits in the given condition.
Args:
cond (tuple or None): optional condition (ClassicalRegister, int)
Returns:
list[(ClassicalRegister, idx)]: list of bits
"""
all_bits = []
if cond is not No... | python | {
"resource": ""
} |
q268431 | DAGCircuit._add_op_node | test | def _add_op_node(self, op, qargs, cargs, condition=None):
"""Add a new operation node to the graph and assign properties.
Args:
op (Instruction): the operation associated with the DAG node
qargs (list): list of quantum wires to attach to.
cargs (list): list of classi... | python | {
"resource": ""
} |
q268432 | DAGCircuit.apply_operation_back | test | def apply_operation_back(self, op, qargs=None, cargs=None, condition=None):
"""Apply an operation to the output of the circuit.
Args:
op (Instruction): the operation associated with the DAG node
qargs (list[tuple]): qubits that op will be applied to
cargs (list[tuple... | python | {
"resource": ""
} |
q268433 | DAGCircuit._check_edgemap_registers | test | def _check_edgemap_registers(self, edge_map, keyregs, valregs, valreg=True):
"""Check that wiremap neither fragments nor leaves duplicate registers.
1. There are no fragmented registers. A register in keyregs
is fragmented if not all of its (qu)bits are renamed by edge_map.
2. There are... | python | {
"resource": ""
} |
q268434 | DAGCircuit._check_wiremap_validity | test | def _check_wiremap_validity(self, wire_map, keymap, valmap):
"""Check that the wiremap is consistent.
Check that the wiremap refers to valid wires and that
those wires have consistent types.
Args:
wire_map (dict): map from (register,idx) in keymap to
(regist... | python | {
"resource": ""
} |
q268435 | DAGCircuit._map_condition | test | def _map_condition(self, wire_map, condition):
"""Use the wire_map dict to change the condition tuple's creg name.
Args:
wire_map (dict): a map from wires to wires
condition (tuple): (ClassicalRegister,int)
Returns:
tuple(ClassicalRegister,int): new condition... | python | {
"resource": ""
} |
q268436 | DAGCircuit.extend_back | test | def extend_back(self, dag, edge_map=None):
"""Add `dag` at the end of `self`, using `edge_map`.
"""
edge_map = edge_map or {}
for qreg in dag.qregs.values():
if qreg.name not in self.qregs:
self.add_qreg(QuantumRegister(qreg.size, qreg.name))
edge_... | python | {
"resource": ""
} |
q268437 | DAGCircuit.compose_back | test | def compose_back(self, input_circuit, edge_map=None):
"""Apply the input circuit to the output of this circuit.
The two bases must be "compatible" or an exception occurs.
A subset of input qubits of the input circuit are mapped
to a subset of output qubits of this circuit.
Args... | python | {
"resource": ""
} |
q268438 | DAGCircuit._check_wires_list | test | def _check_wires_list(self, wires, node):
"""Check that a list of wires is compatible with a node to be replaced.
- no duplicate names
- correct length for operation
Raise an exception otherwise.
Args:
wires (list[register, index]): gives an order for (qu)bits
... | python | {
"resource": ""
} |
q268439 | DAGCircuit._make_pred_succ_maps | test | def _make_pred_succ_maps(self, node):
"""Return predecessor and successor dictionaries.
Args:
node (DAGNode): reference to multi_graph node
Returns:
tuple(dict): tuple(predecessor_map, successor_map)
These map from wire (Register, int) to predecessor (su... | python | {
"resource": ""
} |
q268440 | DAGCircuit._full_pred_succ_maps | test | def _full_pred_succ_maps(self, pred_map, succ_map, input_circuit,
wire_map):
"""Map all wires of the input circuit.
Map all wires of the input circuit to predecessor and
successor nodes in self, keyed on wires in self.
Args:
pred_map (dict): com... | python | {
"resource": ""
} |
q268441 | DAGCircuit.topological_nodes | test | def topological_nodes(self):
"""
Yield nodes in topological order.
Returns:
generator(DAGNode): node in topological order
"""
return nx.lexicographical_topological_sort(self._multi_graph,
key=lambda x: str(x.qargs)) | python | {
"resource": ""
} |
q268442 | DAGCircuit.edges | test | def edges(self, nodes=None):
"""Iterator for node values.
Yield:
node: the node.
"""
for source_node, dest_node, edge_data in self._multi_graph.edges(nodes, data=True):
yield source_node, dest_node, edge_data | python | {
"resource": ""
} |
q268443 | DAGCircuit.op_nodes | test | def op_nodes(self, op=None):
"""Get the list of "op" nodes in the dag.
Args:
op (Type): Instruction subclass op nodes to return. if op=None, return
all op nodes.
Returns:
list[DAGNode]: the list of node ids containing the given op.
"""
nod... | python | {
"resource": ""
} |
q268444 | DAGCircuit.gate_nodes | test | def gate_nodes(self):
"""Get the list of gate nodes in the dag.
Returns:
list: the list of node ids that represent gates.
"""
nodes = []
for node in self.op_nodes():
if isinstance(node.op, Gate):
nodes.append(node)
return nodes | python | {
"resource": ""
} |
q268445 | DAGCircuit.named_nodes | test | def named_nodes(self, *names):
"""Get the set of "op" nodes with the given name."""
named_nodes = []
for node in self._multi_graph.nodes():
if node.type == 'op' and node.op.name in names:
named_nodes.append(node)
return named_nodes | python | {
"resource": ""
} |
q268446 | DAGCircuit.twoQ_gates | test | def twoQ_gates(self):
"""Get list of 2-qubit gates. Ignore snapshot, barriers, and the like."""
two_q_gates = []
for node in self.gate_nodes():
if len(node.qargs) == 2:
two_q_gates.append(node)
return two_q_gates | python | {
"resource": ""
} |
q268447 | DAGCircuit.predecessors | test | def predecessors(self, node):
"""Returns list of the predecessors of a node as DAGNodes."""
if isinstance(node, int):
warnings.warn('Calling predecessors() with a node id is deprecated,'
' use a DAGNode instead',
DeprecationWarning, 2)
... | python | {
"resource": ""
} |
q268448 | DAGCircuit.quantum_predecessors | test | def quantum_predecessors(self, node):
"""Returns list of the predecessors of a node that are
connected by a quantum edge as DAGNodes."""
predecessors = []
for predecessor in self.predecessors(node):
if isinstance(self._multi_graph.get_edge_data(predecessor, node, key=0)['wir... | python | {
"resource": ""
} |
q268449 | DAGCircuit.ancestors | test | def ancestors(self, node):
"""Returns set of the ancestors of a node as DAGNodes."""
if isinstance(node, int):
warnings.warn('Calling ancestors() with a node id is deprecated,'
' use a DAGNode instead',
DeprecationWarning, 2)
no... | python | {
"resource": ""
} |
q268450 | DAGCircuit.quantum_successors | test | def quantum_successors(self, node):
"""Returns list of the successors of a node that are
connected by a quantum edge as DAGNodes."""
if isinstance(node, int):
warnings.warn('Calling quantum_successors() with a node id is deprecated,'
' use a DAGNode instead'... | python | {
"resource": ""
} |
q268451 | DAGCircuit.remove_op_node | test | def remove_op_node(self, node):
"""Remove an operation node n.
Add edges from predecessors to successors.
"""
if isinstance(node, int):
warnings.warn('Calling remove_op_node() with a node id is deprecated,'
' use a DAGNode instead',
... | python | {
"resource": ""
} |
q268452 | DAGCircuit.remove_ancestors_of | test | def remove_ancestors_of(self, node):
"""Remove all of the ancestor operation nodes of node."""
if isinstance(node, int):
warnings.warn('Calling remove_ancestors_of() with a node id is deprecated,'
' use a DAGNode instead',
DeprecationWarnin... | python | {
"resource": ""
} |
q268453 | DAGCircuit.remove_descendants_of | test | def remove_descendants_of(self, node):
"""Remove all of the descendant operation nodes of node."""
if isinstance(node, int):
warnings.warn('Calling remove_descendants_of() with a node id is deprecated,'
' use a DAGNode instead',
Deprecation... | python | {
"resource": ""
} |
q268454 | DAGCircuit.remove_nonancestors_of | test | def remove_nonancestors_of(self, node):
"""Remove all of the non-ancestors operation nodes of node."""
if isinstance(node, int):
warnings.warn('Calling remove_nonancestors_of() with a node id is deprecated,'
' use a DAGNode instead',
Deprec... | python | {
"resource": ""
} |
q268455 | DAGCircuit.remove_nondescendants_of | test | def remove_nondescendants_of(self, node):
"""Remove all of the non-descendants operation nodes of node."""
if isinstance(node, int):
warnings.warn('Calling remove_nondescendants_of() with a node id is deprecated,'
' use a DAGNode instead',
... | python | {
"resource": ""
} |
q268456 | DAGCircuit.layers | test | def layers(self):
"""Yield a shallow view on a layer of this DAGCircuit for all d layers of this circuit.
A layer is a circuit whose gates act on disjoint qubits, i.e.
a layer has depth 1. The total number of layers equals the
circuit depth d. The layers are indexed from 0 to d-1 with t... | python | {
"resource": ""
} |
q268457 | DAGCircuit.serial_layers | test | def serial_layers(self):
"""Yield a layer for all gates of this circuit.
A serial layer is a circuit with one gate. The layers have the
same structure as in layers().
"""
for next_node in self.topological_op_nodes():
new_layer = DAGCircuit()
for qreg in s... | python | {
"resource": ""
} |
q268458 | DAGCircuit.multigraph_layers | test | def multigraph_layers(self):
"""Yield layers of the multigraph."""
predecessor_count = dict() # Dict[node, predecessors not visited]
cur_layer = [node for node in self.input_map.values()]
yield cur_layer
next_layer = []
while cur_layer:
for node in cur_layer:... | python | {
"resource": ""
} |
q268459 | DAGCircuit.collect_runs | test | def collect_runs(self, namelist):
"""Return a set of non-conditional runs of "op" nodes with the given names.
For example, "... h q[0]; cx q[0],q[1]; cx q[0],q[1]; h q[1]; .."
would produce the tuple of cx nodes as an element of the set returned
from a call to collect_runs(["cx"]). If i... | python | {
"resource": ""
} |
q268460 | DAGCircuit.nodes_on_wire | test | def nodes_on_wire(self, wire, only_ops=False):
"""
Iterator for nodes that affect a given wire
Args:
wire (tuple(Register, index)): the wire to be looked at.
only_ops (bool): True if only the ops nodes are wanted
otherwise all nodes are returned.
... | python | {
"resource": ""
} |
q268461 | DAGCircuit.count_ops | test | def count_ops(self):
"""Count the occurrences of operation names.
Returns a dictionary of counts keyed on the operation name.
"""
op_dict = {}
for node in self.topological_op_nodes():
name = node.name
if name not in op_dict:
op_dict[name] ... | python | {
"resource": ""
} |
q268462 | DAGCircuit.properties | test | def properties(self):
"""Return a dictionary of circuit properties."""
summary = {"size": self.size(),
"depth": self.depth(),
"width": self.width(),
"bits": self.num_cbits(),
"factors": self.num_tensor_factors(),
... | python | {
"resource": ""
} |
q268463 | tomography_basis | test | def tomography_basis(basis, prep_fun=None, meas_fun=None):
"""
Generate a TomographyBasis object.
See TomographyBasis for further details.abs
Args:
prep_fun (callable) optional: the function which adds preparation
gates to a circuit.
meas_fun (callable) optional: the functi... | python | {
"resource": ""
} |
q268464 | __pauli_meas_gates | test | def __pauli_meas_gates(circuit, qreg, op):
"""
Add state measurement gates to a circuit.
"""
if op not in ['X', 'Y', 'Z']:
raise QiskitError("There's no X, Y or Z basis for this Pauli "
"measurement")
if op == "X":
circuit.u2(0., np.pi, qreg) # H
elif ... | python | {
"resource": ""
} |
q268465 | tomography_set | test | def tomography_set(meas_qubits,
meas_basis='Pauli',
prep_qubits=None,
prep_basis=None):
"""
Generate a dictionary of tomography experiment configurations.
This returns a data structure that is used by other tomography functions
to generate state ... | python | {
"resource": ""
} |
q268466 | process_tomography_set | test | def process_tomography_set(meas_qubits, meas_basis='Pauli',
prep_qubits=None, prep_basis='SIC'):
"""
Generate a dictionary of process tomography experiment configurations.
This returns a data structure that is used by other tomography functions
to generate state and process t... | python | {
"resource": ""
} |
q268467 | create_tomography_circuits | test | def create_tomography_circuits(circuit, qreg, creg, tomoset):
"""
Add tomography measurement circuits to a QuantumProgram.
The quantum program must contain a circuit 'name', which is treated as a
state preparation circuit for state tomography, or as teh circuit being
measured for process tomography... | python | {
"resource": ""
} |
q268468 | tomography_data | test | def tomography_data(results, name, tomoset):
"""
Return a results dict for a state or process tomography experiment.
Args:
results (Result): Results from execution of a process tomography
circuits on a backend.
name (string): The name of the circuit being reconstructed.
... | python | {
"resource": ""
} |
q268469 | marginal_counts | test | def marginal_counts(counts, meas_qubits):
"""
Compute the marginal counts for a subset of measured qubits.
Args:
counts (dict): the counts returned from a backend ({str: int}).
meas_qubits (list[int]): the qubits to return the marginal
counts distribution fo... | python | {
"resource": ""
} |
q268470 | fit_tomography_data | test | def fit_tomography_data(tomo_data, method='wizard', options=None):
"""
Reconstruct a density matrix or process-matrix from tomography data.
If the input data is state_tomography_data the returned operator will
be a density matrix. If the input data is process_tomography_data the
returned operator w... | python | {
"resource": ""
} |
q268471 | __leastsq_fit | test | def __leastsq_fit(tomo_data, weights=None, trace=None, beta=None):
"""
Reconstruct a state from unconstrained least-squares fitting.
Args:
tomo_data (list[dict]): state or process tomography data.
weights (list or array or None): weights to use for least squares
fitting. The def... | python | {
"resource": ""
} |
q268472 | __projector | test | def __projector(op_list, basis):
"""Returns a projectors.
"""
ret = 1
# list is from qubit 0 to 1
for op in op_list:
label, eigenstate = op
ret = np.kron(basis[label][eigenstate], ret)
return ret | python | {
"resource": ""
} |
q268473 | __tomo_linear_inv | test | def __tomo_linear_inv(freqs, ops, weights=None, trace=None):
"""
Reconstruct a matrix through linear inversion.
Args:
freqs (list[float]): list of observed frequences.
ops (list[np.array]): list of corresponding projectors.
weights (list[float] or array_like):
weights to... | python | {
"resource": ""
} |
q268474 | __wizard | test | def __wizard(rho, epsilon=None):
"""
Returns the nearest positive semidefinite operator to an operator.
This method is based on reference [1]. It constrains positivity
by setting negative eigenvalues to zero and rescaling the positive
eigenvalues.
Args:
rho (array_like): the input oper... | python | {
"resource": ""
} |
q268475 | wigner_data | test | def wigner_data(q_result, meas_qubits, labels, shots=None):
"""Get the value of the Wigner function from measurement results.
Args:
q_result (Result): Results from execution of a state tomography
circuits on a backend.
meas_qubits (list[int]): a list of the qubit ind... | python | {
"resource": ""
} |
q268476 | TomographyBasis.meas_gate | test | def meas_gate(self, circuit, qreg, op):
"""
Add measurement gates to a circuit.
Args:
circuit (QuantumCircuit): circuit to add measurement to.
qreg (tuple(QuantumRegister,int)): quantum register being measured.
op (str): the basis label for the measurement.
... | python | {
"resource": ""
} |
q268477 | _text_checker | test | def _text_checker(job, interval, _interval_set=False, quiet=False, output=sys.stdout):
"""A text-based job status checker
Args:
job (BaseJob): The job to check.
interval (int): The interval at which to check.
_interval_set (bool): Was interval time set by user?
quiet (bool): If ... | python | {
"resource": ""
} |
q268478 | job_monitor | test | def job_monitor(job, interval=None, monitor_async=False, quiet=False, output=sys.stdout):
"""Monitor the status of a IBMQJob instance.
Args:
job (BaseJob): Job to monitor.
interval (int): Time interval between status queries.
monitor_async (bool): Monitor asyncronously (in Jupyter only)... | python | {
"resource": ""
} |
q268479 | euler_angles_1q | test | def euler_angles_1q(unitary_matrix):
"""Compute Euler angles for a single-qubit gate.
Find angles (theta, phi, lambda) such that
unitary_matrix = phase * Rz(phi) * Ry(theta) * Rz(lambda)
Args:
unitary_matrix (ndarray): 2x2 unitary matrix
Returns:
tuple: (theta, phi, lambda) Euler ... | python | {
"resource": ""
} |
q268480 | simplify_U | test | def simplify_U(theta, phi, lam):
"""Return the gate u1, u2, or u3 implementing U with the fewest pulses.
The returned gate implements U exactly, not up to a global phase.
Args:
theta, phi, lam: input Euler rotation angles for a general U gate
Returns:
Gate: one of IdGate, U1Gate, U2Ga... | python | {
"resource": ""
} |
q268481 | EnlargeWithAncilla.run | test | def run(self, dag):
"""
Extends dag with virtual qubits that are in layout but not in the circuit yet.
Args:
dag (DAGCircuit): DAG to extend.
Returns:
DAGCircuit: An extended DAG.
Raises:
TranspilerError: If there is not layout in the proper... | python | {
"resource": ""
} |
q268482 | qubits_tab | test | def qubits_tab(backend):
"""The qubits properties widget
Args:
backend (IBMQbackend): The backend.
Returns:
VBox: A VBox widget.
"""
props = backend.properties().to_dict()
header_html = "<div><font style='font-weight:bold'>{key}</font>: {value}</div>"
header_html = header_... | python | {
"resource": ""
} |
q268483 | job_history | test | def job_history(backend):
"""Widget for displaying job history
Args:
backend (IBMQbackend): The backend.
Returns:
Tab: A tab widget for history images.
"""
year = widgets.Output(layout=widgets.Layout(display='flex-inline',
align_items='c... | python | {
"resource": ""
} |
q268484 | plot_job_history | test | def plot_job_history(jobs, interval='year'):
"""Plots the job history of the user from the given list of jobs.
Args:
jobs (list): A list of jobs with type IBMQjob.
interval (str): Interval over which to examine.
Returns:
fig: A Matplotlib figure instance.
"""
def get_date(j... | python | {
"resource": ""
} |
q268485 | SamplePulse.draw | test | def draw(self, **kwargs):
"""Plot the interpolated envelope of pulse.
Keyword Args:
dt (float): Time interval of samples.
interp_method (str): Method of interpolation
(set `None` for turn off the interpolation).
filename (str): Name required to save p... | python | {
"resource": ""
} |
q268486 | cu3 | test | def cu3(self, theta, phi, lam, ctl, tgt):
"""Apply cu3 from ctl to tgt with angle theta, phi, lam."""
return self.append(Cu3Gate(theta, phi, lam), [ctl, tgt], []) | python | {
"resource": ""
} |
q268487 | build_bell_circuit | test | def build_bell_circuit():
"""Returns a circuit putting 2 qubits in the Bell state."""
q = QuantumRegister(2)
c = ClassicalRegister(2)
qc = QuantumCircuit(q, c)
qc.h(q[0])
qc.cx(q[0], q[1])
qc.measure(q, c)
return qc | python | {
"resource": ""
} |
q268488 | transpile | test | def transpile(circuits,
backend=None,
basis_gates=None, coupling_map=None, backend_properties=None,
initial_layout=None, seed_transpiler=None,
optimization_level=None,
pass_manager=None,
seed_mapper=None): # deprecated
"""transpile... | python | {
"resource": ""
} |
q268489 | _transpile_circuit | test | def _transpile_circuit(circuit_config_tuple):
"""Select a PassManager and run a single circuit through it.
Args:
circuit_config_tuple (tuple):
circuit (QuantumCircuit): circuit to transpile
transpile_config (TranspileConfig): configuration dictating how to transpile
Returns... | python | {
"resource": ""
} |
q268490 | execute | test | def execute(experiments, backend,
basis_gates=None, coupling_map=None, # circuit transpile options
backend_properties=None, initial_layout=None,
seed_transpiler=None, optimization_level=None, pass_manager=None,
qobj_id=None, qobj_header=None, shots=1024, # common run op... | python | {
"resource": ""
} |
q268491 | Qubit.drive | test | def drive(self) -> DriveChannel:
"""Return the primary drive channel of this qubit."""
if self._drives:
return self._drives[0]
else:
raise PulseError("No drive channels in q[%d]" % self._index) | python | {
"resource": ""
} |
q268492 | Qubit.control | test | def control(self) -> ControlChannel:
"""Return the primary control channel of this qubit."""
if self._controls:
return self._controls[0]
else:
raise PulseError("No control channels in q[%d]" % self._index) | python | {
"resource": ""
} |
q268493 | Qubit.measure | test | def measure(self) -> MeasureChannel:
"""Return the primary measure channel of this qubit."""
if self._measures:
return self._measures[0]
else:
raise PulseError("No measurement channels in q[%d]" % self._index) | python | {
"resource": ""
} |
q268494 | Qubit.acquire | test | def acquire(self) -> AcquireChannel:
"""Return the primary acquire channel of this qubit."""
if self._acquires:
return self._acquires[0]
else:
raise PulseError("No acquire channels in q[%d]" % self._index) | python | {
"resource": ""
} |
q268495 | input_state | test | def input_state(circ, q, n):
"""n-qubit input state for QFT that produces output 1."""
for j in range(n):
circ.h(q[j])
circ.u1(math.pi/float(2**(j)), q[j]).inverse() | python | {
"resource": ""
} |
q268496 | assemble | test | def assemble(experiments,
backend=None,
qobj_id=None, qobj_header=None, # common run options
shots=1024, memory=False, max_credits=None, seed_simulator=None,
default_qubit_los=None, default_meas_los=None, # schedule run options
schedule_los=None, meas_l... | python | {
"resource": ""
} |
q268497 | unset_qiskit_logger | test | def unset_qiskit_logger():
"""Remove the handlers for the 'qiskit' logger."""
qiskit_logger = logging.getLogger('qiskit')
for handler in qiskit_logger.handlers:
qiskit_logger.removeHandler(handler) | python | {
"resource": ""
} |
q268498 | iplot_state_hinton | test | def iplot_state_hinton(rho, figsize=None):
""" Create a hinton representation.
Graphical representation of the input array using a 2D city style
graph (hinton).
Args:
rho (array): Density matrix
figsize (tuple): Figure size in pixels.
"""
# HTML
html_te... | python | {
"resource": ""
} |
q268499 | process_fidelity | test | def process_fidelity(channel1, channel2, require_cptp=True):
"""Return the process fidelity between two quantum channels.
This is given by
F_p(E1, E2) = Tr[S2^dagger.S1])/dim^2
where S1 and S2 are the SuperOp matrices for channels E1 and E2,
and dim is the dimension of the input output states... | python | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.