-
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
Call qc.run_symmetrized_readout in measure_observables #1047
Conversation
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.
more minor docstring stuff
Co-Authored-By: appleby <86076+appleby@users.noreply.github.com>
Also changelog needs to be updated etc. |
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.
Here's a little snippet that should hopefully explain what I'm thinking!
import warnings
from enum import IntEnum
class SymmetrizationLevel(IntEnum):
EXHAUSTIVE = -1
NONE = 0
ONE = 1
TWO = 2
THREE = 3
def fn(level: int = SymmetrizationLevel.EXHAUSTIVE):
if level is None:
warnings.warn(f'Providing None to symmetrize_readout is deprecated, setting to {SymmetrizationLevel.NONE}')
level = SymmetrizationLevel.NONE
elif isinstance(level, str):
warnings.warn(f'Providing a string to symmetrize_readout is deprecated, setting to {SymmetrizationLevel.EXHAUSTIVE}')
level = SymmetrizationLevel.EXHAUSTIVE
elif level not in list(SymmetrizationLevel):
raise TypeError(f'The symmetrize_readout argument must be one of the following ints {list(SymmetrizationLevel)}')
return level
In [2]: fn(4)
---------------------------------------------------------------------------
Exception Traceback (most recent call last)
<ipython-input-2-90297181a897> in <module>
----> 1 fn(4)
<ipython-input-1-5b7d718a32db> in fn(level)
17 level = SymmetrizationLevel.EXHAUSTIVE
18 elif level not in list(SymmetrizationLevel):
---> 19 raise Exception(f'The symmetrize_readout argument must be one of the following ints {list(SymmetrizationLevel)}')
20 return level
21
Exception: The symmetrize_readout argument must be one of the following ints [<SymmetrizationLevel.EXHAUSTIVE: -1>, <SymmetrizationLevel.NONE: 0>, <SymmetrizationLevel.ONE: 1>, <SymmetrizationLevel.TWO: 2>, <SymmetrizationLevel.THREE: 3>]
symmetrize_readout = SymmetrizationLevel.NONE | ||
warnings.warn("'symmetrize_readout' should now be an int, 0 instead of none.", | ||
DeprecationWarning) | ||
elif symmetrize_readout == 'exhaustive': |
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 happens if someone passes a string that is not "exhaustive"?
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 think it matches previous behavior, you just get an error that tells you which values are supported.
Co-Authored-By: Peter Karalekas <peter@rigetti.com>
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.
Last batch of nitpicks.
Co-Authored-By: Peter Karalekas <peter@rigetti.com>
Description
closes #1046. Note that we are still supporting the deprecated
readout_symmetrize
argument; I'm not sure if this is an appropriate opportunity to drop it?Checklist
including author and PR number (@username, gh-xxx).