Skip to content

Commit

Permalink
Remove LegacyFermionicOp (#314)
Browse files Browse the repository at this point in the history
* Remove LegacyFermionicOp

* improve performance by change internal data structure

* compose preserves the label type

* rename to display_format and add to_list(display_format)

Co-authored-by: Max Rossmannek <[email protected]>
Co-authored-by: Steve Wood <[email protected]>
Co-authored-by: Max Rossmannek <[email protected]>
  • Loading branch information
4 people authored Aug 17, 2021
1 parent 9c130b7 commit 1d973e5
Show file tree
Hide file tree
Showing 8 changed files with 277 additions and 558 deletions.
9 changes: 7 additions & 2 deletions qiskit_nature/mappers/second_quantization/qubit_mapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@
from typing import List, Tuple

import numpy as np

from qiskit.opflow import PauliSumOp
from qiskit.quantum_info.operators import Pauli, SparsePauliOp

from qiskit_nature import QiskitNatureError
from qiskit_nature.operators.second_quantization import SecondQuantizedOp
from qiskit_nature.operators.second_quantization.fermionic_op import FermionicOp


class QubitMapper(ABC):
Expand Down Expand Up @@ -107,7 +107,12 @@ def times_annihilation_op(position, pauli_table):

# TODO to_list() is not an attribute of SecondQuantizedOp. Change the former to have this or
# change the signature above to take FermionicOp?
for label, coeff in second_q_op.to_list():
label_coeff_list = (
second_q_op.to_list(display_format="dense")
if isinstance(second_q_op, FermionicOp)
else second_q_op.to_list()
)
for label, coeff in label_coeff_list:

ret_op = SparsePauliOp(Pauli((all_false, all_false)), coeffs=[coeff])

Expand Down
Loading

0 comments on commit 1d973e5

Please sign in to comment.