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

Make InternalGate hashable if all gate args are hashable #6294

Merged
merged 2 commits into from
Sep 19, 2023

Conversation

maffoo
Copy link
Contributor

@maffoo maffoo commented Sep 19, 2023

Currently InternalGate includes a dict in _value_equality_values_, so it is never hashable even if all gate args are hashable. Change to use a frozenset of items instead to make it hashable. We also change to store constructor kwargs directly instead of copying the kwargs dict, since **kwargs passed in to a function is always a unique dictionary which won't alias a caller's dict.

@maffoo maffoo requested review from wcourtney, vtomole, cduck, verult and a team as code owners September 19, 2023 18:57
@CirqBot CirqBot added the size: S 10< lines changed <50 label Sep 19, 2023
@codecov
Copy link

codecov bot commented Sep 19, 2023

Codecov Report

Patch coverage: 100.00% and no project coverage change.

Comparison is base (1366494) 97.88% compared to head (d4a9cc1) 97.88%.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #6294   +/-   ##
=======================================
  Coverage   97.88%   97.88%           
=======================================
  Files        1104     1104           
  Lines       95841    95854   +13     
=======================================
+ Hits        93818    93831   +13     
  Misses       2023     2023           
Files Changed Coverage Δ
cirq-google/cirq_google/ops/internal_gate.py 100.00% <100.00%> (ø)
cirq-google/cirq_google/ops/internal_gate_test.py 100.00% <100.00%> (ø)

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

@maffoo maffoo enabled auto-merge (squash) September 19, 2023 19:53
@maffoo maffoo merged commit d805d82 into master Sep 19, 2023
@maffoo maffoo deleted the u/maffoo/internal-gate-hash branch September 19, 2023 20:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size: S 10< lines changed <50
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants