Skip to content

Commit

Permalink
Add metadata property to device. (#4868)
Browse files Browse the repository at this point in the history
Adds metadata property default to None to all devices. I'm going to leave this open to vendors to add to this as they see fit. Part of #4743 . Note that if in the process of deprecating other things for #4744 , I will pull vendor devices onto using metadata to keep behavior working.
  • Loading branch information
MichaelBroughton authored Jan 21, 2022
1 parent e29f47c commit 394b9cf
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
9 changes: 9 additions & 0 deletions cirq-core/cirq/devices/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,15 @@ def decompose_operation(self, operation: 'cirq.Operation') -> 'cirq.OP_TREE':
"""
return operation

@property
def metadata(self) -> Optional['DeviceMetadata']:
"""Returns the associated Metadata with the device if applicable.
Returns:
`cirq.DeviceMetadata` if specified by the device otherwise None.
"""
return None

def validate_operation(self, operation: 'cirq.Operation') -> None:
"""Raises an exception if an operation is not valid.
Expand Down
7 changes: 7 additions & 0 deletions cirq-core/cirq/devices/device_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,13 @@ def test_qid_pair():
cirq.SymmetricalQidPair(q0, q0)


def test_device_metadata():
class RawDevice(cirq.Device):
pass

assert RawDevice().metadata is None


def test_metadata():
qubits = cirq.LineQubit.range(4)
graph = nx.star_graph(3)
Expand Down

0 comments on commit 394b9cf

Please sign in to comment.