File tree 2 files changed +15
-1
lines changed
2 files changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -168,7 +168,9 @@ def _run(
168
168
resolved_circuit = protocols .resolve_parameters (circuit , param_resolver )
169
169
check_all_resolved (resolved_circuit )
170
170
171
- if circuit .are_all_measurements_terminal ():
171
+ if circuit .are_all_measurements_terminal () and not any (
172
+ circuit .findall_operations (lambda op : isinstance (op , circuits .CircuitOperation ))
173
+ ):
172
174
return self ._run_sweep_sample (resolved_circuit , repetitions )
173
175
return self ._run_sweep_repeat (resolved_circuit , repetitions )
174
176
Original file line number Diff line number Diff line change @@ -1275,6 +1275,18 @@ def test_simulate_noise_with_terminal_measurements():
1275
1275
assert result1 == result2
1276
1276
1277
1277
1278
+ def test_simulate_noise_with_subcircuit_measurements ():
1279
+ q = cirq .LineQubit (0 )
1280
+ circuit1 = cirq .Circuit (cirq .measure (q ))
1281
+ circuit2 = cirq .Circuit (cirq .CircuitOperation (cirq .Circuit (cirq .measure (q )).freeze ()))
1282
+
1283
+ simulator = cirq .DensityMatrixSimulator (noise = cirq .X )
1284
+ result1 = simulator .run (circuit1 , repetitions = 10 )
1285
+ result2 = simulator .run (circuit2 , repetitions = 10 )
1286
+
1287
+ assert result1 == result2
1288
+
1289
+
1278
1290
def test_density_matrix_copy ():
1279
1291
sim = cirq .DensityMatrixSimulator ()
1280
1292
You can’t perform that action at this time.
0 commit comments