#NEWLINE# def test_minimize_scalar( self ) : #NEWLINE# #INDENT# x = optimize . minimize_scalar ( self . fun ) . x #NEWLINE# assert_allclose ( x , self . solution , atol = 1e-06 ) #NEWLINE# x = optimize . minimize_scalar ( self . fun , method = 'Brent' ) #NEWLINE# assert_ ( x . success ) #NEWLINE# x = optimize . minimize_scalar ( self . fun , method = 'Brent' , options = dict ( maxiter = 3 ) ) #NEWLINE# assert_ ( ( not x . success ) ) #NEWLINE# x = optimize . minimize_scalar ( self . fun , bracket = ( ( - 3 ) , ( - 2 ) ) , args = ( 1.5 , ) , method = 'Brent' ) . x #NEWLINE# assert_allclose ( x , self . solution , atol = 1e-06 ) #NEWLINE# x = optimize . minimize_scalar ( self . fun , method = 'Brent' , args = ( 1.5 , ) ) . x #NEWLINE# assert_allclose ( x , self . solution , atol = 1e-06 ) #NEWLINE# x = optimize . minimize_scalar ( self . fun , bracket = ( ( - 15 ) , ( - 1 ) , 15 ) , args = ( 1.5 , ) , method = 'Brent' ) . x #NEWLINE# assert_allclose ( x , self . solution , atol = 1e-06 ) #NEWLINE# x = optimize . minimize_scalar ( self . fun , bracket = ( ( - 3 ) , ( - 2 ) ) , args = ( 1.5 , ) , method = 'golden' ) . x #NEWLINE# assert_allclose ( x , self . solution , atol = 1e-06 ) #NEWLINE# x = optimize . minimize_scalar ( self . fun , method = 'golden' , args = ( 1.5 , ) ) . x #NEWLINE# assert_allclose ( x , self . solution , atol = 1e-06 ) #NEWLINE# x = optimize . minimize_scalar ( self . fun , bracket = ( ( - 15 ) , ( - 1 ) , 15 ) , args = ( 1.5 , ) , method = 'golden' ) . x #NEWLINE# assert_allclose ( x , self . solution , atol = 1e-06 ) #NEWLINE# x = optimize . minimize_scalar ( self . fun , bounds = ( 0 , 1 ) , args = ( 1.5 , ) , method = 'Bounded' ) . x #NEWLINE# assert_allclose ( x , 1 , atol = 0.0001 ) #NEWLINE# x = optimize . minimize_scalar ( self . fun , bounds = ( 1 , 5 ) , args = ( 1.5 , ) , method = 'bounded' ) . x #NEWLINE# assert_allclose ( x , self . solution , atol = 1e-06 ) #NEWLINE# x = optimize . minimize_scalar ( self . fun , bounds = ( np . array ( [ 1 ] ) , np . array ( [ 5 ] ) ) , args = ( np . array ( [ 1.5 ] ) , ) , method = 'bounded' ) . x #NEWLINE# assert_allclose ( x , self . solution , atol = 1e-06 ) #NEWLINE# assert_raises ( ValueError , optimize . minimize_scalar , self . fun , bounds = ( 5 , 1 ) , method = 'bounded' , args = ( 1.5 , ) ) #NEWLINE# assert_raises ( ValueError , optimize . minimize_scalar , self . fun , bounds = ( np . zeros ( 2 ) , 1 ) , method = 'bounded' , args = ( 1.5 , ) ) #NEWLINE# x = optimize . minimize_scalar ( self . fun , bounds = ( 1 , np . array ( 5 ) ) , method = 'bounded' ) . x #NEWLINE# assert_allclose ( x , self . solution , atol = 1e-06 )