2424
2525
2626def test_x_gate () -> None :
27+ """Tests the X gate."""
2728 q0 , q1 = cirq .LineQubit .range (2 )
2829 circuit = cirq .Circuit ()
2930 circuit .append (cirq .X (q0 ))
@@ -37,7 +38,8 @@ def test_x_gate() -> None:
3738 np .testing .assert_equal (results , expected_results )
3839
3940
40- def test_CNOT () -> None :
41+ def test_cnot () -> None :
42+ """Tests the CNOT gate."""
4143 q0 , q1 = cirq .LineQubit .range (2 )
4244 circuit = cirq .Circuit ()
4345 circuit .append (cirq .X (q0 ))
@@ -50,7 +52,8 @@ def test_CNOT() -> None:
5052 np .testing .assert_equal (results , expected_results )
5153
5254
53- def test_Swap () -> None :
55+ def test_swap () -> None :
56+ """Tests the SWAP gate."""
5457 q0 , q1 = cirq .LineQubit .range (2 )
5558 circuit = cirq .Circuit ()
5659 circuit .append (cirq .X (q0 ))
@@ -71,6 +74,7 @@ def test_Swap() -> None:
7174 ],
7275)
7376def test_qubit_permutation_gate (n , perm , state ) -> None :
77+ """Tests the QubitPermutationGate."""
7478 qubits = cirq .LineQubit .range (n )
7579 perm_gate = cirq .QubitPermutationGate (perm )
7680 circuit = cirq .Circuit (perm_gate (* qubits ), cirq .measure (* qubits , key = 'key' ))
@@ -83,7 +87,8 @@ def test_qubit_permutation_gate(n, perm, state) -> None:
8387 np .testing .assert_equal (result .measurements ['key' ], expected )
8488
8589
86- def test_CCNOT () -> None :
90+ def test_ccnot () -> None :
91+ """Tests the CCNOT gate."""
8792 q0 , q1 , q2 = cirq .LineQubit .range (3 )
8893 circuit = cirq .Circuit ()
8994 circuit .append (cirq .CCNOT (q0 , q1 , q2 ))
@@ -108,7 +113,8 @@ def test_CCNOT() -> None:
108113
109114
110115@pytest .mark .parametrize (['initial_state' ], [(list (x ),) for x in product ([0 , 1 ], repeat = 4 )])
111- def test_CCCX (initial_state ) -> None :
116+ def test_cccx (initial_state ) -> None :
117+ """Tests the CCCX gate."""
112118 CCCX = cirq .CCNOT .controlled ()
113119 qubits = cirq .LineQubit .range (4 )
114120
@@ -126,7 +132,8 @@ def test_CCCX(initial_state) -> None:
126132
127133
128134@pytest .mark .parametrize (['initial_state' ], [(list (x ),) for x in product ([0 , 1 ], repeat = 3 )])
129- def test_controlled_SWAP (initial_state ) -> None :
135+ def test_controlled_swap (initial_state ) -> None :
136+ """Tests the controlled SWAP gate."""
130137 CSWAP = cirq .SWAP .controlled ()
131138 qubits = cirq .LineQubit .range (3 )
132139 circuit = cirq .Circuit ()
@@ -146,7 +153,8 @@ def test_controlled_SWAP(initial_state) -> None:
146153 np .testing .assert_equal (results , final_state )
147154
148155
149- def test_CSWAP () -> None :
156+ def test_cswap () -> None :
157+ """Tests the CSWAP gate."""
150158 # Specifically test named CSWAP gate, not just controlled(SWAP)
151159 q0 , q1 , q2 = cirq .LineQubit .range (3 )
152160 circuit = cirq .Circuit ()
@@ -155,7 +163,8 @@ def test_CSWAP() -> None:
155163 circuit .append (cirq .X (q1 ))
156164 circuit .append (cirq .CSWAP (q0 , q1 , q2 )) # q0=1 -> swap q1=1, q2=0 -> q1=0, q2=1
157165 circuit .append (cirq .measure ((q0 , q1 , q2 ), key = 'key' ))
158-
166+
167+ sim : cirq .ClassicalStateSimulator
159168 sim = cirq .ClassicalStateSimulator ()
160169 result = sim .run (circuit , repetitions = 1 )
161170 # Expected: 1, 0, 1
@@ -341,7 +350,7 @@ def test_create_partial_simulation_state_from_int_with_no_qubits() -> None:
341350 with pytest .raises (ValueError ):
342351 sim ._create_partial_simulation_state (
343352 initial_state = initial_state ,
344- qubits = qs , # type: ignore[arg-type]
353+ qubits = qs ,
345354 classical_data = classical_data ,
346355 )
347356
0 commit comments