Changeset 1162
- Timestamp:
- 07/25/08 12:27:25 (4 months ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/openopt/scikits/openopt/Kernel/objFunRelated.py
r1156 r1162 317 317 for fun in getattr(p.user, derivativesType): 318 318 tmp = atleast_1d(fun(*(x,)+getattr(p.args, funcType))) 319 if not ((tmp.size == p.n and nFuncs == 1) or (tmp.ndim>1 and tmp.shape[1] == p.n)):319 if mod(tmp.size, p.n) != 0: 320 320 if funcType=='f': 321 321 p.err('incorrect user-supplied (sub)gradient size of objective function') trunk/openopt/scikits/openopt/Kernel/ooCheckGradient.py
r1128 r1162 1 from numpy import hstack, ceil, floor, log10, inf, tile, argmax, abs, asfarray, ravel 1 from numpy import hstack, ceil, floor, log10, inf, tile, argmax, abs, asfarray, ravel, any 2 2 from string import rjust, ljust 3 3 class autocreate: … … 81 81 82 82 print('OpenOpt checks user-supplied gradient ' + fun_ + ' (shape: ' + str(info_user.shape) + ' )') 83 print('according to prob.diffInt = ' + str(p.diffInt))#TODO: ADD other parameters: allowed epsilon, maxDiffLines etc 84 print('lines with 1 - info_user/info_numerical greater than maxViolation = '+ str(p.maxViolation) + ' will be shown') 83 print('according to:') 84 print(' prob.diffInt = ' + str(p.diffInt))#TODO: ADD other parameters: allowed epsilon, maxDiffLines etc 85 print(' |1 - info_user/info_numerical| <= prob.maxViolation = '+ str(p.maxViolation)) 85 86 86 if (abs(Diff) >= p.maxViolation).any():87 if any(abs(Diff) >= p.maxViolation): 87 88 ss = ' ' 88 89 if fun_ in doubleColumn: … … 116 117 ind_max = argmax(diff_d) 117 118 val_max = diff_d[ind_max] 118 print('max(abs(' + fun_ + '_user - ' + fun_ + '_numerical)) = ' + str(val_max)) 119 print('(is registered in '+ fun_+ ' number ' + str(ind_max) + ')') 119 if any(abs(Diff) >= p.maxViolation): 120 print('max(abs(' + fun_ + '_user - ' + fun_ + '_numerical)) = ' + str(val_max)) 121 print('(is registered in '+ fun_+ ' number ' + str(ind_max) + ')') 122 else: 123 print('derivatives are equal') 120 124 #print('sum(abs(' + fun_ + '_user - ' + fun_ + '_numerical)) = ' + str(p.norm(d[:,2],1))) 121 125
