Skip to content

get_sparse_operator fails on non-simplified QubitOperators #880

Open
@jagunther

Description

@jagunther

Hi,

I noticed that get_sparse_operator() assumes that Paulistrings in a QubitOperator are simplified, i.e. there should be no Paulis within a Paulistring acting on the same tensor-factor. Normally when initialising a QubitOperator the simplification is done automatically, however, the Symmetry-conserving Bravyi-Kitaev transform does not do this. Below is a small example:

from openfermion import (
    get_sparse_operator,
    FermionOperator,
    symmetry_conserving_bravyi_kitaev,
)

fermion_op = FermionOperator("0^ 1^")
qubit_op = symmetry_conserving_bravyi_kitaev(fermion_op, 4, 2)
print(qubit_op)

# throws error
get_sparse_operator(qubit_op)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions