#NEWLINE# def test_PermutationOperator( ) : #NEWLINE# #INDENT# ( p , q , r , s ) = symbols ( 'p,q,r,s' ) #NEWLINE# ( f , g , h , i ) = map ( Function , 'fghi' ) #NEWLINE# P = PermutationOperator #NEWLINE# assert ( P ( p , q ) . get_permuted ( ( f ( p ) * g ( q ) ) ) == ( ( - f ( q ) ) * g ( p ) ) ) #NEWLINE# assert ( P ( p , q ) . get_permuted ( f ( p , q ) ) == ( - f ( q , p ) ) ) #NEWLINE# assert ( P ( p , q ) . get_permuted ( f ( p ) ) == f ( p ) ) #NEWLINE# expr = ( ( ( ( ( ( f ( p ) * g ( q ) ) * h ( r ) ) * i ( s ) ) - ( ( ( f ( q ) * g ( p ) ) * h ( r ) ) * i ( s ) ) ) - ( ( ( f ( p ) * g ( q ) ) * h ( s ) ) * i ( r ) ) ) + ( ( ( f ( q ) * g ( p ) ) * h ( s ) ) * i ( r ) ) ) #NEWLINE# perms = [ P ( p , q ) , P ( r , s ) ] #NEWLINE# assert ( simplify_index_permutations ( expr , perms ) == ( ( ( ( ( P ( p , q ) * P ( r , s ) ) * f ( p ) ) * g ( q ) ) * h ( r ) ) * i ( s ) ) )