Ejemplo n.º 1
0
    def test_supports_observable_argument_types(self):
        """Checks that device.supports_observable returns the correct result 
           when passed both string and Operation class arguments"""
        self.logTestName()

        mock_device = Device()

        self.assertTrue(mock_device.supports_observable('PauliX'))
        self.assertTrue(mock_device.supports_observable(qml.PauliX))
Ejemplo n.º 2
0
    def test_supports_observable_exception(self):
        """check that a the function device.supports_observable raises proper errors
           if the argument is of the wrong type"""
        self.logTestName()

        mock_device = Device()

        with self.assertRaisesRegex(
                ValueError,
                "The given operation must either be a pennylane.Observable class or a string."
        ):
            mock_device.supports_observable(3)

        with self.assertRaisesRegex(
                ValueError,
                "The given operation must either be a pennylane.Observable class or a string."
        ):
            mock_device.supports_observable(qml.CNOT)