<s> from sympy . physics . quantum import Dagger , AntiCommutator , qapply <EOL> from sympy . physics . quantum . fermion import FermionOp <EOL> from sympy . physics . quantum . fermion import FermionFockKet , FermionFockBra <EOL> def test_fermionoperator ( ) : <EOL> c = FermionOp ( '<STR_LIT:c>' ) <EOL> d = FermionOp ( '<STR_LIT:d>' ) <EOL> assert isinstance ( c , FermionOp ) <EOL> assert isinstance ( Dagger ( c ) , FermionOp ) <EOL> assert c . is_annihilation <EOL> assert not Dagger ( c ) . is_annihilation <EOL> assert FermionOp ( "<STR_LIT:c>" ) == FermionOp ( "<STR_LIT:c>" ) <EOL> assert FermionOp ( "<STR_LIT:c>" ) != FermionOp ( "<STR_LIT:d>" ) <EOL> assert FermionOp ( "<STR_LIT:c>" , True ) != FermionOp ( "<STR_LIT:c>" , False ) <EOL> assert AntiCommutator ( c , Dagger ( c ) ) . doit ( ) == <NUM_LIT:1> <EOL> assert AntiCommutator ( c , Dagger ( d ) ) . doit ( ) == c * Dagger ( d ) + Dagger ( d ) * c <EOL> def test_fermion_states ( ) : <EOL> c = FermionOp ( "<STR_LIT:c>" ) <EOL> assert ( FermionFockBra ( <NUM_LIT:0> ) * FermionFockKet ( <NUM_LIT:1> ) ) . doit ( ) == <NUM_LIT:0> <EOL> assert ( FermionFockBra ( <NUM_LIT:1> ) * FermionFockKet ( <NUM_LIT:1> ) ) . doit ( ) == <NUM_LIT:1> <EOL> assert qapply ( c * FermionFockKet ( <NUM_LIT:1> ) ) == FermionFockKet ( <NUM_LIT:0> ) <EOL> assert qapply ( c * FermionFockKet ( <NUM_LIT:0> ) ) == <NUM_LIT:0> <EOL> assert qapply ( Dagger ( c ) * FermionFockKet ( <NUM_LIT:0> ) ) == FermionFockKet ( <NUM_LIT:1> ) <EOL> assert qapply ( Dagger ( c ) * FermionFockKet ( <NUM_LIT:1> ) ) == <NUM_LIT:0> </s>
