Skip to content

Instantly share code, notes, and snippets.

@sanuj
Created August 25, 2023 19:24
Show Gist options
  • Save sanuj/146ca35163154666cf13b817e8f8e0c3 to your computer and use it in GitHub Desktop.
Save sanuj/146ca35163154666cf13b817e8f8e0c3 to your computer and use it in GitHub Desktop.
(cirq-py3) sanuj@DESKTOP-C5HBET3:~/Cirq$ pytest cirq-core/cirq/sim/simulation_state_test.py::test_delegating_gate_channel -x -v -s
======================================================== test session starts ========================================================
platform linux -- Python 3.11.4, pytest-7.4.0, pluggy-1.2.0 -- /home/sanuj/anaconda3/envs/cirq-py3/bin/python
cachedir: .pytest_cache
Using --randomly-seed=3231141503
rootdir: /home/sanuj/Cirq
configfile: pyproject.toml
plugins: xdist-2.2.1, forked-1.6.0, anyio-3.7.1, asyncio-0.21.1, randomly-3.15.0, cov-3.0.0
asyncio: mode=Mode.STRICT
collected 1 item

cirq-core/cirq/sim/simulation_state_test.py::test_delegating_gate_channel[0.0] FAILED

============================================================= FAILURES ==============================================================
_________________________________________________ test_delegating_gate_channel[0.0] _________________________________________________

exp = 0.0

    @pytest.mark.parametrize('exp', np.linspace(0, 2 * np.pi, 1))
    def test_delegating_gate_channel(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_dm_simulator(test_circuit, control_circuit)

cirq-core/cirq/sim/simulation_state_test.py:181:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
cirq-core/cirq/sim/simulation_state_test.py:217: in assert_test_circuit_for_dm_simulator
    test_sim = sim.simulate(test_circuit).final_density_matrix
cirq-core/cirq/sim/density_matrix_simulator.py:368: in final_density_matrix
    tensor = self._get_merged_sim_state().target_tensor
cirq-core/cirq/sim/simulator_base.py:450: in _get_merged_sim_state
    self._merged_sim_state_cache = self._final_simulator_state.create_merged_state()
cirq-core/cirq/sim/simulation_product_state.py:71: in create_merged_state
    return final_args.transpose_to_qubit_order(self.qubits)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = cirq.DensityMatrixSimulationState(initial_state=np.array([[[[(0.4999999701976776+0j), 0j], [(0.4999999701976776+0j), 0...'): [(cirq.NamedQubit('a'),)]}, _measurement_types={cirq.MeasurementKey(name='a'): cirq.MeasurementType.MEASUREMENT},))
qubits = (cirq.LineQubit(0),)

    def transpose_to_qubit_order(self, qubits: Sequence['cirq.Qid'], *, inplace=False) -> Self:
        """Physically reindexes the state by the new basis.

        Args:
            qubits: The desired qubit order.
            inplace: True to perform this operation inplace.

        Returns:
            The state with qubit order transposed and underlying representation
            updated.

        Raises:
            ValueError: If the provided qubits do not match the existing ones.
        """
        if len(self.qubits) != len(qubits) or set(qubits) != set(self.qubits):
>           raise ValueError(f'Qubits do not match. Existing: {self.qubits}, provided: {qubits}')
E           ValueError: Qubits do not match. Existing: (cirq.LineQubit(0), cirq.NamedQubit('a')), provided: (cirq.LineQubit(0),)

cirq-core/cirq/sim/simulation_state.py:242: ValueError
====================================================== short test summary info ======================================================
FAILED cirq-core/cirq/sim/simulation_state_test.py::test_delegating_gate_channel[0.0] - ValueError: Qubits do not match. Existing: (cirq.LineQubit(0), cirq.NamedQubit('a')), provided: (cirq.LineQubit(0),)
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! stopping after 1 failures !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
========================================================= 1 failed in 0.14s =========================================================
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment