SupportsFermionOperator¶
- class SupportsFermionOperator(*args, **kwargs)¶
Bases:
ProtocolThis package’s operator-conversion contract, converting an operator to a
FermionOperator.See
fermion_operator()for the type-agnostic helper function dispatching to the method below.Caution
Despite the shared method name, this is not the same contract as
ffsim.SupportsFermionOperator: this one returns aFermionOperator, whereas ffsim’s returns anffsim.FermionOperator. The two types are unrelated. Sinceffsim.fermion_operator()dispatches purely on the method name, calling it on an operator of this package returns this package’s type rather than ffsim’s; usefermion_operator()when that is what you mean.>>> from qiskit_fermions.operators import MajoranaOperator >>> maj_op = MajoranaOperator.from_dict({(0, 1): 1}) >>> fer_op = maj_op._fermion_operator_() >>> print(format(fer_op.normal_ordered().simplify())) 0.000000e0 +1.000000e0j * () 0.000000e0 -2.000000e0j * (+0 -0)
Protocol Methods
- _fermion_operator_()¶
Converts this operator into a
FermionOperatorinstance.- Return type: