def operable_mock_device_2_wires(monkeypatch): """A mock instance of the abstract Device class that can support qfuncs.""" dev = Device with monkeypatch.context() as m: m.setattr(dev, '__abstractmethods__', frozenset()) m.setattr(dev, '_capabilities', {"model": "qubit"}) m.setattr(dev, 'operations', ["BasisState", "RX", "RY", "CNOT", "Rot", "PhaseShift"]) m.setattr(dev, 'observables', ["PauliX", "PauliY", "PauliZ"]) m.setattr(dev, 'reset', lambda self: None) m.setattr(dev, 'apply', lambda self, x, y, z: None) m.setattr(dev, 'expval', lambda self, x, y, z: 1) yield Device(wires=2)
def operable_mock_device_2_wires_with_inverses(monkeypatch): """A mock instance of the abstract Device class that can support Qubit qfuncs.""" dev = Device with monkeypatch.context() as m: m.setattr(dev, "__abstractmethods__", frozenset()) m.setattr(dev, "capabilities", lambda cls: {"model": "qubit", "inverse_operations": True}) m.setattr(dev, "operations", ["BasisState", "RX", "RY", "RZ", "CNOT", "PhaseShift"]) m.setattr(dev, "observables", ["PauliX", "PauliY", "PauliZ"]) m.setattr(dev, "reset", lambda self: None) m.setattr(dev, "apply", lambda self, x, y, z: None) m.setattr(dev, "expval", lambda self, x, y, z: 1) yield Device(wires=2)
def operable_mock_CV_device_2_wires(monkeypatch): """A mock instance of the abstract Device class that can support qfuncs.""" dev = Device with monkeypatch.context() as m: m.setattr(dev, '__abstractmethods__', frozenset()) m.setattr(dev, '_capabilities', {"model": "cv"}) m.setattr(dev, 'operations', ["FockState", "Displacement", "CubicPhase", "Squeezing", "Rotation", "Kerr", "Beamsplitter"]) m.setattr(dev, 'observables', ["X", "NumberOperator", "PolyXP"]) m.setattr(dev, 'reset', lambda self: None) m.setattr(dev, 'apply', lambda self, x, y, z: None) m.setattr(dev, 'expval', lambda self, x, y, z: 1) yield Device(wires=2)
def operable_mock_CV_device_2_wires(monkeypatch): """A mock instance of the abstract Device class that can support CV qfuncs.""" dev = Device with monkeypatch.context() as m: m.setattr(dev, "__abstractmethods__", frozenset()) m.setattr( dev, "operations", ["Displacement", "CubicPhase", "Squeezing", "Rotation", "Kerr", "Beamsplitter"], ) m.setattr(dev, "observables", ["X", "NumberOperator"]) m.setattr(dev, "reset", lambda self: None) m.setattr(dev, "apply", lambda self, x, y, z: None) m.setattr(dev, "expval", lambda self, x, y, z: 1) yield Device(wires=2)