Example #1
0
    def test_generate_samples(self, samples, indices):
        """Tests that the generate_samples function of AQTDevice provides samples in
        the correct format expected by PennyLane."""

        dev = AQTDevice(3, api_key=SOME_API_KEY)
        dev.shots = 10
        dev.samples = samples
        res = dev.generate_samples()
        expected_array = np.stack([np.ravel(indices)] * 10)

        assert res.shape == (dev.shots, dev.num_wires)
        assert np.all(res == expected_array)
Example #2
0
    def test_reset(self):
        """Tests that the ``reset`` method corretly resets data."""

        dev = AQTDevice(3, api_key=SOME_API_KEY)
        assert dev.circuit == []

        dev.circuit = [["RX", 0.5, [0]]]
        dev.circuit_json = "some dummy string"
        dev.samples = [5, 5, 5]
        dev.shots = 55

        dev.reset()

        assert dev.circuit == []
        assert dev.circuit_json == ""
        assert dev.samples == None
        assert dev.shots == 55  # should not be reset