diff --git a/examples/gate_zoo.py b/examples/gate_zoo.py index 6e2b5dac..684addfa 100644 --- a/examples/gate_zoo.py +++ b/examples/gate_zoo.py @@ -7,10 +7,34 @@ from projectq import MainEngine from projectq.backends import CircuitDrawer -from projectq.ops import (CNOT, QFT, All, Barrier, BasicMathGate, C, Entangle, - H, Measure, Ph, QubitOperator, Rx, Ry, Rz, S, - SqrtSwap, SqrtX, Swap, T, Tensor, TimeEvolution, - Toffoli, X, Y, Z, get_inverse) +from projectq.ops import ( + CNOT, + QFT, + All, + Barrier, + BasicMathGate, + C, + Entangle, + H, + Measure, + Ph, + QubitOperator, + Rx, + Ry, + Rz, + S, + SqrtSwap, + SqrtX, + Swap, + T, + Tensor, + TimeEvolution, + Toffoli, + X, + Y, + Z, + get_inverse, +) def zoo_profile(): diff --git a/examples/shor.py b/examples/shor.py index dafa6996..cb5d41bd 100755 --- a/examples/shor.py +++ b/examples/shor.py @@ -15,14 +15,17 @@ import projectq.libs.math import projectq.setups.decompositions from projectq.backends import ResourceCounter, Simulator -from projectq.cengines import (AutoReplacer, DecompositionRuleSet, - InstructionFilter, LocalOptimizer, MainEngine, - TagRemover) -from projectq.libs.math import (AddConstant, AddConstantModN, - MultiplyByConstantModN) +from projectq.cengines import ( + AutoReplacer, + DecompositionRuleSet, + InstructionFilter, + LocalOptimizer, + MainEngine, + TagRemover, +) +from projectq.libs.math import AddConstant, AddConstantModN, MultiplyByConstantModN from projectq.meta import Control -from projectq.ops import (QFT, All, BasicMathGate, H, Measure, R, Swap, X, - get_inverse) +from projectq.ops import QFT, All, BasicMathGate, H, Measure, R, Swap, X, get_inverse def run_shor(eng, N, a, verbose=False): diff --git a/projectq/backends/__init__.py b/projectq/backends/__init__.py index 639b0c96..e531ed9f 100755 --- a/projectq/backends/__init__.py +++ b/projectq/backends/__init__.py @@ -32,8 +32,7 @@ from ._awsbraket import AWSBraketBackend from ._azure import AzureQuantumBackend from ._circuits import CircuitDrawer, CircuitDrawerMatplotlib -from ._exceptions import (DeviceNotHandledError, DeviceOfflineError, - DeviceTooSmall) +from ._exceptions import DeviceNotHandledError, DeviceOfflineError, DeviceTooSmall from ._ibm import IBMBackend from ._ionq import IonQBackend from ._printer import CommandPrinter diff --git a/projectq/backends/_aqt/_aqt.py b/projectq/backends/_aqt/_aqt.py index 778cba9e..9d5e5e2f 100644 --- a/projectq/backends/_aqt/_aqt.py +++ b/projectq/backends/_aqt/_aqt.py @@ -19,8 +19,7 @@ from projectq.cengines import BasicEngine from projectq.meta import LogicalQubitIDTag, get_control_count -from projectq.ops import (Allocate, Barrier, Deallocate, FlushGate, Measure, - Rx, Rxx, Ry) +from projectq.ops import Allocate, Barrier, Deallocate, FlushGate, Measure, Rx, Rxx, Ry from projectq.types import WeakQubitRef from .._exceptions import InvalidCommandError diff --git a/projectq/backends/_aqt/_aqt_http_client.py b/projectq/backends/_aqt/_aqt_http_client.py index cfff2973..b2c8d904 100644 --- a/projectq/backends/_aqt/_aqt_http_client.py +++ b/projectq/backends/_aqt/_aqt_http_client.py @@ -22,8 +22,7 @@ from requests import Session from requests.compat import urljoin -from .._exceptions import (DeviceOfflineError, DeviceTooSmall, - RequestTimeoutError) +from .._exceptions import DeviceOfflineError, DeviceTooSmall, RequestTimeoutError # An AQT token can be requested at: # https://gateway-portal.aqt.eu/ diff --git a/projectq/backends/_aqt/_aqt_test.py b/projectq/backends/_aqt/_aqt_test.py index 0dc80c2f..d35bcaf6 100644 --- a/projectq/backends/_aqt/_aqt_test.py +++ b/projectq/backends/_aqt/_aqt_test.py @@ -20,9 +20,27 @@ from projectq import MainEngine from projectq.backends._aqt import _aqt from projectq.cengines import BasicMapperEngine, DummyEngine -from projectq.ops import (NOT, All, Allocate, Barrier, Command, Deallocate, - Entangle, Measure, Rx, Rxx, Ry, Rz, S, Sdag, T, Tdag, - X, Y, Z) +from projectq.ops import ( + NOT, + All, + Allocate, + Barrier, + Command, + Deallocate, + Entangle, + Measure, + Rx, + Rxx, + Ry, + Rz, + S, + Sdag, + T, + Tdag, + X, + Y, + Z, +) from projectq.types import WeakQubitRef diff --git a/projectq/backends/_awsbraket/_awsbraket.py b/projectq/backends/_awsbraket/_awsbraket.py index 6eabbab3..78fe5bd0 100755 --- a/projectq/backends/_awsbraket/_awsbraket.py +++ b/projectq/backends/_awsbraket/_awsbraket.py @@ -18,12 +18,29 @@ import random from projectq.cengines import BasicEngine -from projectq.meta import (LogicalQubitIDTag, get_control_count, - has_negative_control) -from projectq.ops import (Allocate, Barrier, DaggeredGate, Deallocate, - FlushGate, HGate, Measure, R, Rx, Ry, Rz, Sdag, - SGate, SqrtXGate, SwapGate, Tdag, TGate, XGate, - YGate, ZGate) +from projectq.meta import LogicalQubitIDTag, get_control_count, has_negative_control +from projectq.ops import ( + Allocate, + Barrier, + DaggeredGate, + Deallocate, + FlushGate, + HGate, + Measure, + R, + Rx, + Ry, + Rz, + Sdag, + SGate, + SqrtXGate, + SwapGate, + Tdag, + TGate, + XGate, + YGate, + ZGate, +) from projectq.types import WeakQubitRef from ._awsbraket_boto3_client import retrieve, send diff --git a/projectq/backends/_awsbraket/_awsbraket_boto3_client.py b/projectq/backends/_awsbraket/_awsbraket_boto3_client.py index 02ea006a..7924a40b 100755 --- a/projectq/backends/_awsbraket/_awsbraket_boto3_client.py +++ b/projectq/backends/_awsbraket/_awsbraket_boto3_client.py @@ -28,8 +28,7 @@ import boto3 import botocore -from .._exceptions import (DeviceOfflineError, DeviceTooSmall, - RequestTimeoutError) +from .._exceptions import DeviceOfflineError, DeviceTooSmall, RequestTimeoutError class AWSBraket: diff --git a/projectq/backends/_awsbraket/_awsbraket_test.py b/projectq/backends/_awsbraket/_awsbraket_test.py index a663b009..1a5288c8 100644 --- a/projectq/backends/_awsbraket/_awsbraket_test.py +++ b/projectq/backends/_awsbraket/_awsbraket_test.py @@ -19,12 +19,41 @@ import pytest from projectq import MainEngine -from projectq.cengines import (AutoReplacer, BasicMapperEngine, - DecompositionRuleSet, DummyEngine) +from projectq.cengines import ( + AutoReplacer, + BasicMapperEngine, + DecompositionRuleSet, + DummyEngine, +) from projectq.cengines._replacer import NoGateDecompositionError -from projectq.ops import (CNOT, NOT, All, Allocate, Barrier, C, Command, - Deallocate, Entangle, H, MatrixGate, Measure, Ph, R, - Rx, Ry, Rz, S, Sdag, SqrtX, Swap, T, Tdag, X, Y, Z) +from projectq.ops import ( + CNOT, + NOT, + All, + Allocate, + Barrier, + C, + Command, + Deallocate, + Entangle, + H, + MatrixGate, + Measure, + Ph, + R, + Rx, + Ry, + Rz, + S, + Sdag, + SqrtX, + Swap, + T, + Tdag, + X, + Y, + Z, +) from projectq.types import WeakQubitRef from ._awsbraket_test_fixtures import * # noqa: F401,F403 diff --git a/projectq/backends/_azure/_azure_quantum.py b/projectq/backends/_azure/_azure_quantum.py index 2600fb05..682caa69 100644 --- a/projectq/backends/_azure/_azure_quantum.py +++ b/projectq/backends/_azure/_azure_quantum.py @@ -20,16 +20,20 @@ from projectq.cengines import BasicEngine from projectq.meta import LogicalQubitIDTag -from projectq.ops import (AllocateQubitGate, DeallocateQubitGate, FlushGate, - MeasureGate) +from projectq.ops import AllocateQubitGate, DeallocateQubitGate, FlushGate, MeasureGate from projectq.types import WeakQubitRef from .._utils import _rearrange_result from ._azure_quantum_client import retrieve, send from ._exceptions import AzureQuantumTargetNotFoundError -from ._utils import (IONQ_PROVIDER_ID, QUANTINUUM_PROVIDER_ID, - is_available_ionq, is_available_quantinuum, to_json, - to_qasm) +from ._utils import ( + IONQ_PROVIDER_ID, + QUANTINUUM_PROVIDER_ID, + is_available_ionq, + is_available_quantinuum, + to_json, + to_qasm, +) try: from azure.quantum import Workspace diff --git a/projectq/backends/_azure/_azure_quantum_test.py b/projectq/backends/_azure/_azure_quantum_test.py index 7b624ae4..3cdc51bb 100644 --- a/projectq/backends/_azure/_azure_quantum_test.py +++ b/projectq/backends/_azure/_azure_quantum_test.py @@ -28,8 +28,7 @@ import projectq.backends._azure._azure_quantum from projectq.backends import AzureQuantumBackend - from projectq.backends._azure._exceptions import \ - AzureQuantumTargetNotFoundError + from projectq.backends._azure._exceptions import AzureQuantumTargetNotFoundError except ImportError: _has_azure_quantum = False diff --git a/projectq/backends/_azure/_utils.py b/projectq/backends/_azure/_utils.py index 83e5f2b9..0031f843 100644 --- a/projectq/backends/_azure/_utils.py +++ b/projectq/backends/_azure/_utils.py @@ -15,11 +15,32 @@ """Utility functions for Azure Quantum.""" from projectq.meta import get_control_count, has_negative_control -from projectq.ops import (AllocateQubitGate, BarrierGate, ControlledGate, - DaggeredGate, DeallocateQubitGate, HGate, - MeasureGate, R, Rx, Rxx, Ry, Ryy, Rz, Rzz, Sdag, - SGate, SqrtXGate, SwapGate, Tdag, TGate, XGate, - YGate, ZGate, get_inverse) +from projectq.ops import ( + AllocateQubitGate, + BarrierGate, + ControlledGate, + DaggeredGate, + DeallocateQubitGate, + HGate, + MeasureGate, + R, + Rx, + Rxx, + Ry, + Ryy, + Rz, + Rzz, + Sdag, + SGate, + SqrtXGate, + SwapGate, + Tdag, + TGate, + XGate, + YGate, + ZGate, + get_inverse, +) from .._exceptions import InvalidCommandError diff --git a/projectq/backends/_azure/_utils_test.py b/projectq/backends/_azure/_utils_test.py index 99b8db10..8fdf70b4 100644 --- a/projectq/backends/_azure/_utils_test.py +++ b/projectq/backends/_azure/_utils_test.py @@ -19,10 +19,37 @@ import pytest from projectq.cengines import DummyEngine, MainEngine -from projectq.ops import (CNOT, CX, NOT, Allocate, Barrier, C, Command, - Deallocate, H, Measure, Rx, Rxx, Ry, Ryy, Rz, Rzz, S, - Sdag, Sdagger, SqrtX, SqrtXGate, Swap, T, Tdag, - Tdagger, X, Y, Z, get_inverse) +from projectq.ops import ( + CNOT, + CX, + NOT, + Allocate, + Barrier, + C, + Command, + Deallocate, + H, + Measure, + Rx, + Rxx, + Ry, + Ryy, + Rz, + Rzz, + S, + Sdag, + Sdagger, + SqrtX, + SqrtXGate, + Swap, + T, + Tdag, + Tdagger, + X, + Y, + Z, + get_inverse, +) from projectq.types import WeakQubitRef from .._exceptions import InvalidCommandError @@ -31,9 +58,12 @@ try: import azure.quantum # noqa: F401 - from projectq.backends._azure._utils import (is_available_ionq, - is_available_quantinuum, - to_json, to_qasm) + from projectq.backends._azure._utils import ( + is_available_ionq, + is_available_quantinuum, + to_json, + to_qasm, + ) except ImportError: _has_azure_quantum = False diff --git a/projectq/backends/_circuits/_to_latex.py b/projectq/backends/_circuits/_to_latex.py index 65f101ae..c2f870b7 100755 --- a/projectq/backends/_circuits/_to_latex.py +++ b/projectq/backends/_circuits/_to_latex.py @@ -16,8 +16,17 @@ import json -from projectq.ops import (Allocate, DaggeredGate, Deallocate, Measure, - SqrtSwap, Swap, X, Z, get_inverse) +from projectq.ops import ( + Allocate, + DaggeredGate, + Deallocate, + Measure, + SqrtSwap, + Swap, + X, + Z, + get_inverse, +) def _gate_name(gate): diff --git a/projectq/backends/_circuits/_to_latex_test.py b/projectq/backends/_circuits/_to_latex_test.py index 304a4201..3369e681 100755 --- a/projectq/backends/_circuits/_to_latex_test.py +++ b/projectq/backends/_circuits/_to_latex_test.py @@ -23,8 +23,19 @@ import projectq.backends._circuits._to_latex as _to_latex from projectq import MainEngine from projectq.meta import Control -from projectq.ops import (CNOT, BasicGate, C, H, Measure, SqrtSwap, SqrtX, - Swap, X, Z, get_inverse) +from projectq.ops import ( + CNOT, + BasicGate, + C, + H, + Measure, + SqrtSwap, + SqrtX, + Swap, + X, + Z, + get_inverse, +) def test_tolatex(): diff --git a/projectq/backends/_ibm/_ibm.py b/projectq/backends/_ibm/_ibm.py index 4ab65a66..2a11aa5a 100755 --- a/projectq/backends/_ibm/_ibm.py +++ b/projectq/backends/_ibm/_ibm.py @@ -18,10 +18,19 @@ import random from projectq.cengines import BasicEngine -from projectq.meta import (LogicalQubitIDTag, get_control_count, - has_negative_control) -from projectq.ops import (NOT, Allocate, Barrier, Deallocate, FlushGate, H, - Measure, Rx, Ry, Rz) +from projectq.meta import LogicalQubitIDTag, get_control_count, has_negative_control +from projectq.ops import ( + NOT, + Allocate, + Barrier, + Deallocate, + FlushGate, + H, + Measure, + Rx, + Ry, + Rz, +) from projectq.types import WeakQubitRef from .._exceptions import InvalidCommandError diff --git a/projectq/backends/_ibm/_ibm_test.py b/projectq/backends/_ibm/_ibm_test.py index 6eb0d406..dc9e2c2c 100755 --- a/projectq/backends/_ibm/_ibm_test.py +++ b/projectq/backends/_ibm/_ibm_test.py @@ -20,9 +20,28 @@ from projectq.backends._ibm import _ibm from projectq.cengines import BasicMapperEngine, DummyEngine, MainEngine from projectq.meta import LogicalQubitIDTag -from projectq.ops import (CNOT, NOT, All, Allocate, Barrier, Command, - Deallocate, Entangle, H, Measure, Rx, Ry, Rz, S, - Sdag, T, Tdag, X, Y, Z) +from projectq.ops import ( + CNOT, + NOT, + All, + Allocate, + Barrier, + Command, + Deallocate, + Entangle, + H, + Measure, + Rx, + Ry, + Rz, + S, + Sdag, + T, + Tdag, + X, + Y, + Z, +) from projectq.setups import restrictedgateset from projectq.types import WeakQubitRef diff --git a/projectq/backends/_ionq/_ionq.py b/projectq/backends/_ionq/_ionq.py index 3a6af008..4c59369c 100644 --- a/projectq/backends/_ionq/_ionq.py +++ b/projectq/backends/_ionq/_ionq.py @@ -17,12 +17,32 @@ import random from projectq.cengines import BasicEngine -from projectq.meta import (LogicalQubitIDTag, get_control_count, - has_negative_control) -from projectq.ops import (Allocate, Barrier, DaggeredGate, Deallocate, - FlushGate, HGate, Measure, R, Rx, Rxx, Ry, Ryy, Rz, - Rzz, Sdag, SGate, SqrtXGate, SwapGate, Tdag, TGate, - XGate, YGate, ZGate) +from projectq.meta import LogicalQubitIDTag, get_control_count, has_negative_control +from projectq.ops import ( + Allocate, + Barrier, + DaggeredGate, + Deallocate, + FlushGate, + HGate, + Measure, + R, + Rx, + Rxx, + Ry, + Ryy, + Rz, + Rzz, + Sdag, + SGate, + SqrtXGate, + SwapGate, + Tdag, + TGate, + XGate, + YGate, + ZGate, +) from projectq.types import WeakQubitRef from .._exceptions import InvalidCommandError, MidCircuitMeasurementError diff --git a/projectq/backends/_ionq/_ionq_http_client.py b/projectq/backends/_ionq/_ionq_http_client.py index 1badac6c..72e16555 100644 --- a/projectq/backends/_ionq/_ionq_http_client.py +++ b/projectq/backends/_ionq/_ionq_http_client.py @@ -23,8 +23,12 @@ from requests import Session from requests.compat import urljoin -from .._exceptions import (DeviceOfflineError, DeviceTooSmall, - JobSubmissionError, RequestTimeoutError) +from .._exceptions import ( + DeviceOfflineError, + DeviceTooSmall, + JobSubmissionError, + RequestTimeoutError, +) _API_URL = 'https://api.ionq.co/v0.2/' _JOB_API_URL = urljoin(_API_URL, 'jobs/') diff --git a/projectq/backends/_ionq/_ionq_http_client_test.py b/projectq/backends/_ionq/_ionq_http_client_test.py index f73be731..d1df8fb6 100644 --- a/projectq/backends/_ionq/_ionq_http_client_test.py +++ b/projectq/backends/_ionq/_ionq_http_client_test.py @@ -18,8 +18,7 @@ import pytest import requests -from projectq.backends._exceptions import (JobSubmissionError, - RequestTimeoutError) +from projectq.backends._exceptions import JobSubmissionError, RequestTimeoutError from projectq.backends._ionq import _ionq_http_client diff --git a/projectq/backends/_ionq/_ionq_mapper.py b/projectq/backends/_ionq/_ionq_mapper.py index fec6e519..e77b92c1 100644 --- a/projectq/backends/_ionq/_ionq_mapper.py +++ b/projectq/backends/_ionq/_ionq_mapper.py @@ -16,8 +16,7 @@ from projectq.cengines import BasicMapperEngine from projectq.meta import LogicalQubitIDTag -from projectq.ops import (AllocateQubitGate, Command, DeallocateQubitGate, - FlushGate) +from projectq.ops import AllocateQubitGate, Command, DeallocateQubitGate, FlushGate from projectq.types import WeakQubitRef diff --git a/projectq/backends/_ionq/_ionq_test.py b/projectq/backends/_ionq/_ionq_test.py index 5c363cf4..5a846b03 100644 --- a/projectq/backends/_ionq/_ionq_test.py +++ b/projectq/backends/_ionq/_ionq_test.py @@ -20,13 +20,38 @@ import pytest from projectq import MainEngine -from projectq.backends._exceptions import (InvalidCommandError, - MidCircuitMeasurementError) +from projectq.backends._exceptions import ( + InvalidCommandError, + MidCircuitMeasurementError, +) from projectq.backends._ionq import _ionq, _ionq_http_client from projectq.cengines import DummyEngine -from projectq.ops import (CNOT, All, Allocate, Barrier, Command, Deallocate, - Entangle, H, Measure, Ph, R, Rx, Rxx, Ry, Rz, S, - Sdag, SqrtX, T, Tdag, Toffoli, X, Y, Z) +from projectq.ops import ( + CNOT, + All, + Allocate, + Barrier, + Command, + Deallocate, + Entangle, + H, + Measure, + Ph, + R, + Rx, + Rxx, + Ry, + Rz, + S, + Sdag, + SqrtX, + T, + Tdag, + Toffoli, + X, + Y, + Z, +) from projectq.types import WeakQubitRef from ._ionq_mapper import BoundedQubitMapper diff --git a/projectq/backends/_printer_test.py b/projectq/backends/_printer_test.py index 268cd046..658fb78c 100755 --- a/projectq/backends/_printer_test.py +++ b/projectq/backends/_printer_test.py @@ -21,8 +21,7 @@ from projectq import MainEngine from projectq.backends import _printer -from projectq.cengines import (DummyEngine, InstructionFilter, - NotYetMeasuredError) +from projectq.cengines import DummyEngine, InstructionFilter, NotYetMeasuredError from projectq.meta import LogicalQubitIDTag from projectq.ops import NOT, Allocate, Command, H, Measure, T from projectq.types import WeakQubitRef diff --git a/projectq/backends/_resource_test.py b/projectq/backends/_resource_test.py index 5c5ae658..426d2916 100755 --- a/projectq/backends/_resource_test.py +++ b/projectq/backends/_resource_test.py @@ -20,8 +20,7 @@ from projectq.backends import ResourceCounter from projectq.cengines import DummyEngine, MainEngine, NotYetMeasuredError from projectq.meta import LogicalQubitIDTag -from projectq.ops import (CNOT, QFT, All, Allocate, Command, H, Measure, Rz, - Rzz, X) +from projectq.ops import CNOT, QFT, All, Allocate, Command, H, Measure, Rz, Rzz, X from projectq.types import WeakQubitRef diff --git a/projectq/backends/_sim/_classical_simulator.py b/projectq/backends/_sim/_classical_simulator.py index 8f16a9da..f873d109 100755 --- a/projectq/backends/_sim/_classical_simulator.py +++ b/projectq/backends/_sim/_classical_simulator.py @@ -16,8 +16,7 @@ from projectq.cengines import BasicEngine from projectq.meta import LogicalQubitIDTag -from projectq.ops import (Allocate, BasicMathGate, Deallocate, FlushGate, - Measure, XGate) +from projectq.ops import Allocate, BasicMathGate, Deallocate, FlushGate, Measure, XGate from projectq.types import WeakQubitRef diff --git a/projectq/backends/_sim/_classical_simulator_test.py b/projectq/backends/_sim/_classical_simulator_test.py index 99a9ccb8..67db700e 100755 --- a/projectq/backends/_sim/_classical_simulator_test.py +++ b/projectq/backends/_sim/_classical_simulator_test.py @@ -15,8 +15,12 @@ import pytest from projectq import MainEngine -from projectq.cengines import (AutoReplacer, BasicMapperEngine, - DecompositionRuleSet, DummyEngine) +from projectq.cengines import ( + AutoReplacer, + BasicMapperEngine, + DecompositionRuleSet, + DummyEngine, +) from projectq.ops import NOT, All, BasicMathGate, C, Measure, X, Y from projectq.types import WeakQubitRef diff --git a/projectq/backends/_sim/_simulator.py b/projectq/backends/_sim/_simulator.py index d1a01eab..f3365fbc 100755 --- a/projectq/backends/_sim/_simulator.py +++ b/projectq/backends/_sim/_simulator.py @@ -23,10 +23,15 @@ import random from projectq.cengines import BasicEngine -from projectq.meta import (LogicalQubitIDTag, get_control_count, - has_negative_control) -from projectq.ops import (Allocate, BasicMathGate, Deallocate, FlushGate, - Measure, TimeEvolution) +from projectq.meta import LogicalQubitIDTag, get_control_count, has_negative_control +from projectq.ops import ( + Allocate, + BasicMathGate, + Deallocate, + FlushGate, + Measure, + TimeEvolution, +) from projectq.types import WeakQubitRef FALLBACK_TO_PYSIM = False @@ -356,7 +361,10 @@ def _handle(self, cmd): # pylint: disable=too-many-branches,too-many-locals,too elif isinstance(cmd.gate, BasicMathGate): # improve performance by using C++ code for some commomn gates from projectq.libs.math import ( # pylint: disable=import-outside-toplevel - AddConstant, AddConstantModN, MultiplyByConstantModN) + AddConstant, + AddConstantModN, + MultiplyByConstantModN, + ) qubitids = [] for qureg in cmd.qubits: diff --git a/projectq/backends/_sim/_simulator_test.py b/projectq/backends/_sim/_simulator_test.py index 592329ec..1b4b6b7b 100755 --- a/projectq/backends/_sim/_simulator_test.py +++ b/projectq/backends/_sim/_simulator_test.py @@ -28,12 +28,34 @@ from projectq import MainEngine from projectq.backends import Simulator -from projectq.cengines import (BasicMapperEngine, DummyEngine, LocalOptimizer, - NotYetMeasuredError) +from projectq.cengines import ( + BasicMapperEngine, + DummyEngine, + LocalOptimizer, + NotYetMeasuredError, +) from projectq.meta import Control, Dagger, LogicalQubitIDTag -from projectq.ops import (CNOT, All, Allocate, BasicGate, BasicMathGate, - Command, H, MatrixGate, Measure, QubitOperator, Rx, - Ry, Rz, S, TimeEvolution, Toffoli, X, Y, Z) +from projectq.ops import ( + CNOT, + All, + Allocate, + BasicGate, + BasicMathGate, + Command, + H, + MatrixGate, + Measure, + QubitOperator, + Rx, + Ry, + Rz, + S, + TimeEvolution, + Toffoli, + X, + Y, + Z, +) from projectq.types import WeakQubitRef @@ -724,8 +746,7 @@ def test_simulator_constant_math_emulation(): import projectq.backends._sim._simulator as _sim from projectq.backends._sim._cppsim import Simulator as CppSim from projectq.backends._sim._pysim import Simulator as PySim - from projectq.libs.math import (AddConstant, AddConstantModN, - MultiplyByConstantModN) + from projectq.libs.math import AddConstant, AddConstantModN, MultiplyByConstantModN def gate_filter(eng, cmd): g = cmd.gate diff --git a/projectq/backends/_unitary.py b/projectq/backends/_unitary.py index 436f4466..a8941b1e 100644 --- a/projectq/backends/_unitary.py +++ b/projectq/backends/_unitary.py @@ -23,10 +23,8 @@ import numpy as np from projectq.cengines import BasicEngine -from projectq.meta import (LogicalQubitIDTag, get_control_count, - has_negative_control) -from projectq.ops import (AllocateQubitGate, DeallocateQubitGate, FlushGate, - MeasureGate) +from projectq.meta import LogicalQubitIDTag, get_control_count, has_negative_control +from projectq.ops import AllocateQubitGate, DeallocateQubitGate, FlushGate, MeasureGate from projectq.types import WeakQubitRef diff --git a/projectq/backends/_unitary_test.py b/projectq/backends/_unitary_test.py index 89626fd1..4053bd41 100644 --- a/projectq/backends/_unitary_test.py +++ b/projectq/backends/_unitary_test.py @@ -24,8 +24,21 @@ from projectq.cengines import DummyEngine, MainEngine, NotYetMeasuredError from projectq.meta import Control, LogicalQubitIDTag -from projectq.ops import (CNOT, All, Allocate, BasicGate, Command, Deallocate, - H, MatrixGate, Measure, Rx, Rxx, X, Y) +from projectq.ops import ( + CNOT, + All, + Allocate, + BasicGate, + Command, + Deallocate, + H, + MatrixGate, + Measure, + Rx, + Rxx, + X, + Y, +) from projectq.types import WeakQubitRef from ._unitary import UnitarySimulator diff --git a/projectq/cengines/__init__.py b/projectq/cengines/__init__.py index 7bd34242..bb487c74 100755 --- a/projectq/cengines/__init__.py +++ b/projectq/cengines/__init__.py @@ -27,8 +27,12 @@ from ._main import MainEngine, NotYetMeasuredError, UnsupportedEngineError from ._manualmapper import ManualMapper from ._optimize import LocalOptimizer -from ._replacer import (AutoReplacer, DecompositionRule, DecompositionRuleSet, - InstructionFilter) +from ._replacer import ( + AutoReplacer, + DecompositionRule, + DecompositionRuleSet, + InstructionFilter, +) from ._swapandcnotflipper import SwapAndCNOTFlipper from ._tagremover import TagRemover from ._testengine import CompareEngine, DummyEngine diff --git a/projectq/cengines/_basicmapper_test.py b/projectq/cengines/_basicmapper_test.py index b4438a0b..2d319702 100644 --- a/projectq/cengines/_basicmapper_test.py +++ b/projectq/cengines/_basicmapper_test.py @@ -15,8 +15,7 @@ from projectq.cengines import DummyEngine, _basicmapper from projectq.meta import LogicalQubitIDTag -from projectq.ops import (Allocate, BasicGate, Command, Deallocate, FlushGate, - Measure) +from projectq.ops import Allocate, BasicGate, Command, Deallocate, FlushGate, Measure from projectq.types import WeakQubitRef diff --git a/projectq/cengines/_basics.py b/projectq/cengines/_basics.py index 7a3d902c..b1f508fc 100755 --- a/projectq/cengines/_basics.py +++ b/projectq/cengines/_basics.py @@ -105,8 +105,9 @@ def allocate_qubit(self, dirty=False): qb = Qureg([Qubit(self, new_id)]) cmd = Command(self, Allocate, (qb,)) if dirty: - from projectq.meta import \ - DirtyQubitTag # pylint: disable=import-outside-toplevel + from projectq.meta import ( + DirtyQubitTag, # pylint: disable=import-outside-toplevel + ) if self.is_meta_tag_supported(DirtyQubitTag): cmd.tags += [DirtyQubitTag()] @@ -140,8 +141,9 @@ def deallocate_qubit(self, qubit): if qubit.id == -1: raise ValueError("Already deallocated.") - from projectq.meta import \ - DirtyQubitTag # pylint: disable=import-outside-toplevel + from projectq.meta import ( + DirtyQubitTag, # pylint: disable=import-outside-toplevel + ) is_dirty = qubit.id in self.main_engine.dirty_qubits self.send( diff --git a/projectq/cengines/_basics_test.py b/projectq/cengines/_basics_test.py index 0190e82d..b521abf2 100755 --- a/projectq/cengines/_basics_test.py +++ b/projectq/cengines/_basics_test.py @@ -20,8 +20,13 @@ from projectq import MainEngine from projectq.cengines import DummyEngine, InstructionFilter, _basics from projectq.meta import DirtyQubitTag -from projectq.ops import (AllocateQubitGate, ClassicalInstructionGate, - DeallocateQubitGate, FastForwardingGate, H) +from projectq.ops import ( + AllocateQubitGate, + ClassicalInstructionGate, + DeallocateQubitGate, + FastForwardingGate, + H, +) from projectq.types import Qubit # try: diff --git a/projectq/cengines/_linearmapper.py b/projectq/cengines/_linearmapper.py index a92b9149..0e39bbf5 100644 --- a/projectq/cengines/_linearmapper.py +++ b/projectq/cengines/_linearmapper.py @@ -23,8 +23,15 @@ from copy import deepcopy from projectq.meta import LogicalQubitIDTag -from projectq.ops import (Allocate, AllocateQubitGate, Command, Deallocate, - DeallocateQubitGate, FlushGate, Swap) +from projectq.ops import ( + Allocate, + AllocateQubitGate, + Command, + Deallocate, + DeallocateQubitGate, + FlushGate, + Swap, +) from projectq.types import WeakQubitRef from ._basicmapper import BasicMapperEngine diff --git a/projectq/cengines/_linearmapper_test.py b/projectq/cengines/_linearmapper_test.py index 128ab5cc..5a5657ad 100644 --- a/projectq/cengines/_linearmapper_test.py +++ b/projectq/cengines/_linearmapper_test.py @@ -19,8 +19,16 @@ from projectq.cengines import DummyEngine from projectq.cengines import _linearmapper as lm from projectq.meta import LogicalQubitIDTag -from projectq.ops import (CNOT, QFT, Allocate, BasicGate, Command, Deallocate, - FlushGate, X) +from projectq.ops import ( + CNOT, + QFT, + Allocate, + BasicGate, + Command, + Deallocate, + FlushGate, + X, +) from projectq.types import WeakQubitRef diff --git a/projectq/cengines/_main_test.py b/projectq/cengines/_main_test.py index 9cd708a0..392fff73 100755 --- a/projectq/cengines/_main_test.py +++ b/projectq/cengines/_main_test.py @@ -18,8 +18,7 @@ import pytest from projectq.backends import Simulator -from projectq.cengines import (BasicMapperEngine, DummyEngine, LocalOptimizer, - _main) +from projectq.cengines import BasicMapperEngine, DummyEngine, LocalOptimizer, _main from projectq.ops import AllocateQubitGate, DeallocateQubitGate, FlushGate, H diff --git a/projectq/cengines/_optimize_test.py b/projectq/cengines/_optimize_test.py index e346a884..72aa4656 100755 --- a/projectq/cengines/_optimize_test.py +++ b/projectq/cengines/_optimize_test.py @@ -19,8 +19,16 @@ from projectq import MainEngine from projectq.cengines import DummyEngine, _optimize -from projectq.ops import (CNOT, AllocateQubitGate, ClassicalInstructionGate, - FastForwardingGate, H, Rx, Ry, X) +from projectq.ops import ( + CNOT, + AllocateQubitGate, + ClassicalInstructionGate, + FastForwardingGate, + H, + Rx, + Ry, + X, +) def test_local_optimizer_init_api_change(): diff --git a/projectq/cengines/_replacer/__init__.py b/projectq/cengines/_replacer/__init__.py index 7febe9a5..312e4b22 100755 --- a/projectq/cengines/_replacer/__init__.py +++ b/projectq/cengines/_replacer/__init__.py @@ -14,5 +14,4 @@ from ._decomposition_rule import DecompositionRule, ThisIsNotAGateClassError from ._decomposition_rule_set import DecompositionRuleSet -from ._replacer import (AutoReplacer, InstructionFilter, - NoGateDecompositionError) +from ._replacer import AutoReplacer, InstructionFilter, NoGateDecompositionError diff --git a/projectq/cengines/_replacer/_replacer_test.py b/projectq/cengines/_replacer/_replacer_test.py index e8e89826..b6dabffa 100755 --- a/projectq/cengines/_replacer/_replacer_test.py +++ b/projectq/cengines/_replacer/_replacer_test.py @@ -16,11 +16,18 @@ import pytest from projectq import MainEngine -from projectq.cengines import (DecompositionRule, DecompositionRuleSet, - DummyEngine) +from projectq.cengines import DecompositionRule, DecompositionRuleSet, DummyEngine from projectq.cengines._replacer import _replacer -from projectq.ops import (BasicGate, ClassicalInstructionGate, Command, H, - NotInvertible, Rx, S, X) +from projectq.ops import ( + BasicGate, + ClassicalInstructionGate, + Command, + H, + NotInvertible, + Rx, + S, + X, +) def test_filter_engine(): diff --git a/projectq/cengines/_twodmapper.py b/projectq/cengines/_twodmapper.py index 598c2098..7a54a029 100644 --- a/projectq/cengines/_twodmapper.py +++ b/projectq/cengines/_twodmapper.py @@ -27,8 +27,13 @@ import networkx as nx from projectq.meta import LogicalQubitIDTag -from projectq.ops import (AllocateQubitGate, Command, DeallocateQubitGate, - FlushGate, Swap) +from projectq.ops import ( + AllocateQubitGate, + Command, + DeallocateQubitGate, + FlushGate, + Swap, +) from projectq.types import WeakQubitRef from ._basicmapper import BasicMapperEngine diff --git a/projectq/libs/math/__init__.py b/projectq/libs/math/__init__.py index d9f38fdd..87e1eee3 100755 --- a/projectq/libs/math/__init__.py +++ b/projectq/libs/math/__init__.py @@ -15,7 +15,15 @@ """Math gate definitions.""" from ._default_rules import all_defined_decomposition_rules -from ._gates import (AddConstant, AddConstantModN, AddQuantum, - ComparatorQuantum, DivideQuantum, MultiplyByConstantModN, - MultiplyQuantum, SubConstant, SubConstantModN, - SubtractQuantum) +from ._gates import ( + AddConstant, + AddConstantModN, + AddQuantum, + ComparatorQuantum, + DivideQuantum, + MultiplyByConstantModN, + MultiplyQuantum, + SubConstant, + SubConstantModN, + SubtractQuantum, +) diff --git a/projectq/libs/math/_constantmath_test.py b/projectq/libs/math/_constantmath_test.py index f3fff046..d4ff4cf4 100755 --- a/projectq/libs/math/_constantmath_test.py +++ b/projectq/libs/math/_constantmath_test.py @@ -18,12 +18,9 @@ import projectq.libs.math from projectq import MainEngine from projectq.backends import Simulator -from projectq.cengines import (AutoReplacer, DecompositionRuleSet, - InstructionFilter) -from projectq.libs.math import (AddConstant, AddConstantModN, - MultiplyByConstantModN) -from projectq.ops import (All, BasicMathGate, ClassicalInstructionGate, - Measure, X) +from projectq.cengines import AutoReplacer, DecompositionRuleSet, InstructionFilter +from projectq.libs.math import AddConstant, AddConstantModN, MultiplyByConstantModN +from projectq.ops import All, BasicMathGate, ClassicalInstructionGate, Measure, X from projectq.setups.decompositions import qft2crandhadamard, swap2cnot diff --git a/projectq/libs/math/_default_rules.py b/projectq/libs/math/_default_rules.py index afc4ac45..7243feae 100755 --- a/projectq/libs/math/_default_rules.py +++ b/projectq/libs/math/_default_rules.py @@ -17,18 +17,32 @@ from projectq.cengines import DecompositionRule from projectq.meta import Control -from ._constantmath import (add_constant, add_constant_modN, - mul_by_constant_modN) -from ._gates import (AddConstant, AddConstantModN, AddQuantum, - ComparatorQuantum, DivideQuantum, MultiplyByConstantModN, - MultiplyQuantum, SubtractQuantum, _InverseAddQuantumGate, - _InverseDivideQuantumGate, _InverseMultiplyQuantumGate) -from ._quantummath import (add_quantum, comparator, inverse_add_quantum_carry, - inverse_quantum_division, - inverse_quantum_multiplication, - quantum_conditional_add, - quantum_conditional_add_carry, quantum_division, - quantum_multiplication, subtract_quantum) +from ._constantmath import add_constant, add_constant_modN, mul_by_constant_modN +from ._gates import ( + AddConstant, + AddConstantModN, + AddQuantum, + ComparatorQuantum, + DivideQuantum, + MultiplyByConstantModN, + MultiplyQuantum, + SubtractQuantum, + _InverseAddQuantumGate, + _InverseDivideQuantumGate, + _InverseMultiplyQuantumGate, +) +from ._quantummath import ( + add_quantum, + comparator, + inverse_add_quantum_carry, + inverse_quantum_division, + inverse_quantum_multiplication, + quantum_conditional_add, + quantum_conditional_add_carry, + quantum_division, + quantum_multiplication, + subtract_quantum, +) def _replace_addconstant(cmd): diff --git a/projectq/libs/math/_gates_math_test.py b/projectq/libs/math/_gates_math_test.py index 75bad8cf..6bf28f77 100644 --- a/projectq/libs/math/_gates_math_test.py +++ b/projectq/libs/math/_gates_math_test.py @@ -18,14 +18,24 @@ import projectq.libs.math import projectq.setups.decompositions from projectq.backends import CommandPrinter -from projectq.cengines import (AutoReplacer, DecompositionRuleSet, - InstructionFilter, MainEngine, TagRemover) +from projectq.cengines import ( + AutoReplacer, + DecompositionRuleSet, + InstructionFilter, + MainEngine, + TagRemover, +) from projectq.meta import Compute, Control, Uncompute -from projectq.ops import (All, BasicMathGate, ClassicalInstructionGate, - Measure, X) - -from . import (AddConstant, AddQuantum, ComparatorQuantum, DivideQuantum, - MultiplyQuantum, SubtractQuantum) +from projectq.ops import All, BasicMathGate, ClassicalInstructionGate, Measure, X + +from . import ( + AddConstant, + AddQuantum, + ComparatorQuantum, + DivideQuantum, + MultiplyQuantum, + SubtractQuantum, +) def print_all_probabilities(eng, qureg): diff --git a/projectq/libs/math/_gates_test.py b/projectq/libs/math/_gates_test.py index 1c26ba56..6eb9613e 100755 --- a/projectq/libs/math/_gates_test.py +++ b/projectq/libs/math/_gates_test.py @@ -13,13 +13,26 @@ # limitations under the License. """Tests for projectq.libs.math._gates.py.""" -from projectq.libs.math import (AddConstant, AddConstantModN, AddQuantum, - ComparatorQuantum, DivideQuantum, - MultiplyByConstantModN, MultiplyQuantum, - SubConstant, SubConstantModN, SubtractQuantum) - -from ._gates import (AddQuantumGate, ComparatorQuantumGate, DivideQuantumGate, - MultiplyQuantumGate, SubtractQuantumGate) +from projectq.libs.math import ( + AddConstant, + AddConstantModN, + AddQuantum, + ComparatorQuantum, + DivideQuantum, + MultiplyByConstantModN, + MultiplyQuantum, + SubConstant, + SubConstantModN, + SubtractQuantum, +) + +from ._gates import ( + AddQuantumGate, + ComparatorQuantumGate, + DivideQuantumGate, + MultiplyQuantumGate, + SubtractQuantumGate, +) def test_addconstant(): diff --git a/projectq/libs/math/_quantummath_test.py b/projectq/libs/math/_quantummath_test.py index 735dc158..d32715ca 100644 --- a/projectq/libs/math/_quantummath_test.py +++ b/projectq/libs/math/_quantummath_test.py @@ -17,13 +17,16 @@ import projectq.libs.math from projectq import MainEngine from projectq.backends import Simulator -from projectq.cengines import (AutoReplacer, DecompositionRuleSet, - InstructionFilter) -from projectq.libs.math import (AddQuantum, ComparatorQuantum, DivideQuantum, - MultiplyQuantum, SubtractQuantum) +from projectq.cengines import AutoReplacer, DecompositionRuleSet, InstructionFilter +from projectq.libs.math import ( + AddQuantum, + ComparatorQuantum, + DivideQuantum, + MultiplyQuantum, + SubtractQuantum, +) from projectq.meta import Compute, Control, Dagger, Uncompute -from projectq.ops import (All, BasicMathGate, ClassicalInstructionGate, - Measure, X) +from projectq.ops import All, BasicMathGate, ClassicalInstructionGate, Measure, X from projectq.setups.decompositions import swap2cnot diff --git a/projectq/meta/__init__.py b/projectq/meta/__init__.py index 54faab83..382148d7 100755 --- a/projectq/meta/__init__.py +++ b/projectq/meta/__init__.py @@ -22,10 +22,13 @@ * Dagger (with Dagger(eng): ...) """ -from ._compute import (Compute, ComputeTag, CustomUncompute, Uncompute, - UncomputeTag) -from ._control import (Control, canonical_ctrl_state, get_control_count, - has_negative_control) +from ._compute import Compute, ComputeTag, CustomUncompute, Uncompute, UncomputeTag +from ._control import ( + Control, + canonical_ctrl_state, + get_control_count, + has_negative_control, +) from ._dagger import Dagger from ._dirtyqubit import DirtyQubitTag from ._logicalqubit import LogicalQubitIDTag diff --git a/projectq/meta/_control_test.py b/projectq/meta/_control_test.py index 7e95d50e..73810b95 100755 --- a/projectq/meta/_control_test.py +++ b/projectq/meta/_control_test.py @@ -16,8 +16,14 @@ from projectq import MainEngine from projectq.cengines import DummyEngine -from projectq.meta import (Compute, ComputeTag, DirtyQubitTag, Uncompute, - UncomputeTag, _control) +from projectq.meta import ( + Compute, + ComputeTag, + DirtyQubitTag, + Uncompute, + UncomputeTag, + _control, +) from projectq.ops import Command, CtrlAll, H, IncompatibleControlState, Rx, X from projectq.types import WeakQubitRef diff --git a/projectq/ops/__init__.py b/projectq/ops/__init__.py index 90312f0f..2a931b61 100755 --- a/projectq/ops/__init__.py +++ b/projectq/ops/__init__.py @@ -14,14 +14,29 @@ """ProjectQ module containing all basic gates (operations).""" -from ._basics import (BasicGate, BasicMathGate, BasicPhaseGate, - BasicRotationGate, ClassicalInstructionGate, - FastForwardingGate, MatrixGate, NotInvertible, - NotMergeable, SelfInverseGate) +from ._basics import ( + BasicGate, + BasicMathGate, + BasicPhaseGate, + BasicRotationGate, + ClassicalInstructionGate, + FastForwardingGate, + MatrixGate, + NotInvertible, + NotMergeable, + SelfInverseGate, +) from ._command import Command, CtrlAll, IncompatibleControlState, apply_command from ._gates import * -from ._metagates import (All, C, ControlledGate, DaggeredGate, Tensor, - get_inverse, is_identity) +from ._metagates import ( + All, + C, + ControlledGate, + DaggeredGate, + Tensor, + get_inverse, + is_identity, +) from ._qaagate import QAA from ._qftgate import QFT, QFTGate from ._qpegate import QPE @@ -29,5 +44,4 @@ from ._shortcuts import * from ._state_prep import StatePreparation from ._time_evolution import TimeEvolution -from ._uniformly_controlled_rotation import (UniformlyControlledRy, - UniformlyControlledRz) +from ._uniformly_controlled_rotation import UniformlyControlledRy, UniformlyControlledRz diff --git a/projectq/ops/_command.py b/projectq/ops/_command.py index 4cd17f09..0e69afe7 100755 --- a/projectq/ops/_command.py +++ b/projectq/ops/_command.py @@ -245,8 +245,9 @@ def control_state(self, state): state (int,str,projectq.meta.CtrtAll): state of control qubit (ie. positive or negative) """ # NB: avoid circular imports - from projectq.meta import \ - canonical_ctrl_state # pylint: disable=import-outside-toplevel + from projectq.meta import ( + canonical_ctrl_state, # pylint: disable=import-outside-toplevel + ) self._control_state = canonical_ctrl_state(state, len(self._control_qubits)) @@ -264,8 +265,9 @@ def add_control_qubits(self, qubits, state=CtrlAll.One): control qubits. """ # NB: avoid circular imports - from projectq.meta import \ - canonical_ctrl_state # pylint: disable=import-outside-toplevel + from projectq.meta import ( + canonical_ctrl_state, # pylint: disable=import-outside-toplevel + ) if not isinstance(qubits, list): raise ValueError('Control qubits must be a list of qubits!') diff --git a/projectq/ops/_gates.py b/projectq/ops/_gates.py index 9a178d54..10527a86 100755 --- a/projectq/ops/_gates.py +++ b/projectq/ops/_gates.py @@ -47,9 +47,14 @@ import numpy as np -from ._basics import (BasicGate, BasicPhaseGate, BasicRotationGate, - ClassicalInstructionGate, FastForwardingGate, - SelfInverseGate) +from ._basics import ( + BasicGate, + BasicPhaseGate, + BasicRotationGate, + ClassicalInstructionGate, + FastForwardingGate, + SelfInverseGate, +) from ._command import apply_command from ._metagates import get_inverse diff --git a/projectq/ops/_metagates_test.py b/projectq/ops/_metagates_test.py index 516ca7a6..cacd1fb8 100755 --- a/projectq/ops/_metagates_test.py +++ b/projectq/ops/_metagates_test.py @@ -21,9 +21,19 @@ from projectq import MainEngine from projectq.cengines import DummyEngine -from projectq.ops import (All, C, ClassicalInstructionGate, Command, Entangle, - FastForwardingGate, NotInvertible, Rx, T, Y, - _metagates) +from projectq.ops import ( + All, + C, + ClassicalInstructionGate, + Command, + Entangle, + FastForwardingGate, + NotInvertible, + Rx, + T, + Y, + _metagates, +) from projectq.types import Qubit, WeakQubitRef diff --git a/projectq/setups/_utils.py b/projectq/setups/_utils.py index b179f52d..20c531ab 100644 --- a/projectq/setups/_utils.py +++ b/projectq/setups/_utils.py @@ -18,10 +18,22 @@ import projectq.libs.math import projectq.setups.decompositions -from projectq.cengines import (AutoReplacer, DecompositionRuleSet, - InstructionFilter, LocalOptimizer, TagRemover) -from projectq.ops import (CNOT, QFT, BasicMathGate, ClassicalInstructionGate, - ControlledGate, Swap, get_inverse) +from projectq.cengines import ( + AutoReplacer, + DecompositionRuleSet, + InstructionFilter, + LocalOptimizer, + TagRemover, +) +from projectq.ops import ( + CNOT, + QFT, + BasicMathGate, + ClassicalInstructionGate, + ControlledGate, + Swap, + get_inverse, +) def one_and_two_qubit_gates(eng, cmd): # pylint: disable=unused-argument diff --git a/projectq/setups/aqt.py b/projectq/setups/aqt.py index 1427be4e..96465842 100644 --- a/projectq/setups/aqt.py +++ b/projectq/setups/aqt.py @@ -26,8 +26,7 @@ """ from projectq.backends._aqt._aqt_http_client import show_devices -from projectq.backends._exceptions import (DeviceNotHandledError, - DeviceOfflineError) +from projectq.backends._exceptions import DeviceNotHandledError, DeviceOfflineError from projectq.cengines import BasicMapperEngine from projectq.ops import Barrier, Rx, Rxx, Ry from projectq.setups import restrictedgateset diff --git a/projectq/setups/awsbraket.py b/projectq/setups/awsbraket.py index 82578508..46247ca9 100644 --- a/projectq/setups/awsbraket.py +++ b/projectq/setups/awsbraket.py @@ -26,10 +26,24 @@ """ from projectq.backends._awsbraket._awsbraket_boto3_client import show_devices -from projectq.backends._exceptions import (DeviceNotHandledError, - DeviceOfflineError) -from projectq.ops import (Barrier, H, R, Rx, Ry, Rz, S, Sdag, SqrtX, Swap, T, - Tdag, X, Y, Z) +from projectq.backends._exceptions import DeviceNotHandledError, DeviceOfflineError +from projectq.ops import ( + Barrier, + H, + R, + Rx, + Ry, + Rz, + S, + Sdag, + SqrtX, + Swap, + T, + Tdag, + X, + Y, + Z, +) from projectq.setups import restrictedgateset diff --git a/projectq/setups/decompositions/__init__.py b/projectq/setups/decompositions/__init__.py index 5b0c4267..f377093a 100755 --- a/projectq/setups/decompositions/__init__.py +++ b/projectq/setups/decompositions/__init__.py @@ -14,12 +14,34 @@ """ProjectQ's decomposition rules.""" -from . import (amplitudeamplification, arb1qubit2rzandry, barrier, - carb1qubit2cnotrzandry, cnot2cz, cnot2rxx, cnu2toffoliandcu, - controlstate, crz2cxandrz, entangle, globalphase, h2rx, ph2r, - phaseestimation, qft2crandhadamard, qubitop2onequbit, r2rzandph, - rx2rz, ry2rz, rz2rx, sqrtswap2cnot, stateprep2cnot, swap2cnot, - time_evolution, toffoli2cnotandtgate, uniformlycontrolledr2cnot) +from . import ( + amplitudeamplification, + arb1qubit2rzandry, + barrier, + carb1qubit2cnotrzandry, + cnot2cz, + cnot2rxx, + cnu2toffoliandcu, + controlstate, + crz2cxandrz, + entangle, + globalphase, + h2rx, + ph2r, + phaseestimation, + qft2crandhadamard, + qubitop2onequbit, + r2rzandph, + rx2rz, + ry2rz, + rz2rx, + sqrtswap2cnot, + stateprep2cnot, + swap2cnot, + time_evolution, + toffoli2cnotandtgate, + uniformlycontrolledr2cnot, +) all_defined_decomposition_rules = [ rule diff --git a/projectq/setups/decompositions/_gates_test.py b/projectq/setups/decompositions/_gates_test.py index 3cd9e4b2..12c05cdc 100755 --- a/projectq/setups/decompositions/_gates_test.py +++ b/projectq/setups/decompositions/_gates_test.py @@ -18,14 +18,37 @@ import pytest from projectq.backends import Simulator -from projectq.cengines import (AutoReplacer, DecompositionRuleSet, DummyEngine, - InstructionFilter, MainEngine) +from projectq.cengines import ( + AutoReplacer, + DecompositionRuleSet, + DummyEngine, + InstructionFilter, + MainEngine, +) from projectq.meta import Control -from projectq.ops import (All, ClassicalInstructionGate, CRz, Entangle, H, - Measure, Ph, R, Rz, T, Tdag, Toffoli, X) -from projectq.setups.decompositions import (crz2cxandrz, entangle, globalphase, - ph2r, r2rzandph, - toffoli2cnotandtgate) +from projectq.ops import ( + All, + ClassicalInstructionGate, + CRz, + Entangle, + H, + Measure, + Ph, + R, + Rz, + T, + Tdag, + Toffoli, + X, +) +from projectq.setups.decompositions import ( + crz2cxandrz, + entangle, + globalphase, + ph2r, + r2rzandph, + toffoli2cnotandtgate, +) def low_level_gates(eng, cmd): diff --git a/projectq/setups/decompositions/arb1qubit2rzandry_test.py b/projectq/setups/decompositions/arb1qubit2rzandry_test.py index eb86d43b..452e4d9c 100644 --- a/projectq/setups/decompositions/arb1qubit2rzandry_test.py +++ b/projectq/setups/decompositions/arb1qubit2rzandry_test.py @@ -21,11 +21,26 @@ import pytest from projectq.backends import Simulator -from projectq.cengines import (AutoReplacer, DecompositionRuleSet, DummyEngine, - InstructionFilter, MainEngine) +from projectq.cengines import ( + AutoReplacer, + DecompositionRuleSet, + DummyEngine, + InstructionFilter, + MainEngine, +) from projectq.meta import Control -from projectq.ops import (BasicGate, ClassicalInstructionGate, MatrixGate, - Measure, Ph, R, Rx, Ry, Rz, X) +from projectq.ops import ( + BasicGate, + ClassicalInstructionGate, + MatrixGate, + Measure, + Ph, + R, + Rx, + Ry, + Rz, + X, +) from . import arb1qubit2rzandry as arb1q diff --git a/projectq/setups/decompositions/carb1qubit2cnotrzandry_test.py b/projectq/setups/decompositions/carb1qubit2cnotrzandry_test.py index ccce1428..f402f702 100644 --- a/projectq/setups/decompositions/carb1qubit2cnotrzandry_test.py +++ b/projectq/setups/decompositions/carb1qubit2cnotrzandry_test.py @@ -18,11 +18,28 @@ import pytest from projectq.backends import Simulator -from projectq.cengines import (AutoReplacer, DecompositionRuleSet, DummyEngine, - InstructionFilter, MainEngine) +from projectq.cengines import ( + AutoReplacer, + DecompositionRuleSet, + DummyEngine, + InstructionFilter, + MainEngine, +) from projectq.meta import Control -from projectq.ops import (All, BasicGate, ClassicalInstructionGate, MatrixGate, - Measure, Ph, R, Rx, Ry, Rz, X, XGate) +from projectq.ops import ( + All, + BasicGate, + ClassicalInstructionGate, + MatrixGate, + Measure, + Ph, + R, + Rx, + Ry, + Rz, + X, + XGate, +) from projectq.setups.decompositions import arb1qubit2rzandry_test as arb1q_t from . import carb1qubit2cnotrzandry as carb1q diff --git a/projectq/setups/decompositions/cnot2cz_test.py b/projectq/setups/decompositions/cnot2cz_test.py index e3da2dba..6738f048 100644 --- a/projectq/setups/decompositions/cnot2cz_test.py +++ b/projectq/setups/decompositions/cnot2cz_test.py @@ -18,8 +18,12 @@ from projectq import MainEngine from projectq.backends import Simulator -from projectq.cengines import (AutoReplacer, DecompositionRuleSet, DummyEngine, - InstructionFilter) +from projectq.cengines import ( + AutoReplacer, + DecompositionRuleSet, + DummyEngine, + InstructionFilter, +) from projectq.meta import Control from projectq.ops import CNOT, CZ, All, Measure, X, Z from projectq.setups.decompositions import cnot2cz diff --git a/projectq/setups/decompositions/cnot2rxx_test.py b/projectq/setups/decompositions/cnot2rxx_test.py index 00c2d6c7..e131ab92 100644 --- a/projectq/setups/decompositions/cnot2rxx_test.py +++ b/projectq/setups/decompositions/cnot2rxx_test.py @@ -18,8 +18,12 @@ from projectq import MainEngine from projectq.backends import Simulator -from projectq.cengines import (AutoReplacer, DecompositionRuleSet, DummyEngine, - InstructionFilter) +from projectq.cengines import ( + AutoReplacer, + DecompositionRuleSet, + DummyEngine, + InstructionFilter, +) from projectq.meta import Control from projectq.ops import CNOT, CZ, All, Measure, X, Z diff --git a/projectq/setups/decompositions/cnu2toffoliandcu_test.py b/projectq/setups/decompositions/cnu2toffoliandcu_test.py index a7efe862..b64203bf 100644 --- a/projectq/setups/decompositions/cnu2toffoliandcu_test.py +++ b/projectq/setups/decompositions/cnu2toffoliandcu_test.py @@ -17,11 +17,25 @@ import pytest from projectq.backends import Simulator -from projectq.cengines import (AutoReplacer, DecompositionRuleSet, DummyEngine, - InstructionFilter, MainEngine) +from projectq.cengines import ( + AutoReplacer, + DecompositionRuleSet, + DummyEngine, + InstructionFilter, + MainEngine, +) from projectq.meta import Control -from projectq.ops import (QFT, All, ClassicalInstructionGate, Measure, Ph, Rx, - Ry, X, XGate) +from projectq.ops import ( + QFT, + All, + ClassicalInstructionGate, + Measure, + Ph, + Rx, + Ry, + X, + XGate, +) from . import cnu2toffoliandcu diff --git a/projectq/setups/decompositions/controlstate_test.py b/projectq/setups/decompositions/controlstate_test.py index 0c55331f..02512e5e 100755 --- a/projectq/setups/decompositions/controlstate_test.py +++ b/projectq/setups/decompositions/controlstate_test.py @@ -17,8 +17,12 @@ """ from projectq import MainEngine -from projectq.cengines import (AutoReplacer, DecompositionRuleSet, DummyEngine, - InstructionFilter) +from projectq.cengines import ( + AutoReplacer, + DecompositionRuleSet, + DummyEngine, + InstructionFilter, +) from projectq.meta import Control, has_negative_control from projectq.ops import X from projectq.setups.decompositions import cnot2cz, controlstate diff --git a/projectq/setups/decompositions/h2rx_test.py b/projectq/setups/decompositions/h2rx_test.py index 77107f9f..fb3d2045 100644 --- a/projectq/setups/decompositions/h2rx_test.py +++ b/projectq/setups/decompositions/h2rx_test.py @@ -18,8 +18,12 @@ from projectq import MainEngine from projectq.backends import Simulator -from projectq.cengines import (AutoReplacer, DecompositionRuleSet, DummyEngine, - InstructionFilter) +from projectq.cengines import ( + AutoReplacer, + DecompositionRuleSet, + DummyEngine, + InstructionFilter, +) from projectq.meta import Control from projectq.ops import H, HGate, Measure diff --git a/projectq/setups/decompositions/phaseestimation_test.py b/projectq/setups/decompositions/phaseestimation_test.py index 250fa53f..08e33e58 100644 --- a/projectq/setups/decompositions/phaseestimation_test.py +++ b/projectq/setups/decompositions/phaseestimation_test.py @@ -24,8 +24,7 @@ import projectq.setups.decompositions.uniformlycontrolledr2cnot as ucr2cnot from projectq.backends import Simulator from projectq.cengines import AutoReplacer, DecompositionRuleSet, MainEngine -from projectq.ops import (CNOT, QPE, All, H, Measure, Ph, StatePreparation, - Tensor, X) +from projectq.ops import CNOT, QPE, All, H, Measure, Ph, StatePreparation, Tensor, X from projectq.setups.decompositions import phaseestimation as pe from projectq.setups.decompositions import qft2crandhadamard as dqft diff --git a/projectq/setups/decompositions/qubitop2onequbit_test.py b/projectq/setups/decompositions/qubitop2onequbit_test.py index c44f4f2b..ed124c96 100644 --- a/projectq/setups/decompositions/qubitop2onequbit_test.py +++ b/projectq/setups/decompositions/qubitop2onequbit_test.py @@ -19,8 +19,12 @@ import projectq.setups.decompositions.qubitop2onequbit as qubitop2onequbit from projectq import MainEngine from projectq.backends import Simulator -from projectq.cengines import (AutoReplacer, DecompositionRuleSet, DummyEngine, - InstructionFilter) +from projectq.cengines import ( + AutoReplacer, + DecompositionRuleSet, + DummyEngine, + InstructionFilter, +) from projectq.meta import Control from projectq.ops import All, Command, Measure, Ph, QubitOperator, X, Y, Z from projectq.types import WeakQubitRef diff --git a/projectq/setups/decompositions/rx2rz_test.py b/projectq/setups/decompositions/rx2rz_test.py index 7eb00875..767c805a 100644 --- a/projectq/setups/decompositions/rx2rz_test.py +++ b/projectq/setups/decompositions/rx2rz_test.py @@ -19,8 +19,13 @@ import pytest from projectq.backends import Simulator -from projectq.cengines import (AutoReplacer, DecompositionRuleSet, DummyEngine, - InstructionFilter, MainEngine) +from projectq.cengines import ( + AutoReplacer, + DecompositionRuleSet, + DummyEngine, + InstructionFilter, + MainEngine, +) from projectq.meta import Control from projectq.ops import Measure, Rx diff --git a/projectq/setups/decompositions/ry2rz_test.py b/projectq/setups/decompositions/ry2rz_test.py index e284ee47..61f9e1cf 100644 --- a/projectq/setups/decompositions/ry2rz_test.py +++ b/projectq/setups/decompositions/ry2rz_test.py @@ -19,8 +19,13 @@ import pytest from projectq.backends import Simulator -from projectq.cengines import (AutoReplacer, DecompositionRuleSet, DummyEngine, - InstructionFilter, MainEngine) +from projectq.cengines import ( + AutoReplacer, + DecompositionRuleSet, + DummyEngine, + InstructionFilter, + MainEngine, +) from projectq.meta import Control from projectq.ops import Measure, Ry diff --git a/projectq/setups/decompositions/rz2rx_test.py b/projectq/setups/decompositions/rz2rx_test.py index 57d1904b..7418c5a1 100644 --- a/projectq/setups/decompositions/rz2rx_test.py +++ b/projectq/setups/decompositions/rz2rx_test.py @@ -21,8 +21,12 @@ from projectq import MainEngine from projectq.backends import Simulator -from projectq.cengines import (AutoReplacer, DecompositionRuleSet, DummyEngine, - InstructionFilter) +from projectq.cengines import ( + AutoReplacer, + DecompositionRuleSet, + DummyEngine, + InstructionFilter, +) from projectq.meta import Control from projectq.ops import Measure, Rz diff --git a/projectq/setups/decompositions/sqrtswap2cnot_test.py b/projectq/setups/decompositions/sqrtswap2cnot_test.py index 90aa23bd..2e920a70 100644 --- a/projectq/setups/decompositions/sqrtswap2cnot_test.py +++ b/projectq/setups/decompositions/sqrtswap2cnot_test.py @@ -18,8 +18,12 @@ import projectq.setups.decompositions.sqrtswap2cnot as sqrtswap2cnot from projectq import MainEngine from projectq.backends import Simulator -from projectq.cengines import (AutoReplacer, DecompositionRuleSet, DummyEngine, - InstructionFilter) +from projectq.cengines import ( + AutoReplacer, + DecompositionRuleSet, + DummyEngine, + InstructionFilter, +) from projectq.ops import All, Command, Measure, SqrtSwap from projectq.types import WeakQubitRef diff --git a/projectq/setups/decompositions/stateprep2cnot.py b/projectq/setups/decompositions/stateprep2cnot.py index 7a0e83d0..80e399ac 100644 --- a/projectq/setups/decompositions/stateprep2cnot.py +++ b/projectq/setups/decompositions/stateprep2cnot.py @@ -19,8 +19,12 @@ from projectq.cengines import DecompositionRule from projectq.meta import Control, Dagger -from projectq.ops import (Ph, StatePreparation, UniformlyControlledRy, - UniformlyControlledRz) +from projectq.ops import ( + Ph, + StatePreparation, + UniformlyControlledRy, + UniformlyControlledRz, +) def _decompose_state_preparation(cmd): # pylint: disable=too-many-locals diff --git a/projectq/setups/decompositions/time_evolution_test.py b/projectq/setups/decompositions/time_evolution_test.py index d711c860..8d0197a5 100644 --- a/projectq/setups/decompositions/time_evolution_test.py +++ b/projectq/setups/decompositions/time_evolution_test.py @@ -23,11 +23,24 @@ from projectq import MainEngine from projectq.backends import Simulator -from projectq.cengines import (AutoReplacer, DecompositionRuleSet, DummyEngine, - InstructionFilter) +from projectq.cengines import ( + AutoReplacer, + DecompositionRuleSet, + DummyEngine, + InstructionFilter, +) from projectq.meta import Control -from projectq.ops import (All, ClassicalInstructionGate, Command, Measure, Ph, - QubitOperator, Rx, Ry, TimeEvolution) +from projectq.ops import ( + All, + ClassicalInstructionGate, + Command, + Measure, + Ph, + QubitOperator, + Rx, + Ry, + TimeEvolution, +) from projectq.types import WeakQubitRef from . import time_evolution as te diff --git a/projectq/setups/decompositions/uniformlycontrolledr2cnot.py b/projectq/setups/decompositions/uniformlycontrolledr2cnot.py index 6d3c5042..e865e939 100644 --- a/projectq/setups/decompositions/uniformlycontrolledr2cnot.py +++ b/projectq/setups/decompositions/uniformlycontrolledr2cnot.py @@ -16,8 +16,7 @@ from projectq.cengines import DecompositionRule from projectq.meta import Compute, Control, CustomUncompute -from projectq.ops import (CNOT, Ry, Rz, UniformlyControlledRy, - UniformlyControlledRz) +from projectq.ops import CNOT, Ry, Rz, UniformlyControlledRy, UniformlyControlledRz def _apply_ucr_n( diff --git a/projectq/setups/decompositions/uniformlycontrolledr2cnot_test.py b/projectq/setups/decompositions/uniformlycontrolledr2cnot_test.py index e501e87d..08564ecd 100644 --- a/projectq/setups/decompositions/uniformlycontrolledr2cnot_test.py +++ b/projectq/setups/decompositions/uniformlycontrolledr2cnot_test.py @@ -18,11 +18,22 @@ import projectq.setups.decompositions.uniformlycontrolledr2cnot as ucr2cnot from projectq import MainEngine from projectq.backends import Simulator -from projectq.cengines import (AutoReplacer, DecompositionRuleSet, DummyEngine, - InstructionFilter) +from projectq.cengines import ( + AutoReplacer, + DecompositionRuleSet, + DummyEngine, + InstructionFilter, +) from projectq.meta import Compute, Control, Uncompute -from projectq.ops import (All, Measure, Ry, Rz, UniformlyControlledRy, - UniformlyControlledRz, X) +from projectq.ops import ( + All, + Measure, + Ry, + Rz, + UniformlyControlledRy, + UniformlyControlledRz, + X, +) def slow_implementation(angles, control_qubits, target_qubit, eng, gate_class): diff --git a/projectq/setups/default.py b/projectq/setups/default.py index a204782e..109f9c10 100755 --- a/projectq/setups/default.py +++ b/projectq/setups/default.py @@ -21,8 +21,12 @@ import projectq import projectq.setups.decompositions -from projectq.cengines import (AutoReplacer, DecompositionRuleSet, - LocalOptimizer, TagRemover) +from projectq.cengines import ( + AutoReplacer, + DecompositionRuleSet, + LocalOptimizer, + TagRemover, +) def get_engine_list(): diff --git a/projectq/setups/ibm.py b/projectq/setups/ibm.py index a6cea2f2..122febaa 100755 --- a/projectq/setups/ibm.py +++ b/projectq/setups/ibm.py @@ -25,11 +25,15 @@ set. """ -from projectq.backends._exceptions import (DeviceNotHandledError, - DeviceOfflineError) +from projectq.backends._exceptions import DeviceNotHandledError, DeviceOfflineError from projectq.backends._ibm._ibm_http_client import show_devices -from projectq.cengines import (BasicMapperEngine, GridMapper, IBM5QubitMapper, - LocalOptimizer, SwapAndCNOTFlipper) +from projectq.cengines import ( + BasicMapperEngine, + GridMapper, + IBM5QubitMapper, + LocalOptimizer, + SwapAndCNOTFlipper, +) from projectq.ops import CNOT, Barrier, H, Rx, Ry, Rz from projectq.setups import restrictedgateset diff --git a/projectq/setups/ionq.py b/projectq/setups/ionq.py index 1ceddd66..3c451048 100644 --- a/projectq/setups/ionq.py +++ b/projectq/setups/ionq.py @@ -22,8 +22,25 @@ from projectq.backends._exceptions import DeviceOfflineError from projectq.backends._ionq._ionq_http_client import IonQ from projectq.backends._ionq._ionq_mapper import BoundedQubitMapper -from projectq.ops import (Barrier, H, Rx, Rxx, Ry, Ryy, Rz, Rzz, S, Sdag, - SqrtX, Swap, T, Tdag, X, Y, Z) +from projectq.ops import ( + Barrier, + H, + Rx, + Rxx, + Ry, + Ryy, + Rz, + Rzz, + S, + Sdag, + SqrtX, + Swap, + T, + Tdag, + X, + Y, + Z, +) from projectq.setups import restrictedgateset diff --git a/projectq/setups/restrictedgateset.py b/projectq/setups/restrictedgateset.py index e660a8e3..202bb990 100644 --- a/projectq/setups/restrictedgateset.py +++ b/projectq/setups/restrictedgateset.py @@ -24,10 +24,14 @@ import projectq import projectq.libs.math import projectq.setups.decompositions -from projectq.cengines import (AutoReplacer, DecompositionRuleSet, - InstructionFilter, LocalOptimizer, TagRemover) -from projectq.ops import (CNOT, BasicGate, ClassicalInstructionGate, - ControlledGate) +from projectq.cengines import ( + AutoReplacer, + DecompositionRuleSet, + InstructionFilter, + LocalOptimizer, + TagRemover, +) +from projectq.ops import CNOT, BasicGate, ClassicalInstructionGate, ControlledGate from ._utils import high_level_gates, one_and_two_qubit_gates diff --git a/projectq/setups/restrictedgateset_test.py b/projectq/setups/restrictedgateset_test.py index 3aaaf57d..92144bde 100644 --- a/projectq/setups/restrictedgateset_test.py +++ b/projectq/setups/restrictedgateset_test.py @@ -18,11 +18,23 @@ import projectq import projectq.setups.restrictedgateset as restrictedgateset from projectq.cengines import DummyEngine -from projectq.libs.math import (AddConstant, AddConstantModN, - MultiplyByConstantModN) +from projectq.libs.math import AddConstant, AddConstantModN, MultiplyByConstantModN from projectq.meta import Control -from projectq.ops import (CNOT, QFT, BasicGate, CRz, H, Measure, QubitOperator, - Rx, Rz, Swap, TimeEvolution, Toffoli, X) +from projectq.ops import ( + CNOT, + QFT, + BasicGate, + CRz, + H, + Measure, + QubitOperator, + Rx, + Rz, + Swap, + TimeEvolution, + Toffoli, + X, +) def test_parameter_any(): diff --git a/projectq/setups/trapped_ion_decomposer_test.py b/projectq/setups/trapped_ion_decomposer_test.py index 5f9c8ad7..8670ef1e 100644 --- a/projectq/setups/trapped_ion_decomposer_test.py +++ b/projectq/setups/trapped_ion_decomposer_test.py @@ -15,12 +15,17 @@ "Tests for projectq.setups.trapped_ion_decomposer.py." import projectq -from projectq.cengines import (AutoReplacer, DecompositionRule, - DecompositionRuleSet, DummyEngine, - InstructionFilter, MainEngine, TagRemover) +from projectq.cengines import ( + AutoReplacer, + DecompositionRule, + DecompositionRuleSet, + DummyEngine, + InstructionFilter, + MainEngine, + TagRemover, +) from projectq.meta import get_control_count -from projectq.ops import (CNOT, ClassicalInstructionGate, H, Measure, Rx, Rxx, - Ry, Rz, X) +from projectq.ops import CNOT, ClassicalInstructionGate, H, Measure, Rx, Rxx, Ry, Rz, X from . import restrictedgateset from .trapped_ion_decomposer import chooser_Ry_reducer, get_engine_list diff --git a/projectq/tests/_factoring_test.py b/projectq/tests/_factoring_test.py index 45446443..541c1492 100755 --- a/projectq/tests/_factoring_test.py +++ b/projectq/tests/_factoring_test.py @@ -17,13 +17,17 @@ import projectq.libs.math import projectq.setups.decompositions from projectq.backends._sim._simulator_test import sim -from projectq.cengines import (AutoReplacer, DecompositionRuleSet, - InstructionFilter, LocalOptimizer, MainEngine, - TagRemover) +from projectq.cengines import ( + AutoReplacer, + DecompositionRuleSet, + InstructionFilter, + LocalOptimizer, + MainEngine, + TagRemover, +) from projectq.libs.math import MultiplyByConstantModN from projectq.meta import Control -from projectq.ops import (QFT, All, BasicMathGate, H, Measure, Swap, X, - get_inverse) +from projectq.ops import QFT, All, BasicMathGate, H, Measure, Swap, X, get_inverse rule_set = DecompositionRuleSet(modules=(projectq.libs.math, projectq.setups.decompositions)) diff --git a/setup.py b/setup.py index 45f12349..5605d3e0 100755 --- a/setup.py +++ b/setup.py @@ -46,8 +46,13 @@ import sys import tempfile from distutils.cmd import Command -from distutils.errors import (CCompilerError, CompileError, DistutilsExecError, - DistutilsPlatformError, LinkError) +from distutils.errors import ( + CCompilerError, + CompileError, + DistutilsExecError, + DistutilsPlatformError, + LinkError, +) from distutils.spawn import find_executable, spawn from operator import itemgetter from pathlib import Path