fermion_operator¶
- fermion_operator(operator)¶
Converts an operator into a
FermionOperator.This is a thin, type-agnostic wrapper around the
SupportsFermionOperatorprotocol method, mirroring the free-function style offfsim.fermion_operator().- Parameters:
operator (SupportsFermionOperator) – the operator to convert, implementing
SupportsFermionOperator.- Returns:
The operator converted into a
FermionOperator.- Return type:
>>> from qiskit_fermions.mappers.library import fermion_operator >>> from qiskit_fermions.operators import MajoranaOperator >>> maj_op = MajoranaOperator.from_dict({(0, 1): 1}) >>> fer_op = fermion_operator(maj_op) >>> print(format(fer_op.normal_ordered().simplify())) 0.000000e0 +1.000000e0j * () 0.000000e0 -2.000000e0j * (+0 -0)