From 8213b67eaaf6229303e4575bdee1b44848ded01a Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 20 Dec 2022 00:00:51 +0000 Subject: [PATCH 1/3] [pre-commit.ci] pre-commit autoupdate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/pre-commit/pre-commit-hooks: v4.3.0 → v4.4.0](https://github.com/pre-commit/pre-commit-hooks/compare/v4.3.0...v4.4.0) - [github.com/PyCQA/docformatter: v1.5.0 → v1.5.1](https://github.com/PyCQA/docformatter/compare/v1.5.0...v1.5.1) - [github.com/pre-commit/mirrors-autopep8: v1.7.0 → v2.0.1](https://github.com/pre-commit/mirrors-autopep8/compare/v1.7.0...v2.0.1) - [github.com/asottile/pyupgrade: v3.1.0 → v3.3.1](https://github.com/asottile/pyupgrade/compare/v3.1.0...v3.3.1) - [github.com/asottile/add-trailing-comma: v2.3.0 → v2.4.0](https://github.com/asottile/add-trailing-comma/compare/v2.3.0...v2.4.0) - [github.com/PyCQA/autoflake: v1.7.7 → v2.0.0](https://github.com/PyCQA/autoflake/compare/v1.7.7...v2.0.0) - [github.com/pre-commit/mirrors-mypy: v0.982 → v0.991](https://github.com/pre-commit/mirrors-mypy/compare/v0.982...v0.991) - [github.com/PyCQA/flake8: 5.0.4 → 6.0.0](https://github.com/PyCQA/flake8/compare/5.0.4...6.0.0) --- .pre-commit-config.yaml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index afcc0fcee..0ebb00edf 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -2,7 +2,7 @@ ci: skip: [mypy] repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.3.0 + rev: v4.4.0 hooks: - id: trailing-whitespace - id: end-of-file-fixer @@ -24,7 +24,7 @@ repos: - id: no-commit-to-branch args: [--branch, master] - repo: https://github.com/PyCQA/docformatter - rev: v1.5.0 + rev: v1.5.1 hooks: - id: docformatter args: @@ -33,7 +33,7 @@ repos: - --wrap-summaries=80 - --wrap-descriptions=80 - repo: https://github.com/pre-commit/mirrors-autopep8 - rev: v1.7.0 + rev: v2.0.1 hooks: - id: autopep8 args: @@ -41,7 +41,7 @@ repos: - --max-line-length=80 - --ignore=E731 - repo: https://github.com/asottile/pyupgrade - rev: v3.1.0 + rev: v3.3.1 hooks: - id: pyupgrade args: @@ -55,7 +55,7 @@ repos: - from __future__ import annotations - --py37-plus - repo: https://github.com/asottile/add-trailing-comma - rev: v2.3.0 + rev: v2.4.0 hooks: - id: add-trailing-comma args: @@ -65,19 +65,19 @@ repos: hooks: - id: setup-cfg-fmt - repo: https://github.com/PyCQA/autoflake - rev: v1.7.7 + rev: v2.0.0 hooks: - id: autoflake args: - --in-place - repo: https://github.com/pre-commit/mirrors-mypy - rev: v0.982 + rev: v0.991 hooks: - id: mypy exclude: tests/qis/test_pauli.py additional_dependencies: ["numpy>=1.21"] - repo: https://github.com/PyCQA/flake8 - rev: 5.0.4 + rev: 6.0.0 hooks: - id: flake8 args: From c710bd54c7c4fc81d2fd7508b5806f4111a067c7 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 20 Dec 2022 00:01:23 +0000 Subject: [PATCH 2/3] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- bqskit/ext/rigetti.py | 4 ++-- bqskit/ir/circuit.py | 20 ++++++++++---------- bqskit/ir/opt/multistartgen.py | 1 - tests/ext/test_cirq.py | 1 - tests/ext/test_pytket.py | 1 - tests/ext/test_qiskit.py | 1 - tests/ext/test_qutip.py | 1 - tests/ir/circuit/test_point_methods.py | 3 --- tests/ir/gates/parameterized/test_unitary.py | 2 -- tests/ir/gates/test_circuitgate.py | 1 - tests/ir/lang/test_qasm_decode.py | 1 - tests/ir/opt/instantiaters/test_qfactor.py | 1 - tests/ir/test_gate.py | 1 - tests/ir/test_interval.py | 6 ------ tests/ir/test_iterator.py | 1 - tests/ir/test_location.py | 3 --- tests/ir/test_operation.py | 1 - tests/ir/test_point.py | 3 --- tests/ir/test_region.py | 7 ------- tests/passes/partitioning/test_cluster.py | 1 - tests/passes/partitioning/test_greedy.py | 1 - tests/passes/partitioning/test_quick.py | 1 - tests/passes/partitioning/test_scan.py | 1 - tests/passes/processing/test_substitute.py | 1 - tests/passes/synthesis/test_leap.py | 1 - tests/passes/synthesis/test_qfast.py | 1 - tests/passes/synthesis/test_qpredict.py | 1 - tests/passes/synthesis/test_qsearch.py | 1 - tests/qis/state/test_state.py | 2 -- tests/qis/test_graph.py | 2 -- tests/qis/test_pauli.py | 4 ---- tests/qis/unitary/test_meta.py | 2 -- tests/qis/unitary/test_unitarybuilder.py | 4 ---- tests/qis/unitary/test_unitarymatrix.py | 6 ------ tests/utils/test_math.py | 4 ---- 35 files changed, 12 insertions(+), 80 deletions(-) diff --git a/bqskit/ext/rigetti.py b/bqskit/ext/rigetti.py index 0c0be1b94..1db32b9ef 100644 --- a/bqskit/ext/rigetti.py +++ b/bqskit/ext/rigetti.py @@ -43,7 +43,7 @@ # Ring 4-5 (25, 38), (26, 37), ]) -"""Retrieved August 31, 2022: https://qcs.rigetti.com/qpus""" +"""Retrieved August 31, 2022: https://qcs.rigetti.com/qpus.""" _octo_rings = [ [ @@ -77,7 +77,7 @@ _links.extend(l) _aspen_m2_coupling_graph = CouplingGraph(_links) -"""Retrieved August 31, 2022: https://qcs.rigetti.com/qpus""" +"""Retrieved August 31, 2022: https://qcs.rigetti.com/qpus.""" Aspen11Model = MachineModel(40, _aspen_11_coupling_graph, rigetti_gate_set) """A BQSKit MachineModel for Rigetti's Aspen-11 quantum processor.""" diff --git a/bqskit/ir/circuit.py b/bqskit/ir/circuit.py index 92423add8..d0932f884 100644 --- a/bqskit/ir/circuit.py +++ b/bqskit/ir/circuit.py @@ -2090,8 +2090,9 @@ def surround( HalfWire = Tuple[CircuitPoint, str] """ - A HalfWire is a point in the circuit and a direction. This - represents a point to start exploring from and a direction to + A HalfWire is a point in the circuit and a direction. + + This represents a point to start exploring from and a direction to explore in. """ @@ -2104,14 +2105,13 @@ def surround( """ A Node in the search tree. - Each node represents a region that may grow further. - The data structure tracks all HalfWires in the region and - the set of operations inside the region. During node exploration - each HalfWire is walked until we find a multi-qudit gate. Multi- - qudit gates form branches in the tree on whether on the gate - should be included. The node structure additionally stores the - set of qudit indices involved in the region currently. Also, we - track points that have already been explored to reduce repetition. + Each node represents a region that may grow further. The data structure + tracks all HalfWires in the region and the set of operations inside the + region. During node exploration each HalfWire is walked until we find a + multi-qudit gate. Multi- qudit gates form branches in the tree on + whether on the gate should be included. The node structure additionally + stores the set of qudit indices involved in the region currently. Also, + we track points that have already been explored to reduce repetition. """ # Initialize the frontier diff --git a/bqskit/ir/opt/multistartgen.py b/bqskit/ir/opt/multistartgen.py index 0bf58a82a..9847318dd 100644 --- a/bqskit/ir/opt/multistartgen.py +++ b/bqskit/ir/opt/multistartgen.py @@ -13,7 +13,6 @@ class MultiStartGenerator(abc.ABC): - @abc.abstractmethod def gen_starting_points( self, diff --git a/tests/ext/test_cirq.py b/tests/ext/test_cirq.py index ede832ce8..c5e602502 100644 --- a/tests/ext/test_cirq.py +++ b/tests/ext/test_cirq.py @@ -15,7 +15,6 @@ class TestTranslate: - @pytest.fixture def bqskit_circuit(self) -> Circuit: circuit = Circuit(3) diff --git a/tests/ext/test_pytket.py b/tests/ext/test_pytket.py index 47c4c165f..8cd46b483 100644 --- a/tests/ext/test_pytket.py +++ b/tests/ext/test_pytket.py @@ -17,7 +17,6 @@ class TestTranslate: - @pytest.fixture def bqskit_circuit(self) -> Circuit: circuit = Circuit(3) diff --git a/tests/ext/test_qiskit.py b/tests/ext/test_qiskit.py index 76352e3af..6131a2eda 100644 --- a/tests/ext/test_qiskit.py +++ b/tests/ext/test_qiskit.py @@ -16,7 +16,6 @@ class TestTranslate: - @pytest.fixture def bqskit_circuit(self) -> Circuit: circuit = Circuit(3) diff --git a/tests/ext/test_qutip.py b/tests/ext/test_qutip.py index 4821c1120..0d1869183 100644 --- a/tests/ext/test_qutip.py +++ b/tests/ext/test_qutip.py @@ -15,7 +15,6 @@ class TestTranslate: - @pytest.fixture def bqskit_circuit(self) -> Circuit: circuit = Circuit(3) diff --git a/tests/ir/circuit/test_point_methods.py b/tests/ir/circuit/test_point_methods.py index b237ed2d7..e5f69b5e1 100644 --- a/tests/ir/circuit/test_point_methods.py +++ b/tests/ir/circuit/test_point_methods.py @@ -16,7 +16,6 @@ class TestIsPointInRange: - @valid_type_test(Circuit(1).is_point_in_range) def test_valid_type(self) -> None: pass @@ -111,7 +110,6 @@ def test_false_pos(self, point: CircuitPointLike) -> None: class TestIsPointIdle: - @valid_type_test(Circuit(1).is_point_idle) def test_valid_type(self) -> None: pass @@ -141,7 +139,6 @@ def test_not_idle(self, circuit: Circuit) -> None: class TestNormalizePoint: - @valid_type_test(Circuit(1).normalize_point) def test_valid_type(self) -> None: pass diff --git a/tests/ir/gates/parameterized/test_unitary.py b/tests/ir/gates/parameterized/test_unitary.py index 82a314b9b..503e0de2e 100644 --- a/tests/ir/gates/parameterized/test_unitary.py +++ b/tests/ir/gates/parameterized/test_unitary.py @@ -13,7 +13,6 @@ class TestInit: - @given(num_qudits_and_radixes(3, (2, 3))) def test_valid(self, pair: tuple[int, tuple[int, ...]]) -> None: num_qudits, radixes = pair @@ -29,7 +28,6 @@ def test_invalid(self, num_qudits: int) -> None: class TestGetUnitary: - @given(unitaries()) def test_exact(self, utry: UnitaryMatrix) -> None: params = list(np.reshape(np.real(utry.numpy), (-1,))) + \ diff --git a/tests/ir/gates/test_circuitgate.py b/tests/ir/gates/test_circuitgate.py index b826f30bf..c3b7e3ee6 100644 --- a/tests/ir/gates/test_circuitgate.py +++ b/tests/ir/gates/test_circuitgate.py @@ -11,7 +11,6 @@ class TestPickle: - @given(circuits([2, 2], max_gates=3), circuits([2, 2], max_gates=3)) def test_pickle_individual(self, c1: Circuit, c2: Circuit) -> None: gate1 = CircuitGate(c1) diff --git a/tests/ir/lang/test_qasm_decode.py b/tests/ir/lang/test_qasm_decode.py index aeb8661b2..f749ee933 100644 --- a/tests/ir/lang/test_qasm_decode.py +++ b/tests/ir/lang/test_qasm_decode.py @@ -255,7 +255,6 @@ def test_nested_gate_decl(self) -> None: class TestIncludeStatements: - def test_include_no_exists(self) -> None: input = """ OPENQASM 2.0; diff --git a/tests/ir/opt/instantiaters/test_qfactor.py b/tests/ir/opt/instantiaters/test_qfactor.py index f7e1a1aee..3fae7839e 100644 --- a/tests/ir/opt/instantiaters/test_qfactor.py +++ b/tests/ir/opt/instantiaters/test_qfactor.py @@ -11,7 +11,6 @@ class TestQFactorEndToEnd: - def test_no_change(self) -> None: u1 = unitary_group.rvs(8) g1 = VariableUnitaryGate(3) diff --git a/tests/ir/test_gate.py b/tests/ir/test_gate.py index ae2740483..a98ae867d 100644 --- a/tests/ir/test_gate.py +++ b/tests/ir/test_gate.py @@ -11,7 +11,6 @@ class TestBasicGate: - def test_get_name(self, gate: Gate) -> None: assert isinstance(gate.name, str) diff --git a/tests/ir/test_interval.py b/tests/ir/test_interval.py index a91a92221..f45ef37c8 100644 --- a/tests/ir/test_interval.py +++ b/tests/ir/test_interval.py @@ -26,7 +26,6 @@ def test_strategy(interval: CycleInterval) -> None: class TestCycleIntervalNew: - @valid_type_test(CycleInterval) def test_valid_type(self) -> None: pass @@ -100,7 +99,6 @@ def test_indices(interval: CycleInterval) -> None: class TestCycleIntervalOverlaps: - @valid_type_test(CycleInterval(0, 0).overlaps) def test_valid_type(self) -> None: pass @@ -122,7 +120,6 @@ def test_overlaps( class TestCycleIntervalIntersection: - @valid_type_test(CycleInterval(0, 0).intersection) def test_valid_type(self) -> None: pass @@ -159,7 +156,6 @@ def test_valid( class TestCycleIntervalUnion: - @valid_type_test(CycleInterval(0, 0).union) def test_valid_type(self) -> None: pass @@ -196,7 +192,6 @@ def test_valid( class TestCycleIntervalLt: - @given(cycle_intervals(), everything_except(tuple)) # @example(CycleInterval(0, 0), tuple()) def test_invalid(self, interval: CycleInterval, other: Any) -> None: @@ -222,7 +217,6 @@ def test_valid( class TestCycleIntervalIsBounds: - @given(cycle_intervals()) def test_true_1(self, interval: CycleInterval) -> None: assert CycleInterval.is_interval(interval) diff --git a/tests/ir/test_iterator.py b/tests/ir/test_iterator.py index 169455bc5..bc12347ec 100644 --- a/tests/ir/test_iterator.py +++ b/tests/ir/test_iterator.py @@ -14,7 +14,6 @@ class TestCircuitIterator: - def test_empty(self) -> None: circuit = Circuit(1) ops = [cast(Operation, op) for op in CircuitIterator(circuit)] diff --git a/tests/ir/test_location.py b/tests/ir/test_location.py index 60debef00..969da1fd0 100644 --- a/tests/ir/test_location.py +++ b/tests/ir/test_location.py @@ -14,7 +14,6 @@ class TestInit: - @invalid_type_test(CircuitLocation) def test_invalid_type(self) -> None: pass @@ -31,7 +30,6 @@ def test_from_list(self, loc: list[int]) -> None: class TestUnion: - @given(circuit_locations()) def test_self(self, loc: CircuitLocation) -> None: assert set(loc.union(loc)) == set(loc) @@ -46,7 +44,6 @@ def test_other(self, l1: CircuitLocation, l2: CircuitLocationLike) -> None: class TestIntersection: - @given(circuit_locations()) def test_self(self, loc: CircuitLocation) -> None: assert loc.intersection(loc) == loc diff --git a/tests/ir/test_operation.py b/tests/ir/test_operation.py index c3c1e93eb..7c5501e63 100644 --- a/tests/ir/test_operation.py +++ b/tests/ir/test_operation.py @@ -23,7 +23,6 @@ def test_init(op: Operation) -> None: class TestGetQasm: - def test_cx(self) -> None: op = Operation(CXGate(), (0, 1)) assert op.get_qasm() == 'cx q[0], q[1];\n' diff --git a/tests/ir/test_point.py b/tests/ir/test_point.py index f8246d537..519f9132f 100644 --- a/tests/ir/test_point.py +++ b/tests/ir/test_point.py @@ -18,7 +18,6 @@ class TestNew: - @invalid_type_test(CircuitPoint) def test_invalid_type(self) -> None: pass @@ -56,7 +55,6 @@ def test_invalid(self, cycle: int) -> None: class TestIsPoint: - @given(circuit_points()) def test_from_point(self, point: CircuitPoint) -> None: assert CircuitPoint.is_point(point) @@ -71,7 +69,6 @@ def test_false(self, not_a_point: Any) -> None: class TestConversionToTuple: - @given(circuit_points()) def test_from_point(self, point: CircuitPoint) -> None: assert isinstance(point, tuple) diff --git a/tests/ir/test_region.py b/tests/ir/test_region.py index 1d31ab4ab..3dd00ca29 100644 --- a/tests/ir/test_region.py +++ b/tests/ir/test_region.py @@ -25,7 +25,6 @@ def test_strategy(region: CircuitRegion) -> None: class TestCircuitRegionInit: - @valid_type_test(CircuitRegion) def test_valid_type(self) -> None: pass @@ -187,7 +186,6 @@ def test_empty(region: CircuitRegion) -> None: class TestShiftLeft: - @valid_type_test(CircuitRegion({}).shift_left) def test_valid_type(self) -> None: pass @@ -230,7 +228,6 @@ def test_invalid(self, region: CircuitRegion) -> None: class TestShiftRight: - @valid_type_test(CircuitRegion({}).shift_right) def test_valid_type(self) -> None: pass @@ -273,7 +270,6 @@ def test_invalid(self, region: CircuitRegion) -> None: class TestOverlaps: - @valid_type_test(CircuitRegion({}).overlaps) def test_valid_type(self) -> None: pass @@ -306,7 +302,6 @@ def test_region_by_point( class TestContains: - @given(circuit_regions(), circuit_regions()) def test_region_by_region( self, @@ -360,7 +355,6 @@ def test_transpose(region: CircuitRegion) -> None: class TestIntersection: - @valid_type_test(CircuitRegion({}).intersection) def test_valid_type(self) -> None: pass @@ -384,7 +378,6 @@ def test_region_by_region( class TestUnion: - @valid_type_test(CircuitRegion({}).union) def test_valid_type(self) -> None: pass diff --git a/tests/passes/partitioning/test_cluster.py b/tests/passes/partitioning/test_cluster.py index 3aa630639..33d0898c3 100644 --- a/tests/passes/partitioning/test_cluster.py +++ b/tests/passes/partitioning/test_cluster.py @@ -6,7 +6,6 @@ class TestClusteringPartitioner: - def test_run_r6(self, r6_qudit_circuit: Circuit) -> None: utry = r6_qudit_circuit.get_unitary() ClusteringPartitioner(3, 2).run(r6_qudit_circuit, {}) diff --git a/tests/passes/partitioning/test_greedy.py b/tests/passes/partitioning/test_greedy.py index bcffeb7ec..b30d1bcfa 100644 --- a/tests/passes/partitioning/test_greedy.py +++ b/tests/passes/partitioning/test_greedy.py @@ -8,7 +8,6 @@ class TestGreedyPartitioner: - def test_run_r6(self, r6_qudit_circuit: Circuit) -> None: utry = r6_qudit_circuit.get_unitary() GreedyPartitioner(3).run(r6_qudit_circuit, {}) diff --git a/tests/passes/partitioning/test_quick.py b/tests/passes/partitioning/test_quick.py index 8731a23d4..473ed955c 100644 --- a/tests/passes/partitioning/test_quick.py +++ b/tests/passes/partitioning/test_quick.py @@ -9,7 +9,6 @@ class TestQuickPartitioner: - def test_run_r6(self, r6_qudit_circuit: Circuit) -> None: utry = r6_qudit_circuit.get_unitary() QuickPartitioner(3).run(r6_qudit_circuit, {}) diff --git a/tests/passes/partitioning/test_scan.py b/tests/passes/partitioning/test_scan.py index 79e474403..43cbe6eae 100644 --- a/tests/passes/partitioning/test_scan.py +++ b/tests/passes/partitioning/test_scan.py @@ -13,7 +13,6 @@ class TestScanPartitioner: - def test_run(self) -> None: """Test run with a linear topology.""" # 0 1 2 3 4 ######### diff --git a/tests/passes/processing/test_substitute.py b/tests/passes/processing/test_substitute.py index 208740101..0b1f6e2f7 100644 --- a/tests/passes/processing/test_substitute.py +++ b/tests/passes/processing/test_substitute.py @@ -10,7 +10,6 @@ class TestSubstitute: - def test_small_qubit(self) -> None: utry = UnitaryMatrix.identity(4) circuit = Circuit(2) diff --git a/tests/passes/synthesis/test_leap.py b/tests/passes/synthesis/test_leap.py index a48e78516..a1e685b86 100644 --- a/tests/passes/synthesis/test_leap.py +++ b/tests/passes/synthesis/test_leap.py @@ -11,7 +11,6 @@ class TestLeap: - def test_small_qubit(self) -> None: utry = UnitaryMatrix.random(2) circuit = Circuit.from_unitary(utry) diff --git a/tests/passes/synthesis/test_qfast.py b/tests/passes/synthesis/test_qfast.py index e317d83ba..e32c80e8e 100644 --- a/tests/passes/synthesis/test_qfast.py +++ b/tests/passes/synthesis/test_qfast.py @@ -13,7 +13,6 @@ class TestQFAST: - def test_small_qubit(self) -> None: utry = UnitaryMatrix.random(2) circuit = Circuit.from_unitary(utry) diff --git a/tests/passes/synthesis/test_qpredict.py b/tests/passes/synthesis/test_qpredict.py index cdd3b18d0..3637001e1 100644 --- a/tests/passes/synthesis/test_qpredict.py +++ b/tests/passes/synthesis/test_qpredict.py @@ -8,7 +8,6 @@ class TestQPredict: - def test_small_qubit(self) -> None: utry = UnitaryMatrix.random(2) circuit = Circuit.from_unitary(utry) diff --git a/tests/passes/synthesis/test_qsearch.py b/tests/passes/synthesis/test_qsearch.py index 4fa5c8b5f..deed27f4c 100644 --- a/tests/passes/synthesis/test_qsearch.py +++ b/tests/passes/synthesis/test_qsearch.py @@ -11,7 +11,6 @@ class TestQSearch: - def test_small_qubit(self) -> None: utry = UnitaryMatrix.random(2) circuit = Circuit.from_unitary(utry) diff --git a/tests/qis/state/test_state.py b/tests/qis/state/test_state.py index 53c518282..cf28c8e30 100644 --- a/tests/qis/state/test_state.py +++ b/tests/qis/state/test_state.py @@ -13,7 +13,6 @@ class TestInit: - @given(state_vectors()) def test_init_copy(self, vec: StateVector) -> None: new_vec = StateVector(vec) @@ -51,7 +50,6 @@ def test_random(pair: tuple[int, tuple[int, ...]]) -> None: class TestClosedOperations: - @given(state_vectors()) def test_conjugate(self, v: StateVector) -> None: out = np.conjugate(v) diff --git a/tests/qis/test_graph.py b/tests/qis/test_graph.py index 940215beb..d4ea681df 100644 --- a/tests/qis/test_graph.py +++ b/tests/qis/test_graph.py @@ -7,7 +7,6 @@ class TestGraphGetSubgraphsOfSize: - def test_1(self) -> None: coupling_graph = CouplingGraph({(0, 1), (1, 2), (2, 3)}) l = coupling_graph.get_subgraphs_of_size(2) @@ -43,7 +42,6 @@ def test_invalid(self) -> None: class TestMachineGetSubgraph: - def test_1(self) -> None: coupling_graph = CouplingGraph({(0, 1), (1, 2), (2, 3)}) l = coupling_graph.get_subgraph((0, 1, 2)) diff --git a/tests/qis/test_pauli.py b/tests/qis/test_pauli.py index f5f8a8c8b..8e8c3ef4f 100644 --- a/tests/qis/test_pauli.py +++ b/tests/qis/test_pauli.py @@ -16,7 +16,6 @@ class TestPauliMatricesConstructor: - def in_array(self, needle: Any, haystack: Any) -> bool: for elem in haystack: if np.allclose(elem, needle): @@ -152,7 +151,6 @@ def test_size_3(self) -> None: class TestPauliMatricesGetProjectionMatrices: - def in_array(self, needle: Any, haystack: Any) -> bool: for elem in haystack: if np.allclose(elem, needle): @@ -500,7 +498,6 @@ def test_proj_4_02(self) -> None: class TestPauliMatricesDotProduct: - @pytest.mark.parametrize('invalid_alpha', [[1.1] * i for i in range(4)]) def test_invalid_value(self, invalid_alpha: RealVector) -> None: with pytest.raises(ValueError): @@ -618,7 +615,6 @@ def test_size_2( class TestPauliMatricesFromString: - def in_array(self, needle: Any, haystack: Any) -> bool: for elem in haystack: if not needle.shape == elem.shape: diff --git a/tests/qis/unitary/test_meta.py b/tests/qis/unitary/test_meta.py index d485dd65e..bd47e96e8 100644 --- a/tests/qis/unitary/test_meta.py +++ b/tests/qis/unitary/test_meta.py @@ -12,7 +12,6 @@ class TestIsLocallyOptimizable: - def test_normal_inheritance(self) -> None: class test_class(LocallyOptimizableUnitary): def get_unitary(self, p: RealVector = []) -> UnitaryMatrix: @@ -60,7 +59,6 @@ def is_locally_optimizable(self) -> bool: class TestIsDifferentiable: - def test_normal_inheritance(self) -> None: class test_class(DifferentiableUnitary): def get_unitary(self, p: RealVector = []) -> UnitaryMatrix: diff --git a/tests/qis/unitary/test_unitarybuilder.py b/tests/qis/unitary/test_unitarybuilder.py index c3692cdf2..cf0344df8 100644 --- a/tests/qis/unitary/test_unitarybuilder.py +++ b/tests/qis/unitary/test_unitarybuilder.py @@ -13,7 +13,6 @@ class TestConstructor: - @given(integers(max_value=0)) def test_invalid_value_size(self, size: int) -> None: with pytest.raises(ValueError): @@ -51,7 +50,6 @@ def test_valid(self, size: int, radixes: Sequence[int]) -> None: class TestApplyLeft: - def test_valid_1(self) -> None: u1 = UnitaryMatrix.random(3) ub = UnitaryBuilder(3) @@ -83,7 +81,6 @@ def test_valid_3(self) -> None: class TestApplyRight: - def test_valid_1(self) -> None: u1 = UnitaryMatrix.random(3) ub = UnitaryBuilder(3) @@ -115,7 +112,6 @@ def test_valid_3(self) -> None: class TestCalcEnvMatrix: - def test_valid_1(self) -> None: u1 = UnitaryMatrix.random(3) ub = UnitaryBuilder(3) diff --git a/tests/qis/unitary/test_unitarymatrix.py b/tests/qis/unitary/test_unitarymatrix.py index 0dbfc85da..046057c45 100644 --- a/tests/qis/unitary/test_unitarymatrix.py +++ b/tests/qis/unitary/test_unitarymatrix.py @@ -24,7 +24,6 @@ class TestInit: - @given(unitaries()) def test_init_copy(self, utry: UnitaryMatrix) -> None: new_utry = UnitaryMatrix(utry) @@ -54,7 +53,6 @@ def test_conj(utry: UnitaryMatrix) -> None: class TestOtimes: - @given(unitaries(2), unitaries(2)) def test_two(self, u1: UnitaryMatrix, u2: UnitaryMatrix) -> None: kron = u1.otimes(u2) @@ -88,7 +86,6 @@ def test_get_unitary(utry: UnitaryMatrix) -> None: class TestGetDistanceFrom: - @given(unitaries(1, (2,)), unitaries(1, (2,))) def test_get_distance_from( self, u1: UnitaryMatrix, @@ -113,7 +110,6 @@ def test_numpy(self) -> None: class TestGetStateVector: - @given(unitaries(1, (2,)), state_likes(1, (2,))) def test_simple(self, u: UnitaryMatrix, v: StateLike) -> None: o = u.get_statevector(v) @@ -132,7 +128,6 @@ def test_radixes(self, pair: tuple[int, tuple[int, ...]]) -> None: class TestIdentity: - @given(radixes()) def test_identity(self, radixes: tuple[int, ...]) -> None: utry = UnitaryMatrix.identity(int(np.prod(radixes)), radixes) @@ -177,7 +172,6 @@ def test_is_unitary(u: UnitaryLike) -> None: class TestClosedOperations: - @given(num_qudits_and_radixes(3, (2, 3))) def test_matmul(self, pair: tuple[int, tuple[int, ...]]) -> None: num_qudits, radixes = pair diff --git a/tests/utils/test_math.py b/tests/utils/test_math.py index 15647aea8..fafbacde9 100644 --- a/tests/utils/test_math.py +++ b/tests/utils/test_math.py @@ -42,7 +42,6 @@ def dexpm_exact( class TestDexpmv: - @pytest.mark.parametrize( 'alpha', [np.random.random(16) for i in range(100)], ) @@ -104,7 +103,6 @@ def test_invalid(self) -> None: class TestSoftmax: - @pytest.mark.parametrize('x', [np.random.random(100) for i in range(100)]) def test_1(self, x: npt.NDArray[np.float64]) -> None: assert np.abs(np.sum(softmax(10 * x)) - 1) < 1e-15 @@ -147,7 +145,6 @@ def test_invalid(self) -> None: class TestUnitaryLog: - @pytest.mark.parametrize( 'reU', PauliMatrices(1).paulis @@ -176,7 +173,6 @@ def test_valid(self, reU: npt.NDArray[np.complex128]) -> None: class TestPauliExpansion: - @pytest.mark.parametrize( 'reH', PauliMatrices(1).paulis From e3ceab1d4a6e915849a430fa2d5fd0c393e238bc Mon Sep 17 00:00:00 2001 From: Ed Younis Date: Thu, 19 Jan 2023 16:30:56 -0500 Subject: [PATCH 3/3] Pre-commit --- bqskit/exec/results.py | 2 +- bqskit/ir/gates/composedgate.py | 12 ++++++------ bqskit/ir/opt/instantiaters/qfactor.py | 2 +- tests/qis/unitary/test_meta.py | 24 ++++++++++++------------ 4 files changed, 20 insertions(+), 20 deletions(-) diff --git a/bqskit/exec/results.py b/bqskit/exec/results.py index e64a33384..d8951fa72 100644 --- a/bqskit/exec/results.py +++ b/bqskit/exec/results.py @@ -24,4 +24,4 @@ def get_counts(self, shots: int) -> npt.NDArray[np.int64]: return np.asarray(np.multiply(shots, self.probs), np.int64) def __str__(self) -> str: - pass + return str(self.probs) diff --git a/bqskit/ir/gates/composedgate.py b/bqskit/ir/gates/composedgate.py index f1a1c42f6..0892858ab 100644 --- a/bqskit/ir/gates/composedgate.py +++ b/bqskit/ir/gates/composedgate.py @@ -24,11 +24,11 @@ class ComposedGate(Gate): def is_differentiable(self) -> bool: """Check if all sub gates are differentiable.""" if hasattr(self, 'gate'): - return isinstance(self.gate, DifferentiableUnitary) # type: ignore + return isinstance(self.gate, DifferentiableUnitary) if hasattr(self, 'gates'): return all( isinstance(gate, DifferentiableUnitary) - for gate in self.gates # type: ignore + for gate in self.gates ) raise AttributeError( @@ -40,12 +40,12 @@ def is_locally_optimizable(self) -> bool: """Check if all sub gates are locally optimizable.""" if hasattr(self, 'gate'): return isinstance( - self.gate, LocallyOptimizableUnitary, # type: ignore + self.gate, LocallyOptimizableUnitary, ) if hasattr(self, 'gates'): return all( isinstance(gate, LocallyOptimizableUnitary) - for gate in self.gates # type: ignore + for gate in self.gates ) raise AttributeError( @@ -55,9 +55,9 @@ def is_locally_optimizable(self) -> bool: def __hash__(self) -> int: if hasattr(self, 'gate'): - return hash((self.name, self.gate)) # type: ignore + return hash((self.name, self.gate)) if hasattr(self, 'gates'): - return hash((self.name, tuple(self.gates))) # type: ignore + return hash((self.name, tuple(self.gates))) raise RuntimeError( f"Composed gate '{self.name}' has no attribute 'gate' or 'gates'.", ) diff --git a/bqskit/ir/opt/instantiaters/qfactor.py b/bqskit/ir/opt/instantiaters/qfactor.py index 78d0513e1..f769ea6e0 100644 --- a/bqskit/ir/opt/instantiaters/qfactor.py +++ b/bqskit/ir/opt/instantiaters/qfactor.py @@ -42,7 +42,7 @@ def instantiate( x0: npt.NDArray[np.float64], ) -> npt.NDArray[np.float64]: """Instantiate `circuit`, see Instantiater for more info.""" - return super().instantiate(circuit, target, x0) + return QFactorInstantiatorNative.instantiate(self, circuit, target, x0) @staticmethod def is_capable(circuit: Circuit) -> bool: diff --git a/tests/qis/unitary/test_meta.py b/tests/qis/unitary/test_meta.py index bd47e96e8..26e192f4c 100644 --- a/tests/qis/unitary/test_meta.py +++ b/tests/qis/unitary/test_meta.py @@ -14,10 +14,10 @@ class TestIsLocallyOptimizable: def test_normal_inheritance(self) -> None: class test_class(LocallyOptimizableUnitary): - def get_unitary(self, p: RealVector = []) -> UnitaryMatrix: + def get_unitary(self, p: RealVector = []) -> UnitaryMatrix: # type: ignore # noqa pass - def optimize( + def optimize( # type: ignore # noqa self, env_matrix: npt.NDArray[np.complex128], ) -> list[float]: pass @@ -27,10 +27,10 @@ def optimize( def test_conditional_inheritance_true(self) -> None: class test_class(LocallyOptimizableUnitary): - def get_unitary(self, p: RealVector = []) -> UnitaryMatrix: + def get_unitary(self, p: RealVector = []) -> UnitaryMatrix: # type: ignore # noqa pass - def optimize( + def optimize( # type: ignore # noqa self, env_matrix: npt.NDArray[np.complex128], ) -> list[float]: pass @@ -43,10 +43,10 @@ def is_locally_optimizable(self) -> bool: def test_conditional_inheritance_false(self) -> None: class test_class(LocallyOptimizableUnitary): - def get_unitary(self, p: RealVector = []) -> UnitaryMatrix: + def get_unitary(self, p: RealVector = []) -> UnitaryMatrix: # type: ignore # noqa pass - def optimize( + def optimize( # type: ignore # noqa self, env_matrix: npt.NDArray[np.complex128], ) -> list[float]: pass @@ -61,10 +61,10 @@ def is_locally_optimizable(self) -> bool: class TestIsDifferentiable: def test_normal_inheritance(self) -> None: class test_class(DifferentiableUnitary): - def get_unitary(self, p: RealVector = []) -> UnitaryMatrix: + def get_unitary(self, p: RealVector = []) -> UnitaryMatrix: # type: ignore # noqa pass - def get_grad( + def get_grad( # type: ignore # noqa self, params: RealVector = [], ) -> npt.NDArray[np.complex128]: pass @@ -74,10 +74,10 @@ def get_grad( def test_conditional_inheritance_true(self) -> None: class test_class(DifferentiableUnitary): - def get_unitary(self, p: RealVector = []) -> UnitaryMatrix: + def get_unitary(self, p: RealVector = []) -> UnitaryMatrix: # type: ignore # noqa pass - def get_grad( + def get_grad( # type: ignore # noqa self, params: RealVector = [], ) -> npt.NDArray[np.complex128]: pass @@ -90,10 +90,10 @@ def is_differentiable(self) -> bool: def test_conditional_inheritance_false(self) -> None: class test_class(DifferentiableUnitary): - def get_unitary(self, p: RealVector = []) -> UnitaryMatrix: + def get_unitary(self, p: RealVector = []) -> UnitaryMatrix: # type: ignore # noqa pass - def get_grad( + def get_grad( # type: ignore # noqa self, params: RealVector = [], ) -> npt.NDArray[np.complex128]: pass