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
CHGate._define
gate ch a,b { h b; sdg b; cx a,b; h b; t b; cx a,b; t b; h b; s b; x b; s a;}
qiskit/extensions/standard/ch.py
def _define(self): """ gate ch a,b { h b; sdg b; cx a,b; h b; t b; cx a,b; t b; h b; s b; x b; s a;} """ definition = [] q = QuantumRegister(2, "q") rule = [ (HGate(), [q[1...
def _define(self): """ gate ch a,b { h b; sdg b; cx a,b; h b; t b; cx a,b; t b; h b; s b; x b; s a;} """ definition = [] q = QuantumRegister(2, "q") rule = [ (HGate(), [q[1...
[ "gate", "ch", "a", "b", "{", "h", "b", ";", "sdg", "b", ";", "cx", "a", "b", ";", "h", "b", ";", "t", "b", ";", "cx", "a", "b", ";", "t", "b", ";", "h", "b", ";", "s", "b", ";", "x", "b", ";", "s", "a", ";", "}" ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/extensions/standard/ch.py#L33-L65
[ "def", "_define", "(", "self", ")", ":", "definition", "=", "[", "]", "q", "=", "QuantumRegister", "(", "2", ",", "\"q\"", ")", "rule", "=", "[", "(", "HGate", "(", ")", ",", "[", "q", "[", "1", "]", "]", ",", "[", "]", ")", ",", "(", "SdgG...
d4f58d903bc96341b816f7c35df936d6421267d1
test
config_tab
The backend configuration widget. Args: backend (IBMQbackend): The backend. Returns: grid: A GridBox widget.
qiskit/tools/jupyter/backend_monitor.py
def config_tab(backend): """The backend configuration widget. Args: backend (IBMQbackend): The backend. Returns: grid: A GridBox widget. """ status = backend.status().to_dict() config = backend.configuration().to_dict() config_dict = {**status, **config} upper_list = ...
def config_tab(backend): """The backend configuration widget. Args: backend (IBMQbackend): The backend. Returns: grid: A GridBox widget. """ status = backend.status().to_dict() config = backend.configuration().to_dict() config_dict = {**status, **config} upper_list = ...
[ "The", "backend", "configuration", "widget", "." ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/tools/jupyter/backend_monitor.py#L73-L170
[ "def", "config_tab", "(", "backend", ")", ":", "status", "=", "backend", ".", "status", "(", ")", ".", "to_dict", "(", ")", "config", "=", "backend", ".", "configuration", "(", ")", ".", "to_dict", "(", ")", "config_dict", "=", "{", "*", "*", "status...
d4f58d903bc96341b816f7c35df936d6421267d1
test
qubits_tab
The qubits properties widget Args: backend (IBMQbackend): The backend. Returns: VBox: A VBox widget.
qiskit/tools/jupyter/backend_monitor.py
def qubits_tab(backend): """The qubits properties widget Args: backend (IBMQbackend): The backend. Returns: VBox: A VBox widget. """ props = backend.properties().to_dict() header_html = "<div><font style='font-weight:bold'>{key}</font>: {value}</div>" header_html = header_...
def qubits_tab(backend): """The qubits properties widget Args: backend (IBMQbackend): The backend. Returns: VBox: A VBox widget. """ props = backend.properties().to_dict() header_html = "<div><font style='font-weight:bold'>{key}</font>: {value}</div>" header_html = header_...
[ "The", "qubits", "properties", "widget" ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/tools/jupyter/backend_monitor.py#L173-L241
[ "def", "qubits_tab", "(", "backend", ")", ":", "props", "=", "backend", ".", "properties", "(", ")", ".", "to_dict", "(", ")", "header_html", "=", "\"<div><font style='font-weight:bold'>{key}</font>: {value}</div>\"", "header_html", "=", "header_html", ".", "format", ...
d4f58d903bc96341b816f7c35df936d6421267d1
test
gates_tab
The multiple qubit gate error widget. Args: backend (IBMQbackend): The backend. Returns: VBox: A VBox widget.
qiskit/tools/jupyter/backend_monitor.py
def gates_tab(backend): """The multiple qubit gate error widget. Args: backend (IBMQbackend): The backend. Returns: VBox: A VBox widget. """ config = backend.configuration().to_dict() props = backend.properties().to_dict() multi_qubit_gates = props['gates'][3*config['n_qub...
def gates_tab(backend): """The multiple qubit gate error widget. Args: backend (IBMQbackend): The backend. Returns: VBox: A VBox widget. """ config = backend.configuration().to_dict() props = backend.properties().to_dict() multi_qubit_gates = props['gates'][3*config['n_qub...
[ "The", "multiple", "qubit", "gate", "error", "widget", "." ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/tools/jupyter/backend_monitor.py#L244-L346
[ "def", "gates_tab", "(", "backend", ")", ":", "config", "=", "backend", ".", "configuration", "(", ")", ".", "to_dict", "(", ")", "props", "=", "backend", ".", "properties", "(", ")", ".", "to_dict", "(", ")", "multi_qubit_gates", "=", "props", "[", "'...
d4f58d903bc96341b816f7c35df936d6421267d1
test
detailed_map
Widget for displaying detailed noise map. Args: backend (IBMQbackend): The backend. Returns: GridBox: Widget holding noise map images.
qiskit/tools/jupyter/backend_monitor.py
def detailed_map(backend): """Widget for displaying detailed noise map. Args: backend (IBMQbackend): The backend. Returns: GridBox: Widget holding noise map images. """ props = backend.properties().to_dict() config = backend.configuration().to_dict() single_gate_errors = [q...
def detailed_map(backend): """Widget for displaying detailed noise map. Args: backend (IBMQbackend): The backend. Returns: GridBox: Widget holding noise map images. """ props = backend.properties().to_dict() config = backend.configuration().to_dict() single_gate_errors = [q...
[ "Widget", "for", "displaying", "detailed", "noise", "map", "." ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/tools/jupyter/backend_monitor.py#L349-L437
[ "def", "detailed_map", "(", "backend", ")", ":", "props", "=", "backend", ".", "properties", "(", ")", ".", "to_dict", "(", ")", "config", "=", "backend", ".", "configuration", "(", ")", ".", "to_dict", "(", ")", "single_gate_errors", "=", "[", "q", "[...
d4f58d903bc96341b816f7c35df936d6421267d1
test
job_history
Widget for displaying job history Args: backend (IBMQbackend): The backend. Returns: Tab: A tab widget for history images.
qiskit/tools/jupyter/backend_monitor.py
def job_history(backend): """Widget for displaying job history Args: backend (IBMQbackend): The backend. Returns: Tab: A tab widget for history images. """ year = widgets.Output(layout=widgets.Layout(display='flex-inline', align_items='c...
def job_history(backend): """Widget for displaying job history Args: backend (IBMQbackend): The backend. Returns: Tab: A tab widget for history images. """ year = widgets.Output(layout=widgets.Layout(display='flex-inline', align_items='c...
[ "Widget", "for", "displaying", "job", "history" ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/tools/jupyter/backend_monitor.py#L440-L469
[ "def", "job_history", "(", "backend", ")", ":", "year", "=", "widgets", ".", "Output", "(", "layout", "=", "widgets", ".", "Layout", "(", "display", "=", "'flex-inline'", ",", "align_items", "=", "'center'", ",", "min_height", "=", "'400px'", ")", ")", "...
d4f58d903bc96341b816f7c35df936d6421267d1
test
plot_job_history
Plots the job history of the user from the given list of jobs. Args: jobs (list): A list of jobs with type IBMQjob. interval (str): Interval over which to examine. Returns: fig: A Matplotlib figure instance.
qiskit/tools/jupyter/backend_monitor.py
def plot_job_history(jobs, interval='year'): """Plots the job history of the user from the given list of jobs. Args: jobs (list): A list of jobs with type IBMQjob. interval (str): Interval over which to examine. Returns: fig: A Matplotlib figure instance. """ def get_date(j...
def plot_job_history(jobs, interval='year'): """Plots the job history of the user from the given list of jobs. Args: jobs (list): A list of jobs with type IBMQjob. interval (str): Interval over which to examine. Returns: fig: A Matplotlib figure instance. """ def get_date(j...
[ "Plots", "the", "job", "history", "of", "the", "user", "from", "the", "given", "list", "of", "jobs", "." ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/tools/jupyter/backend_monitor.py#L497-L573
[ "def", "plot_job_history", "(", "jobs", ",", "interval", "=", "'year'", ")", ":", "def", "get_date", "(", "job", ")", ":", "\"\"\"Returns a datetime object from a IBMQJob instance.\n\n Args:\n job (IBMQJob): A job.\n\n Returns:\n dt: A datetime obj...
d4f58d903bc96341b816f7c35df936d6421267d1
test
RemoveResetInZeroState.run
Return a new circuit that has been optimized.
qiskit/transpiler/passes/remove_reset_in_zero_state.py
def run(self, dag): """Return a new circuit that has been optimized.""" resets = dag.op_nodes(Reset) for reset in resets: predecessor = next(dag.predecessors(reset)) if predecessor.type == 'in': dag.remove_op_node(reset) return dag
def run(self, dag): """Return a new circuit that has been optimized.""" resets = dag.op_nodes(Reset) for reset in resets: predecessor = next(dag.predecessors(reset)) if predecessor.type == 'in': dag.remove_op_node(reset) return dag
[ "Return", "a", "new", "circuit", "that", "has", "been", "optimized", "." ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/transpiler/passes/remove_reset_in_zero_state.py#L20-L27
[ "def", "run", "(", "self", ",", "dag", ")", ":", "resets", "=", "dag", ".", "op_nodes", "(", "Reset", ")", "for", "reset", "in", "resets", ":", "predecessor", "=", "next", "(", "dag", ".", "predecessors", "(", "reset", ")", ")", "if", "predecessor", ...
d4f58d903bc96341b816f7c35df936d6421267d1
test
SamplePulse.draw
Plot the interpolated envelope of pulse. Keyword Args: dt (float): Time interval of samples. interp_method (str): Method of interpolation (set `None` for turn off the interpolation). filename (str): Name required to save pulse image. interactive (...
qiskit/pulse/commands/sample_pulse.py
def draw(self, **kwargs): """Plot the interpolated envelope of pulse. Keyword Args: dt (float): Time interval of samples. interp_method (str): Method of interpolation (set `None` for turn off the interpolation). filename (str): Name required to save p...
def draw(self, **kwargs): """Plot the interpolated envelope of pulse. Keyword Args: dt (float): Time interval of samples. interp_method (str): Method of interpolation (set `None` for turn off the interpolation). filename (str): Name required to save p...
[ "Plot", "the", "interpolated", "envelope", "of", "pulse", "." ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/pulse/commands/sample_pulse.py#L43-L59
[ "def", "draw", "(", "self", ",", "*", "*", "kwargs", ")", ":", "from", "qiskit", ".", "tools", ".", "visualization", "import", "pulse_drawer", "return", "pulse_drawer", "(", "self", ".", "_samples", ",", "self", ".", "duration", ",", "*", "*", "kwargs", ...
d4f58d903bc96341b816f7c35df936d6421267d1
test
cu3
Apply cu3 from ctl to tgt with angle theta, phi, lam.
qiskit/extensions/standard/cu3.py
def cu3(self, theta, phi, lam, ctl, tgt): """Apply cu3 from ctl to tgt with angle theta, phi, lam.""" return self.append(Cu3Gate(theta, phi, lam), [ctl, tgt], [])
def cu3(self, theta, phi, lam, ctl, tgt): """Apply cu3 from ctl to tgt with angle theta, phi, lam.""" return self.append(Cu3Gate(theta, phi, lam), [ctl, tgt], [])
[ "Apply", "cu3", "from", "ctl", "to", "tgt", "with", "angle", "theta", "phi", "lam", "." ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/extensions/standard/cu3.py#L56-L58
[ "def", "cu3", "(", "self", ",", "theta", ",", "phi", ",", "lam", ",", "ctl", ",", "tgt", ")", ":", "return", "self", ".", "append", "(", "Cu3Gate", "(", "theta", ",", "phi", ",", "lam", ")", ",", "[", "ctl", ",", "tgt", "]", ",", "[", "]", ...
d4f58d903bc96341b816f7c35df936d6421267d1
test
Cu3Gate._define
gate cu3(theta,phi,lambda) c, t { u1((lambda-phi)/2) t; cx c,t; u3(-theta/2,0,-(phi+lambda)/2) t; cx c,t; u3(theta/2,phi,0) t; }
qiskit/extensions/standard/cu3.py
def _define(self): """ gate cu3(theta,phi,lambda) c, t { u1((lambda-phi)/2) t; cx c,t; u3(-theta/2,0,-(phi+lambda)/2) t; cx c,t; u3(theta/2,phi,0) t; } """ definition = [] q = QuantumRegister(2, "q") rule = [ (U1Gate((self.p...
def _define(self): """ gate cu3(theta,phi,lambda) c, t { u1((lambda-phi)/2) t; cx c,t; u3(-theta/2,0,-(phi+lambda)/2) t; cx c,t; u3(theta/2,phi,0) t; } """ definition = [] q = QuantumRegister(2, "q") rule = [ (U1Gate((self.p...
[ "gate", "cu3", "(", "theta", "phi", "lambda", ")", "c", "t", "{", "u1", "((", "lambda", "-", "phi", ")", "/", "2", ")", "t", ";", "cx", "c", "t", ";", "u3", "(", "-", "theta", "/", "2", "0", "-", "(", "phi", "+", "lambda", ")", "/", "2", ...
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/extensions/standard/cu3.py#L28-L47
[ "def", "_define", "(", "self", ")", ":", "definition", "=", "[", "]", "q", "=", "QuantumRegister", "(", "2", ",", "\"q\"", ")", "rule", "=", "[", "(", "U1Gate", "(", "(", "self", ".", "params", "[", "2", "]", "-", "self", ".", "params", "[", "1...
d4f58d903bc96341b816f7c35df936d6421267d1
test
build_bell_circuit
Returns a circuit putting 2 qubits in the Bell state.
examples/python/circuit_draw.py
def build_bell_circuit(): """Returns a circuit putting 2 qubits in the Bell state.""" q = QuantumRegister(2) c = ClassicalRegister(2) qc = QuantumCircuit(q, c) qc.h(q[0]) qc.cx(q[0], q[1]) qc.measure(q, c) return qc
def build_bell_circuit(): """Returns a circuit putting 2 qubits in the Bell state.""" q = QuantumRegister(2) c = ClassicalRegister(2) qc = QuantumCircuit(q, c) qc.h(q[0]) qc.cx(q[0], q[1]) qc.measure(q, c) return qc
[ "Returns", "a", "circuit", "putting", "2", "qubits", "in", "the", "Bell", "state", "." ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/examples/python/circuit_draw.py#L16-L24
[ "def", "build_bell_circuit", "(", ")", ":", "q", "=", "QuantumRegister", "(", "2", ")", "c", "=", "ClassicalRegister", "(", "2", ")", "qc", "=", "QuantumCircuit", "(", "q", ",", "c", ")", "qc", ".", "h", "(", "q", "[", "0", "]", ")", "qc", ".", ...
d4f58d903bc96341b816f7c35df936d6421267d1
test
transpile
transpile one or more circuits, according to some desired transpilation targets. All arguments may be given as either singleton or list. In case of list, the length must be equal to the number of circuits being transpiled. Transpilation is done in parallel using multiprocessing. Args: cir...
qiskit/compiler/transpiler.py
def transpile(circuits, backend=None, basis_gates=None, coupling_map=None, backend_properties=None, initial_layout=None, seed_transpiler=None, optimization_level=None, pass_manager=None, seed_mapper=None): # deprecated """transpile...
def transpile(circuits, backend=None, basis_gates=None, coupling_map=None, backend_properties=None, initial_layout=None, seed_transpiler=None, optimization_level=None, pass_manager=None, seed_mapper=None): # deprecated """transpile...
[ "transpile", "one", "or", "more", "circuits", "according", "to", "some", "desired", "transpilation", "targets", "." ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/compiler/transpiler.py#L19-L147
[ "def", "transpile", "(", "circuits", ",", "backend", "=", "None", ",", "basis_gates", "=", "None", ",", "coupling_map", "=", "None", ",", "backend_properties", "=", "None", ",", "initial_layout", "=", "None", ",", "seed_transpiler", "=", "None", ",", "optimi...
d4f58d903bc96341b816f7c35df936d6421267d1
test
_transpile_circuit
Select a PassManager and run a single circuit through it. Args: circuit_config_tuple (tuple): circuit (QuantumCircuit): circuit to transpile transpile_config (TranspileConfig): configuration dictating how to transpile Returns: QuantumCircuit: transpiled circuit
qiskit/compiler/transpiler.py
def _transpile_circuit(circuit_config_tuple): """Select a PassManager and run a single circuit through it. Args: circuit_config_tuple (tuple): circuit (QuantumCircuit): circuit to transpile transpile_config (TranspileConfig): configuration dictating how to transpile Returns...
def _transpile_circuit(circuit_config_tuple): """Select a PassManager and run a single circuit through it. Args: circuit_config_tuple (tuple): circuit (QuantumCircuit): circuit to transpile transpile_config (TranspileConfig): configuration dictating how to transpile Returns...
[ "Select", "a", "PassManager", "and", "run", "a", "single", "circuit", "through", "it", "." ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/compiler/transpiler.py#L153-L178
[ "def", "_transpile_circuit", "(", "circuit_config_tuple", ")", ":", "circuit", ",", "transpile_config", "=", "circuit_config_tuple", "# if the pass manager is not already selected, choose an appropriate one.", "if", "transpile_config", ".", "pass_manager", ":", "pass_manager", "=...
d4f58d903bc96341b816f7c35df936d6421267d1
test
_parse_transpile_args
Resolve the various types of args allowed to the transpile() function through duck typing, overriding args, etc. Refer to the transpile() docstring for details on what types of inputs are allowed. Here the args are resolved by converting them to standard instances, and prioritizing them in case a trans...
qiskit/compiler/transpiler.py
def _parse_transpile_args(circuits, backend, basis_gates, coupling_map, backend_properties, initial_layout, seed_transpiler, optimization_level, pass_manager): """Resolve the various types of args allowed to the transpile() function throu...
def _parse_transpile_args(circuits, backend, basis_gates, coupling_map, backend_properties, initial_layout, seed_transpiler, optimization_level, pass_manager): """Resolve the various types of args allowed to the transpile() function throu...
[ "Resolve", "the", "various", "types", "of", "args", "allowed", "to", "the", "transpile", "()", "function", "through", "duck", "typing", "overriding", "args", "etc", ".", "Refer", "to", "the", "transpile", "()", "docstring", "for", "details", "on", "what", "t...
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/compiler/transpiler.py#L181-L227
[ "def", "_parse_transpile_args", "(", "circuits", ",", "backend", ",", "basis_gates", ",", "coupling_map", ",", "backend_properties", ",", "initial_layout", ",", "seed_transpiler", ",", "optimization_level", ",", "pass_manager", ")", ":", "# Each arg could be single or a l...
d4f58d903bc96341b816f7c35df936d6421267d1
test
execute
Execute a list of circuits or pulse schedules on a backend. The execution is asynchronous, and a handle to a job instance is returned. Args: experiments (QuantumCircuit or list[QuantumCircuit] or Schedule or list[Schedule]): Circuit(s) or pulse schedule(s) to execute backend (Base...
qiskit/execute.py
def execute(experiments, backend, basis_gates=None, coupling_map=None, # circuit transpile options backend_properties=None, initial_layout=None, seed_transpiler=None, optimization_level=None, pass_manager=None, qobj_id=None, qobj_header=None, shots=1024, # common run op...
def execute(experiments, backend, basis_gates=None, coupling_map=None, # circuit transpile options backend_properties=None, initial_layout=None, seed_transpiler=None, optimization_level=None, pass_manager=None, qobj_id=None, qobj_header=None, shots=1024, # common run op...
[ "Execute", "a", "list", "of", "circuits", "or", "pulse", "schedules", "on", "a", "backend", "." ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/execute.py#L22-L241
[ "def", "execute", "(", "experiments", ",", "backend", ",", "basis_gates", "=", "None", ",", "coupling_map", "=", "None", ",", "# circuit transpile options", "backend_properties", "=", "None", ",", "initial_layout", "=", "None", ",", "seed_transpiler", "=", "None",...
d4f58d903bc96341b816f7c35df936d6421267d1
test
Qubit.drive
Return the primary drive channel of this qubit.
qiskit/pulse/channels/qubit.py
def drive(self) -> DriveChannel: """Return the primary drive channel of this qubit.""" if self._drives: return self._drives[0] else: raise PulseError("No drive channels in q[%d]" % self._index)
def drive(self) -> DriveChannel: """Return the primary drive channel of this qubit.""" if self._drives: return self._drives[0] else: raise PulseError("No drive channels in q[%d]" % self._index)
[ "Return", "the", "primary", "drive", "channel", "of", "this", "qubit", "." ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/pulse/channels/qubit.py#L57-L62
[ "def", "drive", "(", "self", ")", "->", "DriveChannel", ":", "if", "self", ".", "_drives", ":", "return", "self", ".", "_drives", "[", "0", "]", "else", ":", "raise", "PulseError", "(", "\"No drive channels in q[%d]\"", "%", "self", ".", "_index", ")" ]
d4f58d903bc96341b816f7c35df936d6421267d1
test
Qubit.control
Return the primary control channel of this qubit.
qiskit/pulse/channels/qubit.py
def control(self) -> ControlChannel: """Return the primary control channel of this qubit.""" if self._controls: return self._controls[0] else: raise PulseError("No control channels in q[%d]" % self._index)
def control(self) -> ControlChannel: """Return the primary control channel of this qubit.""" if self._controls: return self._controls[0] else: raise PulseError("No control channels in q[%d]" % self._index)
[ "Return", "the", "primary", "control", "channel", "of", "this", "qubit", "." ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/pulse/channels/qubit.py#L65-L70
[ "def", "control", "(", "self", ")", "->", "ControlChannel", ":", "if", "self", ".", "_controls", ":", "return", "self", ".", "_controls", "[", "0", "]", "else", ":", "raise", "PulseError", "(", "\"No control channels in q[%d]\"", "%", "self", ".", "_index", ...
d4f58d903bc96341b816f7c35df936d6421267d1
test
Qubit.measure
Return the primary measure channel of this qubit.
qiskit/pulse/channels/qubit.py
def measure(self) -> MeasureChannel: """Return the primary measure channel of this qubit.""" if self._measures: return self._measures[0] else: raise PulseError("No measurement channels in q[%d]" % self._index)
def measure(self) -> MeasureChannel: """Return the primary measure channel of this qubit.""" if self._measures: return self._measures[0] else: raise PulseError("No measurement channels in q[%d]" % self._index)
[ "Return", "the", "primary", "measure", "channel", "of", "this", "qubit", "." ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/pulse/channels/qubit.py#L73-L78
[ "def", "measure", "(", "self", ")", "->", "MeasureChannel", ":", "if", "self", ".", "_measures", ":", "return", "self", ".", "_measures", "[", "0", "]", "else", ":", "raise", "PulseError", "(", "\"No measurement channels in q[%d]\"", "%", "self", ".", "_inde...
d4f58d903bc96341b816f7c35df936d6421267d1
test
Qubit.acquire
Return the primary acquire channel of this qubit.
qiskit/pulse/channels/qubit.py
def acquire(self) -> AcquireChannel: """Return the primary acquire channel of this qubit.""" if self._acquires: return self._acquires[0] else: raise PulseError("No acquire channels in q[%d]" % self._index)
def acquire(self) -> AcquireChannel: """Return the primary acquire channel of this qubit.""" if self._acquires: return self._acquires[0] else: raise PulseError("No acquire channels in q[%d]" % self._index)
[ "Return", "the", "primary", "acquire", "channel", "of", "this", "qubit", "." ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/pulse/channels/qubit.py#L81-L86
[ "def", "acquire", "(", "self", ")", "->", "AcquireChannel", ":", "if", "self", ".", "_acquires", ":", "return", "self", ".", "_acquires", "[", "0", "]", "else", ":", "raise", "PulseError", "(", "\"No acquire channels in q[%d]\"", "%", "self", ".", "_index", ...
d4f58d903bc96341b816f7c35df936d6421267d1
test
input_state
n-qubit input state for QFT that produces output 1.
examples/python/qft.py
def input_state(circ, q, n): """n-qubit input state for QFT that produces output 1.""" for j in range(n): circ.h(q[j]) circ.u1(math.pi/float(2**(j)), q[j]).inverse()
def input_state(circ, q, n): """n-qubit input state for QFT that produces output 1.""" for j in range(n): circ.h(q[j]) circ.u1(math.pi/float(2**(j)), q[j]).inverse()
[ "n", "-", "qubit", "input", "state", "for", "QFT", "that", "produces", "output", "1", "." ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/examples/python/qft.py#L24-L28
[ "def", "input_state", "(", "circ", ",", "q", ",", "n", ")", ":", "for", "j", "in", "range", "(", "n", ")", ":", "circ", ".", "h", "(", "q", "[", "j", "]", ")", "circ", ".", "u1", "(", "math", ".", "pi", "/", "float", "(", "2", "**", "(", ...
d4f58d903bc96341b816f7c35df936d6421267d1
test
assemble_circuits
Assembles a list of circuits into a qobj which can be run on the backend. Args: circuits (list[QuantumCircuits]): circuit(s) to assemble qobj_id (int): identifier for the generated qobj qobj_header (QobjHeader): header to pass to the results run_config (RunConfig): configuration of ...
qiskit/compiler/assembler.py
def assemble_circuits(circuits, qobj_id=None, qobj_header=None, run_config=None): """Assembles a list of circuits into a qobj which can be run on the backend. Args: circuits (list[QuantumCircuits]): circuit(s) to assemble qobj_id (int): identifier for the generated qobj qobj_header (Qob...
def assemble_circuits(circuits, qobj_id=None, qobj_header=None, run_config=None): """Assembles a list of circuits into a qobj which can be run on the backend. Args: circuits (list[QuantumCircuits]): circuit(s) to assemble qobj_id (int): identifier for the generated qobj qobj_header (Qob...
[ "Assembles", "a", "list", "of", "circuits", "into", "a", "qobj", "which", "can", "be", "run", "on", "the", "backend", "." ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/compiler/assembler.py#L29-L150
[ "def", "assemble_circuits", "(", "circuits", ",", "qobj_id", "=", "None", ",", "qobj_header", "=", "None", ",", "run_config", "=", "None", ")", ":", "qobj_config", "=", "QasmQobjConfig", "(", ")", "if", "run_config", ":", "qobj_config", "=", "QasmQobjConfig", ...
d4f58d903bc96341b816f7c35df936d6421267d1
test
assemble_schedules
Assembles a list of schedules into a qobj which can be run on the backend. Args: schedules (list[Schedule]): schedules to assemble qobj_id (int): identifier for the generated qobj qobj_header (QobjHeader): header to pass to the results run_config (RunConfig): configuration of the run...
qiskit/compiler/assembler.py
def assemble_schedules(schedules, qobj_id=None, qobj_header=None, run_config=None): """Assembles a list of schedules into a qobj which can be run on the backend. Args: schedules (list[Schedule]): schedules to assemble qobj_id (int): identifier for the generated qobj qobj_header (QobjHead...
def assemble_schedules(schedules, qobj_id=None, qobj_header=None, run_config=None): """Assembles a list of schedules into a qobj which can be run on the backend. Args: schedules (list[Schedule]): schedules to assemble qobj_id (int): identifier for the generated qobj qobj_header (QobjHead...
[ "Assembles", "a", "list", "of", "schedules", "into", "a", "qobj", "which", "can", "be", "run", "on", "the", "backend", ".", "Args", ":", "schedules", "(", "list", "[", "Schedule", "]", ")", ":", "schedules", "to", "assemble", "qobj_id", "(", "int", ")"...
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/compiler/assembler.py#L153-L251
[ "def", "assemble_schedules", "(", "schedules", ",", "qobj_id", "=", "None", ",", "qobj_header", "=", "None", ",", "run_config", "=", "None", ")", ":", "qobj_config", "=", "QasmQobjConfig", "(", ")", "if", "run_config", ":", "qobj_config", "=", "QasmQobjConfig"...
d4f58d903bc96341b816f7c35df936d6421267d1
test
assemble
Assemble a list of circuits or pulse schedules into a Qobj. This function serializes the payloads, which could be either circuits or schedules, to create Qobj "experiments". It further annotates the experiment payload with header and configurations. Args: experiments (QuantumCircuit or list[Qu...
qiskit/compiler/assembler.py
def assemble(experiments, backend=None, qobj_id=None, qobj_header=None, # common run options shots=1024, memory=False, max_credits=None, seed_simulator=None, default_qubit_los=None, default_meas_los=None, # schedule run options schedule_los=None, meas_l...
def assemble(experiments, backend=None, qobj_id=None, qobj_header=None, # common run options shots=1024, memory=False, max_credits=None, seed_simulator=None, default_qubit_los=None, default_meas_los=None, # schedule run options schedule_los=None, meas_l...
[ "Assemble", "a", "list", "of", "circuits", "or", "pulse", "schedules", "into", "a", "Qobj", "." ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/compiler/assembler.py#L255-L389
[ "def", "assemble", "(", "experiments", ",", "backend", "=", "None", ",", "qobj_id", "=", "None", ",", "qobj_header", "=", "None", ",", "# common run options", "shots", "=", "1024", ",", "memory", "=", "False", ",", "max_credits", "=", "None", ",", "seed_si...
d4f58d903bc96341b816f7c35df936d6421267d1
test
_parse_run_args
Resolve the various types of args allowed to the assemble() function through duck typing, overriding args, etc. Refer to the assemble() docstring for details on what types of inputs are allowed. Here the args are resolved by converting them to standard instances, and prioritizing them in case a run opt...
qiskit/compiler/assembler.py
def _parse_run_args(backend, qobj_id, qobj_header, shots, memory, max_credits, seed_simulator, default_qubit_los, default_meas_los, schedule_los, meas_level, meas_return, memory_slots, memory_slot_size, rep_time, paramet...
def _parse_run_args(backend, qobj_id, qobj_header, shots, memory, max_credits, seed_simulator, default_qubit_los, default_meas_los, schedule_los, meas_level, meas_return, memory_slots, memory_slot_size, rep_time, paramet...
[ "Resolve", "the", "various", "types", "of", "args", "allowed", "to", "the", "assemble", "()", "function", "through", "duck", "typing", "overriding", "args", "etc", ".", "Refer", "to", "the", "assemble", "()", "docstring", "for", "details", "on", "what", "typ...
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/compiler/assembler.py#L393-L479
[ "def", "_parse_run_args", "(", "backend", ",", "qobj_id", ",", "qobj_header", ",", "shots", ",", "memory", ",", "max_credits", ",", "seed_simulator", ",", "default_qubit_los", ",", "default_meas_los", ",", "schedule_los", ",", "meas_level", ",", "meas_return", ","...
d4f58d903bc96341b816f7c35df936d6421267d1
test
_expand_parameters
Verifies that there is a single common set of parameters shared between all circuits and all parameter binds in the run_config. Returns an expanded list of circuits (if parameterized) with all parameters bound, and a copy of the run_config with parameter_binds cleared. If neither the circuits nor the r...
qiskit/compiler/assembler.py
def _expand_parameters(circuits, run_config): """Verifies that there is a single common set of parameters shared between all circuits and all parameter binds in the run_config. Returns an expanded list of circuits (if parameterized) with all parameters bound, and a copy of the run_config with parameter_...
def _expand_parameters(circuits, run_config): """Verifies that there is a single common set of parameters shared between all circuits and all parameter binds in the run_config. Returns an expanded list of circuits (if parameterized) with all parameters bound, and a copy of the run_config with parameter_...
[ "Verifies", "that", "there", "is", "a", "single", "common", "set", "of", "parameters", "shared", "between", "all", "circuits", "and", "all", "parameter", "binds", "in", "the", "run_config", ".", "Returns", "an", "expanded", "list", "of", "circuits", "(", "if...
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/compiler/assembler.py#L482-L531
[ "def", "_expand_parameters", "(", "circuits", ",", "run_config", ")", ":", "parameter_binds", "=", "run_config", ".", "parameter_binds", "if", "parameter_binds", "or", "any", "(", "circuit", ".", "parameters", "for", "circuit", "in", "circuits", ")", ":", "all_b...
d4f58d903bc96341b816f7c35df936d6421267d1
test
unset_qiskit_logger
Remove the handlers for the 'qiskit' logger.
qiskit/tools/logging.py
def unset_qiskit_logger(): """Remove the handlers for the 'qiskit' logger.""" qiskit_logger = logging.getLogger('qiskit') for handler in qiskit_logger.handlers: qiskit_logger.removeHandler(handler)
def unset_qiskit_logger(): """Remove the handlers for the 'qiskit' logger.""" qiskit_logger = logging.getLogger('qiskit') for handler in qiskit_logger.handlers: qiskit_logger.removeHandler(handler)
[ "Remove", "the", "handlers", "for", "the", "qiskit", "logger", "." ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/tools/logging.py#L66-L70
[ "def", "unset_qiskit_logger", "(", ")", ":", "qiskit_logger", "=", "logging", ".", "getLogger", "(", "'qiskit'", ")", "for", "handler", "in", "qiskit_logger", ".", "handlers", ":", "qiskit_logger", ".", "removeHandler", "(", "handler", ")" ]
d4f58d903bc96341b816f7c35df936d6421267d1
test
iplot_state_hinton
Create a hinton representation. Graphical representation of the input array using a 2D city style graph (hinton). Args: rho (array): Density matrix figsize (tuple): Figure size in pixels.
qiskit/visualization/interactive/iplot_hinton.py
def iplot_state_hinton(rho, figsize=None): """ Create a hinton representation. Graphical representation of the input array using a 2D city style graph (hinton). Args: rho (array): Density matrix figsize (tuple): Figure size in pixels. """ # HTML html_te...
def iplot_state_hinton(rho, figsize=None): """ Create a hinton representation. Graphical representation of the input array using a 2D city style graph (hinton). Args: rho (array): Density matrix figsize (tuple): Figure size in pixels. """ # HTML html_te...
[ "Create", "a", "hinton", "representation", "." ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/visualization/interactive/iplot_hinton.py#L23-L93
[ "def", "iplot_state_hinton", "(", "rho", ",", "figsize", "=", "None", ")", ":", "# HTML", "html_template", "=", "Template", "(", "\"\"\"\n <p>\n <div id=\"hinton_$divNumber\"></div>\n </p>\n \"\"\"", ")", "# JavaScript", "javascript_template", "=", "Template",...
d4f58d903bc96341b816f7c35df936d6421267d1
test
process_fidelity
Return the process fidelity between two quantum channels. This is given by F_p(E1, E2) = Tr[S2^dagger.S1])/dim^2 where S1 and S2 are the SuperOp matrices for channels E1 and E2, and dim is the dimension of the input output statespace. Args: channel1 (QuantumChannel or matrix): a quan...
qiskit/quantum_info/operators/measures.py
def process_fidelity(channel1, channel2, require_cptp=True): """Return the process fidelity between two quantum channels. This is given by F_p(E1, E2) = Tr[S2^dagger.S1])/dim^2 where S1 and S2 are the SuperOp matrices for channels E1 and E2, and dim is the dimension of the input output states...
def process_fidelity(channel1, channel2, require_cptp=True): """Return the process fidelity between two quantum channels. This is given by F_p(E1, E2) = Tr[S2^dagger.S1])/dim^2 where S1 and S2 are the SuperOp matrices for channels E1 and E2, and dim is the dimension of the input output states...
[ "Return", "the", "process", "fidelity", "between", "two", "quantum", "channels", "." ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/quantum_info/operators/measures.py#L21-L85
[ "def", "process_fidelity", "(", "channel1", ",", "channel2", ",", "require_cptp", "=", "True", ")", ":", "# First we must determine if input is to be interpreted as a unitary matrix", "# or as a channel.", "# If input is a raw numpy array we will interpret it as a unitary matrix.", "is...
d4f58d903bc96341b816f7c35df936d6421267d1
test
QasmLexer.input
Set the input text data.
qiskit/qasm/qasmlexer.py
def input(self, data): """Set the input text data.""" self.data = data self.lexer.input(data)
def input(self, data): """Set the input text data.""" self.data = data self.lexer.input(data)
[ "Set", "the", "input", "text", "data", "." ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/qasm/qasmlexer.py#L52-L55
[ "def", "input", "(", "self", ",", "data", ")", ":", "self", ".", "data", "=", "data", "self", ".", "lexer", ".", "input", "(", "data", ")" ]
d4f58d903bc96341b816f7c35df936d6421267d1
test
QasmLexer.pop
Pop a PLY lexer off the stack.
qiskit/qasm/qasmlexer.py
def pop(self): """Pop a PLY lexer off the stack.""" self.lexer = self.stack.pop() self.filename = self.lexer.qasm_file self.lineno = self.lexer.qasm_line
def pop(self): """Pop a PLY lexer off the stack.""" self.lexer = self.stack.pop() self.filename = self.lexer.qasm_file self.lineno = self.lexer.qasm_line
[ "Pop", "a", "PLY", "lexer", "off", "the", "stack", "." ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/qasm/qasmlexer.py#L62-L66
[ "def", "pop", "(", "self", ")", ":", "self", ".", "lexer", "=", "self", ".", "stack", ".", "pop", "(", ")", "self", ".", "filename", "=", "self", ".", "lexer", ".", "qasm_file", "self", ".", "lineno", "=", "self", ".", "lexer", ".", "qasm_line" ]
d4f58d903bc96341b816f7c35df936d6421267d1
test
QasmLexer.push
Push a PLY lexer on the stack to parse filename.
qiskit/qasm/qasmlexer.py
def push(self, filename): """Push a PLY lexer on the stack to parse filename.""" self.lexer.qasm_file = self.filename self.lexer.qasm_line = self.lineno self.stack.append(self.lexer) self.__mklexer__(filename)
def push(self, filename): """Push a PLY lexer on the stack to parse filename.""" self.lexer.qasm_file = self.filename self.lexer.qasm_line = self.lineno self.stack.append(self.lexer) self.__mklexer__(filename)
[ "Push", "a", "PLY", "lexer", "on", "the", "stack", "to", "parse", "filename", "." ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/qasm/qasmlexer.py#L68-L73
[ "def", "push", "(", "self", ",", "filename", ")", ":", "self", ".", "lexer", ".", "qasm_file", "=", "self", ".", "filename", "self", ".", "lexer", ".", "qasm_line", "=", "self", ".", "lineno", "self", ".", "stack", ".", "append", "(", "self", ".", ...
d4f58d903bc96341b816f7c35df936d6421267d1
test
QasmLexer.t_INCLUDE
include
qiskit/qasm/qasmlexer.py
def t_INCLUDE(self, t): 'include' # # Now eat up the next two tokens which must be # 1 - the name of the include file, and # 2 - a terminating semicolon # # Then push the current lexer onto the stack, create a new one from # the include file, and push it o...
def t_INCLUDE(self, t): 'include' # # Now eat up the next two tokens which must be # 1 - the name of the include file, and # 2 - a terminating semicolon # # Then push the current lexer onto the stack, create a new one from # the include file, and push it o...
[ "include" ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/qasm/qasmlexer.py#L123-L154
[ "def", "t_INCLUDE", "(", "self", ",", "t", ")", ":", "#", "# Now eat up the next two tokens which must be", "# 1 - the name of the include file, and", "# 2 - a terminating semicolon", "#", "# Then push the current lexer onto the stack, create a new one from", "# the include file, and pus...
d4f58d903bc96341b816f7c35df936d6421267d1
test
QasmLexer.t_ID
r'[a-z][a-zA-Z0-9_]*
qiskit/qasm/qasmlexer.py
def t_ID(self, t): r'[a-z][a-zA-Z0-9_]*' t.type = self.reserved.get(t.value, 'ID') if t.type == 'ID': t.value = node.Id(t.value, self.lineno, self.filename) return t
def t_ID(self, t): r'[a-z][a-zA-Z0-9_]*' t.type = self.reserved.get(t.value, 'ID') if t.type == 'ID': t.value = node.Id(t.value, self.lineno, self.filename) return t
[ "r", "[", "a", "-", "z", "]", "[", "a", "-", "zA", "-", "Z0", "-", "9_", "]", "*" ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/qasm/qasmlexer.py#L172-L178
[ "def", "t_ID", "(", "self", ",", "t", ")", ":", "t", ".", "type", "=", "self", ".", "reserved", ".", "get", "(", "t", ".", "value", ",", "'ID'", ")", "if", "t", ".", "type", "==", "'ID'", ":", "t", ".", "value", "=", "node", ".", "Id", "(",...
d4f58d903bc96341b816f7c35df936d6421267d1
test
QasmLexer.t_newline
r'\n+
qiskit/qasm/qasmlexer.py
def t_newline(self, t): r'\n+' self.lineno += len(t.value) t.lexer.lineno = self.lineno
def t_newline(self, t): r'\n+' self.lineno += len(t.value) t.lexer.lineno = self.lineno
[ "r", "\\", "n", "+" ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/qasm/qasmlexer.py#L180-L183
[ "def", "t_newline", "(", "self", ",", "t", ")", ":", "self", ".", "lineno", "+=", "len", "(", "t", ".", "value", ")", "t", ".", "lexer", ".", "lineno", "=", "self", ".", "lineno" ]
d4f58d903bc96341b816f7c35df936d6421267d1
test
DeviceSpecification.create_from
Create device specification with values in backend configuration. Args: backend(Backend): backend configuration Returns: DeviceSpecification: created device specification Raises: PulseError: when an invalid backend is specified
qiskit/pulse/channels/device_specification.py
def create_from(cls, backend): """ Create device specification with values in backend configuration. Args: backend(Backend): backend configuration Returns: DeviceSpecification: created device specification Raises: PulseError: when an invalid ba...
def create_from(cls, backend): """ Create device specification with values in backend configuration. Args: backend(Backend): backend configuration Returns: DeviceSpecification: created device specification Raises: PulseError: when an invalid ba...
[ "Create", "device", "specification", "with", "values", "in", "backend", "configuration", ".", "Args", ":", "backend", "(", "Backend", ")", ":", "backend", "configuration", "Returns", ":", "DeviceSpecification", ":", "created", "device", "specification", "Raises", ...
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/pulse/channels/device_specification.py#L40-L104
[ "def", "create_from", "(", "cls", ",", "backend", ")", ":", "backend_config", "=", "backend", ".", "configuration", "(", ")", "# TODO : Remove usage of config.defaults when backend.defaults() is updated.", "try", ":", "backend_default", "=", "backend", ".", "defaults", ...
d4f58d903bc96341b816f7c35df936d6421267d1
test
ConsolidateBlocks.run
iterate over each block and replace it with an equivalent Unitary on the same wires.
qiskit/transpiler/passes/consolidate_blocks.py
def run(self, dag): """iterate over each block and replace it with an equivalent Unitary on the same wires. """ new_dag = DAGCircuit() for qreg in dag.qregs.values(): new_dag.add_qreg(qreg) for creg in dag.cregs.values(): new_dag.add_creg(creg) ...
def run(self, dag): """iterate over each block and replace it with an equivalent Unitary on the same wires. """ new_dag = DAGCircuit() for qreg in dag.qregs.values(): new_dag.add_qreg(qreg) for creg in dag.cregs.values(): new_dag.add_creg(creg) ...
[ "iterate", "over", "each", "block", "and", "replace", "it", "with", "an", "equivalent", "Unitary", "on", "the", "same", "wires", "." ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/transpiler/passes/consolidate_blocks.py#L35-L92
[ "def", "run", "(", "self", ",", "dag", ")", ":", "new_dag", "=", "DAGCircuit", "(", ")", "for", "qreg", "in", "dag", ".", "qregs", ".", "values", "(", ")", ":", "new_dag", ".", "add_qreg", "(", "qreg", ")", "for", "creg", "in", "dag", ".", "cregs...
d4f58d903bc96341b816f7c35df936d6421267d1
test
ConsolidateBlocks._block_qargs_to_indices
Map each qubit in block_qargs to its wire position among the block's wires. Args: block_qargs (list): list of qubits that a block acts on global_index_map (dict): mapping from each qubit in the circuit to its wire position within that circuit Returns: ...
qiskit/transpiler/passes/consolidate_blocks.py
def _block_qargs_to_indices(self, block_qargs, global_index_map): """ Map each qubit in block_qargs to its wire position among the block's wires. Args: block_qargs (list): list of qubits that a block acts on global_index_map (dict): mapping from each qubit in the ...
def _block_qargs_to_indices(self, block_qargs, global_index_map): """ Map each qubit in block_qargs to its wire position among the block's wires. Args: block_qargs (list): list of qubits that a block acts on global_index_map (dict): mapping from each qubit in the ...
[ "Map", "each", "qubit", "in", "block_qargs", "to", "its", "wire", "position", "among", "the", "block", "s", "wires", ".", "Args", ":", "block_qargs", "(", "list", ")", ":", "list", "of", "qubits", "that", "a", "block", "acts", "on", "global_index_map", "...
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/transpiler/passes/consolidate_blocks.py#L94-L108
[ "def", "_block_qargs_to_indices", "(", "self", ",", "block_qargs", ",", "global_index_map", ")", ":", "block_indices", "=", "[", "global_index_map", "[", "q", "]", "for", "q", "in", "block_qargs", "]", "ordered_block_indices", "=", "sorted", "(", "block_indices", ...
d4f58d903bc96341b816f7c35df936d6421267d1
test
ConversionMethodBinder.get_bound_method
Get conversion method for instruction.
qiskit/qobj/converters/pulse_instruction.py
def get_bound_method(self, instruction): """Get conversion method for instruction.""" try: return self._bound_instructions[type(instruction)] except KeyError: raise PulseError('Qobj conversion method for %s is not found.' % instruction)
def get_bound_method(self, instruction): """Get conversion method for instruction.""" try: return self._bound_instructions[type(instruction)] except KeyError: raise PulseError('Qobj conversion method for %s is not found.' % instruction)
[ "Get", "conversion", "method", "for", "instruction", "." ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/qobj/converters/pulse_instruction.py#L56-L61
[ "def", "get_bound_method", "(", "self", ",", "instruction", ")", ":", "try", ":", "return", "self", ".", "_bound_instructions", "[", "type", "(", "instruction", ")", "]", "except", "KeyError", ":", "raise", "PulseError", "(", "'Qobj conversion method for %s is not...
d4f58d903bc96341b816f7c35df936d6421267d1
test
PulseQobjConverter.convert_acquire
Return converted `AcquireInstruction`. Args: shift(int): Offset time. instruction (AcquireInstruction): acquire instruction. Returns: dict: Dictionary of required parameters.
qiskit/qobj/converters/pulse_instruction.py
def convert_acquire(self, shift, instruction): """Return converted `AcquireInstruction`. Args: shift(int): Offset time. instruction (AcquireInstruction): acquire instruction. Returns: dict: Dictionary of required parameters. """ meas_level = s...
def convert_acquire(self, shift, instruction): """Return converted `AcquireInstruction`. Args: shift(int): Offset time. instruction (AcquireInstruction): acquire instruction. Returns: dict: Dictionary of required parameters. """ meas_level = s...
[ "Return", "converted", "AcquireInstruction", "." ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/qobj/converters/pulse_instruction.py#L115-L157
[ "def", "convert_acquire", "(", "self", ",", "shift", ",", "instruction", ")", ":", "meas_level", "=", "self", ".", "_run_config", ".", "get", "(", "'meas_level'", ",", "2", ")", "command_dict", "=", "{", "'name'", ":", "'acquire'", ",", "'t0'", ":", "shi...
d4f58d903bc96341b816f7c35df936d6421267d1
test
PulseQobjConverter.convert_frame_change
Return converted `FrameChangeInstruction`. Args: shift(int): Offset time. instruction (FrameChangeInstruction): frame change instruction. Returns: dict: Dictionary of required parameters.
qiskit/qobj/converters/pulse_instruction.py
def convert_frame_change(self, shift, instruction): """Return converted `FrameChangeInstruction`. Args: shift(int): Offset time. instruction (FrameChangeInstruction): frame change instruction. Returns: dict: Dictionary of required parameters. """ ...
def convert_frame_change(self, shift, instruction): """Return converted `FrameChangeInstruction`. Args: shift(int): Offset time. instruction (FrameChangeInstruction): frame change instruction. Returns: dict: Dictionary of required parameters. """ ...
[ "Return", "converted", "FrameChangeInstruction", "." ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/qobj/converters/pulse_instruction.py#L160-L175
[ "def", "convert_frame_change", "(", "self", ",", "shift", ",", "instruction", ")", ":", "command_dict", "=", "{", "'name'", ":", "'fc'", ",", "'t0'", ":", "shift", "+", "instruction", ".", "start_time", ",", "'ch'", ":", "instruction", ".", "channels", "["...
d4f58d903bc96341b816f7c35df936d6421267d1
test
PulseQobjConverter.convert_persistent_value
Return converted `PersistentValueInstruction`. Args: shift(int): Offset time. instruction (PersistentValueInstruction): persistent value instruction. Returns: dict: Dictionary of required parameters.
qiskit/qobj/converters/pulse_instruction.py
def convert_persistent_value(self, shift, instruction): """Return converted `PersistentValueInstruction`. Args: shift(int): Offset time. instruction (PersistentValueInstruction): persistent value instruction. Returns: dict: Dictionary of required parameters. ...
def convert_persistent_value(self, shift, instruction): """Return converted `PersistentValueInstruction`. Args: shift(int): Offset time. instruction (PersistentValueInstruction): persistent value instruction. Returns: dict: Dictionary of required parameters. ...
[ "Return", "converted", "PersistentValueInstruction", "." ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/qobj/converters/pulse_instruction.py#L178-L193
[ "def", "convert_persistent_value", "(", "self", ",", "shift", ",", "instruction", ")", ":", "command_dict", "=", "{", "'name'", ":", "'pv'", ",", "'t0'", ":", "shift", "+", "instruction", ".", "start_time", ",", "'ch'", ":", "instruction", ".", "channels", ...
d4f58d903bc96341b816f7c35df936d6421267d1
test
PulseQobjConverter.convert_drive
Return converted `PulseInstruction`. Args: shift(int): Offset time. instruction (PulseInstruction): drive instruction. Returns: dict: Dictionary of required parameters.
qiskit/qobj/converters/pulse_instruction.py
def convert_drive(self, shift, instruction): """Return converted `PulseInstruction`. Args: shift(int): Offset time. instruction (PulseInstruction): drive instruction. Returns: dict: Dictionary of required parameters. """ command_dict = { ...
def convert_drive(self, shift, instruction): """Return converted `PulseInstruction`. Args: shift(int): Offset time. instruction (PulseInstruction): drive instruction. Returns: dict: Dictionary of required parameters. """ command_dict = { ...
[ "Return", "converted", "PulseInstruction", "." ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/qobj/converters/pulse_instruction.py#L196-L210
[ "def", "convert_drive", "(", "self", ",", "shift", ",", "instruction", ")", ":", "command_dict", "=", "{", "'name'", ":", "instruction", ".", "command", ".", "name", ",", "'t0'", ":", "shift", "+", "instruction", ".", "start_time", ",", "'ch'", ":", "ins...
d4f58d903bc96341b816f7c35df936d6421267d1
test
PulseQobjConverter.convert_snapshot
Return converted `Snapshot`. Args: shift(int): Offset time. instruction (Snapshot): snapshot instruction. Returns: dict: Dictionary of required parameters.
qiskit/qobj/converters/pulse_instruction.py
def convert_snapshot(self, shift, instruction): """Return converted `Snapshot`. Args: shift(int): Offset time. instruction (Snapshot): snapshot instruction. Returns: dict: Dictionary of required parameters. """ command_dict = { 'na...
def convert_snapshot(self, shift, instruction): """Return converted `Snapshot`. Args: shift(int): Offset time. instruction (Snapshot): snapshot instruction. Returns: dict: Dictionary of required parameters. """ command_dict = { 'na...
[ "Return", "converted", "Snapshot", "." ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/qobj/converters/pulse_instruction.py#L213-L228
[ "def", "convert_snapshot", "(", "self", ",", "shift", ",", "instruction", ")", ":", "command_dict", "=", "{", "'name'", ":", "'snapshot'", ",", "'t0'", ":", "shift", "+", "instruction", ".", "start_time", ",", "'label'", ":", "instruction", ".", "name", ",...
d4f58d903bc96341b816f7c35df936d6421267d1
test
_update_annotations
Update annotations of discretized continuous pulse function with duration. Args: discretized_pulse: Discretized decorated continuous pulse.
qiskit/pulse/samplers/decorators.py
def _update_annotations(discretized_pulse: Callable) -> Callable: """Update annotations of discretized continuous pulse function with duration. Args: discretized_pulse: Discretized decorated continuous pulse. """ undecorated_annotations = list(discretized_pulse.__annotations__.items()) deco...
def _update_annotations(discretized_pulse: Callable) -> Callable: """Update annotations of discretized continuous pulse function with duration. Args: discretized_pulse: Discretized decorated continuous pulse. """ undecorated_annotations = list(discretized_pulse.__annotations__.items()) deco...
[ "Update", "annotations", "of", "discretized", "continuous", "pulse", "function", "with", "duration", "." ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/pulse/samplers/decorators.py#L135-L145
[ "def", "_update_annotations", "(", "discretized_pulse", ":", "Callable", ")", "->", "Callable", ":", "undecorated_annotations", "=", "list", "(", "discretized_pulse", ".", "__annotations__", ".", "items", "(", ")", ")", "decorated_annotations", "=", "undecorated_annot...
d4f58d903bc96341b816f7c35df936d6421267d1
test
_update_docstring
Update annotations of discretized continuous pulse function. Args: discretized_pulse: Discretized decorated continuous pulse. sampler_inst: Applied sampler.
qiskit/pulse/samplers/decorators.py
def _update_docstring(discretized_pulse: Callable, sampler_inst: Callable) -> Callable: """Update annotations of discretized continuous pulse function. Args: discretized_pulse: Discretized decorated continuous pulse. sampler_inst: Applied sampler. """ wrapped_docstring = pydoc.render_do...
def _update_docstring(discretized_pulse: Callable, sampler_inst: Callable) -> Callable: """Update annotations of discretized continuous pulse function. Args: discretized_pulse: Discretized decorated continuous pulse. sampler_inst: Applied sampler. """ wrapped_docstring = pydoc.render_do...
[ "Update", "annotations", "of", "discretized", "continuous", "pulse", "function", "." ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/pulse/samplers/decorators.py#L148-L181
[ "def", "_update_docstring", "(", "discretized_pulse", ":", "Callable", ",", "sampler_inst", ":", "Callable", ")", "->", "Callable", ":", "wrapped_docstring", "=", "pydoc", ".", "render_doc", "(", "discretized_pulse", ",", "'%s'", ")", "header", ",", "body", "=",...
d4f58d903bc96341b816f7c35df936d6421267d1
test
sampler
Sampler decorator base method. Samplers are used for converting an continuous function to a discretized pulse. They operate on a function with the signature: `def f(times: np.ndarray, *args, **kwargs) -> np.ndarray` Where `times` is a numpy array of floats with length n_times and the output array ...
qiskit/pulse/samplers/decorators.py
def sampler(sample_function: Callable) -> Callable: """Sampler decorator base method. Samplers are used for converting an continuous function to a discretized pulse. They operate on a function with the signature: `def f(times: np.ndarray, *args, **kwargs) -> np.ndarray` Where `times` is a nump...
def sampler(sample_function: Callable) -> Callable: """Sampler decorator base method. Samplers are used for converting an continuous function to a discretized pulse. They operate on a function with the signature: `def f(times: np.ndarray, *args, **kwargs) -> np.ndarray` Where `times` is a nump...
[ "Sampler", "decorator", "base", "method", "." ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/pulse/samplers/decorators.py#L184-L227
[ "def", "sampler", "(", "sample_function", ":", "Callable", ")", "->", "Callable", ":", "def", "generate_sampler", "(", "continuous_pulse", ":", "Callable", ")", "->", "Callable", ":", "\"\"\"Return a decorated sampler function.\"\"\"", "@", "functools", ".", "wraps", ...
d4f58d903bc96341b816f7c35df936d6421267d1
test
filter_backends
Return the backends matching the specified filtering. Filter the `backends` list by their `configuration` or `status` attributes, or from a boolean callable. The criteria for filtering can be specified via `**kwargs` or as a callable via `filters`, and the backends must fulfill all specified conditions...
qiskit/providers/providerutils.py
def filter_backends(backends, filters=None, **kwargs): """Return the backends matching the specified filtering. Filter the `backends` list by their `configuration` or `status` attributes, or from a boolean callable. The criteria for filtering can be specified via `**kwargs` or as a callable via `filter...
def filter_backends(backends, filters=None, **kwargs): """Return the backends matching the specified filtering. Filter the `backends` list by their `configuration` or `status` attributes, or from a boolean callable. The criteria for filtering can be specified via `**kwargs` or as a callable via `filter...
[ "Return", "the", "backends", "matching", "the", "specified", "filtering", "." ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/providers/providerutils.py#L15-L62
[ "def", "filter_backends", "(", "backends", ",", "filters", "=", "None", ",", "*", "*", "kwargs", ")", ":", "def", "_match_all", "(", "obj", ",", "criteria", ")", ":", "\"\"\"Return True if all items in criteria matches items in obj.\"\"\"", "return", "all", "(", "...
d4f58d903bc96341b816f7c35df936d6421267d1
test
resolve_backend_name
Resolve backend name from a deprecated name or an alias. A group will be resolved in order of member priorities, depending on availability. Args: name (str): name of backend to resolve backends (list[BaseBackend]): list of available backends. deprecated (dict[str: str]): dict of de...
qiskit/providers/providerutils.py
def resolve_backend_name(name, backends, deprecated, aliased): """Resolve backend name from a deprecated name or an alias. A group will be resolved in order of member priorities, depending on availability. Args: name (str): name of backend to resolve backends (list[BaseBackend]): list ...
def resolve_backend_name(name, backends, deprecated, aliased): """Resolve backend name from a deprecated name or an alias. A group will be resolved in order of member priorities, depending on availability. Args: name (str): name of backend to resolve backends (list[BaseBackend]): list ...
[ "Resolve", "backend", "name", "from", "a", "deprecated", "name", "or", "an", "alias", "." ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/providers/providerutils.py#L65-L96
[ "def", "resolve_backend_name", "(", "name", ",", "backends", ",", "deprecated", ",", "aliased", ")", ":", "available", "=", "[", "backend", ".", "name", "(", ")", "for", "backend", "in", "backends", "]", "resolved_name", "=", "deprecated", ".", "get", "(",...
d4f58d903bc96341b816f7c35df936d6421267d1
test
dag_to_circuit
Build a ``QuantumCircuit`` object from a ``DAGCircuit``. Args: dag (DAGCircuit): the input dag. Return: QuantumCircuit: the circuit representing the input dag.
qiskit/converters/dag_to_circuit.py
def dag_to_circuit(dag): """Build a ``QuantumCircuit`` object from a ``DAGCircuit``. Args: dag (DAGCircuit): the input dag. Return: QuantumCircuit: the circuit representing the input dag. """ qregs = collections.OrderedDict() for qreg in dag.qregs.values(): qreg_tmp = Q...
def dag_to_circuit(dag): """Build a ``QuantumCircuit`` object from a ``DAGCircuit``. Args: dag (DAGCircuit): the input dag. Return: QuantumCircuit: the circuit representing the input dag. """ qregs = collections.OrderedDict() for qreg in dag.qregs.values(): qreg_tmp = Q...
[ "Build", "a", "QuantumCircuit", "object", "from", "a", "DAGCircuit", "." ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/converters/dag_to_circuit.py#L16-L55
[ "def", "dag_to_circuit", "(", "dag", ")", ":", "qregs", "=", "collections", ".", "OrderedDict", "(", ")", "for", "qreg", "in", "dag", ".", "qregs", ".", "values", "(", ")", ":", "qreg_tmp", "=", "QuantumRegister", "(", "qreg", ".", "size", ",", "name",...
d4f58d903bc96341b816f7c35df936d6421267d1
test
make_dict_observable
Convert an observable in matrix form to dictionary form. Takes in a diagonal observable as a matrix and converts it to a dictionary form. Can also handle a list sorted of the diagonal elements. Args: matrix_observable (list): The observable to be converted to dictionary form. Can be a matr...
qiskit/quantum_info/analyzation/make_observable.py
def make_dict_observable(matrix_observable): """Convert an observable in matrix form to dictionary form. Takes in a diagonal observable as a matrix and converts it to a dictionary form. Can also handle a list sorted of the diagonal elements. Args: matrix_observable (list): The observable to be...
def make_dict_observable(matrix_observable): """Convert an observable in matrix form to dictionary form. Takes in a diagonal observable as a matrix and converts it to a dictionary form. Can also handle a list sorted of the diagonal elements. Args: matrix_observable (list): The observable to be...
[ "Convert", "an", "observable", "in", "matrix", "form", "to", "dictionary", "form", "." ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/quantum_info/analyzation/make_observable.py#L13-L37
[ "def", "make_dict_observable", "(", "matrix_observable", ")", ":", "dict_observable", "=", "{", "}", "observable", "=", "np", ".", "array", "(", "matrix_observable", ")", "observable_size", "=", "len", "(", "observable", ")", "observable_bits", "=", "int", "(", ...
d4f58d903bc96341b816f7c35df936d6421267d1
test
QasmParser.update_symtab
Update a node in the symbol table. Everything in the symtab must be a node with these attributes: name - the string name of the object type - the string type of the object line - the source line where the type was first found file - the source file where the type was first found
qiskit/qasm/qasmparser.py
def update_symtab(self, obj): """Update a node in the symbol table. Everything in the symtab must be a node with these attributes: name - the string name of the object type - the string type of the object line - the source line where the type was first found file - the s...
def update_symtab(self, obj): """Update a node in the symbol table. Everything in the symtab must be a node with these attributes: name - the string name of the object type - the string type of the object line - the source line where the type was first found file - the s...
[ "Update", "a", "node", "in", "the", "symbol", "table", "." ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/qasm/qasmparser.py#L57-L73
[ "def", "update_symtab", "(", "self", ",", "obj", ")", ":", "if", "obj", ".", "name", "in", "self", ".", "current_symtab", ":", "prev", "=", "self", ".", "current_symtab", "[", "obj", ".", "name", "]", "raise", "QasmError", "(", "\"Duplicate declaration for...
d4f58d903bc96341b816f7c35df936d6421267d1
test
QasmParser.verify_declared_bit
Verify a qubit id against the gate prototype.
qiskit/qasm/qasmparser.py
def verify_declared_bit(self, obj): """Verify a qubit id against the gate prototype.""" # We are verifying gate args against the formal parameters of a # gate prototype. if obj.name not in self.current_symtab: raise QasmError("Cannot find symbol '" + obj.name ...
def verify_declared_bit(self, obj): """Verify a qubit id against the gate prototype.""" # We are verifying gate args against the formal parameters of a # gate prototype. if obj.name not in self.current_symtab: raise QasmError("Cannot find symbol '" + obj.name ...
[ "Verify", "a", "qubit", "id", "against", "the", "gate", "prototype", "." ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/qasm/qasmparser.py#L75-L89
[ "def", "verify_declared_bit", "(", "self", ",", "obj", ")", ":", "# We are verifying gate args against the formal parameters of a", "# gate prototype.", "if", "obj", ".", "name", "not", "in", "self", ".", "current_symtab", ":", "raise", "QasmError", "(", "\"Cannot find ...
d4f58d903bc96341b816f7c35df936d6421267d1
test
QasmParser.verify_exp_list
Verify each expression in a list.
qiskit/qasm/qasmparser.py
def verify_exp_list(self, obj): """Verify each expression in a list.""" # A tad harder. This is a list of expressions each of which could be # the head of a tree. We need to recursively walk each of these and # ensure that any Id elements resolve to the current stack. # ...
def verify_exp_list(self, obj): """Verify each expression in a list.""" # A tad harder. This is a list of expressions each of which could be # the head of a tree. We need to recursively walk each of these and # ensure that any Id elements resolve to the current stack. # ...
[ "Verify", "each", "expression", "in", "a", "list", "." ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/qasm/qasmparser.py#L99-L119
[ "def", "verify_exp_list", "(", "self", ",", "obj", ")", ":", "# A tad harder. This is a list of expressions each of which could be", "# the head of a tree. We need to recursively walk each of these and", "# ensure that any Id elements resolve to the current stack.", "#", "# I believe we onl...
d4f58d903bc96341b816f7c35df936d6421267d1
test
QasmParser.verify_as_gate
Verify a user defined gate call.
qiskit/qasm/qasmparser.py
def verify_as_gate(self, obj, bitlist, arglist=None): """Verify a user defined gate call.""" if obj.name not in self.global_symtab: raise QasmError("Cannot find gate definition for '" + obj.name + "', line", str(obj.line), 'file', obj.file) g_sym = self.gl...
def verify_as_gate(self, obj, bitlist, arglist=None): """Verify a user defined gate call.""" if obj.name not in self.global_symtab: raise QasmError("Cannot find gate definition for '" + obj.name + "', line", str(obj.line), 'file', obj.file) g_sym = self.gl...
[ "Verify", "a", "user", "defined", "gate", "call", "." ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/qasm/qasmparser.py#L121-L152
[ "def", "verify_as_gate", "(", "self", ",", "obj", ",", "bitlist", ",", "arglist", "=", "None", ")", ":", "if", "obj", ".", "name", "not", "in", "self", ".", "global_symtab", ":", "raise", "QasmError", "(", "\"Cannot find gate definition for '\"", "+", "obj",...
d4f58d903bc96341b816f7c35df936d6421267d1
test
QasmParser.verify_reg
Verify a register.
qiskit/qasm/qasmparser.py
def verify_reg(self, obj, object_type): """Verify a register.""" # How to verify: # types must match # indexes must be checked if obj.name not in self.global_symtab: raise QasmError('Cannot find definition for', object_type, "'" + obj...
def verify_reg(self, obj, object_type): """Verify a register.""" # How to verify: # types must match # indexes must be checked if obj.name not in self.global_symtab: raise QasmError('Cannot find definition for', object_type, "'" + obj...
[ "Verify", "a", "register", "." ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/qasm/qasmparser.py#L154-L179
[ "def", "verify_reg", "(", "self", ",", "obj", ",", "object_type", ")", ":", "# How to verify:", "# types must match", "# indexes must be checked", "if", "obj", ".", "name", "not", "in", "self", ".", "global_symtab", ":", "raise", "QasmError", "(", "'Cannot f...
d4f58d903bc96341b816f7c35df936d6421267d1
test
QasmParser.verify_reg_list
Verify a list of registers.
qiskit/qasm/qasmparser.py
def verify_reg_list(self, obj, object_type): """Verify a list of registers.""" # We expect the object to be a bitlist or an idlist, we don't care. # We will iterate it and ensure everything in it is declared as a bit, # and throw if not. for children in obj.children: ...
def verify_reg_list(self, obj, object_type): """Verify a list of registers.""" # We expect the object to be a bitlist or an idlist, we don't care. # We will iterate it and ensure everything in it is declared as a bit, # and throw if not. for children in obj.children: ...
[ "Verify", "a", "list", "of", "registers", "." ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/qasm/qasmparser.py#L181-L187
[ "def", "verify_reg_list", "(", "self", ",", "obj", ",", "object_type", ")", ":", "# We expect the object to be a bitlist or an idlist, we don't care.", "# We will iterate it and ensure everything in it is declared as a bit,", "# and throw if not.", "for", "children", "in", "obj", "...
d4f58d903bc96341b816f7c35df936d6421267d1
test
QasmParser.id_tuple_list
Return a list of (name, index) tuples for this id node.
qiskit/qasm/qasmparser.py
def id_tuple_list(self, id_node): """Return a list of (name, index) tuples for this id node.""" if id_node.type != "id": raise QasmError("internal error, id_tuple_list") bit_list = [] try: g_sym = self.current_symtab[id_node.name] except KeyError: ...
def id_tuple_list(self, id_node): """Return a list of (name, index) tuples for this id node.""" if id_node.type != "id": raise QasmError("internal error, id_tuple_list") bit_list = [] try: g_sym = self.current_symtab[id_node.name] except KeyError: ...
[ "Return", "a", "list", "of", "(", "name", "index", ")", "tuples", "for", "this", "id", "node", "." ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/qasm/qasmparser.py#L189-L205
[ "def", "id_tuple_list", "(", "self", ",", "id_node", ")", ":", "if", "id_node", ".", "type", "!=", "\"id\"", ":", "raise", "QasmError", "(", "\"internal error, id_tuple_list\"", ")", "bit_list", "=", "[", "]", "try", ":", "g_sym", "=", "self", ".", "curren...
d4f58d903bc96341b816f7c35df936d6421267d1
test
QasmParser.verify_distinct
Check that objects in list_of_nodes represent distinct (qu)bits. list_of_nodes is a list containing nodes of type id, indexed_id, primary_list, or id_list. We assume these are all the same type 'qreg' or 'creg'. This method raises an exception if list_of_nodes refers to the same...
qiskit/qasm/qasmparser.py
def verify_distinct(self, list_of_nodes): """Check that objects in list_of_nodes represent distinct (qu)bits. list_of_nodes is a list containing nodes of type id, indexed_id, primary_list, or id_list. We assume these are all the same type 'qreg' or 'creg'. This method raises an ...
def verify_distinct(self, list_of_nodes): """Check that objects in list_of_nodes represent distinct (qu)bits. list_of_nodes is a list containing nodes of type id, indexed_id, primary_list, or id_list. We assume these are all the same type 'qreg' or 'creg'. This method raises an ...
[ "Check", "that", "objects", "in", "list_of_nodes", "represent", "distinct", "(", "qu", ")", "bits", "." ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/qasm/qasmparser.py#L207-L249
[ "def", "verify_distinct", "(", "self", ",", "list_of_nodes", ")", ":", "bit_list", "=", "[", "]", "line_number", "=", "-", "1", "filename", "=", "\"\"", "for", "node_", "in", "list_of_nodes", ":", "# id node: add all bits in register or (name, -1) for id", "if", "...
d4f58d903bc96341b816f7c35df936d6421267d1
test
QasmParser.p_statement
statement : decl | quantum_op ';' | format ';' | ignore | quantum_op error | format error
qiskit/qasm/qasmparser.py
def p_statement(self, program): """ statement : decl | quantum_op ';' | format ';' | ignore | quantum_op error | format error """ if len(program) > 2: if program[2] != ...
def p_statement(self, program): """ statement : decl | quantum_op ';' | format ';' | ignore | quantum_op error | format error """ if len(program) > 2: if program[2] != ...
[ "statement", ":", "decl", "|", "quantum_op", ";", "|", "format", ";", "|", "ignore", "|", "quantum_op", "error", "|", "format", "error" ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/qasm/qasmparser.py#L291-L304
[ "def", "p_statement", "(", "self", ",", "program", ")", ":", "if", "len", "(", "program", ")", ">", "2", ":", "if", "program", "[", "2", "]", "!=", "';'", ":", "raise", "QasmError", "(", "\"Missing ';' at end of statement; \"", "+", "\"received\"", ",", ...
d4f58d903bc96341b816f7c35df936d6421267d1
test
QasmParser.p_indexed_id
indexed_id : id '[' NNINTEGER ']' | id '[' NNINTEGER error | id '[' error
qiskit/qasm/qasmparser.py
def p_indexed_id(self, program): """ indexed_id : id '[' NNINTEGER ']' | id '[' NNINTEGER error | id '[' error """ if len(program) == 4: raise QasmError("Expecting an integer index; received", str(prog...
def p_indexed_id(self, program): """ indexed_id : id '[' NNINTEGER ']' | id '[' NNINTEGER error | id '[' error """ if len(program) == 4: raise QasmError("Expecting an integer index; received", str(prog...
[ "indexed_id", ":", "id", "[", "NNINTEGER", "]", "|", "id", "[", "NNINTEGER", "error", "|", "id", "[", "error" ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/qasm/qasmparser.py#L339-L351
[ "def", "p_indexed_id", "(", "self", ",", "program", ")", ":", "if", "len", "(", "program", ")", "==", "4", ":", "raise", "QasmError", "(", "\"Expecting an integer index; received\"", ",", "str", "(", "program", "[", "3", "]", ".", "value", ")", ")", "if"...
d4f58d903bc96341b816f7c35df936d6421267d1
test
QasmParser.p_gate_id_list_0
gate_id_list : id
qiskit/qasm/qasmparser.py
def p_gate_id_list_0(self, program): """ gate_id_list : id """ program[0] = node.IdList([program[1]]) self.update_symtab(program[1])
def p_gate_id_list_0(self, program): """ gate_id_list : id """ program[0] = node.IdList([program[1]]) self.update_symtab(program[1])
[ "gate_id_list", ":", "id" ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/qasm/qasmparser.py#L385-L390
[ "def", "p_gate_id_list_0", "(", "self", ",", "program", ")", ":", "program", "[", "0", "]", "=", "node", ".", "IdList", "(", "[", "program", "[", "1", "]", "]", ")", "self", ".", "update_symtab", "(", "program", "[", "1", "]", ")" ]
d4f58d903bc96341b816f7c35df936d6421267d1
test
QasmParser.p_gate_id_list_1
gate_id_list : gate_id_list ',' id
qiskit/qasm/qasmparser.py
def p_gate_id_list_1(self, program): """ gate_id_list : gate_id_list ',' id """ program[0] = program[1] program[0].add_child(program[3]) self.update_symtab(program[3])
def p_gate_id_list_1(self, program): """ gate_id_list : gate_id_list ',' id """ program[0] = program[1] program[0].add_child(program[3]) self.update_symtab(program[3])
[ "gate_id_list", ":", "gate_id_list", "id" ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/qasm/qasmparser.py#L392-L398
[ "def", "p_gate_id_list_1", "(", "self", ",", "program", ")", ":", "program", "[", "0", "]", "=", "program", "[", "1", "]", "program", "[", "0", "]", ".", "add_child", "(", "program", "[", "3", "]", ")", "self", ".", "update_symtab", "(", "program", ...
d4f58d903bc96341b816f7c35df936d6421267d1
test
QasmParser.p_bit_list_0
bit_list : id
qiskit/qasm/qasmparser.py
def p_bit_list_0(self, program): """ bit_list : id """ program[0] = node.IdList([program[1]]) program[1].is_bit = True self.update_symtab(program[1])
def p_bit_list_0(self, program): """ bit_list : id """ program[0] = node.IdList([program[1]]) program[1].is_bit = True self.update_symtab(program[1])
[ "bit_list", ":", "id" ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/qasm/qasmparser.py#L404-L410
[ "def", "p_bit_list_0", "(", "self", ",", "program", ")", ":", "program", "[", "0", "]", "=", "node", ".", "IdList", "(", "[", "program", "[", "1", "]", "]", ")", "program", "[", "1", "]", ".", "is_bit", "=", "True", "self", ".", "update_symtab", ...
d4f58d903bc96341b816f7c35df936d6421267d1
test
QasmParser.p_bit_list_1
bit_list : bit_list ',' id
qiskit/qasm/qasmparser.py
def p_bit_list_1(self, program): """ bit_list : bit_list ',' id """ program[0] = program[1] program[0].add_child(program[3]) program[3].is_bit = True self.update_symtab(program[3])
def p_bit_list_1(self, program): """ bit_list : bit_list ',' id """ program[0] = program[1] program[0].add_child(program[3]) program[3].is_bit = True self.update_symtab(program[3])
[ "bit_list", ":", "bit_list", "id" ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/qasm/qasmparser.py#L412-L419
[ "def", "p_bit_list_1", "(", "self", ",", "program", ")", ":", "program", "[", "0", "]", "=", "program", "[", "1", "]", "program", "[", "0", "]", ".", "add_child", "(", "program", "[", "3", "]", ")", "program", "[", "3", "]", ".", "is_bit", "=", ...
d4f58d903bc96341b816f7c35df936d6421267d1
test
QasmParser.p_decl
decl : qreg_decl ';' | creg_decl ';' | qreg_decl error | creg_decl error | gate_decl
qiskit/qasm/qasmparser.py
def p_decl(self, program): """ decl : qreg_decl ';' | creg_decl ';' | qreg_decl error | creg_decl error | gate_decl """ if len(program) > 2: if program[2] != ';': raise QasmError("Missing ';' i...
def p_decl(self, program): """ decl : qreg_decl ';' | creg_decl ';' | qreg_decl error | creg_decl error | gate_decl """ if len(program) > 2: if program[2] != ';': raise QasmError("Missing ';' i...
[ "decl", ":", "qreg_decl", ";", "|", "creg_decl", ";", "|", "qreg_decl", "error", "|", "creg_decl", "error", "|", "gate_decl" ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/qasm/qasmparser.py#L443-L455
[ "def", "p_decl", "(", "self", ",", "program", ")", ":", "if", "len", "(", "program", ")", ">", "2", ":", "if", "program", "[", "2", "]", "!=", "';'", ":", "raise", "QasmError", "(", "\"Missing ';' in qreg or creg declaration.\"", "\" Instead received '\"", "...
d4f58d903bc96341b816f7c35df936d6421267d1
test
QasmParser.p_qreg_decl
qreg_decl : QREG indexed_id
qiskit/qasm/qasmparser.py
def p_qreg_decl(self, program): """ qreg_decl : QREG indexed_id """ program[0] = node.Qreg([program[2]]) if program[2].name in self.external_functions: raise QasmError("QREG names cannot be reserved words. " + "Received '" + program[2].n...
def p_qreg_decl(self, program): """ qreg_decl : QREG indexed_id """ program[0] = node.Qreg([program[2]]) if program[2].name in self.external_functions: raise QasmError("QREG names cannot be reserved words. " + "Received '" + program[2].n...
[ "qreg_decl", ":", "QREG", "indexed_id" ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/qasm/qasmparser.py#L460-L470
[ "def", "p_qreg_decl", "(", "self", ",", "program", ")", ":", "program", "[", "0", "]", "=", "node", ".", "Qreg", "(", "[", "program", "[", "2", "]", "]", ")", "if", "program", "[", "2", "]", ".", "name", "in", "self", ".", "external_functions", "...
d4f58d903bc96341b816f7c35df936d6421267d1
test
QasmParser.p_creg_decl
creg_decl : CREG indexed_id
qiskit/qasm/qasmparser.py
def p_creg_decl(self, program): """ creg_decl : CREG indexed_id """ program[0] = node.Creg([program[2]]) if program[2].name in self.external_functions: raise QasmError("CREG names cannot be reserved words. " + "Received '" + program[2].n...
def p_creg_decl(self, program): """ creg_decl : CREG indexed_id """ program[0] = node.Creg([program[2]]) if program[2].name in self.external_functions: raise QasmError("CREG names cannot be reserved words. " + "Received '" + program[2].n...
[ "creg_decl", ":", "CREG", "indexed_id" ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/qasm/qasmparser.py#L482-L492
[ "def", "p_creg_decl", "(", "self", ",", "program", ")", ":", "program", "[", "0", "]", "=", "node", ".", "Creg", "(", "[", "program", "[", "2", "]", "]", ")", "if", "program", "[", "2", "]", ".", "name", "in", "self", ".", "external_functions", "...
d4f58d903bc96341b816f7c35df936d6421267d1
test
QasmParser.p_gate_decl_1
gate_decl : GATE id gate_scope '(' ')' bit_list gate_body
qiskit/qasm/qasmparser.py
def p_gate_decl_1(self, program): """ gate_decl : GATE id gate_scope '(' ')' bit_list gate_body """ program[0] = node.Gate([program[2], program[6], program[7]]) if program[2].name in self.external_functions: raise QasmError("GATE names cannot be reserved words. " ...
def p_gate_decl_1(self, program): """ gate_decl : GATE id gate_scope '(' ')' bit_list gate_body """ program[0] = node.Gate([program[2], program[6], program[7]]) if program[2].name in self.external_functions: raise QasmError("GATE names cannot be reserved words. " ...
[ "gate_decl", ":", "GATE", "id", "gate_scope", "(", ")", "bit_list", "gate_body" ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/qasm/qasmparser.py#L522-L531
[ "def", "p_gate_decl_1", "(", "self", ",", "program", ")", ":", "program", "[", "0", "]", "=", "node", ".", "Gate", "(", "[", "program", "[", "2", "]", ",", "program", "[", "6", "]", ",", "program", "[", "7", "]", "]", ")", "if", "program", "[",...
d4f58d903bc96341b816f7c35df936d6421267d1
test
QasmParser.p_gate_body_0
gate_body : '{' '}'
qiskit/qasm/qasmparser.py
def p_gate_body_0(self, program): """ gate_body : '{' '}' """ if program[2] != '}': raise QasmError("Missing '}' in gate definition; received'" + str(program[2].value) + "'") program[0] = node.GateBody(None)
def p_gate_body_0(self, program): """ gate_body : '{' '}' """ if program[2] != '}': raise QasmError("Missing '}' in gate definition; received'" + str(program[2].value) + "'") program[0] = node.GateBody(None)
[ "gate_body", ":", "{", "}" ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/qasm/qasmparser.py#L561-L568
[ "def", "p_gate_body_0", "(", "self", ",", "program", ")", ":", "if", "program", "[", "2", "]", "!=", "'}'", ":", "raise", "QasmError", "(", "\"Missing '}' in gate definition; received'\"", "+", "str", "(", "program", "[", "2", "]", ".", "value", ")", "+", ...
d4f58d903bc96341b816f7c35df936d6421267d1
test
QasmParser.p_unitary_op_0
unitary_op : U '(' exp_list ')' primary
qiskit/qasm/qasmparser.py
def p_unitary_op_0(self, program): """ unitary_op : U '(' exp_list ')' primary """ program[0] = node.UniversalUnitary([program[3], program[5]]) self.verify_reg(program[5], 'qreg') self.verify_exp_list(program[3])
def p_unitary_op_0(self, program): """ unitary_op : U '(' exp_list ')' primary """ program[0] = node.UniversalUnitary([program[3], program[5]]) self.verify_reg(program[5], 'qreg') self.verify_exp_list(program[3])
[ "unitary_op", ":", "U", "(", "exp_list", ")", "primary" ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/qasm/qasmparser.py#L609-L615
[ "def", "p_unitary_op_0", "(", "self", ",", "program", ")", ":", "program", "[", "0", "]", "=", "node", ".", "UniversalUnitary", "(", "[", "program", "[", "3", "]", ",", "program", "[", "5", "]", "]", ")", "self", ".", "verify_reg", "(", "program", ...
d4f58d903bc96341b816f7c35df936d6421267d1
test
QasmParser.p_unitary_op_1
unitary_op : CX primary ',' primary
qiskit/qasm/qasmparser.py
def p_unitary_op_1(self, program): """ unitary_op : CX primary ',' primary """ program[0] = node.Cnot([program[2], program[4]]) self.verify_reg(program[2], 'qreg') self.verify_reg(program[4], 'qreg') self.verify_distinct([program[2], program[4]])
def p_unitary_op_1(self, program): """ unitary_op : CX primary ',' primary """ program[0] = node.Cnot([program[2], program[4]]) self.verify_reg(program[2], 'qreg') self.verify_reg(program[4], 'qreg') self.verify_distinct([program[2], program[4]])
[ "unitary_op", ":", "CX", "primary", "primary" ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/qasm/qasmparser.py#L617-L624
[ "def", "p_unitary_op_1", "(", "self", ",", "program", ")", ":", "program", "[", "0", "]", "=", "node", ".", "Cnot", "(", "[", "program", "[", "2", "]", ",", "program", "[", "4", "]", "]", ")", "self", ".", "verify_reg", "(", "program", "[", "2", ...
d4f58d903bc96341b816f7c35df936d6421267d1
test
QasmParser.p_unitary_op_2
unitary_op : id primary_list
qiskit/qasm/qasmparser.py
def p_unitary_op_2(self, program): """ unitary_op : id primary_list """ program[0] = node.CustomUnitary([program[1], program[2]]) self.verify_as_gate(program[1], program[2]) self.verify_reg_list(program[2], 'qreg') self.verify_distinct([program[2]])
def p_unitary_op_2(self, program): """ unitary_op : id primary_list """ program[0] = node.CustomUnitary([program[1], program[2]]) self.verify_as_gate(program[1], program[2]) self.verify_reg_list(program[2], 'qreg') self.verify_distinct([program[2]])
[ "unitary_op", ":", "id", "primary_list" ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/qasm/qasmparser.py#L628-L635
[ "def", "p_unitary_op_2", "(", "self", ",", "program", ")", ":", "program", "[", "0", "]", "=", "node", ".", "CustomUnitary", "(", "[", "program", "[", "1", "]", ",", "program", "[", "2", "]", "]", ")", "self", ".", "verify_as_gate", "(", "program", ...
d4f58d903bc96341b816f7c35df936d6421267d1
test
QasmParser.p_unitary_op_3
unitary_op : id '(' ')' primary_list
qiskit/qasm/qasmparser.py
def p_unitary_op_3(self, program): """ unitary_op : id '(' ')' primary_list """ program[0] = node.CustomUnitary([program[1], program[4]]) self.verify_as_gate(program[1], program[4]) self.verify_reg_list(program[4], 'qreg') self.verify_distinct([program[4]])
def p_unitary_op_3(self, program): """ unitary_op : id '(' ')' primary_list """ program[0] = node.CustomUnitary([program[1], program[4]]) self.verify_as_gate(program[1], program[4]) self.verify_reg_list(program[4], 'qreg') self.verify_distinct([program[4]])
[ "unitary_op", ":", "id", "(", ")", "primary_list" ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/qasm/qasmparser.py#L637-L644
[ "def", "p_unitary_op_3", "(", "self", ",", "program", ")", ":", "program", "[", "0", "]", "=", "node", ".", "CustomUnitary", "(", "[", "program", "[", "1", "]", ",", "program", "[", "4", "]", "]", ")", "self", ".", "verify_as_gate", "(", "program", ...
d4f58d903bc96341b816f7c35df936d6421267d1
test
QasmParser.p_unitary_op_4
unitary_op : id '(' exp_list ')' primary_list
qiskit/qasm/qasmparser.py
def p_unitary_op_4(self, program): """ unitary_op : id '(' exp_list ')' primary_list """ program[0] = node.CustomUnitary([program[1], program[3], program[5]]) self.verify_as_gate(program[1], program[5], arglist=program[3]) self.verify_reg_list(program[5], 'qreg') ...
def p_unitary_op_4(self, program): """ unitary_op : id '(' exp_list ')' primary_list """ program[0] = node.CustomUnitary([program[1], program[3], program[5]]) self.verify_as_gate(program[1], program[5], arglist=program[3]) self.verify_reg_list(program[5], 'qreg') ...
[ "unitary_op", ":", "id", "(", "exp_list", ")", "primary_list" ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/qasm/qasmparser.py#L646-L654
[ "def", "p_unitary_op_4", "(", "self", ",", "program", ")", ":", "program", "[", "0", "]", "=", "node", ".", "CustomUnitary", "(", "[", "program", "[", "1", "]", ",", "program", "[", "3", "]", ",", "program", "[", "5", "]", "]", ")", "self", ".", ...
d4f58d903bc96341b816f7c35df936d6421267d1
test
QasmParser.p_gate_op_0
gate_op : U '(' exp_list ')' id ';'
qiskit/qasm/qasmparser.py
def p_gate_op_0(self, program): """ gate_op : U '(' exp_list ')' id ';' """ program[0] = node.UniversalUnitary([program[3], program[5]]) self.verify_declared_bit(program[5]) self.verify_exp_list(program[3])
def p_gate_op_0(self, program): """ gate_op : U '(' exp_list ')' id ';' """ program[0] = node.UniversalUnitary([program[3], program[5]]) self.verify_declared_bit(program[5]) self.verify_exp_list(program[3])
[ "gate_op", ":", "U", "(", "exp_list", ")", "id", ";" ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/qasm/qasmparser.py#L667-L673
[ "def", "p_gate_op_0", "(", "self", ",", "program", ")", ":", "program", "[", "0", "]", "=", "node", ".", "UniversalUnitary", "(", "[", "program", "[", "3", "]", ",", "program", "[", "5", "]", "]", ")", "self", ".", "verify_declared_bit", "(", "progra...
d4f58d903bc96341b816f7c35df936d6421267d1
test
QasmParser.p_gate_op_1
gate_op : CX id ',' id ';'
qiskit/qasm/qasmparser.py
def p_gate_op_1(self, program): """ gate_op : CX id ',' id ';' """ program[0] = node.Cnot([program[2], program[4]]) self.verify_declared_bit(program[2]) self.verify_declared_bit(program[4]) self.verify_distinct([program[2], program[4]])
def p_gate_op_1(self, program): """ gate_op : CX id ',' id ';' """ program[0] = node.Cnot([program[2], program[4]]) self.verify_declared_bit(program[2]) self.verify_declared_bit(program[4]) self.verify_distinct([program[2], program[4]])
[ "gate_op", ":", "CX", "id", "id", ";" ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/qasm/qasmparser.py#L688-L695
[ "def", "p_gate_op_1", "(", "self", ",", "program", ")", ":", "program", "[", "0", "]", "=", "node", ".", "Cnot", "(", "[", "program", "[", "2", "]", ",", "program", "[", "4", "]", "]", ")", "self", ".", "verify_declared_bit", "(", "program", "[", ...
d4f58d903bc96341b816f7c35df936d6421267d1
test
QasmParser.p_gate_op_2
gate_op : id id_list ';'
qiskit/qasm/qasmparser.py
def p_gate_op_2(self, program): """ gate_op : id id_list ';' """ program[0] = node.CustomUnitary([program[1], program[2]]) # To verify: # 1. id is declared as a gate in global scope # 2. everything in the id_list is declared as a bit in local scope self.ve...
def p_gate_op_2(self, program): """ gate_op : id id_list ';' """ program[0] = node.CustomUnitary([program[1], program[2]]) # To verify: # 1. id is declared as a gate in global scope # 2. everything in the id_list is declared as a bit in local scope self.ve...
[ "gate_op", ":", "id", "id_list", ";" ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/qasm/qasmparser.py#L713-L723
[ "def", "p_gate_op_2", "(", "self", ",", "program", ")", ":", "program", "[", "0", "]", "=", "node", ".", "CustomUnitary", "(", "[", "program", "[", "1", "]", ",", "program", "[", "2", "]", "]", ")", "# To verify:", "# 1. id is declared as a gate in global ...
d4f58d903bc96341b816f7c35df936d6421267d1
test
QasmParser.p_gate_op_3
gate_op : id '(' ')' id_list ';'
qiskit/qasm/qasmparser.py
def p_gate_op_3(self, program): """ gate_op : id '(' ')' id_list ';' """ program[0] = node.CustomUnitary([program[1], program[4]]) self.verify_as_gate(program[1], program[4]) self.verify_bit_list(program[4]) self.verify_distinct([program[4]])
def p_gate_op_3(self, program): """ gate_op : id '(' ')' id_list ';' """ program[0] = node.CustomUnitary([program[1], program[4]]) self.verify_as_gate(program[1], program[4]) self.verify_bit_list(program[4]) self.verify_distinct([program[4]])
[ "gate_op", ":", "id", "(", ")", "id_list", ";" ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/qasm/qasmparser.py#L731-L738
[ "def", "p_gate_op_3", "(", "self", ",", "program", ")", ":", "program", "[", "0", "]", "=", "node", ".", "CustomUnitary", "(", "[", "program", "[", "1", "]", ",", "program", "[", "4", "]", "]", ")", "self", ".", "verify_as_gate", "(", "program", "[...
d4f58d903bc96341b816f7c35df936d6421267d1
test
QasmParser.p_gate_op_4
gate_op : id '(' exp_list ')' id_list ';'
qiskit/qasm/qasmparser.py
def p_gate_op_4(self, program): """ gate_op : id '(' exp_list ')' id_list ';' """ program[0] = node.CustomUnitary([program[1], program[3], program[5]]) self.verify_as_gate(program[1], program[5], arglist=program[3]) self.verify_bit_list(program[5]) self.verify_exp...
def p_gate_op_4(self, program): """ gate_op : id '(' exp_list ')' id_list ';' """ program[0] = node.CustomUnitary([program[1], program[3], program[5]]) self.verify_as_gate(program[1], program[5], arglist=program[3]) self.verify_bit_list(program[5]) self.verify_exp...
[ "gate_op", ":", "id", "(", "exp_list", ")", "id_list", ";" ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/qasm/qasmparser.py#L740-L748
[ "def", "p_gate_op_4", "(", "self", ",", "program", ")", ":", "program", "[", "0", "]", "=", "node", ".", "CustomUnitary", "(", "[", "program", "[", "1", "]", ",", "program", "[", "3", "]", ",", "program", "[", "5", "]", "]", ")", "self", ".", "...
d4f58d903bc96341b816f7c35df936d6421267d1
test
QasmParser.p_gate_op_5
gate_op : BARRIER id_list ';'
qiskit/qasm/qasmparser.py
def p_gate_op_5(self, program): """ gate_op : BARRIER id_list ';' """ program[0] = node.Barrier([program[2]]) self.verify_bit_list(program[2]) self.verify_distinct([program[2]])
def p_gate_op_5(self, program): """ gate_op : BARRIER id_list ';' """ program[0] = node.Barrier([program[2]]) self.verify_bit_list(program[2]) self.verify_distinct([program[2]])
[ "gate_op", ":", "BARRIER", "id_list", ";" ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/qasm/qasmparser.py#L764-L770
[ "def", "p_gate_op_5", "(", "self", ",", "program", ")", ":", "program", "[", "0", "]", "=", "node", ".", "Barrier", "(", "[", "program", "[", "2", "]", "]", ")", "self", ".", "verify_bit_list", "(", "program", "[", "2", "]", ")", "self", ".", "ve...
d4f58d903bc96341b816f7c35df936d6421267d1
test
QasmParser.p_opaque_0
opaque : OPAQUE id gate_scope bit_list
qiskit/qasm/qasmparser.py
def p_opaque_0(self, program): """ opaque : OPAQUE id gate_scope bit_list """ # TODO: Review Opaque function program[0] = node.Opaque([program[2], program[4]]) if program[2].name in self.external_functions: raise QasmError("OPAQUE names cannot be reserved w...
def p_opaque_0(self, program): """ opaque : OPAQUE id gate_scope bit_list """ # TODO: Review Opaque function program[0] = node.Opaque([program[2], program[4]]) if program[2].name in self.external_functions: raise QasmError("OPAQUE names cannot be reserved w...
[ "opaque", ":", "OPAQUE", "id", "gate_scope", "bit_list" ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/qasm/qasmparser.py#L785-L795
[ "def", "p_opaque_0", "(", "self", ",", "program", ")", ":", "# TODO: Review Opaque function", "program", "[", "0", "]", "=", "node", ".", "Opaque", "(", "[", "program", "[", "2", "]", ",", "program", "[", "4", "]", "]", ")", "if", "program", "[", "2"...
d4f58d903bc96341b816f7c35df936d6421267d1
test
QasmParser.p_opaque_1
opaque : OPAQUE id gate_scope '(' ')' bit_list
qiskit/qasm/qasmparser.py
def p_opaque_1(self, program): """ opaque : OPAQUE id gate_scope '(' ')' bit_list """ program[0] = node.Opaque([program[2], program[6]]) self.pop_scope() self.update_symtab(program[0])
def p_opaque_1(self, program): """ opaque : OPAQUE id gate_scope '(' ')' bit_list """ program[0] = node.Opaque([program[2], program[6]]) self.pop_scope() self.update_symtab(program[0])
[ "opaque", ":", "OPAQUE", "id", "gate_scope", "(", ")", "bit_list" ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/qasm/qasmparser.py#L797-L803
[ "def", "p_opaque_1", "(", "self", ",", "program", ")", ":", "program", "[", "0", "]", "=", "node", ".", "Opaque", "(", "[", "program", "[", "2", "]", ",", "program", "[", "6", "]", "]", ")", "self", ".", "pop_scope", "(", ")", "self", ".", "upd...
d4f58d903bc96341b816f7c35df936d6421267d1
test
QasmParser.p_measure
measure : MEASURE primary ASSIGN primary
qiskit/qasm/qasmparser.py
def p_measure(self, program): """ measure : MEASURE primary ASSIGN primary """ program[0] = node.Measure([program[2], program[4]]) self.verify_reg(program[2], 'qreg') self.verify_reg(program[4], 'creg')
def p_measure(self, program): """ measure : MEASURE primary ASSIGN primary """ program[0] = node.Measure([program[2], program[4]]) self.verify_reg(program[2], 'qreg') self.verify_reg(program[4], 'creg')
[ "measure", ":", "MEASURE", "primary", "ASSIGN", "primary" ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/qasm/qasmparser.py#L825-L831
[ "def", "p_measure", "(", "self", ",", "program", ")", ":", "program", "[", "0", "]", "=", "node", ".", "Measure", "(", "[", "program", "[", "2", "]", ",", "program", "[", "4", "]", "]", ")", "self", ".", "verify_reg", "(", "program", "[", "2", ...
d4f58d903bc96341b816f7c35df936d6421267d1
test
QasmParser.p_barrier
barrier : BARRIER primary_list
qiskit/qasm/qasmparser.py
def p_barrier(self, program): """ barrier : BARRIER primary_list """ program[0] = node.Barrier([program[2]]) self.verify_reg_list(program[2], 'qreg') self.verify_distinct([program[2]])
def p_barrier(self, program): """ barrier : BARRIER primary_list """ program[0] = node.Barrier([program[2]]) self.verify_reg_list(program[2], 'qreg') self.verify_distinct([program[2]])
[ "barrier", ":", "BARRIER", "primary_list" ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/qasm/qasmparser.py#L845-L851
[ "def", "p_barrier", "(", "self", ",", "program", ")", ":", "program", "[", "0", "]", "=", "node", ".", "Barrier", "(", "[", "program", "[", "2", "]", "]", ")", "self", ".", "verify_reg_list", "(", "program", "[", "2", "]", ",", "'qreg'", ")", "se...
d4f58d903bc96341b816f7c35df936d6421267d1
test
QasmParser.p_reset
reset : RESET primary
qiskit/qasm/qasmparser.py
def p_reset(self, program): """ reset : RESET primary """ program[0] = node.Reset([program[2]]) self.verify_reg(program[2], 'qreg')
def p_reset(self, program): """ reset : RESET primary """ program[0] = node.Reset([program[2]]) self.verify_reg(program[2], 'qreg')
[ "reset", ":", "RESET", "primary" ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/qasm/qasmparser.py#L856-L861
[ "def", "p_reset", "(", "self", ",", "program", ")", ":", "program", "[", "0", "]", "=", "node", ".", "Reset", "(", "[", "program", "[", "2", "]", "]", ")", "self", ".", "verify_reg", "(", "program", "[", "2", "]", ",", "'qreg'", ")" ]
d4f58d903bc96341b816f7c35df936d6421267d1
test
QasmParser.p_if
if : IF '(' id MATCHES NNINTEGER ')' quantum_op if : IF '(' id error if : IF '(' id MATCHES error if : IF '(' id MATCHES NNINTEGER error if : IF error
qiskit/qasm/qasmparser.py
def p_if(self, program): """ if : IF '(' id MATCHES NNINTEGER ')' quantum_op if : IF '(' id error if : IF '(' id MATCHES error if : IF '(' id MATCHES NNINTEGER error if : IF error """ if len(program) == 3: raise QasmError("Ill-formed IF stateme...
def p_if(self, program): """ if : IF '(' id MATCHES NNINTEGER ')' quantum_op if : IF '(' id error if : IF '(' id MATCHES error if : IF '(' id MATCHES NNINTEGER error if : IF error """ if len(program) == 3: raise QasmError("Ill-formed IF stateme...
[ "if", ":", "IF", "(", "id", "MATCHES", "NNINTEGER", ")", "quantum_op", "if", ":", "IF", "(", "id", "error", "if", ":", "IF", "(", "id", "MATCHES", "error", "if", ":", "IF", "(", "id", "MATCHES", "NNINTEGER", "error", "if", ":", "IF", "error" ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/qasm/qasmparser.py#L866-L891
[ "def", "p_if", "(", "self", ",", "program", ")", ":", "if", "len", "(", "program", ")", "==", "3", ":", "raise", "QasmError", "(", "\"Ill-formed IF statement. Perhaps a\"", "+", "\" missing '('?\"", ")", "if", "len", "(", "program", ")", "==", "5", ":", ...
d4f58d903bc96341b816f7c35df936d6421267d1
test
QasmParser.p_unary_6
unary : id '(' expression ')'
qiskit/qasm/qasmparser.py
def p_unary_6(self, program): """ unary : id '(' expression ')' """ # note this is a semantic check, not syntactic if program[1].name not in self.external_functions: raise QasmError("Illegal external function call: ", str(program[1].name...
def p_unary_6(self, program): """ unary : id '(' expression ')' """ # note this is a semantic check, not syntactic if program[1].name not in self.external_functions: raise QasmError("Illegal external function call: ", str(program[1].name...
[ "unary", ":", "id", "(", "expression", ")" ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/qasm/qasmparser.py#L954-L962
[ "def", "p_unary_6", "(", "self", ",", "program", ")", ":", "# note this is a semantic check, not syntactic", "if", "program", "[", "1", "]", ".", "name", "not", "in", "self", ".", "external_functions", ":", "raise", "QasmError", "(", "\"Illegal external function cal...
d4f58d903bc96341b816f7c35df936d6421267d1
test
QasmParser.p_expression_1
expression : '-' expression %prec negative | '+' expression %prec positive
qiskit/qasm/qasmparser.py
def p_expression_1(self, program): """ expression : '-' expression %prec negative | '+' expression %prec positive """ program[0] = node.Prefix([node.UnaryOperator(program[1]), program[2]])
def p_expression_1(self, program): """ expression : '-' expression %prec negative | '+' expression %prec positive """ program[0] = node.Prefix([node.UnaryOperator(program[1]), program[2]])
[ "expression", ":", "-", "expression", "%prec", "negative", "|", "+", "expression", "%prec", "positive" ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/qasm/qasmparser.py#L968-L973
[ "def", "p_expression_1", "(", "self", ",", "program", ")", ":", "program", "[", "0", "]", "=", "node", ".", "Prefix", "(", "[", "node", ".", "UnaryOperator", "(", "program", "[", "1", "]", ")", ",", "program", "[", "2", "]", "]", ")" ]
d4f58d903bc96341b816f7c35df936d6421267d1
test
QasmParser.p_expression_0
expression : expression '*' expression | expression '/' expression | expression '+' expression | expression '-' expression | expression '^' expression
qiskit/qasm/qasmparser.py
def p_expression_0(self, program): """ expression : expression '*' expression | expression '/' expression | expression '+' expression | expression '-' expression | expression '^' expression """ program[0] = n...
def p_expression_0(self, program): """ expression : expression '*' expression | expression '/' expression | expression '+' expression | expression '-' expression | expression '^' expression """ program[0] = n...
[ "expression", ":", "expression", "*", "expression", "|", "expression", "/", "expression", "|", "expression", "+", "expression", "|", "expression", "-", "expression", "|", "expression", "^", "expression" ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/qasm/qasmparser.py#L975-L984
[ "def", "p_expression_0", "(", "self", ",", "program", ")", ":", "program", "[", "0", "]", "=", "node", ".", "BinaryOp", "(", "[", "node", ".", "BinaryOperator", "(", "program", "[", "2", "]", ")", ",", "program", "[", "1", "]", ",", "program", "[",...
d4f58d903bc96341b816f7c35df936d6421267d1
test
QasmParser.find_column
Compute the column. Input is the input text string. token is a token instance.
qiskit/qasm/qasmparser.py
def find_column(self, input_, token): """Compute the column. Input is the input text string. token is a token instance. """ if token is None: return 0 last_cr = input_.rfind('\n', 0, token.lexpos) if last_cr < 0: last_cr = 0 column...
def find_column(self, input_, token): """Compute the column. Input is the input text string. token is a token instance. """ if token is None: return 0 last_cr = input_.rfind('\n', 0, token.lexpos) if last_cr < 0: last_cr = 0 column...
[ "Compute", "the", "column", "." ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/qasm/qasmparser.py#L1026-L1038
[ "def", "find_column", "(", "self", ",", "input_", ",", "token", ")", ":", "if", "token", "is", "None", ":", "return", "0", "last_cr", "=", "input_", ".", "rfind", "(", "'\\n'", ",", "0", ",", "token", ".", "lexpos", ")", "if", "last_cr", "<", "0", ...
d4f58d903bc96341b816f7c35df936d6421267d1
test
QasmParser.get_tokens
Returns a generator of the tokens.
qiskit/qasm/qasmparser.py
def get_tokens(self): """Returns a generator of the tokens.""" try: while True: token = self.lexer.token() if not token: break yield token except QasmError as e: print('Exception tokenizing qasm file:',...
def get_tokens(self): """Returns a generator of the tokens.""" try: while True: token = self.lexer.token() if not token: break yield token except QasmError as e: print('Exception tokenizing qasm file:',...
[ "Returns", "a", "generator", "of", "the", "tokens", "." ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/qasm/qasmparser.py#L1040-L1051
[ "def", "get_tokens", "(", "self", ")", ":", "try", ":", "while", "True", ":", "token", "=", "self", ".", "lexer", ".", "token", "(", ")", "if", "not", "token", ":", "break", "yield", "token", "except", "QasmError", "as", "e", ":", "print", "(", "'E...
d4f58d903bc96341b816f7c35df936d6421267d1
test
QasmParser.parse_debug
Set the parse_deb field.
qiskit/qasm/qasmparser.py
def parse_debug(self, val): """Set the parse_deb field.""" if val is True: self.parse_deb = True elif val is False: self.parse_deb = False else: raise QasmError("Illegal debug value '" + str(val) + "' must be True or False."...
def parse_debug(self, val): """Set the parse_deb field.""" if val is True: self.parse_deb = True elif val is False: self.parse_deb = False else: raise QasmError("Illegal debug value '" + str(val) + "' must be True or False."...
[ "Set", "the", "parse_deb", "field", "." ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/qasm/qasmparser.py#L1053-L1061
[ "def", "parse_debug", "(", "self", ",", "val", ")", ":", "if", "val", "is", "True", ":", "self", ".", "parse_deb", "=", "True", "elif", "val", "is", "False", ":", "self", ".", "parse_deb", "=", "False", "else", ":", "raise", "QasmError", "(", "\"Ille...
d4f58d903bc96341b816f7c35df936d6421267d1
test
QasmParser.parse
Parse some data.
qiskit/qasm/qasmparser.py
def parse(self, data): """Parse some data.""" self.parser.parse(data, lexer=self.lexer, debug=self.parse_deb) if self.qasm is None: raise QasmError("Uncaught exception in parser; " + "see previous messages for details.") return self.qasm
def parse(self, data): """Parse some data.""" self.parser.parse(data, lexer=self.lexer, debug=self.parse_deb) if self.qasm is None: raise QasmError("Uncaught exception in parser; " + "see previous messages for details.") return self.qasm
[ "Parse", "some", "data", "." ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/qasm/qasmparser.py#L1063-L1069
[ "def", "parse", "(", "self", ",", "data", ")", ":", "self", ".", "parser", ".", "parse", "(", "data", ",", "lexer", "=", "self", ".", "lexer", ",", "debug", "=", "self", ".", "parse_deb", ")", "if", "self", ".", "qasm", "is", "None", ":", "raise"...
d4f58d903bc96341b816f7c35df936d6421267d1
test
QasmParser.run
Parser runner. To use this module stand-alone.
qiskit/qasm/qasmparser.py
def run(self, data): """Parser runner. To use this module stand-alone. """ ast = self.parser.parse(data, debug=True) self.parser.parse(data, debug=True) ast.to_string(0)
def run(self, data): """Parser runner. To use this module stand-alone. """ ast = self.parser.parse(data, debug=True) self.parser.parse(data, debug=True) ast.to_string(0)
[ "Parser", "runner", "." ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/qasm/qasmparser.py#L1078-L1085
[ "def", "run", "(", "self", ",", "data", ")", ":", "ast", "=", "self", ".", "parser", ".", "parse", "(", "data", ",", "debug", "=", "True", ")", "self", ".", "parser", ".", "parse", "(", "data", ",", "debug", "=", "True", ")", "ast", ".", "to_st...
d4f58d903bc96341b816f7c35df936d6421267d1
test
Qasm.get_tokens
Returns a generator of the tokens.
qiskit/qasm/qasm.py
def get_tokens(self): """Returns a generator of the tokens.""" if self._filename: with open(self._filename) as ifile: self._data = ifile.read() with QasmParser(self._filename) as qasm_p: return qasm_p.get_tokens()
def get_tokens(self): """Returns a generator of the tokens.""" if self._filename: with open(self._filename) as ifile: self._data = ifile.read() with QasmParser(self._filename) as qasm_p: return qasm_p.get_tokens()
[ "Returns", "a", "generator", "of", "the", "tokens", "." ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/qasm/qasm.py#L32-L39
[ "def", "get_tokens", "(", "self", ")", ":", "if", "self", ".", "_filename", ":", "with", "open", "(", "self", ".", "_filename", ")", "as", "ifile", ":", "self", ".", "_data", "=", "ifile", ".", "read", "(", ")", "with", "QasmParser", "(", "self", "...
d4f58d903bc96341b816f7c35df936d6421267d1
test
Qasm.parse
Parse the data.
qiskit/qasm/qasm.py
def parse(self): """Parse the data.""" if self._filename: with open(self._filename) as ifile: self._data = ifile.read() with QasmParser(self._filename) as qasm_p: qasm_p.parse_debug(False) return qasm_p.parse(self._data)
def parse(self): """Parse the data.""" if self._filename: with open(self._filename) as ifile: self._data = ifile.read() with QasmParser(self._filename) as qasm_p: qasm_p.parse_debug(False) return qasm_p.parse(self._data)
[ "Parse", "the", "data", "." ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/qasm/qasm.py#L41-L49
[ "def", "parse", "(", "self", ")", ":", "if", "self", ".", "_filename", ":", "with", "open", "(", "self", ".", "_filename", ")", "as", "ifile", ":", "self", ".", "_data", "=", "ifile", ".", "read", "(", ")", "with", "QasmParser", "(", "self", ".", ...
d4f58d903bc96341b816f7c35df936d6421267d1
test
crz
Apply crz from ctl to tgt with angle theta.
qiskit/extensions/standard/crz.py
def crz(self, theta, ctl, tgt): """Apply crz from ctl to tgt with angle theta.""" return self.append(CrzGate(theta), [ctl, tgt], [])
def crz(self, theta, ctl, tgt): """Apply crz from ctl to tgt with angle theta.""" return self.append(CrzGate(theta), [ctl, tgt], [])
[ "Apply", "crz", "from", "ctl", "to", "tgt", "with", "angle", "theta", "." ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/extensions/standard/crz.py#L53-L55
[ "def", "crz", "(", "self", ",", "theta", ",", "ctl", ",", "tgt", ")", ":", "return", "self", ".", "append", "(", "CrzGate", "(", "theta", ")", ",", "[", "ctl", ",", "tgt", "]", ",", "[", "]", ")" ]
d4f58d903bc96341b816f7c35df936d6421267d1
test
basis_state
Return a basis state ndarray. Args: str_state (string): a string representing the state. num (int): the number of qubits Returns: ndarray: state(2**num) a quantum state with basis basis state. Raises: QiskitError: if the dimensions is wrong
qiskit/quantum_info/states/states.py
def basis_state(str_state, num): """ Return a basis state ndarray. Args: str_state (string): a string representing the state. num (int): the number of qubits Returns: ndarray: state(2**num) a quantum state with basis basis state. Raises: QiskitError: if the dimensi...
def basis_state(str_state, num): """ Return a basis state ndarray. Args: str_state (string): a string representing the state. num (int): the number of qubits Returns: ndarray: state(2**num) a quantum state with basis basis state. Raises: QiskitError: if the dimensi...
[ "Return", "a", "basis", "state", "ndarray", "." ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/quantum_info/states/states.py#L22-L40
[ "def", "basis_state", "(", "str_state", ",", "num", ")", ":", "n", "=", "int", "(", "str_state", ",", "2", ")", "if", "num", ">=", "len", "(", "str_state", ")", ":", "state", "=", "np", ".", "zeros", "(", "1", "<<", "num", ",", "dtype", "=", "c...
d4f58d903bc96341b816f7c35df936d6421267d1
test
projector
maps a pure state to a state matrix Args: state (ndarray): the number of qubits flatten (bool): determine if state matrix of column work Returns: ndarray: state_mat(2**num, 2**num) if flatten is false ndarray: state_mat(4**num) if flatten is true stacked on by the column
qiskit/quantum_info/states/states.py
def projector(state, flatten=False): """ maps a pure state to a state matrix Args: state (ndarray): the number of qubits flatten (bool): determine if state matrix of column work Returns: ndarray: state_mat(2**num, 2**num) if flatten is false ndarray: state_mat(4**num) ...
def projector(state, flatten=False): """ maps a pure state to a state matrix Args: state (ndarray): the number of qubits flatten (bool): determine if state matrix of column work Returns: ndarray: state_mat(2**num, 2**num) if flatten is false ndarray: state_mat(4**num) ...
[ "maps", "a", "pure", "state", "to", "a", "state", "matrix" ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/quantum_info/states/states.py#L43-L57
[ "def", "projector", "(", "state", ",", "flatten", "=", "False", ")", ":", "density_matrix", "=", "np", ".", "outer", "(", "state", ".", "conjugate", "(", ")", ",", "state", ")", "if", "flatten", ":", "return", "density_matrix", ".", "flatten", "(", "or...
d4f58d903bc96341b816f7c35df936d6421267d1