Skip to content

Commit

Permalink
test & lint
Browse files Browse the repository at this point in the history
  • Loading branch information
Cryoris committed Feb 11, 2025
1 parent a90b61d commit 00867cb
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 12 deletions.
9 changes: 9 additions & 0 deletions qiskit/circuit/library/arithmetic/piecewise_chebyshev.py
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,15 @@ def __init__(

@property
def polynomials(self):
"""The polynomials for the piecewise approximation.
Returns:
The polynomials for the piecewise approximation.
Raises:
TypeError: If the input function is not in the correct format.
"""

# note this must be the private attribute since we handle missing breakpoints at
# 0 and 2 ^ num_qubits here (e.g. if the function we approximate is not defined at 0
# and the user takes that into account we just add an identity)
Expand Down
16 changes: 5 additions & 11 deletions qiskit/synthesis/arithmetic/comparators/compare_2s.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
"""Integer comparator based on 2s complement."""

import math
from qiskit.circuit import QuantumCircuit
from qiskit.circuit.library import OR
from qiskit.circuit.quantumcircuit import QuantumCircuit
from qiskit.circuit.library.boolean_logic.quantum_or import OrGate


def synth_integer_comparator_2s(
Expand All @@ -40,18 +40,14 @@ def synth_integer_comparator_2s(
circuit.cx(qr_state[i], qr_ancilla[i])
elif i < num_state_qubits - 1:
if twos[i] == 1:
circuit.compose(
OR(2), [qr_state[i], qr_ancilla[i - 1], qr_ancilla[i]], inplace=True
)
circuit.append(OrGate(2), [qr_state[i], qr_ancilla[i - 1], qr_ancilla[i]])
else:
circuit.ccx(qr_state[i], qr_ancilla[i - 1], qr_ancilla[i])
else:
if twos[i] == 1:
# OR needs the result argument as qubit not register, thus
# access the index [0]
circuit.compose(
OR(2), [qr_state[i], qr_ancilla[i - 1], q_compare], inplace=True
)
circuit.append(OrGate(2), [qr_state[i], qr_ancilla[i - 1], q_compare])
else:
circuit.ccx(qr_state[i], qr_ancilla[i - 1], q_compare)

Expand All @@ -66,9 +62,7 @@ def synth_integer_comparator_2s(
circuit.cx(qr_state[i], qr_ancilla[i])
else:
if twos[i] == 1:
circuit.compose(
OR(2), [qr_state[i], qr_ancilla[i - 1], qr_ancilla[i]], inplace=True
)
circuit.append(OrGate(2), [qr_state[i], qr_ancilla[i - 1], qr_ancilla[i]])
else:
circuit.ccx(qr_state[i], qr_ancilla[i - 1], qr_ancilla[i])
else:
Expand Down
2 changes: 1 addition & 1 deletion qiskit/synthesis/arithmetic/comparators/compare_greedy.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"""Integer comparator based on 2s complement."""

import numpy as np
from qiskit.circuit import QuantumCircuit
from qiskit.circuit.quantumcircuit import QuantumCircuit


def synth_integer_comparator_greedy(
Expand Down
8 changes: 8 additions & 0 deletions test/python/circuit/test_gate_definitions.py
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,14 @@ class TestGateEquivalenceEqual(QiskitTestCase):
"OrGate",
"BitwiseXorGate",
"InnerProductGate",
"IntegerComparatorGate",
"PolynomialPauliRotationsGate",
"PiecewiseLinearPauliRotationsGate",
"PiecewisePolynomialPauliRotationsGate",
"PiecewiseChebyshevGate",
"ExactReciprocalGate",
"LinearPauliRotationsGate",
"LinearAmplitudeFunctionGate",
}

# Amazingly, Python's scoping rules for class bodies means that this is the closest we can get
Expand Down

0 comments on commit 00867cb

Please sign in to comment.