#NEWLINE# def test_subtraction_opt( ) : #NEWLINE# #INDENT# e = ( ( ( x - y ) * ( z - y ) ) + exp ( ( ( x - y ) * ( z - y ) ) ) ) #NEWLINE# ( substs , reduced ) = cse ( [ e ] , optimizations = [ ( cse_opts . sub_pre , cse_opts . sub_post ) ] ) #NEWLINE# assert ( substs == [ ( x0 , ( ( x - y ) * ( y - z ) ) ) ] ) #NEWLINE# assert ( reduced == [ ( ( - x0 ) + exp ( ( - x0 ) ) ) ] ) #NEWLINE# e = ( ( ( - ( x - y ) ) * ( z - y ) ) + exp ( ( ( - ( x - y ) ) * ( z - y ) ) ) ) #NEWLINE# ( substs , reduced ) = cse ( [ e ] , optimizations = [ ( cse_opts . sub_pre , cse_opts . sub_post ) ] ) #NEWLINE# assert ( substs == [ ( x0 , ( ( x - y ) * ( y - z ) ) ) ] ) #NEWLINE# assert ( reduced == [ ( x0 + exp ( x0 ) ) ] ) #NEWLINE# n = ( ( - 1 ) + ( 1 / x ) ) #NEWLINE# e = ( ( ( n / x ) / ( ( - n ) ** 2 ) ) - ( ( 1 / n ) / x ) ) #NEWLINE# assert ( cse ( e , optimizations = [ ( cse_opts . sub_pre , cse_opts . sub_post ) ] ) == ( [ ] , [ 0 ] ) )