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

Allow symbolic scalars in LinearDict #7003

Merged
merged 11 commits into from
Feb 4, 2025

Conversation

daxfohl
Copy link
Collaborator

@daxfohl daxfohl commented Jan 30, 2025

Allows symbolic scalars in LinearDict, plus implementations of Pauli expansions for symbolic exponents in X, Y, and Z gates.

Applies to #1617. Resolves the core issue, though there are follow up tasks to update remaining gates _pauli_expansion_ methods, and then also PauliSum and LinearCombinationOfGates/Ops, along with the functions that create these classes, to accept or handle parameters.

@daxfohl daxfohl requested review from vtomole and a team as code owners January 30, 2025 01:20
@daxfohl daxfohl requested a review from viathor January 30, 2025 01:20
@CirqBot CirqBot added the size: M 50< lines changed <250 label Jan 30, 2025
@daxfohl daxfohl changed the title Parameterize LinearDict Allow symbolic scalars in LinearDict Jan 30, 2025
@daxfohl daxfohl marked this pull request as draft January 30, 2025 05:17
@@ -423,6 +465,7 @@ def test_unequal(terms_1, terms_2):
({'X': 1e-12}, {'X': 0}),
({'X': 5e-10}, {'Y': 2e-11}),
({'X': 1.000000001}, {'X': 1, 'Z': 0}),
({'X': sym + 0.000000001}, {'X': sym}),
Copy link
Collaborator Author

@daxfohl daxfohl Jan 30, 2025

Choose a reason for hiding this comment

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

I was impressed that approximate equality worked out of the box. No special handling required.

@daxfohl daxfohl marked this pull request as ready for review January 30, 2025 05:44
Copy link

codecov bot commented Jan 30, 2025

Codecov Report

Attention: Patch coverage is 98.83721% with 1 line in your changes missing coverage. Please review.

Project coverage is 97.89%. Comparing base (3f67923) to head (f523a51).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
cirq-core/cirq/value/linear_dict.py 98.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #7003      +/-   ##
==========================================
- Coverage   97.89%   97.89%   -0.01%     
==========================================
  Files        1085     1085              
  Lines       95132    95184      +52     
==========================================
+ Hits        93127    93176      +49     
- Misses       2005     2008       +3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Collaborator

@pavoljuhas pavoljuhas left a comment

Choose a reason for hiding this comment

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

LGTM with a couple of small suggestions

cirq-core/cirq/ops/common_gates.py Outdated Show resolved Hide resolved
cirq-core/cirq/ops/common_gates.py Outdated Show resolved Hide resolved
cirq-core/cirq/ops/common_gates.py Outdated Show resolved Hide resolved
cirq-core/cirq/value/linear_dict.py Outdated Show resolved Hide resolved
@daxfohl daxfohl enabled auto-merge February 4, 2025 00:24
@daxfohl daxfohl added this pull request to the merge queue Feb 4, 2025
Merged via the queue into quantumlib:main with commit 5c198ce Feb 4, 2025
38 checks passed
@daxfohl daxfohl deleted the param-linear-dict branch February 4, 2025 00:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size: M 50< lines changed <250
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants