#NEWLINE# def assert_wolfe( s , phi , derphi , c1 = 0.0001 , c2 = 0.9 , err_msg = '' ) : #NEWLINE# #INDENT# '\n    Check that strong Wolfe conditions apply\n    ' #NEWLINE# phi1 = phi ( s ) #NEWLINE# phi0 = phi ( 0 ) #NEWLINE# derphi0 = derphi ( 0 ) #NEWLINE# derphi1 = derphi ( s ) #NEWLINE# msg = ( "s = %s; phi(0) = %s; phi(s) = %s; phi'(0) = %s; phi'(s) = %s; %s" % ( s , c2 , phi1 , derphi0 , derphi1 , err_msg ) ) #NEWLINE# assert_ ( ( phi1 <= ( phi0 + ( ( c1 * s ) * derphi0 ) ) ) , ( 'Wolfe 1 failed: ' + msg ) ) #NEWLINE# assert_ ( ( abs ( derphi1 ) <= abs ( ( c2 * derphi0 ) ) ) , ( 'Wolfe 2 failed: ' + msg ) )