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 OpIdentifier serializable for all inputs #6295

Merged
merged 8 commits into from
Sep 26, 2023

Conversation

epelaaez
Copy link
Contributor

Closes #6292

Makes OpIdentifier serializable for inputs that are instances of classes. For example,

qubits = cirq.LineQubit.range(1)
cliff = cirq.SingleQubitCliffordGate.from_xz_map((cirq.X, False), (cirq.Z, False))
op_id = cirq.OpIdentifier(cliff, qubits[0])
print(repr(op_id), "\n")
print(cirq.to_json(op_id))

will output

cirq.devices.noise_utils.OpIdentifier(cirq.CliffordGate.from_clifford_tableau(cirq.CliffordTableau(1,rs=np.array([False, False], dtype=np.dtype('bool')), xs=np.array([[True], [False]], dtype=np.dtype('bool')),zs=np.array([[False], [True]], dtype=np.dtype('bool')), initial_state=0)), cirq.LineQubit(0)) 

{
  "cirq_type": "OpIdentifier",
  "gate_type": {
    "cirq_type": "SingleQubitCliffordGate",
    "n": 1,
    "rs": [
      false,
      false
    ],
    "xs": [
      [
        true
      ],
      [
        false
      ]
    ],
    "zs": [
      [
        false
      ],
      [
        true
      ]
    ]
  },
  "qubits": [
    {
      "cirq_type": "LineQubit",
      "x": 0
    }
  ]
}

@epelaaez epelaaez requested review from vtomole, cduck and a team as code owners September 21, 2023 17:51
@epelaaez epelaaez requested a review from fdmalone September 21, 2023 17:51
@google-cla
Copy link

google-cla bot commented Sep 21, 2023

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@CirqBot CirqBot added the size: M 50< lines changed <250 label Sep 21, 2023
@vtomole
Copy link
Collaborator

vtomole commented Sep 21, 2023

@epelaaez Please sign the CLA

@codecov
Copy link

codecov bot commented Sep 21, 2023

Codecov Report

All modified lines are covered by tests ✅

Comparison is base (c696323) 97.89% compared to head (6e4876f) 97.89%.
Report is 1 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #6295   +/-   ##
=======================================
  Coverage   97.89%   97.89%           
=======================================
  Files        1104     1104           
  Lines       95874    95887   +13     
=======================================
+ Hits        93852    93866   +14     
+ Misses       2022     2021    -1     
Files Coverage Δ
cirq-core/cirq/_compat.py 98.71% <100.00%> (+<0.01%) ⬆️
cirq-core/cirq/devices/noise_utils.py 98.66% <100.00%> (+0.03%) ⬆️
cirq-core/cirq/devices/noise_utils_test.py 100.00% <100.00%> (ø)
cirq-ft/cirq_ft/algos/and_gate.py 100.00% <100.00%> (ø)
cirq-ft/cirq_ft/algos/and_gate_test.py 100.00% <100.00%> (ø)
cirq-ft/cirq_ft/algos/hubbard_model.py 98.21% <ø> (ø)
.../cirq_ft/algos/multi_control_multi_target_pauli.py 100.00% <100.00%> (ø)
...-ft/cirq_ft/algos/prepare_uniform_superposition.py 100.00% <ø> (ø)
cirq-ft/cirq_ft/algos/qrom.py 100.00% <ø> (ø)
cirq-ft/cirq_ft/algos/unary_iteration_gate.py 96.26% <ø> (ø)
... and 2 more

... and 1 file with indirect coverage changes

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

@epelaaez epelaaez requested a review from vtomole September 22, 2023 18:17
Copy link
Collaborator

@vtomole vtomole left a comment

Choose a reason for hiding this comment

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

LGTM

@vtomole vtomole enabled auto-merge (squash) September 26, 2023 17:10
@vtomole vtomole merged commit fd18da5 into quantumlib:master Sep 26, 2023
@epelaaez epelaaez deleted the issue-6292 branch September 26, 2023 18:50
harry-phasecraft pushed a commit to PhaseCraft/Cirq that referenced this pull request Oct 31, 2024
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.

'SingleQubitCliffordGate' object has no attribute '__name__'
3 participants