@@ -1307,7 +1307,7 @@ def test_next_moment_operating_on_distance(circuit_cls):
1307
1307
assert c .next_moment_operating_on ([a ], 1 , max_distance = 500 ) == 4
1308
1308
1309
1309
# Huge max distances should be handled quickly due to capping.
1310
- assert c .next_moment_operating_on ([a ], 5 , max_distance = 10 ** 100 ) is None
1310
+ assert c .next_moment_operating_on ([a ], 5 , max_distance = 10 ** 100 ) is None
1311
1311
1312
1312
with pytest .raises (ValueError , match = 'Negative max_distance' ):
1313
1313
c .next_moment_operating_on ([a ], 0 , max_distance = - 1 )
@@ -1396,7 +1396,7 @@ def test_prev_moment_operating_on_distance(circuit_cls):
1396
1396
assert c .prev_moment_operating_on ([a ], 13 , max_distance = 500 ) == 1
1397
1397
1398
1398
# Huge max distances should be handled quickly due to capping.
1399
- assert c .prev_moment_operating_on ([a ], 1 , max_distance = 10 ** 100 ) is None
1399
+ assert c .prev_moment_operating_on ([a ], 1 , max_distance = 10 ** 100 ) is None
1400
1400
1401
1401
with pytest .raises (ValueError , match = 'Negative max_distance' ):
1402
1402
c .prev_moment_operating_on ([a ], 6 , max_distance = - 1 )
@@ -1703,7 +1703,7 @@ def test_findall_operations_until_blocked(circuit_cls):
1703
1703
)
1704
1704
1705
1705
1706
- @pytest .mark .parametrize ('seed' , [randint (0 , 2 ** 31 )])
1706
+ @pytest .mark .parametrize ('seed' , [randint (0 , 2 ** 31 )])
1707
1707
@pytest .mark .parametrize ('circuit_cls' , [cirq .Circuit , cirq .FrozenCircuit ])
1708
1708
def test_findall_operations_until_blocked_docstring_examples (seed , circuit_cls ):
1709
1709
prng = np .random .RandomState (seed )
@@ -2861,7 +2861,7 @@ def pauli_error_probability(r: float, n_qubits: int) -> float:
2861
2861
makes it simple to compute the serial composition of depolarizing channels. It
2862
2862
is multiplicative under channel composition.
2863
2863
"""
2864
- d2 = 4 ** n_qubits
2864
+ d2 = 4 ** n_qubits
2865
2865
return (1 - r ) * (d2 - 1 ) / d2
2866
2866
2867
2867
def depolarize (r : float , n_qubits : int ) -> cirq .DepolarizingChannel :
@@ -4062,9 +4062,9 @@ def test_submoments(circuit_cls):
4062
4062
cirq .H .on (d ),
4063
4063
cirq .CZ .on (a , d ),
4064
4064
cirq .CZ .on (b , c ),
4065
- (cirq .CNOT ** 0.5 ).on (a , d ),
4066
- (cirq .CNOT ** 0.5 ).on (b , e ),
4067
- (cirq .CNOT ** 0.5 ).on (c , f ),
4065
+ (cirq .CNOT ** 0.5 ).on (a , d ),
4066
+ (cirq .CNOT ** 0.5 ).on (b , e ),
4067
+ (cirq .CNOT ** 0.5 ).on (c , f ),
4068
4068
cirq .H .on (c ),
4069
4069
cirq .H .on (e ),
4070
4070
)
@@ -4191,15 +4191,12 @@ def test_measurement_key_mapping(circuit_cls):
4191
4191
assert simulator .run (c ).measurements == {'m1' : 1 , 'm2' : 0 }
4192
4192
assert simulator .run (c_swapped ).measurements == {'m1' : 0 , 'm2' : 1 }
4193
4193
4194
- assert (
4195
- cirq .with_measurement_key_mapping (
4196
- c ,
4197
- {
4198
- 'x' : 'z' ,
4199
- },
4200
- ).all_measurement_key_names ()
4201
- == {'m1' , 'm2' }
4202
- )
4194
+ assert cirq .with_measurement_key_mapping (
4195
+ c ,
4196
+ {
4197
+ 'x' : 'z' ,
4198
+ },
4199
+ ).all_measurement_key_names () == {'m1' , 'm2' }
4203
4200
4204
4201
4205
4202
@pytest .mark .parametrize ('circuit_cls' , [cirq .Circuit , cirq .FrozenCircuit ])
@@ -4222,7 +4219,7 @@ def test_measurement_key_mapping_preserves_moments(circuit_cls):
4222
4219
@pytest .mark .parametrize ('circuit_cls' , [cirq .Circuit , cirq .FrozenCircuit ])
4223
4220
def test_inverse (circuit_cls ):
4224
4221
a , b = cirq .LineQubit .range (2 )
4225
- forward = circuit_cls ((cirq .X ** 0.5 )(a ), (cirq .Y ** - 0.2 )(b ), cirq .CZ (a , b ))
4222
+ forward = circuit_cls ((cirq .X ** 0.5 )(a ), (cirq .Y ** - 0.2 )(b ), cirq .CZ (a , b ))
4226
4223
backward = circuit_cls ((cirq .CZ ** (- 1.0 ))(a , b ), (cirq .X ** (- 0.5 ))(a ), (cirq .Y ** (0.2 ))(b ))
4227
4224
cirq .testing .assert_same_circuits (cirq .inverse (forward ), backward )
4228
4225
@@ -4233,15 +4230,15 @@ def test_inverse(circuit_cls):
4233
4230
cirq .inverse (no_inverse )
4234
4231
4235
4232
# Default when there is no inverse for an op.
4236
- default = circuit_cls ((cirq .X ** 0.5 )(a ), (cirq .Y ** - 0.2 )(b ))
4233
+ default = circuit_cls ((cirq .X ** 0.5 )(a ), (cirq .Y ** - 0.2 )(b ))
4237
4234
cirq .testing .assert_same_circuits (cirq .inverse (no_inverse , default ), default )
4238
4235
assert cirq .inverse (no_inverse , None ) is None
4239
4236
4240
4237
4241
4238
@pytest .mark .parametrize ('circuit_cls' , [cirq .Circuit , cirq .FrozenCircuit ])
4242
4239
def test_pow_valid_only_for_minus_1 (circuit_cls ):
4243
4240
a , b = cirq .LineQubit .range (2 )
4244
- forward = circuit_cls ((cirq .X ** 0.5 )(a ), (cirq .Y ** - 0.2 )(b ), cirq .CZ (a , b ))
4241
+ forward = circuit_cls ((cirq .X ** 0.5 )(a ), (cirq .Y ** - 0.2 )(b ), cirq .CZ (a , b ))
4245
4242
4246
4243
backward = circuit_cls ((cirq .CZ ** (- 1.0 ))(a , b ), (cirq .X ** (- 0.5 ))(a ), (cirq .Y ** (0.2 ))(b ))
4247
4244
cirq .testing .assert_same_circuits (cirq .pow (forward , - 1 ), backward )
@@ -4642,28 +4639,22 @@ def _measurement_key_name_(self):
4642
4639
assert circuit_cls ().all_measurement_key_names () == set ()
4643
4640
4644
4641
# Order does not matter.
4645
- assert (
4646
- circuit_cls (
4647
- cirq .Moment (
4648
- [
4649
- cirq .measure (a , key = 'x' ),
4650
- cirq .measure (b , key = 'y' ),
4651
- ]
4652
- )
4653
- ).all_measurement_key_names ()
4654
- == {'x' , 'y' }
4655
- )
4656
- assert (
4657
- circuit_cls (
4658
- cirq .Moment (
4659
- [
4660
- cirq .measure (b , key = 'y' ),
4661
- cirq .measure (a , key = 'x' ),
4662
- ]
4663
- )
4664
- ).all_measurement_key_names ()
4665
- == {'x' , 'y' }
4666
- )
4642
+ assert circuit_cls (
4643
+ cirq .Moment (
4644
+ [
4645
+ cirq .measure (a , key = 'x' ),
4646
+ cirq .measure (b , key = 'y' ),
4647
+ ]
4648
+ )
4649
+ ).all_measurement_key_names () == {'x' , 'y' }
4650
+ assert circuit_cls (
4651
+ cirq .Moment (
4652
+ [
4653
+ cirq .measure (b , key = 'y' ),
4654
+ cirq .measure (a , key = 'x' ),
4655
+ ]
4656
+ )
4657
+ ).all_measurement_key_names () == {'x' , 'y' }
4667
4658
4668
4659
4669
4660
def test_zip ():
0 commit comments