Consistent ordering of tuples for qubit-operations pairs in PauliTerm
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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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