@@ -76,21 +76,22 @@ def test_simple_model(model: cirq.NoiseModel, qubits, measurements:bool):
7676 dm = cirq_sim .simulate (noisy_circuit ).final_density_matrix
7777 pops_cirq = np .real (np .diag (dm ))
7878
79- kernel = load_circuit (noisy_circuit )
80- pyqrack_sim = StackMemorySimulator (
81- min_qubits = 2 , rng_state = np .random .default_rng (1234 )
82- )
79+ if not measurements :
80+ kernel = load_circuit (noisy_circuit )
81+ pyqrack_sim = StackMemorySimulator (
82+ min_qubits = 2 , rng_state = np .random .default_rng (1234 )
83+ )
8384
84- pops_bloqade = [0.0 ] * 4
85+ pops_bloqade = [0.0 ] * 4
8586
86- nshots = 500
87- for _ in range (nshots ):
88- ket = pyqrack_sim .state_vector (kernel )
89- for i in range (4 ):
90- pops_bloqade [i ] += abs (ket [i ]) ** 2 / nshots
87+ nshots = 500
88+ for _ in range (nshots ):
89+ ket = pyqrack_sim .state_vector (kernel )
90+ for i in range (4 ):
91+ pops_bloqade [i ] += abs (ket [i ]) ** 2 / nshots
9192
9293 if measurements is True :
93- for pops in ( pops_bloqade , pops_cirq ) :
94+ for pops in [ pops_cirq ] :
9495 assert math .isclose (pops [0 ], 1.0 , abs_tol = 1e-1 )
9596 assert math .isclose (pops [3 ], 0.0 , abs_tol = 1e-1 )
9697 assert math .isclose (pops [1 ], 0.0 , abs_tol = 1e-1 )
0 commit comments