-
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
V4 Setters for the Gate class #1535
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -236,10 +236,18 @@ def get_qubits(self, indices: bool = True) -> Set[QubitDesignator]: | |
def qubits(self): | ||
return list(self.get_qubits(indices=False)) | ||
|
||
@qubits.setter | ||
def qubits(self, qubits: Iterable[Union[Qubit, QubitPlaceholder, FormalArgument]]): | ||
quil_rs.Gate.qubits.__set__(self, _convert_to_rs_qubits(qubits)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This syntax may look weird, but it's necessary. If you are like me, you might think that something like this would work: super().qubits = ... But it doesn't! Turns out that syntax is only good for getting attributes, not setting them. This workaround was shamelessly stolen from this decade old issue on the topic of setting superclass attributes via |
||
|
||
@property | ||
def params(self): | ||
return _convert_to_py_parameters(super().parameters) | ||
|
||
@params.setter | ||
def params(self, params: Iterable[ParameterDesignator]): | ||
quil_rs.Gate.parameters.__set__(self, _convert_to_rs_expressions(params)) | ||
|
||
def get_qubit_indices(self) -> Set[int]: | ||
return {qubit.as_fixed() for qubit in super().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.
This is just a quick fix unrelated to the other changes. We changed how the
InfixOperator
enum was exported from the quil library and these needed to be updated to match.