rigetti / rigetti/pyquil

Consistent ordering of tuples for qubit-operations pairs in PauliTerm

Open
#766 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
1.5k
Forks
358
Avg merge
1d 58m
Merged PRs (30d)
4

Description

The PauliTerm class has an inconsistent ordering for tuples formed out of pairs of qubits and operations on qubits. Consider the following code snippet:

from pyquil.paulis import *

pt = sX(0) * sY(1)
pt_ops = pt.operations_as_set()
pt_new = PauliTerm.from_list(list(pt_ops))

raises an AssertionError with no clear reason why it's failing. The reason is that list(pt_ops) creates a list of tuples of the form (qubit, operation) whereas PauliTerm.from_list(..) demands a list of tuples of the form (operation, qubit). The fix for the above code snippet is then the rather ugly looking

pt_new = PauliTerm.from_list([(i[1], i[0]) for i in pt_ops])
assert pt_new == pt

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in the pyquil.paulis module with PauliTerm.operations_as_set and PauliTerm.from_list, then reproduce the example using sX(0) * sY(1). Trace the tuple order each method returns and accepts; done means the example can pass operations_as_set directly to from_list and the resulting PauliTerm equals the original.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
backend
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
50/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.