Skip to content
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

Fix test failure on differing precision of float in proto string #5911

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions cirq-google/cirq_google/calibration/phased_fsim_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,7 @@ def test_xeb_to_calibration_layer():
layer_str = str(new_layer)
# Fix precision issues
layer_str = re.sub(r'0.004999\d+', '0.005', layer_str)
layer_str = re.sub(r'\b0.78539818\d*', '0.7853982', layer_str)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we fix this by setting theta on the fsim gate to a different value that can be exactly represented by floats, e.g. theta=0.5? We could do something similar on fatol to avoid the need for the previous string substitution hack, setting it to something like 2**-7 == 0.0078125 instead of 0.005.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, that is nicer than substitution. Done in 6148c40.

assert layer_str == desired_textproto


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ layer {
qubit_constant_index: 1
fsimgate {
theta {
float_value: 0.7853981852531433
float_value: 0.7853982
}
phi {
float_value: 0.0
Expand All @@ -24,7 +24,7 @@ layer {
qubit_constant_index: 3
fsimgate {
theta {
float_value: 0.7853981852531433
float_value: 0.7853982
}
phi {
float_value: 0.0
Expand Down