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
T1 constant calculation #4290
T1 constant calculation #4290
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.
Good first pass! I left a few suggestions here and there for some minor tweaks in the code and then a few suggestions for cleaning up the tests.
I'm not sure if I was supposed to be a reviewer on this or not so I'm happy to hand off to others if need be.
bad_fit = cirq.experiments.T1DecayResult( | ||
data=pd.DataFrame( | ||
columns=['delay_ns', 'false_count', 'true_count'], | ||
index=range(4), | ||
data=[ | ||
[100.0, 10, 0], | ||
[400.0, 10, 0], | ||
[700.0, 10, 0], | ||
[1000.0, 10, 0], | ||
], | ||
) | ||
) | ||
|
||
try: | ||
bad_fit.plot(include_fit=True) | ||
assert False | ||
except RuntimeWarning as warning: | ||
assert warning is not None |
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.
It might be a good idea to split this error case off into a separate test method. You can also make use of
with pytest.raises(..., match='whatever the error string is'):
... something that breaks...
to verify an error gets raised in the test.
@@ -165,6 +167,72 @@ def test_all_off_results(): | |||
) | |||
|
|||
|
|||
def test_constant(): |
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.
It might be worth looking into parameterizing this test with @pytest.mark.parameterize
so that you can remove some of the code duplication between the 100 and 400 cases, and just turn the relevant values between these two results into parameters for the test. Here's a quick example: https://github.com/quantumlib/Cirq/blob/master/cirq-core/cirq/ops/common_gates_test.py#L60
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.
Thanks for this suggestion! I've added this to the test, along with the explicitly exponential data from your other comment.
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.
One minor comment then LGTM
good_fit.plot(include_fit=True) | ||
|
||
|
||
def test_curve_fit_plot_error(): |
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.
Might want to indicate this is a warn and not an error.
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.
thanks for catching this!
Performs a curve fit to calculate t1 decay constant, includes option to plot curve fit Addresses Issue [quantumlib#4264](quantumlib#4264)
Performs a curve fit to calculate t1 decay constant, includes option to plot curve fit Addresses Issue [quantumlib#4264](quantumlib#4264)
Performs a curve fit to calculate t1 decay constant, includes option to plot curve fit
Addresses Issue #4264