-
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
Add type annotations to the PauliSum class #1104
Conversation
Here comes the conflict between Line 1025 in 7b8cc72
__rmul__ 's argument is typed to be Number instead of Union[int, float, complex] .
|
b09bd3a
to
7761a5b
Compare
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 looks basically good to me. I think the only open question is whether we want to stick with Number
for now or switch to Union[int, float, ...]
everywhere.
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.
Sorry for all the back and forth, but this is what I think we should do (let's punt on the Number
problem). If you make these two changes I'm happy to move forward 👍
pyquil/paulis.py
Outdated
@@ -22,17 +22,20 @@ | |||
import numpy as np | |||
import copy | |||
|
|||
from typing import Dict, FrozenSet, Iterable, Iterator, List, Optional, Tuple, Union | |||
from typing import Callable, Dict, FrozenSet, Iterable, Iterator, List, Optional, Sequence, Tuple, Union | |||
from pyquil.quilatom import ExpressionValueDesignator |
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.
instead of importing this, let's define PauliCoefficientDesignator = Union[int, float, complex]
and use that in place of ExpressionValueDesignator
pyquil/paulis.py
Outdated
import warnings | ||
|
||
PauliDesignator = Union['PauliTerm', 'PauliSum'] | ||
PauliT = Union[PauliDesignator, ExpressionValueDesignator] |
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.
let's remove PauliT
and replace all of its uses with Union[PauliDesignator, PauliCoefficientDesignator]
@karalekas added the final change in the 3rd commit that will be squashed later. |
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.
Two small changes. Otherwise lgtm.
@appleby addressed in commit "Third-round-of-review". |
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.
looks good to me. thanks @rht!
I will squash after an approval from @karalekas. |
LGTM! I can squash as part of the merge 👍 |
Description
Continuation of the effort to type-annotate paulis.py
Checklist
auto-close keywords.
including author and PR number (@username, gh-xxx).