public static Dictionary <StatisticMethods, double> CalculateMany(IEnumerable <StatisticMethods> methods, ParameterTimeSeries forecast, ParameterTimeSeries real) { var result = new Dictionary <StatisticMethods, double>(); if (methods.Contains(StatisticMethods.All)) { methods = new List <StatisticMethods> { StatisticMethods.Mae, StatisticMethods.Mase, StatisticMethods.Mape, StatisticMethods.Rmse }; } foreach (var method in methods.Distinct()) { try { result.Add(method, GetFunc(method)(forecast, real)); } catch (Exception e) { OnCalculatingFailed(method, e.Message); } } return(result); }
public int InvokeFunction(int callAmount) { var invokes = 0; var invokesLeft = 0L; // return prematurely because no invocations are left if (!TryGetInvocationsLeft(out invokesLeft)) { return(0); } // correct callAmount down if not enough invocations left callAmount = invokesLeft >= callAmount ? callAmount : (int)invokesLeft; try { for (int i = 0; i < callAmount; i++) { // call the function with parameters and iterate the number of calls // while updating the parameter set SetParameters(GetFunc()(GetParameters())); invokes++; } } catch (Exception ex) { MakeLogError(ex); } return(invokes); }
public void RegisterPushAndGetAndUpdate <T>(Action <RealStatePtr, T> push, GetFunc <T> get, Action <RealStatePtr, int, T> update) { Type type = typeof(T); Action <RealStatePtr, T> org_push; Func <RealStatePtr, int, T> org_get; if (tryGetPushFuncByType(type, out org_push) || tryGetGetFuncByType(type, out org_get)) { throw new InvalidOperationException("push or get of " + type + " has register!"); } push_func_with_type.Add(type, push); get_func_with_type.Add(type, new Func <RealStatePtr, int, T>((L, idx) => { T ret; get(L, idx, out ret); return(ret); })); registerCustomOp(type, (RealStatePtr L, object obj) => { push(L, (T)obj); }, (RealStatePtr L, int idx) => { T val; get(L, idx, out val); return(val); }, (RealStatePtr L, int idx, object obj) => { update(L, idx, (T)obj); } ); }
public void RegisterCaster <T>(GetFunc <T> get) { objectCasters.AddCaster(typeof(T), (L, idx, o) => { T obj; get(L, idx, out obj); return(obj); }); }
// Update is called once per frame void Update() { //the only exception to the below general input loop is when configuring a new input in the menu if (gameState == e_GameState.BUTTONCONFIGMENUANYINPUT) { for (int i = 0; i < (int)e_KeyButtonName.MAXNUMKEYBUTTON; i++) { if (Input.GetButtonDown(Header.keyButtonNames[i])) { menuReferenceComponent.ReceiveAnyInput((e_KeyButtonName)i); } } return; } for (int i = 0; i < (int)Header.e_ButtonAction.MAXNUMINPUT; i++) { if (Input.GetButtonDown(inputStorageArray[i].nameOfInputAxis) || Input.GetButtonDown(inputStorageArray[i].nameOfInputAxis2)) { GetFunc(i) (pID); } } }
public static void InitMyContentGet(IContentService service, IContentTypeService typeService) { MyGetContentByid = id => { return(GetFunc.GetContentByKey <int, IContent, CacheIContent>(id, true, service.GetById, MyCache)); }; MyGetContentsByIds = (ids, alive, queryName) => { return(GetFunc.GetContentByKeys <int, IContent, CacheIContent>(ids, alive, GetContentsByIdsFromService(service), GetContentsByIdsFromCache(), MyCache, b => b.Id, 30, MyQueryIsNew(queryName))); }; MyGetIContentsByType = (type, where, alive, queryName) => { return(GetFunc.GetChildContentsByQuery <int, IContent, CacheIContent>( MyGetIContentsByTypeFromService(type, service, typeService), MyGetContentByTypeFromCache(type), b => b.Id, MyCache, where, alive, 30, MyQueryIsNew(queryName))); }; MyGetChildByRootId = (rootId, where, alive, queryName) => { return(GetFunc.GetChildContentsByKey <int, IContent, CacheIContent>( GetChildContentsByRootIdFromService(service.GetChildren), GetChildContentsByRootIdFromCache(), b => b.Id, MyCache, rootId, alive, 30, where, MyQueryIsNew(queryName))); }; }
public static void ReplaceDefault(PushFunc pushFunc, GetFunc getFunc) { Set = pushFunc; Get = getFunc; }
public static double AggregateDynamic <T>(this IEnumerable <T> source, string propertyName, string func) { return(GetFunc <T>(propertyName, func)(source)); }
public TTo Map <TFrom, TTo>(TFrom source) { return(GetFunc <TFrom, TTo>()(source)); }
public static TOut Trans <TIn, TOut>(this TIn tIn) { return(GetFunc <TIn, TOut>()(tIn)); }
public ProxyEventPropertyValueGetter(GetFunc procGet) { ProcGet = procGet; }
/// <summary> /// Apply easing for the given function. /// </summary> /// <param name="t">Current time in seconds.</param> /// <param name="b">Starting value.</param> /// <param name="c">Final value.</param> /// <param name="d">Duration of animation.</param> /// <returns>The correct value.</returns> public static float Apply(EasingFunction function, float t, float b, float c, float d) { return(GetFunc(function)(t, b, c, d)); }
public static Task <T> AsyncContinuation(Task <string> getTypeTask, object id, Store store) { return((getTypeTask ?? Task.FromResult <string>(null)).ContinueWith(name => GetFunc(name.Result)(id, store))); }
internal static ScreenMirroringErrorCode GetValue <T>(GetFunc <T> func, IntPtr handle, out T value) { return(func(ref handle, out value)); }
private IBaseExpression ParseSubexpression(int lastPriority) { IBaseExpression left = null; if (Test(Token.Type.LeftPar, State.Pre)) { left = ParseSubexpression(int.MaxValue); Expect(Token.Type.RightPar, State.Post); } else if (Test(Token.Type.Name, State.Pre)) { string name = lastToken.str; // try read left_par if (Test(Token.Type.LeftPar, State.Post)) { // success - function call List <IBaseExpression> args = new List <IBaseExpression>(); // try read right_par right now if (!Test(Token.Type.RightPar, State.Post)) { // some arguments, read them RePeekToken(State.Pre); while (true) { args.Add(ParseSubexpression(int.MaxValue)); if (Test(Token.Type.RightPar, State.Post)) { break; } Expect(Token.Type.Comma, State.Pre); } } left = GetFunc(name)(args.ToArray()); } else { // otherwise - variable name RePeekToken(State.Post); left = GetVar(lastToken.str); } } else if (Test(Token.Type.UnaryOperator, State.Pre)) { var(factory, oper) = lastToken.GetData < KeyValuePair <UnaryOperation.Factory, UnaryOperation.Type> >(); left = factory(ParseSubexpression(oper.GetPriority())); } else { Expect(Token.Type.Number, State.Post); if (lastToken.IsOfType(typeof(long))) { left = new Const(lastToken.GetData <long>()); } else { left = new Const(lastToken.GetData <bool>()); } } while (true) { if (!TestNoShift(Token.Type.BinaryOperator)) { break; } var(factory, oper) = token.GetData <KeyValuePair <BinaryOperation.Factory, BinaryOperation.Type> >(); if (oper.GetPriority() >= lastPriority) { break; } PeekToken(State.Pre); left = factory(left, ParseSubexpression(oper.GetPriority())); } return(left); }