-
Notifications
You must be signed in to change notification settings - Fork 342
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
Back Frame and DefFrame with quil_rs #1542
Back Frame and DefFrame with quil_rs #1542
Conversation
…4-feature-program-use-defframe-api
qubits: Tuple[Union[Qubit, FormalArgument], ...] | ||
""" A tuple of qubits on which the frame exists. """ | ||
@staticmethod | ||
def __new__(cls, qubits: Sequence[Union[int, Qubit, FormalArgument]], name: str) -> "Frame": |
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.
I feel like name
should be the first parameter here for consistency with the other instructions. Should we add a deprecation warning?
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.
What do you think about making it keyword-only so it doesn't matter? I suppose that might be inconsistent with other constructors, but it's more future-proof than just switching them and is good practice anyway
It may also make for a more useful error for scripts where they are present and out of order, than just a type error when qubits are used where a name is expected.
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.
I do like that idea, do we want to commit to that for all instructions? How do we best warn users about that future change? So far we've been adding deprecation warnings, but that would be pretty noisy if all instructions had one.
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.
Since this discussion seems like it'll have impact beyond just this instruction, I've made a note to have a followup discussion and will push forward with this PR as is.
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.
The original classes were @dataclasses. In order to subclass them properly, I removed the @DataClass decorator. This may result in unexpected breaking changes. Might be worth labeling it as such, even if we think most of the functionality is the same.
Agreed.
Reviewed for anything that looked out of place - did not see anything. There may be omitted/missing behavior but we'll spot that in e2e testing if that's the case
qubits: Tuple[Union[Qubit, FormalArgument], ...] | ||
""" A tuple of qubits on which the frame exists. """ | ||
@staticmethod | ||
def __new__(cls, qubits: Sequence[Union[int, Qubit, FormalArgument]], name: str) -> "Frame": |
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.
What do you think about making it keyword-only so it doesn't matter? I suppose that might be inconsistent with other constructors, but it's more future-proof than just switching them and is good practice anyway
It may also make for a more useful error for scripts where they are present and out of order, than just a type error when qubits are used where a name is expected.
Description
Does what it says on the tin, backs the
Frame
andDefFrame
classes withquil_rs.FrameIdentifier
, andquil_rs.FrameDefinition
, respectively.The original classes were
@dataclass
es. In order to subclass them properly, I removed the@dataclass
decorator. This may result in unexpected breaking changes. Might be worth labeling it as such, even if we think most of the functionality is the same.