def generic_check(self,expr,arg_dict,type,size,mod_location): clean_result = array(arg_dict['result'],copy=1) t1 = time.time() exec expr in globals(),arg_dict t2 = time.time() standard = t2 - t1 desired = arg_dict['result'] arg_dict['result'] = clean_result t1 = time.time() old_env = os.environ.get('PYTHONCOMPILED','') os.environ['PYTHONCOMPILED'] = mod_location blitz_tools.blitz(expr,arg_dict,{},verbose=0) #, #extra_compile_args = ['-O3','-malign-double','-funroll-loops']) os.environ['PYTHONCOMPILED'] = old_env t2 = time.time() compiled = t2 - t1 actual = arg_dict['result'] # this really should give more info... try: # this isn't very stringent. Need to tighten this up and # learn where failures are occuring. assert(allclose(abs(actual.ravel()),abs(desired.ravel()),1e-4,1e-6)) except: diff = actual-desired print diff[:4,:4] print diff[:4,-4:] print diff[-4:,:4] print diff[-4:,-4:] print sum(abs(diff.ravel()),axis=0) raise AssertionError return standard,compiled
def generic_check(self, expr, arg_dict, type, size, mod_location): clean_result = array(arg_dict['result'], copy=1) t1 = time.time() exec expr in globals(), arg_dict t2 = time.time() standard = t2 - t1 desired = arg_dict['result'] arg_dict['result'] = clean_result t1 = time.time() old_env = os.environ.get('PYTHONCOMPILED', '') os.environ['PYTHONCOMPILED'] = mod_location blitz_tools.blitz(expr, arg_dict, {}, verbose=0) #, #extra_compile_args = ['-O3','-malign-double','-funroll-loops']) os.environ['PYTHONCOMPILED'] = old_env t2 = time.time() compiled = t2 - t1 actual = arg_dict['result'] # this really should give more info... try: # this isn't very stringent. Need to tighten this up and # learn where failures are occuring. assert (allclose(abs(actual.ravel()), abs(desired.ravel()), 1e-4, 1e-6)) except: diff = actual - desired print diff[:4, :4] print diff[:4, -4:] print diff[-4:, :4] print diff[-4:, -4:] print sum(abs(diff.ravel()), axis=0) raise AssertionError return standard, compiled
def generic_check(self, expr, arg_dict, type, size): clean_result = array(arg_dict['result'],copy=1) t1 = time.time() exec(expr, globals(),arg_dict) t2 = time.time() standard = t2 - t1 desired = arg_dict['result'] arg_dict['result'] = clean_result t1 = time.time() blitz_tools.blitz(expr,arg_dict,{},verbose=0) t2 = time.time() compiled = t2 - t1 actual = arg_dict['result'] # TODO: this isn't very stringent. Need to tighten this up and # learn where failures are occurring. assert_allclose(abs(actual.ravel()), abs(desired.ravel()), rtol=1e-4, atol=1e-6) return standard, compiled
def generic_check(self, expr, arg_dict, type, size): clean_result = array(arg_dict['result'], copy=1) t1 = time.time() exec(expr, globals(), arg_dict) t2 = time.time() standard = t2 - t1 desired = arg_dict['result'] arg_dict['result'] = clean_result t1 = time.time() blitz_tools.blitz(expr, arg_dict, {}, verbose=0) t2 = time.time() compiled = t2 - t1 actual = arg_dict['result'] # TODO: this isn't very stringent. Need to tighten this up and # learn where failures are occurring. assert_allclose(abs(actual.ravel()), abs(desired.ravel()), rtol=1e-4, atol=1e-6) return standard, compiled