Skip to content

Commit

Permalink
Linting
Browse files Browse the repository at this point in the history
  • Loading branch information
davidedellagiustina committed Feb 7, 2024
1 parent e8e031f commit 8415168
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 15 deletions.
3 changes: 0 additions & 3 deletions .pylintrc
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
[design]
max-locals=25

[miscellaneous]
notes=

Expand Down
7 changes: 4 additions & 3 deletions src/examples/grover_search_known_m.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,10 @@ def main():

# Program parameters
n = len(STABLE_MODELS[0])
m = len(STABLE_MODELS)
# pylint: disable=invalid-name
M = len(STABLE_MODELS)
print(f'Number of variables: {n}.')
print(f'Number of stable models: {m}.')
print(f'Number of stable models: {M}.')
print()
pause()

Expand All @@ -49,7 +50,7 @@ def main():

# Simulation
(circuit, iters, stable_model) = qasp.problems.amplification.exec_find_one_known_m(
algorithm, oracle, m)
algorithm, oracle, M)
print(f'Used circuit:\n{tab(str(circuit.draw()))}\n')
pause()
print(f'Found stable model: {stable_model}.')
Expand Down
19 changes: 10 additions & 9 deletions src/examples/oracle_construction.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@


def build_oracle() -> tuple[qasp.oracle.Oracle, list[int]]:
'''Build the quantum oracle shown in Example 4.1.1 in the thesis.
'''Build the quantum oracle shown in Example 4.2.1 in the thesis.
#### Return
tuple[QuantumCircuit, list[int]]: Circuit implementing the oracle and list of auxiliary \
Expand Down Expand Up @@ -84,18 +84,19 @@ def main():
pause()

# Program parameters
n = 2
n_search = 2 # Number of search qubits
n_aux = 6 # Number of auxiliary qubits
m = 1
print(f'Number of variables: {n}.')
print(f'Number of stable models: {m}.')
# pylint: disable=invalid-name
M = 1
print(f'Number of variables: {n_search}.')
print(f'Number of stable models: {M}.')
print()
pause()

# Initialization algorithm
algorithm = qasp.init_algorithm.alg_grover(n) # Walsh-Hadamard
aux_reg = QuantumRegister(n_aux, 'aux')
algorithm.add_register(aux_reg)
algorithm = qasp.init_algorithm.alg_grover(n_search) # Walsh-Hadamard
reg_aux = QuantumRegister(n_aux, 'aux')
algorithm.add_register(reg_aux)
algorithm.name += ' x Id'
print(f'Initialization algorithm:\n{tab(str(algorithm.draw()))}\n')
pause()
Expand All @@ -107,7 +108,7 @@ def main():

# Simulation
(circuit, iters, stable_model) = qasp.problems.amplification.exec_find_one_known_m(
algorithm, oracle, m, aux_qubits)
algorithm, oracle, M, aux_qubits)
print(f'Used circuit:\n{tab(str(circuit.draw()))}\n')
pause()
print(f'Found stable model: {stable_model}.')
Expand Down
4 changes: 4 additions & 0 deletions src/qasp/problems/amplification.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,8 @@ def exec_find_one_known_m(
tuple[QuantumCircuit, int, Interpretation]: Used circuit, number of iterations performed, \
and found solution.
'''
# pylint: disable=too-many-locals

aux_qubits = [] if aux_qubits is None else aux_qubits
(c_oracle, q_oracle) = oracle

Expand Down Expand Up @@ -239,6 +241,8 @@ def exec_find_one_unknown_m(
tuple[list[QuantumCircuit], int, Interpretation]: List of used circuits, number of \
iterations performed, and found solution.
'''
# pylint: disable=too-many-locals

aux_qubits = [] if aux_qubits is None else aux_qubits
(c_oracle, q_oracle) = oracle
inc = True # Since we do not know m, we must be the most general possible
Expand Down
2 changes: 2 additions & 0 deletions src/qasp/problems/estimation.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ def circuit(
#### Return
QuantumCircuit: Built circuit.
'''
# pylint: disable=too-many-locals

aux_qubits = [] if aux_qubits is None else aux_qubits

assert m > 0 and eps > 0
Expand Down

0 comments on commit 8415168

Please sign in to comment.