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
_generate_normals
Takes a list of polygons and return an array of their normals. Normals point towards the viewer for a face with its vertices in counterclockwise order, following the right hand rule. Uses three points equally spaced around the polygon. This normal of course might not make sense for polygons with more th...
qiskit/visualization/state_visualization.py
def _generate_normals(polygons): """ Takes a list of polygons and return an array of their normals. Normals point towards the viewer for a face with its vertices in counterclockwise order, following the right hand rule. Uses three points equally spaced around the polygon. This normal of course m...
def _generate_normals(polygons): """ Takes a list of polygons and return an array of their normals. Normals point towards the viewer for a face with its vertices in counterclockwise order, following the right hand rule. Uses three points equally spaced around the polygon. This normal of course m...
[ "Takes", "a", "list", "of", "polygons", "and", "return", "an", "array", "of", "their", "normals", ".", "Normals", "point", "towards", "the", "viewer", "for", "a", "face", "with", "its", "vertices", "in", "counterclockwise", "order", "following", "the", "righ...
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/visualization/state_visualization.py#L713-L749
[ "def", "_generate_normals", "(", "polygons", ")", ":", "if", "isinstance", "(", "polygons", ",", "np", ".", "ndarray", ")", ":", "# optimization: polygons all have the same number of points, so can", "# vectorize", "n", "=", "polygons", ".", "shape", "[", "-", "2", ...
d4f58d903bc96341b816f7c35df936d6421267d1
test
_shade_colors
Shade *color* using normal vectors given by *normals*. *color* can also be an array of the same length as *normals*.
qiskit/visualization/state_visualization.py
def _shade_colors(color, normals, lightsource=None): """ Shade *color* using normal vectors given by *normals*. *color* can also be an array of the same length as *normals*. """ if lightsource is None: # chosen for backwards-compatibility lightsource = LightSource(azdeg=225, altdeg=1...
def _shade_colors(color, normals, lightsource=None): """ Shade *color* using normal vectors given by *normals*. *color* can also be an array of the same length as *normals*. """ if lightsource is None: # chosen for backwards-compatibility lightsource = LightSource(azdeg=225, altdeg=1...
[ "Shade", "*", "color", "*", "using", "normal", "vectors", "given", "by", "*", "normals", "*", ".", "*", "color", "*", "can", "also", "be", "an", "array", "of", "the", "same", "length", "as", "*", "normals", "*", "." ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/visualization/state_visualization.py#L752-L779
[ "def", "_shade_colors", "(", "color", ",", "normals", ",", "lightsource", "=", "None", ")", ":", "if", "lightsource", "is", "None", ":", "# chosen for backwards-compatibility", "lightsource", "=", "LightSource", "(", "azdeg", "=", "225", ",", "altdeg", "=", "1...
d4f58d903bc96341b816f7c35df936d6421267d1
test
get_unique_backends
Gets the unique backends that are available. Returns: list: Unique available backends. Raises: QiskitError: No backends available.
qiskit/tools/monitor/backend_overview.py
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: ...
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: ...
[ "Gets", "the", "unique", "backends", "that", "are", "available", "." ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/tools/monitor/backend_overview.py#L21-L39
[ "def", "get_unique_backends", "(", ")", ":", "backends", "=", "IBMQ", ".", "backends", "(", ")", "unique_hardware_backends", "=", "[", "]", "unique_names", "=", "[", "]", "for", "back", "in", "backends", ":", "if", "back", ".", "name", "(", ")", "not", ...
d4f58d903bc96341b816f7c35df936d6421267d1
test
backend_monitor
Monitor a single IBMQ backend. Args: backend (IBMQBackend): Backend to monitor. Raises: QiskitError: Input is not a IBMQ backend.
qiskit/tools/monitor/backend_overview.py
def backend_monitor(backend): """Monitor a single IBMQ backend. Args: backend (IBMQBackend): Backend to monitor. Raises: QiskitError: Input is not a IBMQ backend. """ if not isinstance(backend, IBMQBackend): raise QiskitError('Input variable is not of type IBMQBackend.') ...
def backend_monitor(backend): """Monitor a single IBMQ backend. Args: backend (IBMQBackend): Backend to monitor. Raises: QiskitError: Input is not a IBMQ backend. """ if not isinstance(backend, IBMQBackend): raise QiskitError('Input variable is not of type IBMQBackend.') ...
[ "Monitor", "a", "single", "IBMQ", "backend", "." ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/tools/monitor/backend_overview.py#L42-L121
[ "def", "backend_monitor", "(", "backend", ")", ":", "if", "not", "isinstance", "(", "backend", ",", "IBMQBackend", ")", ":", "raise", "QiskitError", "(", "'Input variable is not of type IBMQBackend.'", ")", "config", "=", "backend", ".", "configuration", "(", ")",...
d4f58d903bc96341b816f7c35df936d6421267d1
test
backend_overview
Gives overview information on all the IBMQ backends that are available.
qiskit/tools/monitor/backend_overview.py
def backend_overview(): """Gives overview information on all the IBMQ backends that are available. """ unique_hardware_backends = get_unique_backends() _backends = [] # Sort backends by operational or not for idx, back in enumerate(unique_hardware_backends): if back.status().operatio...
def backend_overview(): """Gives overview information on all the IBMQ backends that are available. """ unique_hardware_backends = get_unique_backends() _backends = [] # Sort backends by operational or not for idx, back in enumerate(unique_hardware_backends): if back.status().operatio...
[ "Gives", "overview", "information", "on", "all", "the", "IBMQ", "backends", "that", "are", "available", "." ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/tools/monitor/backend_overview.py#L124-L190
[ "def", "backend_overview", "(", ")", ":", "unique_hardware_backends", "=", "get_unique_backends", "(", ")", "_backends", "=", "[", "]", "# Sort backends by operational or not", "for", "idx", ",", "back", "in", "enumerate", "(", "unique_hardware_backends", ")", ":", ...
d4f58d903bc96341b816f7c35df936d6421267d1
test
DAGNode.op
Returns the Instruction object corresponding to the op for the node else None
qiskit/dagcircuit/dagnode.py
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')
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')
[ "Returns", "the", "Instruction", "object", "corresponding", "to", "the", "op", "for", "the", "node", "else", "None" ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/dagcircuit/dagnode.py#L33-L37
[ "def", "op", "(", "self", ")", ":", "if", "'type'", "not", "in", "self", ".", "data_dict", "or", "self", ".", "data_dict", "[", "'type'", "]", "!=", "'op'", ":", "raise", "QiskitError", "(", "\"The node %s is not an op node\"", "%", "(", "str", "(", "sel...
d4f58d903bc96341b816f7c35df936d6421267d1
test
DAGNode.wire
Returns (Register, int) tuple where the int is the index of the wire else None
qiskit/dagcircuit/dagnode.py
def wire(self): """ Returns (Register, int) tuple where the int is the index of the wire else None """ if self.data_dict['type'] not in ['in', 'out']: raise QiskitError('The node %s is not an input/output node' % str(self)) return self.data_dict.get('wire')
def wire(self): """ Returns (Register, int) tuple where the int is the index of the wire else None """ if self.data_dict['type'] not in ['in', 'out']: raise QiskitError('The node %s is not an input/output node' % str(self)) return self.data_dict.get('wire')
[ "Returns", "(", "Register", "int", ")", "tuple", "where", "the", "int", "is", "the", "index", "of", "the", "wire", "else", "None" ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/dagcircuit/dagnode.py#L79-L86
[ "def", "wire", "(", "self", ")", ":", "if", "self", ".", "data_dict", "[", "'type'", "]", "not", "in", "[", "'in'", ",", "'out'", "]", ":", "raise", "QiskitError", "(", "'The node %s is not an input/output node'", "%", "str", "(", "self", ")", ")", "retu...
d4f58d903bc96341b816f7c35df936d6421267d1
test
DAGNode.semantic_eq
Check if DAG nodes are considered equivalent, e.g. as a node_match for nx.is_isomorphic. Args: node1 (DAGNode): A node to compare. node2 (DAGNode): The other node to compare. Return: Bool: If node1 == node2
qiskit/dagcircuit/dagnode.py
def semantic_eq(node1, node2): """ Check if DAG nodes are considered equivalent, e.g. as a node_match for nx.is_isomorphic. Args: node1 (DAGNode): A node to compare. node2 (DAGNode): The other node to compare. Return: Bool: If node1 == node2 ...
def semantic_eq(node1, node2): """ Check if DAG nodes are considered equivalent, e.g. as a node_match for nx.is_isomorphic. Args: node1 (DAGNode): A node to compare. node2 (DAGNode): The other node to compare. Return: Bool: If node1 == node2 ...
[ "Check", "if", "DAG", "nodes", "are", "considered", "equivalent", "e", ".", "g", ".", "as", "a", "node_match", "for", "nx", ".", "is_isomorphic", "." ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/dagcircuit/dagnode.py#L110-L124
[ "def", "semantic_eq", "(", "node1", ",", "node2", ")", ":", "# For barriers, qarg order is not significant so compare as sets", "if", "'barrier'", "==", "node1", ".", "name", "==", "node2", ".", "name", ":", "return", "set", "(", "node1", ".", "qargs", ")", "=="...
d4f58d903bc96341b816f7c35df936d6421267d1
test
constant
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 amplitude. name: Name of pulse.
qiskit/pulse/pulse_lib/discrete.py
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...
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...
[ "Generates", "constant", "-", "sampled", "SamplePulse", "." ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/pulse/pulse_lib/discrete.py#L23-L33
[ "def", "constant", "(", "duration", ":", "int", ",", "amp", ":", "complex", ",", "name", ":", "str", "=", "None", ")", "->", "SamplePulse", ":", "return", "_sampled_constant_pulse", "(", "duration", ",", "amp", ",", "name", "=", "name", ")" ]
d4f58d903bc96341b816f7c35df936d6421267d1
test
zero
Generates zero-sampled `SamplePulse`. Args: duration: Duration of pulse. Must be greater than zero. name: Name of pulse.
qiskit/pulse/pulse_lib/discrete.py
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)
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)
[ "Generates", "zero", "-", "sampled", "SamplePulse", "." ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/pulse/pulse_lib/discrete.py#L39-L46
[ "def", "zero", "(", "duration", ":", "int", ",", "name", ":", "str", "=", "None", ")", "->", "SamplePulse", ":", "return", "_sampled_zero_pulse", "(", "duration", ",", "name", "=", "name", ")" ]
d4f58d903bc96341b816f7c35df936d6421267d1
test
square
Generates square wave `SamplePulse`. Applies `left` sampling strategy to generate discrete pulse from continuous function. Args: duration: Duration of pulse. Must be greater than zero. amp: Pulse amplitude. Wave range is [-amp, amp]. period: Pulse period, units of dt. If `None` default...
qiskit/pulse/pulse_lib/discrete.py
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...
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...
[ "Generates", "square", "wave", "SamplePulse", "." ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/pulse/pulse_lib/discrete.py#L52-L68
[ "def", "square", "(", "duration", ":", "int", ",", "amp", ":", "complex", ",", "period", ":", "float", "=", "None", ",", "phase", ":", "float", "=", "0", ",", "name", ":", "str", "=", "None", ")", "->", "SamplePulse", ":", "if", "period", "is", "...
d4f58d903bc96341b816f7c35df936d6421267d1
test
sawtooth
Generates sawtooth wave `SamplePulse`. Args: duration: Duration of pulse. Must be greater than zero. amp: Pulse amplitude. Wave range is [-amp, amp]. period: Pulse period, units of dt. If `None` defaults to single cycle. phase: Pulse phase. name: Name of pulse.
qiskit/pulse/pulse_lib/discrete.py
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...
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...
[ "Generates", "sawtooth", "wave", "SamplePulse", "." ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/pulse/pulse_lib/discrete.py#L74-L88
[ "def", "sawtooth", "(", "duration", ":", "int", ",", "amp", ":", "complex", ",", "period", ":", "float", "=", "None", ",", "phase", ":", "float", "=", "0", ",", "name", ":", "str", "=", "None", ")", "->", "SamplePulse", ":", "if", "period", "is", ...
d4f58d903bc96341b816f7c35df936d6421267d1
test
triangle
Generates triangle wave `SamplePulse`. Applies `left` sampling strategy to generate discrete pulse from continuous function. Args: duration: Duration of pulse. Must be greater than zero. amp: Pulse amplitude. Wave range is [-amp, amp]. period: Pulse period, units of dt. If `None` defau...
qiskit/pulse/pulse_lib/discrete.py
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...
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...
[ "Generates", "triangle", "wave", "SamplePulse", "." ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/pulse/pulse_lib/discrete.py#L94-L110
[ "def", "triangle", "(", "duration", ":", "int", ",", "amp", ":", "complex", ",", "period", ":", "float", "=", "None", ",", "phase", ":", "float", "=", "0", ",", "name", ":", "str", "=", "None", ")", "->", "SamplePulse", ":", "if", "period", "is", ...
d4f58d903bc96341b816f7c35df936d6421267d1
test
cos
Generates cosine wave `SamplePulse`. Applies `left` sampling strategy to generate discrete pulse from continuous function. Args: duration: Duration of pulse. Must be greater than zero. amp: Pulse amplitude. freq: Pulse frequency, units of 1/dt. If `None` defaults to single cycle. ...
qiskit/pulse/pulse_lib/discrete.py
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...
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...
[ "Generates", "cosine", "wave", "SamplePulse", "." ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/pulse/pulse_lib/discrete.py#L116-L132
[ "def", "cos", "(", "duration", ":", "int", ",", "amp", ":", "complex", ",", "freq", ":", "float", "=", "None", ",", "phase", ":", "float", "=", "0", ",", "name", ":", "str", "=", "None", ")", "->", "SamplePulse", ":", "if", "freq", "is", "None", ...
d4f58d903bc96341b816f7c35df936d6421267d1
test
sin
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` defaults to single cycle. phase: Pulse phase. name: Name of pulse.
qiskit/pulse/pulse_lib/discrete.py
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` ...
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` ...
[ "Generates", "sine", "wave", "SamplePulse", "." ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/pulse/pulse_lib/discrete.py#L138-L152
[ "def", "sin", "(", "duration", ":", "int", ",", "amp", ":", "complex", ",", "freq", ":", "float", "=", "None", ",", "phase", ":", "float", "=", "0", ",", "name", ":", "str", "=", "None", ")", "->", "SamplePulse", ":", "if", "freq", "is", "None", ...
d4f58d903bc96341b816f7c35df936d6421267d1
test
gaussian
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 function. Integrated area under curve is $\Omega_g(amp, sigma) = amp \times np.sqrt(2\pi \si...
qiskit/pulse/pulse_lib/discrete.py
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...
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...
[ "r", "Generates", "unnormalized", "gaussian", "SamplePulse", "." ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/pulse/pulse_lib/discrete.py#L158-L176
[ "def", "gaussian", "(", "duration", ":", "int", ",", "amp", ":", "complex", ",", "sigma", ":", "float", ",", "name", ":", "str", "=", "None", ")", "->", "SamplePulse", ":", "center", "=", "duration", "/", "2", "zeroed_width", "=", "duration", "+", "2...
d4f58d903bc96341b816f7c35df936d6421267d1
test
gaussian_deriv
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 than zero. amp: Pulse amplitude at `center`. sigma: Width (standard deviation) of pulse...
qiskit/pulse/pulse_lib/discrete.py
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...
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...
[ "r", "Generates", "unnormalized", "gaussian", "derivative", "SamplePulse", "." ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/pulse/pulse_lib/discrete.py#L182-L194
[ "def", "gaussian_deriv", "(", "duration", ":", "int", ",", "amp", ":", "complex", ",", "sigma", ":", "float", ",", "name", ":", "str", "=", "None", ")", "->", "SamplePulse", ":", "center", "=", "duration", "/", "2", "return", "_sampled_gaussian_deriv_pulse...
d4f58d903bc96341b816f7c35df936d6421267d1
test
gaussian_square
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` sampling strategy to generate discrete pulse from continuous function. Args: duration: Duration of pulse. Must be greater th...
qiskit/pulse/pulse_lib/discrete.py
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...
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...
[ "Generates", "gaussian", "square", "SamplePulse", "." ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/pulse/pulse_lib/discrete.py#L200-L221
[ "def", "gaussian_square", "(", "duration", ":", "int", ",", "amp", ":", "complex", ",", "sigma", ":", "float", ",", "risefall", ":", "int", ",", "name", ":", "str", "=", "None", ")", "->", "SamplePulse", ":", "center", "=", "duration", "/", "2", "wid...
d4f58d903bc96341b816f7c35df936d6421267d1
test
drag
r"""Generates Y-only correction DRAG `SamplePulse` for standard nonlinear oscillator (SNO) [1]. Centered at `duration/2` and zeroed at `t=-1` to prevent large initial discontinuity. Applies `left` sampling strategy to generate discrete pulse from continuous function. [1] Gambetta, J. M., Motzoi, F., Merk...
qiskit/pulse/pulse_lib/discrete.py
def drag(duration: int, amp: complex, sigma: float, beta: float, name: str = None) -> SamplePulse: r"""Generates Y-only correction DRAG `SamplePulse` for standard nonlinear oscillator (SNO) [1]. Centered at `duration/2` and zeroed at `t=-1` to prevent large initial discontinuity. Applies `left` sampling s...
def drag(duration: int, amp: complex, sigma: float, beta: float, name: str = None) -> SamplePulse: r"""Generates Y-only correction DRAG `SamplePulse` for standard nonlinear oscillator (SNO) [1]. Centered at `duration/2` and zeroed at `t=-1` to prevent large initial discontinuity. Applies `left` sampling s...
[ "r", "Generates", "Y", "-", "only", "correction", "DRAG", "SamplePulse", "for", "standard", "nonlinear", "oscillator", "(", "SNO", ")", "[", "1", "]", "." ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/pulse/pulse_lib/discrete.py#L227-L251
[ "def", "drag", "(", "duration", ":", "int", ",", "amp", ":", "complex", ",", "sigma", ":", "float", ",", "beta", ":", "float", ",", "name", ":", "str", "=", "None", ")", "->", "SamplePulse", ":", "center", "=", "duration", "/", "2", "zeroed_width", ...
d4f58d903bc96341b816f7c35df936d6421267d1
test
RemoveDiagonalGatesBeforeMeasure.run
Return a new circuit that has been optimized.
qiskit/transpiler/passes/remove_diagonal_gates_before_measure.py
def run(self, dag): """Return a new circuit that has been optimized.""" diagonal_1q_gates = (RZGate, ZGate, TGate, SGate, TdgGate, SdgGate, U1Gate) diagonal_2q_gates = (CzGate, CrzGate, Cu1Gate, RZZGate) nodes_to_remove = set() for measure in dag.op_nodes(Measure): p...
def run(self, dag): """Return a new circuit that has been optimized.""" diagonal_1q_gates = (RZGate, ZGate, TGate, SGate, TdgGate, SdgGate, U1Gate) diagonal_2q_gates = (CzGate, CrzGate, Cu1Gate, RZZGate) nodes_to_remove = set() for measure in dag.op_nodes(Measure): p...
[ "Return", "a", "new", "circuit", "that", "has", "been", "optimized", "." ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/transpiler/passes/remove_diagonal_gates_before_measure.py#L24-L44
[ "def", "run", "(", "self", ",", "dag", ")", ":", "diagonal_1q_gates", "=", "(", "RZGate", ",", "ZGate", ",", "TGate", ",", "SGate", ",", "TdgGate", ",", "SdgGate", ",", "U1Gate", ")", "diagonal_2q_gates", "=", "(", "CzGate", ",", "CrzGate", ",", "Cu1Ga...
d4f58d903bc96341b816f7c35df936d6421267d1
test
plot_gate_map
Plots the gate map of a device. Args: backend (BaseBackend): A backend instance, figsize (tuple): Output figure size (wxh) in inches. plot_directed (bool): Plot directed coupling map. label_qubits (bool): Label the qubits. qubit_size (float): Size of qubit marker. li...
qiskit/visualization/gate_map.py
def plot_gate_map(backend, figsize=None, plot_directed=False, label_qubits=True, qubit_size=24, line_width=4, font_size=12, qubit_color=None, line_color=None, font_color='w'): ...
def plot_gate_map(backend, figsize=None, plot_directed=False, label_qubits=True, qubit_size=24, line_width=4, font_size=12, qubit_color=None, line_color=None, font_color='w'): ...
[ "Plots", "the", "gate", "map", "of", "a", "device", "." ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/visualization/gate_map.py#L53-L212
[ "def", "plot_gate_map", "(", "backend", ",", "figsize", "=", "None", ",", "plot_directed", "=", "False", ",", "label_qubits", "=", "True", ",", "qubit_size", "=", "24", ",", "line_width", "=", "4", ",", "font_size", "=", "12", ",", "qubit_color", "=", "N...
d4f58d903bc96341b816f7c35df936d6421267d1
test
_GraphDist.dist_real
Compute distance.
qiskit/visualization/gate_map.py
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 ...
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 ...
[ "Compute", "distance", "." ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/visualization/gate_map.py#L26-L34
[ "def", "dist_real", "(", "self", ")", ":", "x0", ",", "y0", "=", "self", ".", "ax", ".", "transAxes", ".", "transform", "(", "# pylint: disable=invalid-name", "(", "0", ",", "0", ")", ")", "x1", ",", "y1", "=", "self", ".", "ax", ".", "transAxes", ...
d4f58d903bc96341b816f7c35df936d6421267d1
test
_GraphDist.dist_abs
Distance abs
qiskit/visualization/gate_map.py
def dist_abs(self): """Distance abs """ bounds = self.ax.get_xlim() if self.x else self.ax.get_ylim() return bounds[0] - bounds[1]
def dist_abs(self): """Distance abs """ bounds = self.ax.get_xlim() if self.x else self.ax.get_ylim() return bounds[0] - bounds[1]
[ "Distance", "abs" ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/visualization/gate_map.py#L37-L41
[ "def", "dist_abs", "(", "self", ")", ":", "bounds", "=", "self", ".", "ax", ".", "get_xlim", "(", ")", "if", "self", ".", "x", "else", "self", ".", "ax", ".", "get_ylim", "(", ")", "return", "bounds", "[", "0", "]", "-", "bounds", "[", "1", "]"...
d4f58d903bc96341b816f7c35df936d6421267d1
test
Qreg.to_string
Print the node data, with indent.
qiskit/qasm/node/qreg.py
def to_string(self, indent): """Print the node data, with indent.""" ind = indent * ' ' print(ind, 'qreg') self.children[0].to_string(indent + 3)
def to_string(self, indent): """Print the node data, with indent.""" ind = indent * ' ' print(ind, 'qreg') self.children[0].to_string(indent + 3)
[ "Print", "the", "node", "data", "with", "indent", "." ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/qasm/node/qreg.py#L35-L39
[ "def", "to_string", "(", "self", ",", "indent", ")", ":", "ind", "=", "indent", "*", "' '", "print", "(", "ind", ",", "'qreg'", ")", "self", ".", "children", "[", "0", "]", ".", "to_string", "(", "indent", "+", "3", ")" ]
d4f58d903bc96341b816f7c35df936d6421267d1
test
BasicAerProvider._verify_backends
Return the Basic Aer backends in `BACKENDS` that are effectively available (as some of them might depend on the presence of an optional dependency or on the existence of a binary). Returns: dict[str:BaseBackend]: a dict of Basic Aer backend instances for the backends...
qiskit/providers/basicaer/basicaerprovider.py
def _verify_backends(self): """ Return the Basic Aer backends in `BACKENDS` that are effectively available (as some of them might depend on the presence of an optional dependency or on the existence of a binary). Returns: dict[str:BaseBackend]: a dict of Basic Aer ba...
def _verify_backends(self): """ Return the Basic Aer backends in `BACKENDS` that are effectively available (as some of them might depend on the presence of an optional dependency or on the existence of a binary). Returns: dict[str:BaseBackend]: a dict of Basic Aer ba...
[ "Return", "the", "Basic", "Aer", "backends", "in", "BACKENDS", "that", "are", "effectively", "available", "(", "as", "some", "of", "them", "might", "depend", "on", "the", "presence", "of", "an", "optional", "dependency", "or", "on", "the", "existence", "of",...
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/providers/basicaer/basicaerprovider.py#L94-L114
[ "def", "_verify_backends", "(", "self", ")", ":", "ret", "=", "OrderedDict", "(", ")", "for", "backend_cls", "in", "SIMULATORS", ":", "try", ":", "backend_instance", "=", "self", ".", "_get_backend_instance", "(", "backend_cls", ")", "backend_name", "=", "back...
d4f58d903bc96341b816f7c35df936d6421267d1
test
BasicAerProvider._get_backend_instance
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.
qiskit/providers/basicaer/basicaerprovider.py
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...
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...
[ "Return", "an", "instance", "of", "a", "backend", "from", "its", "class", "." ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/providers/basicaer/basicaerprovider.py#L116-L134
[ "def", "_get_backend_instance", "(", "self", ",", "backend_cls", ")", ":", "# Verify that the backend can be instantiated.", "try", ":", "backend_instance", "=", "backend_cls", "(", "provider", "=", "self", ")", "except", "Exception", "as", "err", ":", "raise", "Qis...
d4f58d903bc96341b816f7c35df936d6421267d1
test
DAGCircuit.qubits
Return a list of qubits as (QuantumRegister, index) pairs.
qiskit/dagcircuit/dagcircuit.py
def qubits(self): """Return a list of qubits as (QuantumRegister, index) pairs.""" return [(v, i) for k, v in self.qregs.items() for i in range(v.size)]
def qubits(self): """Return a list of qubits as (QuantumRegister, index) pairs.""" return [(v, i) for k, v in self.qregs.items() for i in range(v.size)]
[ "Return", "a", "list", "of", "qubits", "as", "(", "QuantumRegister", "index", ")", "pairs", "." ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/dagcircuit/dagcircuit.py#L104-L106
[ "def", "qubits", "(", "self", ")", ":", "return", "[", "(", "v", ",", "i", ")", "for", "k", ",", "v", "in", "self", ".", "qregs", ".", "items", "(", ")", "for", "i", "in", "range", "(", "v", ".", "size", ")", "]" ]
d4f58d903bc96341b816f7c35df936d6421267d1
test
DAGCircuit.clbits
Return a list of bits as (ClassicalRegister, index) pairs.
qiskit/dagcircuit/dagcircuit.py
def clbits(self): """Return a list of bits as (ClassicalRegister, index) pairs.""" return [(v, i) for k, v in self.cregs.items() for i in range(v.size)]
def clbits(self): """Return a list of bits as (ClassicalRegister, index) pairs.""" return [(v, i) for k, v in self.cregs.items() for i in range(v.size)]
[ "Return", "a", "list", "of", "bits", "as", "(", "ClassicalRegister", "index", ")", "pairs", "." ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/dagcircuit/dagcircuit.py#L114-L116
[ "def", "clbits", "(", "self", ")", ":", "return", "[", "(", "v", ",", "i", ")", "for", "k", ",", "v", "in", "self", ".", "cregs", ".", "items", "(", ")", "for", "i", "in", "range", "(", "v", ".", "size", ")", "]" ]
d4f58d903bc96341b816f7c35df936d6421267d1
test
DAGCircuit.rename_register
Rename a classical or quantum register throughout the circuit. regname = existing register name string newname = replacement register name string
qiskit/dagcircuit/dagcircuit.py
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...
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...
[ "Rename", "a", "classical", "or", "quantum", "register", "throughout", "the", "circuit", "." ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/dagcircuit/dagcircuit.py#L127-L173
[ "def", "rename_register", "(", "self", ",", "regname", ",", "newname", ")", ":", "if", "regname", "==", "newname", ":", "return", "if", "newname", "in", "self", ".", "qregs", "or", "newname", "in", "self", ".", "cregs", ":", "raise", "DAGCircuitError", "...
d4f58d903bc96341b816f7c35df936d6421267d1
test
DAGCircuit.remove_all_ops_named
Remove all operation nodes with the given name.
qiskit/dagcircuit/dagcircuit.py
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)
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)
[ "Remove", "all", "operation", "nodes", "with", "the", "given", "name", "." ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/dagcircuit/dagcircuit.py#L175-L178
[ "def", "remove_all_ops_named", "(", "self", ",", "opname", ")", ":", "for", "n", "in", "self", ".", "named_nodes", "(", "opname", ")", ":", "self", ".", "remove_op_node", "(", "n", ")" ]
d4f58d903bc96341b816f7c35df936d6421267d1
test
DAGCircuit.add_qreg
Add all wires in a quantum register.
qiskit/dagcircuit/dagcircuit.py
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...
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...
[ "Add", "all", "wires", "in", "a", "quantum", "register", "." ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/dagcircuit/dagcircuit.py#L180-L188
[ "def", "add_qreg", "(", "self", ",", "qreg", ")", ":", "if", "not", "isinstance", "(", "qreg", ",", "QuantumRegister", ")", ":", "raise", "DAGCircuitError", "(", "\"not a QuantumRegister instance.\"", ")", "if", "qreg", ".", "name", "in", "self", ".", "qregs...
d4f58d903bc96341b816f7c35df936d6421267d1
test
DAGCircuit.add_creg
Add all wires in a classical register.
qiskit/dagcircuit/dagcircuit.py
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...
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...
[ "Add", "all", "wires", "in", "a", "classical", "register", "." ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/dagcircuit/dagcircuit.py#L190-L198
[ "def", "add_creg", "(", "self", ",", "creg", ")", ":", "if", "not", "isinstance", "(", "creg", ",", "ClassicalRegister", ")", ":", "raise", "DAGCircuitError", "(", "\"not a ClassicalRegister instance.\"", ")", "if", "creg", ".", "name", "in", "self", ".", "c...
d4f58d903bc96341b816f7c35df936d6421267d1
test
DAGCircuit._add_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
qiskit/dagcircuit/dagcircuit.py
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 ...
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 ...
[ "Add", "a", "qubit", "or", "bit", "to", "the", "circuit", "." ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/dagcircuit/dagcircuit.py#L200-L241
[ "def", "_add_wire", "(", "self", ",", "wire", ")", ":", "if", "wire", "not", "in", "self", ".", "wires", ":", "self", ".", "wires", ".", "append", "(", "wire", ")", "self", ".", "_max_node_id", "+=", "1", "input_map_wire", "=", "self", ".", "input_ma...
d4f58d903bc96341b816f7c35df936d6421267d1
test
DAGCircuit._check_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 register
qiskit/dagcircuit/dagcircuit.py
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...
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...
[ "Verify", "that", "the", "condition", "is", "valid", "." ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/dagcircuit/dagcircuit.py#L243-L255
[ "def", "_check_condition", "(", "self", ",", "name", ",", "condition", ")", ":", "# Verify creg exists", "if", "condition", "is", "not", "None", "and", "condition", "[", "0", "]", ".", "name", "not", "in", "self", ".", "cregs", ":", "raise", "DAGCircuitErr...
d4f58d903bc96341b816f7c35df936d6421267d1
test
DAGCircuit._check_bits
Check the values of a list of (qu)bit arguments. For each element of args, check that amap contains it. Args: args (list): (register,idx) tuples amap (dict): a dictionary keyed on (register,idx) tuples Raises: DAGCircuitError: if a qubit is not contained in...
qiskit/dagcircuit/dagcircuit.py
def _check_bits(self, args, amap): """Check the values of a list of (qu)bit arguments. For each element of args, check that amap contains it. Args: args (list): (register,idx) tuples amap (dict): a dictionary keyed on (register,idx) tuples Raises: D...
def _check_bits(self, args, amap): """Check the values of a list of (qu)bit arguments. For each element of args, check that amap contains it. Args: args (list): (register,idx) tuples amap (dict): a dictionary keyed on (register,idx) tuples Raises: D...
[ "Check", "the", "values", "of", "a", "list", "of", "(", "qu", ")", "bit", "arguments", "." ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/dagcircuit/dagcircuit.py#L257-L273
[ "def", "_check_bits", "(", "self", ",", "args", ",", "amap", ")", ":", "# Check for each wire", "for", "wire", "in", "args", ":", "if", "wire", "not", "in", "amap", ":", "raise", "DAGCircuitError", "(", "\"(qu)bit %s[%d] not found\"", "%", "(", "wire", "[", ...
d4f58d903bc96341b816f7c35df936d6421267d1
test
DAGCircuit._bits_in_condition
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
qiskit/dagcircuit/dagcircuit.py
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...
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...
[ "Return", "a", "list", "of", "bits", "in", "the", "given", "condition", "." ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/dagcircuit/dagcircuit.py#L275-L287
[ "def", "_bits_in_condition", "(", "self", ",", "cond", ")", ":", "all_bits", "=", "[", "]", "if", "cond", "is", "not", "None", ":", "all_bits", ".", "extend", "(", "[", "(", "cond", "[", "0", "]", ",", "j", ")", "for", "j", "in", "range", "(", ...
d4f58d903bc96341b816f7c35df936d6421267d1
test
DAGCircuit._add_op_node
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 classical wires to attach to. condition (tuple or None): option...
qiskit/dagcircuit/dagcircuit.py
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...
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...
[ "Add", "a", "new", "operation", "node", "to", "the", "graph", "and", "assign", "properties", "." ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/dagcircuit/dagcircuit.py#L289-L311
[ "def", "_add_op_node", "(", "self", ",", "op", ",", "qargs", ",", "cargs", ",", "condition", "=", "None", ")", ":", "node_properties", "=", "{", "\"type\"", ":", "\"op\"", ",", "\"op\"", ":", "op", ",", "\"name\"", ":", "op", ".", "name", ",", "\"qar...
d4f58d903bc96341b816f7c35df936d6421267d1
test
DAGCircuit.apply_operation_back
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]): cbits that op will be applied to condition (tuple or None): optional co...
qiskit/dagcircuit/dagcircuit.py
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...
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...
[ "Apply", "an", "operation", "to", "the", "output", "of", "the", "circuit", "." ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/dagcircuit/dagcircuit.py#L313-L357
[ "def", "apply_operation_back", "(", "self", ",", "op", ",", "qargs", "=", "None", ",", "cargs", "=", "None", ",", "condition", "=", "None", ")", ":", "qargs", "=", "qargs", "or", "[", "]", "cargs", "=", "cargs", "or", "[", "]", "all_cbits", "=", "s...
d4f58d903bc96341b816f7c35df936d6421267d1
test
DAGCircuit._check_edgemap_registers
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 no duplicate registers. A register is duplicate if it appears in both self and ...
qiskit/dagcircuit/dagcircuit.py
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...
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...
[ "Check", "that", "wiremap", "neither", "fragments", "nor", "leaves", "duplicate", "registers", "." ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/dagcircuit/dagcircuit.py#L397-L448
[ "def", "_check_edgemap_registers", "(", "self", ",", "edge_map", ",", "keyregs", ",", "valregs", ",", "valreg", "=", "True", ")", ":", "# FIXME: some mixing of objects and strings here are awkward (due to", "# self.qregs/self.cregs still keying on string.", "add_regs", "=", "...
d4f58d903bc96341b816f7c35df936d6421267d1
test
DAGCircuit._check_wiremap_validity
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 (register,idx) in valmap keymap (dict): a map whose keys are wire_m...
qiskit/dagcircuit/dagcircuit.py
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...
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...
[ "Check", "that", "the", "wiremap", "is", "consistent", "." ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/dagcircuit/dagcircuit.py#L450-L474
[ "def", "_check_wiremap_validity", "(", "self", ",", "wire_map", ",", "keymap", ",", "valmap", ")", ":", "for", "k", ",", "v", "in", "wire_map", ".", "items", "(", ")", ":", "kname", "=", "\"%s[%d]\"", "%", "(", "k", "[", "0", "]", ".", "name", ",",...
d4f58d903bc96341b816f7c35df936d6421267d1
test
DAGCircuit._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
qiskit/dagcircuit/dagcircuit.py
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...
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...
[ "Use", "the", "wire_map", "dict", "to", "change", "the", "condition", "tuple", "s", "creg", "name", "." ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/dagcircuit/dagcircuit.py#L476-L493
[ "def", "_map_condition", "(", "self", ",", "wire_map", ",", "condition", ")", ":", "if", "condition", "is", "None", ":", "new_condition", "=", "None", "else", ":", "# Map the register name, using fact that registers must not be", "# fragmented by the wire_map (this must hav...
d4f58d903bc96341b816f7c35df936d6421267d1
test
DAGCircuit.extend_back
Add `dag` at the end of `self`, using `edge_map`.
qiskit/dagcircuit/dagcircuit.py
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_...
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_...
[ "Add", "dag", "at", "the", "end", "of", "self", "using", "edge_map", "." ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/dagcircuit/dagcircuit.py#L495-L509
[ "def", "extend_back", "(", "self", ",", "dag", ",", "edge_map", "=", "None", ")", ":", "edge_map", "=", "edge_map", "or", "{", "}", "for", "qreg", "in", "dag", ".", "qregs", ".", "values", "(", ")", ":", "if", "qreg", ".", "name", "not", "in", "s...
d4f58d903bc96341b816f7c35df936d6421267d1
test
DAGCircuit.compose_back
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: input_circuit (DAGCircuit): circuit to append ...
qiskit/dagcircuit/dagcircuit.py
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...
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...
[ "Apply", "the", "input", "circuit", "to", "the", "output", "of", "this", "circuit", "." ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/dagcircuit/dagcircuit.py#L511-L571
[ "def", "compose_back", "(", "self", ",", "input_circuit", ",", "edge_map", "=", "None", ")", ":", "edge_map", "=", "edge_map", "or", "{", "}", "# Check the wire map for duplicate values", "if", "len", "(", "set", "(", "edge_map", ".", "values", "(", ")", ")"...
d4f58d903bc96341b816f7c35df936d6421267d1
test
DAGCircuit.depth
Return the circuit depth. Returns: int: the circuit depth Raises: DAGCircuitError: if not a directed acyclic graph
qiskit/dagcircuit/dagcircuit.py
def depth(self): """Return the circuit depth. Returns: int: the circuit depth Raises: DAGCircuitError: if not a directed acyclic graph """ if not nx.is_directed_acyclic_graph(self._multi_graph): raise DAGCircuitError("not a DAG") depth...
def depth(self): """Return the circuit depth. Returns: int: the circuit depth Raises: DAGCircuitError: if not a directed acyclic graph """ if not nx.is_directed_acyclic_graph(self._multi_graph): raise DAGCircuitError("not a DAG") depth...
[ "Return", "the", "circuit", "depth", ".", "Returns", ":", "int", ":", "the", "circuit", "depth", "Raises", ":", "DAGCircuitError", ":", "if", "not", "a", "directed", "acyclic", "graph" ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/dagcircuit/dagcircuit.py#L641-L652
[ "def", "depth", "(", "self", ")", ":", "if", "not", "nx", ".", "is_directed_acyclic_graph", "(", "self", ".", "_multi_graph", ")", ":", "raise", "DAGCircuitError", "(", "\"not a DAG\"", ")", "depth", "=", "nx", ".", "dag_longest_path_length", "(", "self", "....
d4f58d903bc96341b816f7c35df936d6421267d1
test
DAGCircuit._check_wires_list
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 in the input circuit that is replacing the...
qiskit/dagcircuit/dagcircuit.py
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 ...
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 ...
[ "Check", "that", "a", "list", "of", "wires", "is", "compatible", "with", "a", "node", "to", "be", "replaced", "." ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/dagcircuit/dagcircuit.py#L675-L699
[ "def", "_check_wires_list", "(", "self", ",", "wires", ",", "node", ")", ":", "if", "len", "(", "set", "(", "wires", ")", ")", "!=", "len", "(", "wires", ")", ":", "raise", "DAGCircuitError", "(", "\"duplicate wires\"", ")", "wire_tot", "=", "len", "("...
d4f58d903bc96341b816f7c35df936d6421267d1
test
DAGCircuit._make_pred_succ_maps
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 (successor) nodes of n.
qiskit/dagcircuit/dagcircuit.py
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...
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...
[ "Return", "predecessor", "and", "successor", "dictionaries", "." ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/dagcircuit/dagcircuit.py#L701-L717
[ "def", "_make_pred_succ_maps", "(", "self", ",", "node", ")", ":", "pred_map", "=", "{", "e", "[", "2", "]", "[", "'wire'", "]", ":", "e", "[", "0", "]", "for", "e", "in", "self", ".", "_multi_graph", ".", "in_edges", "(", "nbunch", "=", "node", ...
d4f58d903bc96341b816f7c35df936d6421267d1
test
DAGCircuit._full_pred_succ_maps
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): comes from _make_pred_succ_maps succ_map (dict): comes from _make_pred_succ_maps input_circuit (...
qiskit/dagcircuit/dagcircuit.py
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...
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...
[ "Map", "all", "wires", "of", "the", "input", "circuit", "." ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/dagcircuit/dagcircuit.py#L719-L756
[ "def", "_full_pred_succ_maps", "(", "self", ",", "pred_map", ",", "succ_map", ",", "input_circuit", ",", "wire_map", ")", ":", "full_pred_map", "=", "{", "}", "full_succ_map", "=", "{", "}", "for", "w", "in", "input_circuit", ".", "input_map", ":", "# If w i...
d4f58d903bc96341b816f7c35df936d6421267d1
test
DAGCircuit.topological_nodes
Yield nodes in topological order. Returns: generator(DAGNode): node in topological order
qiskit/dagcircuit/dagcircuit.py
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))
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))
[ "Yield", "nodes", "in", "topological", "order", "." ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/dagcircuit/dagcircuit.py#L771-L779
[ "def", "topological_nodes", "(", "self", ")", ":", "return", "nx", ".", "lexicographical_topological_sort", "(", "self", ".", "_multi_graph", ",", "key", "=", "lambda", "x", ":", "str", "(", "x", ".", "qargs", ")", ")" ]
d4f58d903bc96341b816f7c35df936d6421267d1
test
DAGCircuit.substitute_node_with_dag
Replace one node with dag. Args: node (DAGNode): node to substitute input_dag (DAGCircuit): circuit that will substitute the node wires (list[(Register, index)]): gives an order for (qu)bits in the input circuit. This order gets matched to the node wires ...
qiskit/dagcircuit/dagcircuit.py
def substitute_node_with_dag(self, node, input_dag, wires=None): """Replace one node with dag. Args: node (DAGNode): node to substitute input_dag (DAGCircuit): circuit that will substitute the node wires (list[(Register, index)]): gives an order for (qu)bits ...
def substitute_node_with_dag(self, node, input_dag, wires=None): """Replace one node with dag. Args: node (DAGNode): node to substitute input_dag (DAGCircuit): circuit that will substitute the node wires (list[(Register, index)]): gives an order for (qu)bits ...
[ "Replace", "one", "node", "with", "dag", "." ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/dagcircuit/dagcircuit.py#L790-L908
[ "def", "substitute_node_with_dag", "(", "self", ",", "node", ",", "input_dag", ",", "wires", "=", "None", ")", ":", "if", "isinstance", "(", "node", ",", "int", ")", ":", "warnings", ".", "warn", "(", "'Calling substitute_node_with_dag() with a node id is deprecat...
d4f58d903bc96341b816f7c35df936d6421267d1
test
DAGCircuit.edges
Iterator for node values. Yield: node: the node.
qiskit/dagcircuit/dagcircuit.py
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
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
[ "Iterator", "for", "node", "values", "." ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/dagcircuit/dagcircuit.py#L930-L937
[ "def", "edges", "(", "self", ",", "nodes", "=", "None", ")", ":", "for", "source_node", ",", "dest_node", ",", "edge_data", "in", "self", ".", "_multi_graph", ".", "edges", "(", "nodes", ",", "data", "=", "True", ")", ":", "yield", "source_node", ",", ...
d4f58d903bc96341b816f7c35df936d6421267d1
test
DAGCircuit.get_op_nodes
Deprecated. Use op_nodes().
qiskit/dagcircuit/dagcircuit.py
def get_op_nodes(self, op=None, data=False): """Deprecated. Use op_nodes().""" warnings.warn('The method get_op_nodes() is being replaced by op_nodes().' 'Returning a list of node_ids/(node_id, data) tuples is ' 'also deprecated, op_nodes() returns a list of ...
def get_op_nodes(self, op=None, data=False): """Deprecated. Use op_nodes().""" warnings.warn('The method get_op_nodes() is being replaced by op_nodes().' 'Returning a list of node_ids/(node_id, data) tuples is ' 'also deprecated, op_nodes() returns a list of ...
[ "Deprecated", ".", "Use", "op_nodes", "()", "." ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/dagcircuit/dagcircuit.py#L939-L957
[ "def", "get_op_nodes", "(", "self", ",", "op", "=", "None", ",", "data", "=", "False", ")", ":", "warnings", ".", "warn", "(", "'The method get_op_nodes() is being replaced by op_nodes().'", "'Returning a list of node_ids/(node_id, data) tuples is '", "'also deprecated, op_no...
d4f58d903bc96341b816f7c35df936d6421267d1
test
DAGCircuit.op_nodes
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.
qiskit/dagcircuit/dagcircuit.py
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...
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...
[ "Get", "the", "list", "of", "op", "nodes", "in", "the", "dag", "." ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/dagcircuit/dagcircuit.py#L959-L973
[ "def", "op_nodes", "(", "self", ",", "op", "=", "None", ")", ":", "nodes", "=", "[", "]", "for", "node", "in", "self", ".", "_multi_graph", ".", "nodes", "(", ")", ":", "if", "node", ".", "type", "==", "\"op\"", ":", "if", "op", "is", "None", "...
d4f58d903bc96341b816f7c35df936d6421267d1
test
DAGCircuit.get_gate_nodes
Deprecated. Use gate_nodes().
qiskit/dagcircuit/dagcircuit.py
def get_gate_nodes(self, data=False): """Deprecated. Use gate_nodes().""" warnings.warn('The method get_gate_nodes() is being replaced by gate_nodes().' 'Returning a list of node_ids/(node_id, data) tuples is also ' 'deprecated, gate_nodes() returns a list of ...
def get_gate_nodes(self, data=False): """Deprecated. Use gate_nodes().""" warnings.warn('The method get_gate_nodes() is being replaced by gate_nodes().' 'Returning a list of node_ids/(node_id, data) tuples is also ' 'deprecated, gate_nodes() returns a list of ...
[ "Deprecated", ".", "Use", "gate_nodes", "()", "." ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/dagcircuit/dagcircuit.py#L975-L993
[ "def", "get_gate_nodes", "(", "self", ",", "data", "=", "False", ")", ":", "warnings", ".", "warn", "(", "'The method get_gate_nodes() is being replaced by gate_nodes().'", "'Returning a list of node_ids/(node_id, data) tuples is also '", "'deprecated, gate_nodes() returns a list of ...
d4f58d903bc96341b816f7c35df936d6421267d1
test
DAGCircuit.gate_nodes
Get the list of gate nodes in the dag. Returns: list: the list of node ids that represent gates.
qiskit/dagcircuit/dagcircuit.py
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
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
[ "Get", "the", "list", "of", "gate", "nodes", "in", "the", "dag", "." ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/dagcircuit/dagcircuit.py#L995-L1005
[ "def", "gate_nodes", "(", "self", ")", ":", "nodes", "=", "[", "]", "for", "node", "in", "self", ".", "op_nodes", "(", ")", ":", "if", "isinstance", "(", "node", ".", "op", ",", "Gate", ")", ":", "nodes", ".", "append", "(", "node", ")", "return"...
d4f58d903bc96341b816f7c35df936d6421267d1
test
DAGCircuit.get_named_nodes
Deprecated. Use named_nodes().
qiskit/dagcircuit/dagcircuit.py
def get_named_nodes(self, *names): """Deprecated. Use named_nodes().""" warnings.warn('The method get_named_nodes() is being replaced by named_nodes()', 'Returning a list of node_ids is also deprecated, named_nodes() ' 'returns a list of DAGNodes ', ...
def get_named_nodes(self, *names): """Deprecated. Use named_nodes().""" warnings.warn('The method get_named_nodes() is being replaced by named_nodes()', 'Returning a list of node_ids is also deprecated, named_nodes() ' 'returns a list of DAGNodes ', ...
[ "Deprecated", ".", "Use", "named_nodes", "()", "." ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/dagcircuit/dagcircuit.py#L1007-L1018
[ "def", "get_named_nodes", "(", "self", ",", "*", "names", ")", ":", "warnings", ".", "warn", "(", "'The method get_named_nodes() is being replaced by named_nodes()'", ",", "'Returning a list of node_ids is also deprecated, named_nodes() '", "'returns a list of DAGNodes '", ",", "...
d4f58d903bc96341b816f7c35df936d6421267d1
test
DAGCircuit.named_nodes
Get the set of "op" nodes with the given name.
qiskit/dagcircuit/dagcircuit.py
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
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
[ "Get", "the", "set", "of", "op", "nodes", "with", "the", "given", "name", "." ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/dagcircuit/dagcircuit.py#L1020-L1026
[ "def", "named_nodes", "(", "self", ",", "*", "names", ")", ":", "named_nodes", "=", "[", "]", "for", "node", "in", "self", ".", "_multi_graph", ".", "nodes", "(", ")", ":", "if", "node", ".", "type", "==", "'op'", "and", "node", ".", "op", ".", "...
d4f58d903bc96341b816f7c35df936d6421267d1
test
DAGCircuit.get_2q_nodes
Deprecated. Use twoQ_gates().
qiskit/dagcircuit/dagcircuit.py
def get_2q_nodes(self): """Deprecated. Use twoQ_gates().""" warnings.warn('The method get_2q_nodes() is being replaced by twoQ_gates()', 'Returning a list of data_dicts is also deprecated, twoQ_gates() ' 'returns a list of DAGNodes.', Dep...
def get_2q_nodes(self): """Deprecated. Use twoQ_gates().""" warnings.warn('The method get_2q_nodes() is being replaced by twoQ_gates()', 'Returning a list of data_dicts is also deprecated, twoQ_gates() ' 'returns a list of DAGNodes.', Dep...
[ "Deprecated", ".", "Use", "twoQ_gates", "()", "." ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/dagcircuit/dagcircuit.py#L1028-L1040
[ "def", "get_2q_nodes", "(", "self", ")", ":", "warnings", ".", "warn", "(", "'The method get_2q_nodes() is being replaced by twoQ_gates()'", ",", "'Returning a list of data_dicts is also deprecated, twoQ_gates() '", "'returns a list of DAGNodes.'", ",", "DeprecationWarning", ",", "...
d4f58d903bc96341b816f7c35df936d6421267d1
test
DAGCircuit.twoQ_gates
Get list of 2-qubit gates. Ignore snapshot, barriers, and the like.
qiskit/dagcircuit/dagcircuit.py
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
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
[ "Get", "list", "of", "2", "-", "qubit", "gates", ".", "Ignore", "snapshot", "barriers", "and", "the", "like", "." ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/dagcircuit/dagcircuit.py#L1042-L1048
[ "def", "twoQ_gates", "(", "self", ")", ":", "two_q_gates", "=", "[", "]", "for", "node", "in", "self", ".", "gate_nodes", "(", ")", ":", "if", "len", "(", "node", ".", "qargs", ")", "==", "2", ":", "two_q_gates", ".", "append", "(", "node", ")", ...
d4f58d903bc96341b816f7c35df936d6421267d1
test
DAGCircuit.get_3q_or_more_nodes
Deprecated. Use threeQ_or_more_gates().
qiskit/dagcircuit/dagcircuit.py
def get_3q_or_more_nodes(self): """Deprecated. Use threeQ_or_more_gates().""" warnings.warn('The method get_3q_or_more_nodes() is being replaced by' ' threeQ_or_more_gates()', 'Returning a list of (node_id, data) tuples is also deprecated, ' ...
def get_3q_or_more_nodes(self): """Deprecated. Use threeQ_or_more_gates().""" warnings.warn('The method get_3q_or_more_nodes() is being replaced by' ' threeQ_or_more_gates()', 'Returning a list of (node_id, data) tuples is also deprecated, ' ...
[ "Deprecated", ".", "Use", "threeQ_or_more_gates", "()", "." ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/dagcircuit/dagcircuit.py#L1050-L1062
[ "def", "get_3q_or_more_nodes", "(", "self", ")", ":", "warnings", ".", "warn", "(", "'The method get_3q_or_more_nodes() is being replaced by'", "' threeQ_or_more_gates()'", ",", "'Returning a list of (node_id, data) tuples is also deprecated, '", "'threeQ_or_more_gates() returns a list o...
d4f58d903bc96341b816f7c35df936d6421267d1
test
DAGCircuit.threeQ_or_more_gates
Get list of 3-or-more-qubit gates: (id, data).
qiskit/dagcircuit/dagcircuit.py
def threeQ_or_more_gates(self): """Get list of 3-or-more-qubit gates: (id, data).""" three_q_gates = [] for node in self.gate_nodes(): if len(node.qargs) >= 3: three_q_gates.append(node) return three_q_gates
def threeQ_or_more_gates(self): """Get list of 3-or-more-qubit gates: (id, data).""" three_q_gates = [] for node in self.gate_nodes(): if len(node.qargs) >= 3: three_q_gates.append(node) return three_q_gates
[ "Get", "list", "of", "3", "-", "or", "-", "more", "-", "qubit", "gates", ":", "(", "id", "data", ")", "." ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/dagcircuit/dagcircuit.py#L1064-L1070
[ "def", "threeQ_or_more_gates", "(", "self", ")", ":", "three_q_gates", "=", "[", "]", "for", "node", "in", "self", ".", "gate_nodes", "(", ")", ":", "if", "len", "(", "node", ".", "qargs", ")", ">=", "3", ":", "three_q_gates", ".", "append", "(", "no...
d4f58d903bc96341b816f7c35df936d6421267d1
test
DAGCircuit.predecessors
Returns list of the predecessors of a node as DAGNodes.
qiskit/dagcircuit/dagcircuit.py
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) ...
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) ...
[ "Returns", "list", "of", "the", "predecessors", "of", "a", "node", "as", "DAGNodes", "." ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/dagcircuit/dagcircuit.py#L1082-L1090
[ "def", "predecessors", "(", "self", ",", "node", ")", ":", "if", "isinstance", "(", "node", ",", "int", ")", ":", "warnings", ".", "warn", "(", "'Calling predecessors() with a node id is deprecated,'", "' use a DAGNode instead'", ",", "DeprecationWarning", ",", "2",...
d4f58d903bc96341b816f7c35df936d6421267d1
test
DAGCircuit.quantum_predecessors
Returns list of the predecessors of a node that are connected by a quantum edge as DAGNodes.
qiskit/dagcircuit/dagcircuit.py
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...
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...
[ "Returns", "list", "of", "the", "predecessors", "of", "a", "node", "that", "are", "connected", "by", "a", "quantum", "edge", "as", "DAGNodes", "." ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/dagcircuit/dagcircuit.py#L1092-L1101
[ "def", "quantum_predecessors", "(", "self", ",", "node", ")", ":", "predecessors", "=", "[", "]", "for", "predecessor", "in", "self", ".", "predecessors", "(", "node", ")", ":", "if", "isinstance", "(", "self", ".", "_multi_graph", ".", "get_edge_data", "(...
d4f58d903bc96341b816f7c35df936d6421267d1
test
DAGCircuit.ancestors
Returns set of the ancestors of a node as DAGNodes.
qiskit/dagcircuit/dagcircuit.py
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...
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...
[ "Returns", "set", "of", "the", "ancestors", "of", "a", "node", "as", "DAGNodes", "." ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/dagcircuit/dagcircuit.py#L1103-L1111
[ "def", "ancestors", "(", "self", ",", "node", ")", ":", "if", "isinstance", "(", "node", ",", "int", ")", ":", "warnings", ".", "warn", "(", "'Calling ancestors() with a node id is deprecated,'", "' use a DAGNode instead'", ",", "DeprecationWarning", ",", "2", ")"...
d4f58d903bc96341b816f7c35df936d6421267d1
test
DAGCircuit.quantum_successors
Returns list of the successors of a node that are connected by a quantum edge as DAGNodes.
qiskit/dagcircuit/dagcircuit.py
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'...
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'...
[ "Returns", "list", "of", "the", "successors", "of", "a", "node", "that", "are", "connected", "by", "a", "quantum", "edge", "as", "DAGNodes", "." ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/dagcircuit/dagcircuit.py#L1136-L1151
[ "def", "quantum_successors", "(", "self", ",", "node", ")", ":", "if", "isinstance", "(", "node", ",", "int", ")", ":", "warnings", ".", "warn", "(", "'Calling quantum_successors() with a node id is deprecated,'", "' use a DAGNode instead'", ",", "DeprecationWarning", ...
d4f58d903bc96341b816f7c35df936d6421267d1
test
DAGCircuit.remove_op_node
Remove an operation node n. Add edges from predecessors to successors.
qiskit/dagcircuit/dagcircuit.py
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', ...
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', ...
[ "Remove", "an", "operation", "node", "n", "." ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/dagcircuit/dagcircuit.py#L1153-L1175
[ "def", "remove_op_node", "(", "self", ",", "node", ")", ":", "if", "isinstance", "(", "node", ",", "int", ")", ":", "warnings", ".", "warn", "(", "'Calling remove_op_node() with a node id is deprecated,'", "' use a DAGNode instead'", ",", "DeprecationWarning", ",", ...
d4f58d903bc96341b816f7c35df936d6421267d1
test
DAGCircuit.remove_ancestors_of
Remove all of the ancestor operation nodes of node.
qiskit/dagcircuit/dagcircuit.py
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...
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...
[ "Remove", "all", "of", "the", "ancestor", "operation", "nodes", "of", "node", "." ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/dagcircuit/dagcircuit.py#L1177-L1190
[ "def", "remove_ancestors_of", "(", "self", ",", "node", ")", ":", "if", "isinstance", "(", "node", ",", "int", ")", ":", "warnings", ".", "warn", "(", "'Calling remove_ancestors_of() with a node id is deprecated,'", "' use a DAGNode instead'", ",", "DeprecationWarning",...
d4f58d903bc96341b816f7c35df936d6421267d1
test
DAGCircuit.remove_descendants_of
Remove all of the descendant operation nodes of node.
qiskit/dagcircuit/dagcircuit.py
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...
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...
[ "Remove", "all", "of", "the", "descendant", "operation", "nodes", "of", "node", "." ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/dagcircuit/dagcircuit.py#L1192-L1203
[ "def", "remove_descendants_of", "(", "self", ",", "node", ")", ":", "if", "isinstance", "(", "node", ",", "int", ")", ":", "warnings", ".", "warn", "(", "'Calling remove_descendants_of() with a node id is deprecated,'", "' use a DAGNode instead'", ",", "DeprecationWarni...
d4f58d903bc96341b816f7c35df936d6421267d1
test
DAGCircuit.remove_nonancestors_of
Remove all of the non-ancestors operation nodes of node.
qiskit/dagcircuit/dagcircuit.py
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...
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...
[ "Remove", "all", "of", "the", "non", "-", "ancestors", "operation", "nodes", "of", "node", "." ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/dagcircuit/dagcircuit.py#L1205-L1217
[ "def", "remove_nonancestors_of", "(", "self", ",", "node", ")", ":", "if", "isinstance", "(", "node", ",", "int", ")", ":", "warnings", ".", "warn", "(", "'Calling remove_nonancestors_of() with a node id is deprecated,'", "' use a DAGNode instead'", ",", "DeprecationWar...
d4f58d903bc96341b816f7c35df936d6421267d1
test
DAGCircuit.remove_nondescendants_of
Remove all of the non-descendants operation nodes of node.
qiskit/dagcircuit/dagcircuit.py
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', ...
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', ...
[ "Remove", "all", "of", "the", "non", "-", "descendants", "operation", "nodes", "of", "node", "." ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/dagcircuit/dagcircuit.py#L1219-L1231
[ "def", "remove_nondescendants_of", "(", "self", ",", "node", ")", ":", "if", "isinstance", "(", "node", ",", "int", ")", ":", "warnings", ".", "warn", "(", "'Calling remove_nondescendants_of() with a node id is deprecated,'", "' use a DAGNode instead'", ",", "Deprecatio...
d4f58d903bc96341b816f7c35df936d6421267d1
test
DAGCircuit.layers
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 the earliest layer at ...
qiskit/dagcircuit/dagcircuit.py
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...
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...
[ "Yield", "a", "shallow", "view", "on", "a", "layer", "of", "this", "DAGCircuit", "for", "all", "d", "layers", "of", "this", "circuit", "." ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/dagcircuit/dagcircuit.py#L1233-L1301
[ "def", "layers", "(", "self", ")", ":", "graph_layers", "=", "self", ".", "multigraph_layers", "(", ")", "try", ":", "next", "(", "graph_layers", ")", "# Remove input nodes", "except", "StopIteration", ":", "return", "def", "add_nodes_from", "(", "layer", ",",...
d4f58d903bc96341b816f7c35df936d6421267d1
test
DAGCircuit.serial_layers
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().
qiskit/dagcircuit/dagcircuit.py
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...
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...
[ "Yield", "a", "layer", "for", "all", "gates", "of", "this", "circuit", "." ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/dagcircuit/dagcircuit.py#L1303-L1331
[ "def", "serial_layers", "(", "self", ")", ":", "for", "next_node", "in", "self", ".", "topological_op_nodes", "(", ")", ":", "new_layer", "=", "DAGCircuit", "(", ")", "for", "qreg", "in", "self", ".", "qregs", ".", "values", "(", ")", ":", "new_layer", ...
d4f58d903bc96341b816f7c35df936d6421267d1
test
DAGCircuit.multigraph_layers
Yield layers of the multigraph.
qiskit/dagcircuit/dagcircuit.py
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:...
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:...
[ "Yield", "layers", "of", "the", "multigraph", "." ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/dagcircuit/dagcircuit.py#L1333-L1356
[ "def", "multigraph_layers", "(", "self", ")", ":", "predecessor_count", "=", "dict", "(", ")", "# Dict[node, predecessors not visited]", "cur_layer", "=", "[", "node", "for", "node", "in", "self", ".", "input_map", ".", "values", "(", ")", "]", "yield", "cur_l...
d4f58d903bc96341b816f7c35df936d6421267d1
test
DAGCircuit.collect_runs
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 instead the cx nodes were "cx q[0],q[1...
qiskit/dagcircuit/dagcircuit.py
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...
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...
[ "Return", "a", "set", "of", "non", "-", "conditional", "runs", "of", "op", "nodes", "with", "the", "given", "names", "." ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/dagcircuit/dagcircuit.py#L1358-L1391
[ "def", "collect_runs", "(", "self", ",", "namelist", ")", ":", "group_list", "=", "[", "]", "# Iterate through the nodes of self in topological order", "# and form tuples containing sequences of gates", "# on the same qubit(s).", "topo_ops", "=", "list", "(", "self", ".", "...
d4f58d903bc96341b816f7c35df936d6421267d1
test
DAGCircuit.nodes_on_wire
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. Yield: DAGNode: the successive ops on the give...
qiskit/dagcircuit/dagcircuit.py
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. ...
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. ...
[ "Iterator", "for", "nodes", "that", "affect", "a", "given", "wire" ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/dagcircuit/dagcircuit.py#L1393-L1425
[ "def", "nodes_on_wire", "(", "self", ",", "wire", ",", "only_ops", "=", "False", ")", ":", "current_node", "=", "self", ".", "input_map", ".", "get", "(", "wire", ",", "None", ")", "if", "not", "current_node", ":", "raise", "DAGCircuitError", "(", "'The ...
d4f58d903bc96341b816f7c35df936d6421267d1
test
DAGCircuit.count_ops
Count the occurrences of operation names. Returns a dictionary of counts keyed on the operation name.
qiskit/dagcircuit/dagcircuit.py
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] ...
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] ...
[ "Count", "the", "occurrences", "of", "operation", "names", "." ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/dagcircuit/dagcircuit.py#L1427-L1439
[ "def", "count_ops", "(", "self", ")", ":", "op_dict", "=", "{", "}", "for", "node", "in", "self", ".", "topological_op_nodes", "(", ")", ":", "name", "=", "node", ".", "name", "if", "name", "not", "in", "op_dict", ":", "op_dict", "[", "name", "]", ...
d4f58d903bc96341b816f7c35df936d6421267d1
test
DAGCircuit.properties
Return a dictionary of circuit properties.
qiskit/dagcircuit/dagcircuit.py
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(), ...
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(), ...
[ "Return", "a", "dictionary", "of", "circuit", "properties", "." ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/dagcircuit/dagcircuit.py#L1441-L1449
[ "def", "properties", "(", "self", ")", ":", "summary", "=", "{", "\"size\"", ":", "self", ".", "size", "(", ")", ",", "\"depth\"", ":", "self", ".", "depth", "(", ")", ",", "\"width\"", ":", "self", ".", "width", "(", ")", ",", "\"bits\"", ":", "...
d4f58d903bc96341b816f7c35df936d6421267d1
test
tomography_basis
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 function which adds measurement gates to a circuit. Returns:...
qiskit/tools/qcvv/tomography.py
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...
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...
[ "Generate", "a", "TomographyBasis", "object", "." ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/tools/qcvv/tomography.py#L146-L164
[ "def", "tomography_basis", "(", "basis", ",", "prep_fun", "=", "None", ",", "meas_fun", "=", "None", ")", ":", "ret", "=", "TomographyBasis", "(", "basis", ")", "ret", ".", "prep_fun", "=", "prep_fun", "ret", ".", "meas_fun", "=", "meas_fun", "return", "...
d4f58d903bc96341b816f7c35df936d6421267d1
test
__pauli_prep_gates
Add state preparation gates to a circuit.
qiskit/tools/qcvv/tomography.py
def __pauli_prep_gates(circuit, qreg, op): """ Add state preparation gates to a circuit. """ bas, proj = op if bas not in ['X', 'Y', 'Z']: raise QiskitError("There's no X, Y or Z basis for this Pauli " "preparation") if bas == "X": if proj == 1: ...
def __pauli_prep_gates(circuit, qreg, op): """ Add state preparation gates to a circuit. """ bas, proj = op if bas not in ['X', 'Y', 'Z']: raise QiskitError("There's no X, Y or Z basis for this Pauli " "preparation") if bas == "X": if proj == 1: ...
[ "Add", "state", "preparation", "gates", "to", "a", "circuit", "." ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/tools/qcvv/tomography.py#L173-L193
[ "def", "__pauli_prep_gates", "(", "circuit", ",", "qreg", ",", "op", ")", ":", "bas", ",", "proj", "=", "op", "if", "bas", "not", "in", "[", "'X'", ",", "'Y'", ",", "'Z'", "]", ":", "raise", "QiskitError", "(", "\"There's no X, Y or Z basis for this Pauli ...
d4f58d903bc96341b816f7c35df936d6421267d1
test
__pauli_meas_gates
Add state measurement gates to a circuit.
qiskit/tools/qcvv/tomography.py
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 ...
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 ...
[ "Add", "state", "measurement", "gates", "to", "a", "circuit", "." ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/tools/qcvv/tomography.py#L196-L207
[ "def", "__pauli_meas_gates", "(", "circuit", ",", "qreg", ",", "op", ")", ":", "if", "op", "not", "in", "[", "'X'", ",", "'Y'", ",", "'Z'", "]", ":", "raise", "QiskitError", "(", "\"There's no X, Y or Z basis for this Pauli \"", "\"measurement\"", ")", "if", ...
d4f58d903bc96341b816f7c35df936d6421267d1
test
__sic_prep_gates
Add state preparation gates to a circuit.
qiskit/tools/qcvv/tomography.py
def __sic_prep_gates(circuit, qreg, op): """ Add state preparation gates to a circuit. """ bas, proj = op if bas != 'S': raise QiskitError('Not in SIC basis!') theta = -2 * np.arctan(np.sqrt(2)) if proj == 1: circuit.u3(theta, np.pi, 0.0, qreg) elif proj == 2: c...
def __sic_prep_gates(circuit, qreg, op): """ Add state preparation gates to a circuit. """ bas, proj = op if bas != 'S': raise QiskitError('Not in SIC basis!') theta = -2 * np.arctan(np.sqrt(2)) if proj == 1: circuit.u3(theta, np.pi, 0.0, qreg) elif proj == 2: c...
[ "Add", "state", "preparation", "gates", "to", "a", "circuit", "." ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/tools/qcvv/tomography.py#L230-L245
[ "def", "__sic_prep_gates", "(", "circuit", ",", "qreg", ",", "op", ")", ":", "bas", ",", "proj", "=", "op", "if", "bas", "!=", "'S'", ":", "raise", "QiskitError", "(", "'Not in SIC basis!'", ")", "theta", "=", "-", "2", "*", "np", ".", "arctan", "(",...
d4f58d903bc96341b816f7c35df936d6421267d1
test
tomography_set
Generate a dictionary of tomography experiment configurations. This returns a data structure that is used by other tomography functions to generate state and process tomography circuits, and extract tomography data from results after execution on a backend. Quantum State Tomography: Be default...
qiskit/tools/qcvv/tomography.py
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 ...
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 ...
[ "Generate", "a", "dictionary", "of", "tomography", "experiment", "configurations", "." ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/tools/qcvv/tomography.py#L266-L389
[ "def", "tomography_set", "(", "meas_qubits", ",", "meas_basis", "=", "'Pauli'", ",", "prep_qubits", "=", "None", ",", "prep_basis", "=", "None", ")", ":", "if", "not", "isinstance", "(", "meas_qubits", ",", "list", ")", ":", "raise", "QiskitError", "(", "'...
d4f58d903bc96341b816f7c35df936d6421267d1
test
process_tomography_set
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 tomography circuits, and extract tomography data from results after execution on a backend. A quantum process tomography set is c...
qiskit/tools/qcvv/tomography.py
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...
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...
[ "Generate", "a", "dictionary", "of", "process", "tomography", "experiment", "configurations", "." ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/tools/qcvv/tomography.py#L441-L487
[ "def", "process_tomography_set", "(", "meas_qubits", ",", "meas_basis", "=", "'Pauli'", ",", "prep_qubits", "=", "None", ",", "prep_basis", "=", "'SIC'", ")", ":", "return", "tomography_set", "(", "meas_qubits", ",", "meas_basis", "=", "meas_basis", ",", "prep_q...
d4f58d903bc96341b816f7c35df936d6421267d1
test
create_tomography_circuits
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. This function then appends the circuit with a set of measurements sp...
qiskit/tools/qcvv/tomography.py
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...
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...
[ "Add", "tomography", "measurement", "circuits", "to", "a", "QuantumProgram", "." ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/tools/qcvv/tomography.py#L515-L592
[ "def", "create_tomography_circuits", "(", "circuit", ",", "qreg", ",", "creg", ",", "tomoset", ")", ":", "if", "not", "isinstance", "(", "circuit", ",", "QuantumCircuit", ")", ":", "raise", "QiskitError", "(", "'Input circuit must be a QuantumCircuit object'", ")", ...
d4f58d903bc96341b816f7c35df936d6421267d1
test
tomography_data
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. tomoset (tomography_set): the dict of tomography configur...
qiskit/tools/qcvv/tomography.py
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. ...
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. ...
[ "Return", "a", "results", "dict", "for", "a", "state", "or", "process", "tomography", "experiment", "." ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/tools/qcvv/tomography.py#L600-L641
[ "def", "tomography_data", "(", "results", ",", "name", ",", "tomoset", ")", ":", "labels", "=", "tomography_circuit_names", "(", "tomoset", ",", "name", ")", "circuits", "=", "tomoset", "[", "'circuits'", "]", "data", "=", "[", "]", "prep", "=", "None", ...
d4f58d903bc96341b816f7c35df936d6421267d1
test
marginal_counts
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 for. Returns: dict: A counts dict for the m...
qiskit/tools/qcvv/tomography.py
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...
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...
[ "Compute", "the", "marginal", "counts", "for", "a", "subset", "of", "measured", "qubits", "." ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/tools/qcvv/tomography.py#L644-L684
[ "def", "marginal_counts", "(", "counts", ",", "meas_qubits", ")", ":", "# pylint: disable=cell-var-from-loop", "# Extract total number of qubits from count keys", "num_of_qubits", "=", "len", "(", "list", "(", "counts", ".", "keys", "(", ")", ")", "[", "0", "]", ")"...
d4f58d903bc96341b816f7c35df936d6421267d1
test
fit_tomography_data
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 will be a Choi-matrix in the column-vectorization convention. Args: ...
qiskit/tools/qcvv/tomography.py
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...
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...
[ "Reconstruct", "a", "density", "matrix", "or", "process", "-", "matrix", "from", "tomography", "data", "." ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/tools/qcvv/tomography.py#L705-L755
[ "def", "fit_tomography_data", "(", "tomo_data", ",", "method", "=", "'wizard'", ",", "options", "=", "None", ")", ":", "if", "isinstance", "(", "method", ",", "str", ")", "and", "method", ".", "lower", "(", ")", "in", "[", "'wizard'", ",", "'leastsq'", ...
d4f58d903bc96341b816f7c35df936d6421267d1
test
__leastsq_fit
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 default is standard deviation from a binomial distribution. tr...
qiskit/tools/qcvv/tomography.py
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...
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...
[ "Reconstruct", "a", "state", "from", "unconstrained", "least", "-", "squares", "fitting", "." ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/tools/qcvv/tomography.py#L773-L824
[ "def", "__leastsq_fit", "(", "tomo_data", ",", "weights", "=", "None", ",", "trace", "=", "None", ",", "beta", "=", "None", ")", ":", "if", "trace", "is", "None", ":", "trace", "=", "1.", "# default to unit trace", "data", "=", "tomo_data", "[", "'data'"...
d4f58d903bc96341b816f7c35df936d6421267d1
test
__projector
Returns a projectors.
qiskit/tools/qcvv/tomography.py
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
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
[ "Returns", "a", "projectors", "." ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/tools/qcvv/tomography.py#L827-L835
[ "def", "__projector", "(", "op_list", ",", "basis", ")", ":", "ret", "=", "1", "# list is from qubit 0 to 1", "for", "op", "in", "op_list", ":", "label", ",", "eigenstate", "=", "op", "ret", "=", "np", ".", "kron", "(", "basis", "[", "label", "]", "[",...
d4f58d903bc96341b816f7c35df936d6421267d1
test
__tomo_linear_inv
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 be used for weighted fitting. trace (float or None): trace of re...
qiskit/tools/qcvv/tomography.py
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...
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...
[ "Reconstruct", "a", "matrix", "through", "linear", "inversion", "." ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/tools/qcvv/tomography.py#L838-L876
[ "def", "__tomo_linear_inv", "(", "freqs", ",", "ops", ",", "weights", "=", "None", ",", "trace", "=", "None", ")", ":", "# get weights matrix", "if", "weights", "is", "not", "None", ":", "W", "=", "np", ".", "array", "(", "weights", ")", "if", "W", "...
d4f58d903bc96341b816f7c35df936d6421267d1
test
__wizard
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 operator. epsilon(float or None): thresho...
qiskit/tools/qcvv/tomography.py
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...
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...
[ "Returns", "the", "nearest", "positive", "semidefinite", "operator", "to", "an", "operator", "." ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/tools/qcvv/tomography.py#L884-L917
[ "def", "__wizard", "(", "rho", ",", "epsilon", "=", "None", ")", ":", "if", "epsilon", "is", "None", ":", "epsilon", "=", "0.", "# default value", "dim", "=", "len", "(", "rho", ")", "rho_wizard", "=", "np", ".", "zeros", "(", "[", "dim", ",", "dim...
d4f58d903bc96341b816f7c35df936d6421267d1
test
build_wigner_circuits
Create the circuits to rotate to points in phase space Args: circuit (QuantumCircuit): The circuit to be appended with tomography state preparation and/or measurements. phis (np.matrix[[complex]]): phis thetas (np.matrix[[complex]]): thetas qubits (l...
qiskit/tools/qcvv/tomography.py
def build_wigner_circuits(circuit, phis, thetas, qubits, qreg, creg): """Create the circuits to rotate to points in phase space Args: circuit (QuantumCircuit): The circuit to be appended with tomography state preparation and/or measurements. ...
def build_wigner_circuits(circuit, phis, thetas, qubits, qreg, creg): """Create the circuits to rotate to points in phase space Args: circuit (QuantumCircuit): The circuit to be appended with tomography state preparation and/or measurements. ...
[ "Create", "the", "circuits", "to", "rotate", "to", "points", "in", "phase", "space", "Args", ":", "circuit", "(", "QuantumCircuit", ")", ":", "The", "circuit", "to", "be", "appended", "with", "tomography", "state", "preparation", "and", "/", "or", "measureme...
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/tools/qcvv/tomography.py#L924-L964
[ "def", "build_wigner_circuits", "(", "circuit", ",", "phis", ",", "thetas", ",", "qubits", ",", "qreg", ",", "creg", ")", ":", "if", "not", "isinstance", "(", "circuit", ",", "QuantumCircuit", ")", ":", "raise", "QiskitError", "(", "'Input circuit must be a Qu...
d4f58d903bc96341b816f7c35df936d6421267d1
test
wigner_data
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 indexes measured. labels (list[str]): a list of names of the c...
qiskit/tools/qcvv/tomography.py
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...
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...
[ "Get", "the", "value", "of", "the", "Wigner", "function", "from", "measurement", "results", "." ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/tools/qcvv/tomography.py#L967-L1008
[ "def", "wigner_data", "(", "q_result", ",", "meas_qubits", ",", "labels", ",", "shots", "=", "None", ")", ":", "num", "=", "len", "(", "meas_qubits", ")", "dim", "=", "2", "**", "num", "p", "=", "[", "0.5", "+", "0.5", "*", "np", ".", "sqrt", "("...
d4f58d903bc96341b816f7c35df936d6421267d1
test
TomographyBasis.prep_gate
Add state preparation gates to a circuit. Args: circuit (QuantumCircuit): circuit to add a preparation to. qreg (tuple(QuantumRegister,int)): quantum register to apply preparation to. op (tuple(str, int)): the basis label and index for the preparation...
qiskit/tools/qcvv/tomography.py
def prep_gate(self, circuit, qreg, op): """ Add state preparation gates to a circuit. Args: circuit (QuantumCircuit): circuit to add a preparation to. qreg (tuple(QuantumRegister,int)): quantum register to apply preparation to. op (tuple(str, int)...
def prep_gate(self, circuit, qreg, op): """ Add state preparation gates to a circuit. Args: circuit (QuantumCircuit): circuit to add a preparation to. qreg (tuple(QuantumRegister,int)): quantum register to apply preparation to. op (tuple(str, int)...
[ "Add", "state", "preparation", "gates", "to", "a", "circuit", "." ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/tools/qcvv/tomography.py#L115-L129
[ "def", "prep_gate", "(", "self", ",", "circuit", ",", "qreg", ",", "op", ")", ":", "if", "self", ".", "prep_fun", "is", "None", ":", "pass", "else", ":", "self", ".", "prep_fun", "(", "circuit", ",", "qreg", ",", "op", ")" ]
d4f58d903bc96341b816f7c35df936d6421267d1
test
TomographyBasis.meas_gate
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.
qiskit/tools/qcvv/tomography.py
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. ...
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. ...
[ "Add", "measurement", "gates", "to", "a", "circuit", "." ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/tools/qcvv/tomography.py#L131-L143
[ "def", "meas_gate", "(", "self", ",", "circuit", ",", "qreg", ",", "op", ")", ":", "if", "self", ".", "meas_fun", "is", "None", ":", "pass", "else", ":", "self", ".", "meas_fun", "(", "circuit", ",", "qreg", ",", "op", ")" ]
d4f58d903bc96341b816f7c35df936d6421267d1
test
_text_checker
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 True, do not print status messages. output (file): The file like object to write statu...
qiskit/tools/monitor/job_monitor.py
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 ...
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 ...
[ "A", "text", "-", "based", "job", "status", "checker" ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/tools/monitor/job_monitor.py#L22-L64
[ "def", "_text_checker", "(", "job", ",", "interval", ",", "_interval_set", "=", "False", ",", "quiet", "=", "False", ",", "output", "=", "sys", ".", "stdout", ")", ":", "status", "=", "job", ".", "status", "(", ")", "msg", "=", "status", ".", "value"...
d4f58d903bc96341b816f7c35df936d6421267d1
test
job_monitor
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). quiet (bool): If True, do not print status messages. output (file): The file li...
qiskit/tools/monitor/job_monitor.py
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)...
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)...
[ "Monitor", "the", "status", "of", "a", "IBMQJob", "instance", "." ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/tools/monitor/job_monitor.py#L67-L113
[ "def", "job_monitor", "(", "job", ",", "interval", "=", "None", ",", "monitor_async", "=", "False", ",", "quiet", "=", "False", ",", "output", "=", "sys", ".", "stdout", ")", ":", "if", "interval", "is", "None", ":", "_interval_set", "=", "False", "int...
d4f58d903bc96341b816f7c35df936d6421267d1
test
euler_angles_1q
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 angles of SU(2) Raises: QiskitE...
qiskit/quantum_info/synthesis/two_qubit_kak.py
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 ...
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 ...
[ "Compute", "Euler", "angles", "for", "a", "single", "-", "qubit", "gate", "." ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/quantum_info/synthesis/two_qubit_kak.py#L40-L97
[ "def", "euler_angles_1q", "(", "unitary_matrix", ")", ":", "if", "unitary_matrix", ".", "shape", "!=", "(", "2", ",", "2", ")", ":", "raise", "QiskitError", "(", "\"euler_angles_1q: expected 2x2 matrix\"", ")", "phase", "=", "la", ".", "det", "(", "unitary_mat...
d4f58d903bc96341b816f7c35df936d6421267d1
test
simplify_U
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, U2Gate, U3Gate.
qiskit/quantum_info/synthesis/two_qubit_kak.py
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...
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...
[ "Return", "the", "gate", "u1", "u2", "or", "u3", "implementing", "U", "with", "the", "fewest", "pulses", "." ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/quantum_info/synthesis/two_qubit_kak.py#L100-L128
[ "def", "simplify_U", "(", "theta", ",", "phi", ",", "lam", ")", ":", "gate", "=", "U3Gate", "(", "theta", ",", "phi", ",", "lam", ")", "# Y rotation is 0 mod 2*pi, so the gate is a u1", "if", "abs", "(", "gate", ".", "params", "[", "0", "]", "%", "(", ...
d4f58d903bc96341b816f7c35df936d6421267d1
test
two_qubit_kak
Decompose a two-qubit gate over SU(2)+CNOT using the KAK decomposition. Args: unitary (Operator): a 4x4 unitary operator to decompose. Returns: QuantumCircuit: a circuit implementing the unitary over SU(2)+CNOT Raises: QiskitError: input not a unitary, or error in KAK decompositio...
qiskit/quantum_info/synthesis/two_qubit_kak.py
def two_qubit_kak(unitary): """Decompose a two-qubit gate over SU(2)+CNOT using the KAK decomposition. Args: unitary (Operator): a 4x4 unitary operator to decompose. Returns: QuantumCircuit: a circuit implementing the unitary over SU(2)+CNOT Raises: QiskitError: input not a un...
def two_qubit_kak(unitary): """Decompose a two-qubit gate over SU(2)+CNOT using the KAK decomposition. Args: unitary (Operator): a 4x4 unitary operator to decompose. Returns: QuantumCircuit: a circuit implementing the unitary over SU(2)+CNOT Raises: QiskitError: input not a un...
[ "Decompose", "a", "two", "-", "qubit", "gate", "over", "SU", "(", "2", ")", "+", "CNOT", "using", "the", "KAK", "decomposition", "." ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/quantum_info/synthesis/two_qubit_kak.py#L131-L368
[ "def", "two_qubit_kak", "(", "unitary", ")", ":", "if", "hasattr", "(", "unitary", ",", "'to_operator'", ")", ":", "# If input is a BaseOperator subclass this attempts to convert", "# the object to an Operator so that we can extract the underlying", "# numpy matrix from `Operator.dat...
d4f58d903bc96341b816f7c35df936d6421267d1
test
EnlargeWithAncilla.run
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 property set or not set at init time.
qiskit/transpiler/passes/mapping/enlarge_with_ancilla.py
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...
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...
[ "Extends", "dag", "with", "virtual", "qubits", "that", "are", "in", "layout", "but", "not", "in", "the", "circuit", "yet", "." ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/transpiler/passes/mapping/enlarge_with_ancilla.py#L30-L56
[ "def", "run", "(", "self", ",", "dag", ")", ":", "self", ".", "layout", "=", "self", ".", "layout", "or", "self", ".", "property_set", "[", "'layout'", "]", "if", "self", ".", "layout", "is", "None", ":", "raise", "TranspilerError", "(", "\"EnlargeWith...
d4f58d903bc96341b816f7c35df936d6421267d1