#NEWLINE# def test_cse_Indexed( ) : #NEWLINE# #INDENT# len_y = 5 #NEWLINE# y = IndexedBase ( 'y' , shape = ( len_y , ) ) #NEWLINE# x = IndexedBase ( 'x' , shape = ( len_y , ) ) #NEWLINE# Dy = IndexedBase ( 'Dy' , shape = ( ( len_y - 1 ) , ) ) #NEWLINE# i = Idx ( 'i' , ( len_y - 1 ) ) #NEWLINE# expr1 = ( ( y [ ( i + 1 ) ] - y [ i ] ) / ( x [ ( i + 1 ) ] - x [ i ] ) ) #NEWLINE# expr2 = ( 1 / ( x [ ( i + 1 ) ] - x [ i ] ) ) #NEWLINE# ( replacements , reduced_exprs ) = cse ( [ expr1 , expr2 ] ) #NEWLINE# assert ( len ( replacements ) > 0 )