Пример #1
0
    def test_restless_classify_2(self):
        """Test the classification of restless shots for two eight-qubit shots.
        In this example we run two eight qubit circuits. The first circuit applies an
        X, X, Id, Id, Id, X, X and Id gate, the second an Id, Id, X, Id, Id, X, Id and Id gate
        to qubits one to eight, respectively."""
        previous_shot = "11000110"
        shot = "11100010"

        restless_classified_shot = RestlessToCounts._restless_classify(shot, previous_shot)
        self.assertEqual(restless_classified_shot, "00100100")
Пример #2
0
    def test_restless_classify_1(self):
        """Test the classification of restless shots for two single-qubit shots.
        This example corresponds to running two single-qubit circuits without qubit reset where
        the first and second circuit would be, e.g. an X gate and an identity gate, respectively.
        We measure the qubit in the 1 state for the first circuit and measure 1 again for the
        second circuit. The second shot is reclassified as a 0 since there was no state change."""
        previous_shot = "1"
        shot = "1"

        restless_classified_shot = RestlessToCounts._restless_classify(shot, previous_shot)
        self.assertEqual(restless_classified_shot, "0")
Пример #3
0
    def test_restless_process_1(self):
        """Test that a single-qubit restless memory is correctly post-processed.
        This example corresponds to running an X gate and a SX gate with four shots
        in an ideal restless setting."""
        n_qubits = 1
        node = RestlessToCounts(n_qubits)

        data = [["0x1", "0x1", "0x0", "0x0"], ["0x0", "0x1", "0x1", "0x0"]]
        processed_data = node(data=np.array(data))
        # time-ordered data: ["1", "0", "1", "1", "0", "1", "0", "0"]
        # classification: ["1", "1", "1", "0", "1", "1", "1", "0"]
        expected_data = np.array([{"1": 4}, {"1": 2, "0": 2}])
        self.assertTrue(processed_data.all() == expected_data.all())
Пример #4
0
    def test_restless_process_2(self):
        """Test if a two-qubit restless memory is correctly post-processed.
        This example corresponds to running two two-qubit circuits in an ideal restless setting.
        The first circuit applies an X gate to the first and a SX gate to the second qubit. The
        second circuit applies two identity gates."""
        n_qubits = 2
        node = RestlessToCounts(n_qubits)

        data = [["0x3", "0x1", "0x2", "0x0"], ["0x3", "0x1", "0x2", "0x0"]]
        processed_data = node(data=np.array(data))
        # time-ordered data: ["11", "11", "01", "01", "10", "10", "00", "00"]
        # classification: ["11", "00", "10", "00", "11", "00", "10", "00"]
        expected_data = np.array([{"10": 2, "11": 2}, {"00": 4}])
        self.assertTrue(processed_data.all() == expected_data.all())