def test_sample_attribute_error(self): """Check that an error is raised if a required attribute is not present in a sampled observable""" self.logTestName() dev = qml.device('default.qubit', wires=2) queue = [qml.RX(0.543, wires=[0], do_queue=False)] # Make a sampling observable but delete its num_samples attribute obs = qml.sample(qml.PauliZ(0, do_queue=False), n=10) del obs.num_samples obs = [obs] with self.assertRaisesRegex( qml.DeviceError, "Number of samples not specified for observable"): dev.execute(queue, obs)
def circuit(): return qml.sample(qml.NumberOperator(0), 10) raise NotImplementedError()
def circuit(x): qml.RX(x, wires=[0]) return qml.sample(qml.PauliZ(0), 1), qml.sample(qml.PauliX(1), 1)
def circuit(): return qml.sample(qml.NumberOperator(0), 10)