Exemplo n.º 1
0
 def test_generate_samples(self, results, indices):
     """Tests that the generate_samples function of HQSDevice provides samples in
     the correct format expected by PennyLane."""
     dev = HQSDevice(3,
                     machine=DUMMY_MACHINE,
                     shots=10,
                     user_email=DUMMY_EMAIL)
     dev._results = results
     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)
Exemplo n.º 2
0
    def test_reset(self):
        """Tests that the ``reset`` method corretly resets data."""

        dev = HQSDevice(3,
                        shots=10,
                        machine=DUMMY_MACHINE,
                        user_email=DUMMY_EMAIL)

        dev._results = ["00"] * 10
        dev._samples = np.zeros((10, 3))
        dev.shots = 11

        dev.reset()

        assert dev._results is None
        assert dev._samples is None
        assert dev.shots == 11  # should not be reset