-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add DeviceMetaData class. #4832
Conversation
cirq-core/cirq/devices/device.py
Outdated
|
||
self._nx_graph = nx_graph | ||
self._kwargs_names = kwargs.keys() | ||
self.__dict__.update(kwargs) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Directly modifying the object dict feels super hacky to me - this will lead to cases like:
md = DeviceMetaData(qubits, nx_graph, blah=12)
# elsewhere, maybe in a different file
result = md.blah
which is difficult to trace: DeviceMetaData
has no blah
member variable, and using an instance other than the one initialized above will cause an error.
If we really need to store arbitrary typeless information in this object (as opposed to using subclasses which add explicitly-typed member variables), we should pack it into a Dict[str, Any]
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed altogether.
cirq-core/cirq/devices/device.py
Outdated
if qubits is not None: | ||
qubits = frozenset(qubits) | ||
self._qubits_set: Optional[FrozenSet['cirq.Qid']] = cast( | ||
Optional[FrozenSet['cirq.Qid']], qubits | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: this would be more concise as
self._qubits_set: Optional[FrozenSet['cirq.Qid']] = (
None if qubits is None else frozenset(qubits)
)
Adds standalone DeviceMetaData class. First step in quantumlib#4743 .
Adds standalone DeviceMetaData class. First step in quantumlib#4743 .
Adds standalone DeviceMetaData class. First step in quantumlib#4743 .
Adds standalone DeviceMetaData class. First step in #4743 .