#NEWLINE# def test_minimize_automethod( self ) : #NEWLINE# #INDENT# def f( x ) : #NEWLINE# #INDENT# return ( x ** 2 ) #NEWLINE# #UNINDENT# def cons( x ) : #NEWLINE# #INDENT# return ( x - 2 ) #NEWLINE# #UNINDENT# x0 = np . array ( [ 10.0 ] ) #NEWLINE# sol_0 = optimize . minimize ( f , x0 ) #NEWLINE# sol_1 = optimize . minimize ( f , x0 , constraints = [ { #NEWLINE# #INDENT# 'type' : 'ineq' , #NEWLINE# 'fun' : cons , #NEWLINE# #UNINDENT# } ] ) #NEWLINE# sol_2 = optimize . minimize ( f , x0 , bounds = [ ( 5 , 10 ) ] ) #NEWLINE# sol_3 = optimize . minimize ( f , x0 , constraints = [ { #NEWLINE# #INDENT# 'type' : 'ineq' , #NEWLINE# 'fun' : cons , #NEWLINE# #UNINDENT# } ] , bounds = [ ( 5 , 10 ) ] ) #NEWLINE# sol_4 = optimize . minimize ( f , x0 , constraints = [ { #NEWLINE# #INDENT# 'type' : 'ineq' , #NEWLINE# 'fun' : cons , #NEWLINE# #UNINDENT# } ] , bounds = [ ( 1 , 10 ) ] ) #NEWLINE# for sol in [ sol_0 , sol_1 , sol_2 , sol_3 , sol_4 ] : #NEWLINE# #INDENT# assert_ ( sol . success ) #NEWLINE# #UNINDENT# assert_allclose ( sol_0 . x , 0 , atol = 1e-07 ) #NEWLINE# assert_allclose ( sol_1 . x , 2 , atol = 1e-07 ) #NEWLINE# assert_allclose ( sol_2 . x , 5 , atol = 1e-07 ) #NEWLINE# assert_allclose ( sol_3 . x , 5 , atol = 1e-07 ) #NEWLINE# assert_allclose ( sol_4 . x , 2 , atol = 1e-07 )