Skip to content

Commit 2fe6f7a

Browse files
authored
Merge branch 'master' into issue-3750-delay-instruction
2 parents fda68db + 1996bc2 commit 2fe6f7a

File tree

93 files changed

+1450
-539
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

93 files changed

+1450
-539
lines changed

.travis.yml

-18
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ jobs:
4141
fast_finish: true
4242
allow_failures:
4343
- name: Randomized tests
44-
- name: Benchmarks
4544
include:
4645
- name: Python 3.6 Tests and Coverage Linux
4746
python: 3.6
@@ -65,20 +64,3 @@ jobs:
6564
- python setup.py build_ext --inplace
6665
- pip install "qiskit-aer"
6766
- make test_randomized
68-
69-
- name: Benchmarks
70-
python: 3.5
71-
script:
72-
- python setup.py build_ext --inplace
73-
- pip install "qiskit-aer"
74-
- pip install "asv"
75-
- git clone "https://github.com/Qiskit/qiskit" meta-qiskit
76-
- >-
77-
sed -i
78-
-e 's/"repo": "https:\/\/github.com\/Qiskit\/qiskit-terra.git",/"repo": "..",/'
79-
meta-qiskit/asv.conf.json
80-
- cat meta-qiskit/asv.conf.json
81-
- echo $TRAVIS_BRANCH
82-
- echo $TRAVIS_PULL_REQUEST_BRANCH
83-
- asv --config meta-qiskit/asv.conf.json machine --machine travis-ci
84-
- travis_wait 45 asv --config meta-qiskit/asv.conf.json continuous --interleave-processes --machine travis-ci --no-only-changed --python 3.5 --bench 'converters.*(1|2|5|8|14|20|53)\,.8\)' --bench '^(transpiler_benchmarks|assembler|circuit_construction|isometry|import)\.' $([ "$TRAVIS_BRANCH" == "master" ] || echo "$TRAVIS_BRANCH") HEAD

azure-pipelines.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ stages:
215215
sudo apt install -y graphviz
216216
displayName: 'Install dependencies'
217217
- bash: |
218-
tox -edocs -- -j auto
218+
tox -edocs
219219
displayName: 'Run Docs build'
220220
- task: PublishBuildArtifacts@1
221221
displayName: 'Publish docs'

docs/apidocs/terra.rst

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
.. module:: qiskit
2+
3+
==========================
4+
Qiskit Terra API Reference
5+
==========================
6+
7+
.. toctree::
8+
:maxdepth: 1
9+
10+
circuit
11+
compiler
12+
execute
13+
visualization
14+
converters
15+
assembler
16+
dagcircuit
17+
extensions
18+
providers_basicaer
19+
providers
20+
providers_models
21+
pulse
22+
scheduler
23+
qasm
24+
qobj
25+
quantum_info
26+
result
27+
tools
28+
tools_jupyter
29+
transpiler
30+
transpiler_passes
31+
transpiler_preset
32+
validation
33+
visualization

qiskit/circuit/bit.py

+2
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
class Bit:
2222
"""Implement a generic bit."""
2323

24+
__slots__ = {'register', 'index'}
25+
2426
def __init__(self, register, index):
2527
"""Create a new generic bit.
2628
"""

qiskit/circuit/controlledgate.py

-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ def __init__(self, name, num_qubits, params, label=None, num_ctrl_qubits=1,
2929
3030
Attributes:
3131
num_ctrl_qubits (int): The number of control qubits.
32-
ctrl_state (int): The control state in decimal notation.
3332
3433
Args:
3534
name (str): The Qobj name of the gate.

qiskit/circuit/instruction.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ def mirror(self):
247247
It does not invert any gate.
248248
249249
Returns:
250-
Instruction: a fresh gate with sub-gates reversed
250+
qiskit.circuit.Instruction: a fresh gate with sub-gates reversed
251251
"""
252252
if not self._definition:
253253
return self.copy()
@@ -268,7 +268,7 @@ def inverse(self):
268268
implement their own inverse (e.g. T and Tdg, Barrier, etc.)
269269
270270
Returns:
271-
Instruction: a fresh instruction for the inverse
271+
qiskit.circuit.Instruction: a fresh instruction for the inverse
272272
273273
Raises:
274274
CircuitError: if the instruction is not composite
@@ -300,7 +300,7 @@ def copy(self, name=None):
300300
if None then the name stays the same.
301301
302302
Returns:
303-
Instruction: a shallow copy of the current instruction, with the name
303+
qiskit.circuit.Instruction: a shallow copy of the current instruction, with the name
304304
updated if it was provided
305305
"""
306306
cpy = copy.copy(self)
@@ -366,7 +366,7 @@ def repeat(self, n):
366366
n (int): Number of times to repeat the instruction
367367
368368
Returns:
369-
Instruction: Containing the definition.
369+
qiskit.circuit.Instruction: Containing the definition.
370370
371371
Raises:
372372
CircuitError: If n < 1.

qiskit/circuit/quantumcircuit.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -444,12 +444,12 @@ def append(self, instruction, qargs=None, cargs=None):
444444
the circuit in place. Expands qargs and cargs.
445445
446446
Args:
447-
instruction (Instruction or Operation): Instruction instance to append
447+
instruction (qiskit.circuit.Instruction): Instruction instance to append
448448
qargs (list(argument)): qubits to attach instruction to
449449
cargs (list(argument)): clbits to attach instruction to
450450
451451
Returns:
452-
Instruction: a handle to the instruction that was just added
452+
qiskit.circuit.Instruction: a handle to the instruction that was just added
453453
"""
454454
# Convert input to instruction
455455
if not isinstance(instruction, Instruction) and hasattr(instruction, 'to_instruction'):
@@ -578,7 +578,7 @@ def to_instruction(self, parameter_map=None):
578578
parameterize the instruction.
579579
580580
Returns:
581-
Instruction: a composite instruction encapsulating this circuit
581+
qiskit.circuit.Instruction: a composite instruction encapsulating this circuit
582582
(can be decomposed back)
583583
"""
584584
from qiskit.converters.circuit_to_instruction import circuit_to_instruction

qiskit/compiler/transpile.py

+32-31
Original file line numberDiff line numberDiff line change
@@ -62,61 +62,60 @@ def transpile(circuits: Union[QuantumCircuit, List[QuantumCircuit]],
6262
will override the backend's.
6363
6464
.. note::
65+
6566
The backend arg is purely for convenience. The resulting
6667
circuit may be run on any backend as long as it is compatible.
67-
basis_gates: List of basis gate names to unroll to.
68-
e.g::
69-
['u1', 'u2', 'u3', 'cx']
70-
If ``None``, do not unroll.
68+
basis_gates: List of basis gate names to unroll to
69+
(e.g: ``['u1', 'u2', 'u3', 'cx']``). If ``None``, do not unroll.
7170
coupling_map: Coupling map (perhaps custom) to target in mapping.
7271
Multiple formats are supported:
73-
1. ``CouplingMap`` instance
74-
2. List
75-
Must be given as an adjacency matrix, where each entry
76-
specifies all two-qubit interactions supported by backend,
77-
e.g::
78-
[[0, 1], [0, 3], [1, 2], [1, 5], [2, 5], [4, 1], [5, 3]]
72+
73+
#. ``CouplingMap`` instance
74+
#. List, must be given as an adjacency matrix, where each entry
75+
specifies all two-qubit interactions supported by backend,
76+
e.g: ``[[0, 1], [0, 3], [1, 2], [1, 5], [2, 5], [4, 1], [5, 3]]``
77+
7978
backend_properties: properties returned by a backend, including information on gate
8079
errors, readout errors, qubit coherence times, etc. Find a backend
8180
that provides this information with: ``backend.properties()``
8281
initial_layout: Initial position of virtual qubits on physical qubits.
8382
If this layout makes the circuit compatible with the coupling_map
84-
constraints, it will be used.
85-
The final layout is not guaranteed to be the same, as the transpiler
86-
may permute qubits through swaps or other means.
83+
constraints, it will be used. The final layout is not guaranteed to be the same,
84+
as the transpiler may permute qubits through swaps or other means.
8785
Multiple formats are supported:
8886
89-
1. ``Layout`` instance
90-
91-
2. Dict
92-
93-
* virtual to physical::
87+
#. ``Layout`` instance
88+
#. Dict
89+
* virtual to physical::
9490
9591
{qr[0]: 0,
9692
qr[1]: 3,
9793
qr[2]: 5}
9894
99-
* physical to virtual::
95+
* physical to virtual::
10096
10197
{0: qr[0],
10298
3: qr[1],
10399
5: qr[2]}
104-
3. List
105100
106-
* virtual to physical::
101+
#. List
102+
103+
* virtual to physical::
107104
108105
[0, 3, 5] # virtual qubits are ordered (in addition to named)
109-
* physical to virtual::
106+
107+
* physical to virtual::
110108
111109
[qr[0], None, None, qr[1], None, qr[2]]
110+
112111
seed_transpiler: Sets random seed for the stochastic parts of the transpiler
113112
optimization_level: How much optimization to perform on the circuits.
114113
Higher levels generate more optimized circuits,
115114
at the expense of longer transpilation time.
116-
* 0: no optimization
117-
* 1: light optimization
118-
* 2: heavy optimization
119-
* 3: even heavier optimization
115+
* 0: no optimization
116+
* 1: light optimization
117+
* 2: heavy optimization
118+
* 3: even heavier optimization
120119
If ``None``, level 1 will be chosen as default.
121120
pass_manager: The pass manager to use for a custom pipeline of transpiler passes.
122121
If this arg is present, all other args will be ignored and the
@@ -125,17 +124,18 @@ def transpile(circuits: Union[QuantumCircuit, List[QuantumCircuit]],
125124
callback: A callback function that will be called after each
126125
pass execution. The function will be called with 5 keyword
127126
arguments,
128-
| ``pass_``: the pass being run.
129-
| ``dag``: the dag output of the pass.
130-
| ``time``: the time to execute the pass.
131-
| ``property_set``: the property set.
132-
| ``count``: the index for the pass execution.
127+
| ``pass_``: the pass being run.
128+
| ``dag``: the dag output of the pass.
129+
| ``time``: the time to execute the pass.
130+
| ``property_set``: the property set.
131+
| ``count``: the index for the pass execution.
133132
The exact arguments passed expose the internals of the pass manager,
134133
and are subject to change as the pass manager internals change. If
135134
you intend to reuse a callback function over multiple releases, be
136135
sure to check that the arguments being passed are the same.
137136
To use the callback feature, define a function that will
138137
take in kwargs dict and access the variables. For example::
138+
139139
def callback_func(**kwargs):
140140
pass_ = kwargs['pass_']
141141
dag = kwargs['dag']
@@ -144,6 +144,7 @@ def callback_func(**kwargs):
144144
count = kwargs['count']
145145
...
146146
transpile(circ, callback=callback_func)
147+
147148
output_name: A list with strings to identify the output circuits. The length of
148149
the list should be exactly the length of the ``circuits`` parameter.
149150

qiskit/converters/circuit_to_instruction.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def circuit_to_instruction(circuit, parameter_map=None):
3838
QiskitError: if parameter_map is not compatible with circuit
3939
4040
Return:
41-
Instruction: an instruction equivalent to the action of the
41+
qiskit.circuit.Instruction: an instruction equivalent to the action of the
4242
input circuit. Upon decomposition, this instruction will
4343
yield the components comprising the original circuit.
4444

qiskit/dagcircuit/dagcircuit.py

+7-6
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ def _add_op_node(self, op, qargs, cargs, condition=None):
216216
"""Add a new operation node to the graph and assign properties.
217217
218218
Args:
219-
op (Instruction): the operation associated with the DAG node
219+
op (qiskit.circuit.Instruction): the operation associated with the DAG node
220220
qargs (list[Qubit]): list of quantum wires to attach to.
221221
cargs (list[Clbit]): list of classical wires to attach to.
222222
condition (tuple or None): optional condition (ClassicalRegister, int)
@@ -240,7 +240,7 @@ def apply_operation_back(self, op, qargs=None, cargs=None, condition=None):
240240
"""Apply an operation to the output of the circuit.
241241
242242
Args:
243-
op (Instruction): the operation associated with the DAG node
243+
op (qiskit.circuit.Instruction): the operation associated with the DAG node
244244
qargs (list[Qubit]): qubits that op will be applied to
245245
cargs (list[Clbit]): cbits that op will be applied to
246246
condition (tuple or None): optional condition (ClassicalRegister, int)
@@ -286,7 +286,7 @@ def apply_operation_front(self, op, qargs, cargs, condition=None):
286286
"""Apply an operation to the input of the circuit.
287287
288288
Args:
289-
op (Instruction): the operation associated with the DAG node
289+
op (qiskit.circuit.Instruction): the operation associated with the DAG node
290290
qargs (list[Qubit]): qubits that op will be applied to
291291
cargs (list[Clbit]): cbits that op will be applied to
292292
condition (tuple or None): optional condition (ClassicalRegister, value)
@@ -860,7 +860,8 @@ def substitute_node(self, node, op, inplace=False):
860860
861861
Args:
862862
node (DAGNode): Node to be replaced
863-
op (Instruction): The Instruction instance to be added to the DAG
863+
op (qiskit.circuit.Instruction): The :class:`qiskit.circuit.Instruction`
864+
instance to be added to the DAG
864865
inplace (bool): Optional, default False. If True, existing DAG node
865866
will be modified to include op. Otherwise, a new DAG node will
866867
be used.
@@ -944,8 +945,8 @@ def op_nodes(self, op=None):
944945
"""Get the list of "op" nodes in the dag.
945946
946947
Args:
947-
op (Type): Instruction subclass op nodes to return. if op=None, return
948-
all op nodes.
948+
op (Type): :class:`qiskit.circuit.Instruction` subclass op nodes to return.
949+
if op=None, return all op nodes.
949950
Returns:
950951
list[DAGNode]: the list of node ids containing the given op.
951952
"""

0 commit comments

Comments
 (0)