#NEWLINE# @ suppressed_stdout #NEWLINE# def test_ncg( self ) : #NEWLINE# #INDENT# if self . use_wrapper : #NEWLINE# #INDENT# opts = { #NEWLINE# #INDENT# 'maxiter' : self . maxiter , #NEWLINE# 'disp' : self . disp , #NEWLINE# 'return_all' : False , #NEWLINE# #UNINDENT# } #NEWLINE# retval = optimize . minimize ( self . func , self . startparams , method = 'Newton-CG' , jac = self . grad , args = ( ) , options = opts ) [ 'x' ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# retval = optimize . fmin_ncg ( self . func , self . startparams , self . grad , args = ( ) , maxiter = self . maxiter , full_output = False , disp = self . disp , retall = False ) #NEWLINE# #UNINDENT# params = retval #NEWLINE# assert_allclose ( self . func ( params ) , self . func ( self . solution ) , atol = 1e-06 ) #NEWLINE# assert_ ( ( self . funccalls == 7 ) , self . funccalls ) #NEWLINE# assert_ ( ( self . gradcalls <= 22 ) , self . gradcalls ) #NEWLINE# assert_allclose ( self . trace [ 3 : 5 ] , [ [ ( - 4.35700753e-07 ) , ( - 0.524869435 ) , 0.48752748 ] , [ ( - 4.35700753e-07 ) , ( - 0.524869401 ) , 0.487527774 ] ] , atol = 1e-06 , rtol = 1e-07 )