Skip to content

Commit

Permalink
lint in the example files (Qiskit#4363)
Browse files Browse the repository at this point in the history
Co-authored-by: Jay Gambetta <jay.gambetta@us.ibm.com>
  • Loading branch information
Luciano Bello and jaygambetta authored May 4, 2020
1 parent 54b83b5 commit f0c8331
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 18 deletions.
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ env:
# Ignoring generated ones with .py extension.
lint:
pylint -rn qiskit test
pylint -rn --disable='C0103, C0114, W0621' examples/python/*.py

style:
pycodestyle --max-line-length=100 qiskit test
Expand Down
10 changes: 5 additions & 5 deletions examples/python/commutation_relation.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# copyright notice, and modified files need to carry a notice indicating
# that they have been altered from the originals.

from qiskit import *
from qiskit import QuantumCircuit

from qiskit.transpiler import PassManager
from qiskit.transpiler.passes import CommutationAnalysis, CommutativeCancellation
Expand All @@ -22,18 +22,18 @@
circuit.cx(0, 1)
circuit.cx(2, 1)
circuit.cx(4, 3)
circuit.cx(2, 3)
circuit.cx(2, 3)
circuit.z(0)
circuit.z(4)
circuit.cx(0, 1)
circuit.cx(2, 1)
circuit.cx(4, 3)
circuit.cx(2, 3)
circuit.cx(3, 2)
circuit.cx(2, 3)
circuit.cx(3, 2)

print(circuit)

pm = PassManager()
pm.append([CommutationAnalysis(), CommutativeCancellation()])
new_circuit=pm.run(circuit)
new_circuit = pm.run(circuit)
print(new_circuit)
2 changes: 1 addition & 1 deletion examples/python/load_qasm.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"""Example on how to load a file into a QuantumCircuit."""

from qiskit import QuantumCircuit
from qiskit import QiskitError, execute, BasicAer
from qiskit import execute, BasicAer

circ = QuantumCircuit.from_qasm_file("examples/qasm/entangled_registers.qasm")
print(circ)
Expand Down
6 changes: 3 additions & 3 deletions examples/python/rippleadd.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
# Set the backend name and coupling map.
###############################################################
backend = BasicAer.get_backend("qasm_simulator")
coupling_map = [[0,1], [0, 8], [1, 2], [1, 9], [2, 3], [2, 10], [3, 4], [3, 11],
coupling_map = [[0, 1], [0, 8], [1, 2], [1, 9], [2, 3], [2, 10], [3, 4], [3, 11],
[4, 5], [4, 12], [5, 6], [5, 13], [6, 7], [6, 14], [7, 15], [8, 9],
[9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15]]

Expand All @@ -38,7 +38,7 @@
b = QuantumRegister(n, "b")
cin = QuantumRegister(1, "cin")
cout = QuantumRegister(1, "cout")
ans = ClassicalRegister(n+1, "ans")
ans = ClassicalRegister(n + 1, "ans")
qc = QuantumCircuit(a, b, cin, cout, ans, name="rippleadd")


Expand Down Expand Up @@ -69,7 +69,7 @@ def unmajority(p, a, b, c):

# Set the inputs to the adder
qc.x(a[0]) # Set input a = 0...0001
qc.x(b) # Set input b = 1...1111
qc.x(b) # Set input b = 1...1111
# Apply the adder
qc += adder_subcircuit
# Measure the output register in the computational basis
Expand Down
4 changes: 2 additions & 2 deletions examples/python/stochastic_swap.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
"""Example of using the StochasticSwap pass."""

from qiskit.transpiler.passes import StochasticSwap
from qiskit.transpiler import CouplingMap, Layout
from qiskit.converters import circuit_to_dag, dag_to_circuit
from qiskit.transpiler import CouplingMap
from qiskit.converters import circuit_to_dag
from qiskit import QuantumRegister, ClassicalRegister, QuantumCircuit

coupling = CouplingMap([[0, 1], [1, 2], [1, 3]])
Expand Down
12 changes: 5 additions & 7 deletions examples/python/using_qiskit_terra_level_0.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,27 +18,25 @@
This example shows the most basic way to user Terra. It builds some circuits
and runs them on both the BasicAer (local Qiskit provider) or IBMQ (remote IBMQ provider).
To control the compile parameters we have provided a transpile function which can be used
To control the compile parameters we have provided a transpile function which can be used
as a level 1 user.
"""

import time

# Import the Qiskit modules
from qiskit import QuantumCircuit, QiskitError
from qiskit import QuantumCircuit
from qiskit import execute, BasicAer

# making first circuit: bell state
qc1 = QuantumCircuit(2, 2)
qc1.h(0)
qc1.cx(0, 1)
qc1.measure([0,1], [0,1])
qc1.measure([0, 1], [0, 1])

# making another circuit: superpositions
qc2 = QuantumCircuit(2, 2)
qc2.h([0,1])
qc2.measure([0,1], [0,1])
qc2.h([0, 1])
qc2.measure([0, 1], [0, 1])

# setting up the backend
print("(BasicAER Backends)")
Expand Down

0 comments on commit f0c8331

Please sign in to comment.