qp.is_commuting is a function to quickly determine whether or not two operators should be commuting.
While we support anything with a defined pauli_rep property, we explicitly error out if we encounter Sum , Prod, or SProd instances without a pauli_rep, see here.
>>> qp.is_commuting(qp.X(0) + qp.Y(1), 3* qp.X(0))
True
>>> op1 = qp.RX(0.5, 0) + qp.T(1)
>>> op2 = 2*qp.RX(0.5, 0) @ qp.T(1)
>>> qp.is_commuting(op1, op2)
QuantumFunctionError: Operation RX(0.5, wires=[0]) + T(1) currently not supported. Prod, Sprod, and Sum instances must have a valid Pauli representation.
Instead, we should add logic so that:
- If it commutes with the
op.base of a qp.ops.SProd, it commutes with the SProd
- It commutes with all of the
op.operands of a qp.ops.Prod or a qp.ops.Sum (qp.ops.CompositeOp), the it commutes with the operator itself.
Subtasks
A PR that solves this issue should:
- Add logic to
is_commuting.py to support the above three types
- Adds tests to
test_is_commuting.py
- Adds a changelog entry to
changelog-dev.md under "Improvements", and adds your name to the list of contributors
- Follow our standards for pylint and black see here.
Any use of AI should conform to our AI Policy and be explicitly stated. Note that as this is "good first issue" intended to give newcomers experience contributing to open source software, I would like to discourage the use of AI to solve this issue.
qp.is_commutingis a function to quickly determine whether or not two operators should be commuting.While we support anything with a defined
pauli_repproperty, we explicitly error out if we encounterSum,Prod, orSProdinstances without apauli_rep, see here.Instead, we should add logic so that:
op.baseof aqp.ops.SProd, it commutes with theSProdop.operandsof aqp.ops.Prodor aqp.ops.Sum(qp.ops.CompositeOp), the it commutes with the operator itself.Subtasks
A PR that solves this issue should:
is_commuting.pyto support the above three typestest_is_commuting.pychangelog-dev.mdunder "Improvements", and adds your name to the list of contributorsAny use of AI should conform to our AI Policy and be explicitly stated. Note that as this is "good first issue" intended to give newcomers experience contributing to open source software, I would like to discourage the use of AI to solve this issue.