diff --git a/cirq-core/cirq/sim/density_matrix_simulation_state.py b/cirq-core/cirq/sim/density_matrix_simulation_state.py index 2b81bdbc2e6..bc46c36e0c9 100644 --- a/cirq-core/cirq/sim/density_matrix_simulation_state.py +++ b/cirq-core/cirq/sim/density_matrix_simulation_state.py @@ -297,10 +297,10 @@ def remove_qubits(self, qubits: Sequence['cirq.Qid']): ret = super().remove_qubits(qubits) if ret is not NotImplemented: return ret - extracted, remainder = self.factor(qubits) + extracted, remainder = self.factor(qubits, inplace=True) remainder._state._density_matrix *= extracted._state._density_matrix.reshape(-1)[0] return remainder - + def _act_on_fallback_( self, action: Any, qubits: Sequence['cirq.Qid'], allow_decompose: bool = True ) -> bool: diff --git a/cirq-core/cirq/sim/simulation_state_test.py b/cirq-core/cirq/sim/simulation_state_test.py index 3d86026f7e0..90bd816e9c6 100644 --- a/cirq-core/cirq/sim/simulation_state_test.py +++ b/cirq-core/cirq/sim/simulation_state_test.py @@ -153,21 +153,7 @@ def test_delegating_gate_unitary(exp): assert_test_circuit_for_sv_simulator(test_circuit, control_circuit) -@pytest.mark.parametrize('exp', np.linspace(0, 2 * np.pi, 1)) -def test_delegating_gate_channel_sv(exp): - q = cirq.LineQubit(0) - - test_circuit = cirq.Circuit() - test_circuit.append(cirq.H(q)) - test_circuit.append(DelegatingAncillaZ(exp, True).on(q)) - - control_circuit = cirq.Circuit(cirq.H(q)) - control_circuit.append(cirq.ZPowGate(exponent=exp).on(q)) - - assert_test_circuit_for_sv_simulator(test_circuit, control_circuit) - - -@pytest.mark.parametrize('exp', np.linspace(0, 2 * np.pi, 1)) +@pytest.mark.parametrize('exp', np.linspace(0, 2 * np.pi, 10)) def test_delegating_gate_channel(exp): q = cirq.LineQubit(0) @@ -178,6 +164,7 @@ def test_delegating_gate_channel(exp): control_circuit = cirq.Circuit(cirq.H(q)) control_circuit.append(cirq.ZPowGate(exponent=exp).on(q)) + assert_test_circuit_for_sv_simulator(test_circuit, control_circuit) assert_test_circuit_for_dm_simulator(test_circuit, control_circuit)