public void NestedPropertyShouldWork() { var result = new DataSampler<Model>() .AddPropertyConfiguration(x => x.Sub.SubFoo, () => 3) .AddKnownType(typeof(Sub)) .GenerateListOf(1); Assert.AreEqual(3, result[0].Sub.SubFoo); }
public void UnknownPropertyShouldRemainNull() { var result = new DataSampler<Model>() .AddPropertyConfiguration(x => x.Foo, () => 1) .GenerateListOf(2); Assert.IsNotNull(result); Assert.IsNull(result[0].Bar); }
/// <summary> /// Adds a single sample to the sampler of the specified name, if the sampler does /// not exists it will be created. This function is intended to be used with sampler that /// are not bound to a function. /// </summary> public void AddSample(String name, float value) { DataSampler sampler; if (!_samplers.TryGetValue(name, out sampler)) { sampler = new DataSampler(name); InsertSampler(name, sampler); } sampler.InsertSample(value); }
public Plot(DataSampler sampler, Vector2 position, Vector2 size) : base(position, size) { TitleBarSize = 14; Sampler = sampler; Visible = true; TitleLabelName = "__Plot" + sampler.Name; MinLabelName = "lo" + TitleLabelName; MaxLabelName = "hi" + TitleLabelName; }
public void UnknownSubTypePropertyShouldRemainNull() { var result = new DataSampler<Model>() .AddPropertyConfiguration(x => x.Foo, () => 1) .AddPropertyConfiguration(x => x.Sub.SubFoo, () => 2) .GenerateListOf(2); Assert.IsNotNull(result); Assert.AreEqual(2, result.Count); Assert.AreEqual(1, result[0].Foo); Assert.IsNull(result[0].Sub); }
public void SimpleInitializerOutOfScopeShouldWork() { int i = 0; var result = new DataSampler<Model>() .AddPropertyConfiguration(x => x.Foo, () => i++) .GenerateListOf(3); Assert.AreEqual(0, result[0].Foo); Assert.AreEqual(1, result[1].Foo); Assert.AreEqual(2, result[2].Foo); }
public void MixedModelDataShouldBeGenerated() { int i = 0, j = 0; var result = new DataSampler<Model>() .AddPropertyConfiguration(x => x.Foo, () => i++) .AddPropertyConfiguration(x => x.Baz, () => DateTime.Now.AddDays(j++)) .AddPropertyConfiguration(x => x.Bar, () => Guid.NewGuid().ToString()) .GenerateListOf(2); Assert.AreEqual(0, result[0].Foo); Assert.AreEqual(1, result[1].Foo); Assert.AreNotEqual("aaaaaaaa", result[0].Bar); Assert.AreEqual(result[0].Baz.Day+1, result[1].Baz.Day); }
/// <summary> /// Sets up Device, Reader, and Sampler then start interpreters coroutine /// </summary> public virtual void Setup() { Device = GetDevice(); Reader = GetReader(); Sampler = GetSampler(); Interpeters = GetInterpreters(); DataRateCalculator = GetRateCalculator(); CalculatorConfiguration = GetCalculatorConfiguration(); Reader.OnRead += Sampler.Register; Reader.OnRead += (s) => TotalStatesRead++; Reader.StartReading(); StartCoroutine(InterpetationProcess()); StartCoroutine(UpdateStatusBar()); }
/// <summary> /// Adds a single sample to the sampler of the specified name, if the sampler does /// not exists it will be created with the specified historyLength. /// This function is intended to be used with sampler that are not bound to a function. /// </summary> public void AddSample(string name, float value, int historyLength) { DataSampler sampler; if (!_samplers.TryGetValue(name, out sampler)) { sampler = new DataSampler(name, historyLength, 0, default(Func<float>)); InsertSampler(name, sampler); } else { sampler.Values.Capacity = historyLength; } sampler.InsertSample(value); }
void InsertSampler(String name, DataSampler sampler) { _samplers.Add(name, sampler); ObservableSamplers.Add(sampler); }
/// <summary> /// Adds an sampler which is bound to a <c>function</c> that will be sampled /// every <c>sampleRate</c> frames. <c>historyLength</c> values will be kept. /// </summary> public void AddSampler(String name, int historyLength, int sampleRate, Func<float, float> function) { var sampler = new DataSampler(name, historyLength, sampleRate, function); InsertSampler(name, sampler); }
public override void RunCommand(CalledCommand calledCommand) { string pathDataDir; if (!GetPathOrDefault(calledCommand, out pathDataDir)) { FailCommand("Invalid parameter value: path."); } switch (calledCommand.Name) { case "load": { switch (calledCommand.MandatoryParametersValues[0]) { case "graph": Loader.LoadGraphFromInternet(pathDataDir); break; case "sales": Loader.LoadSalesFromInternet(pathDataDir); break; } break; } case "clean": { switch (calledCommand.MandatoryParametersValues[0]) { case "graph": Cleaner.CleanGraphData(pathDataDir); Cleaner.CleanKey(pathDataDir); break; case "sales": Cleaner.CleanSalesData(pathDataDir); break; } break; } case "filter": { switch (calledCommand.MandatoryParametersValues[0]) { case "graph_links": Linker.FilterLinks(pathDataDir); break; } break; } case "link": { switch (calledCommand.MandatoryParametersValues[0]) { case "graph": Linker.LinkGraphData(pathDataDir); break; case "sales": Linker.LinkGraphWithSales(pathDataDir); break; } break; } case "asm": { switch (calledCommand.MandatoryParametersValues[0]) { case "graph": Assembler.AssembleGraphData(pathDataDir); break; case "sales": Assembler.AssembleSalesData(pathDataDir); break; } break; } case "sample": { SetType trainingSetType = SamplingHelper.GetSetTypeOrDefault(calledCommand.MandatoryParametersValues[0]); int trainingSetSize; if (!IsValidSetSize(calledCommand.MandatoryParametersValues[1], out trainingSetSize)) { FailCommand("Invalid parameter value: training set size."); } SetType testingSetType = SamplingHelper.GetSetTypeOrDefault(calledCommand.MandatoryParametersValues[2]); int testingSetSize; if (!IsValidSetSize(calledCommand.MandatoryParametersValues[3], out testingSetSize)) { FailCommand("Invalid parameter value: testing set size."); } int testingDataAmount = 100; if (calledCommand.OptionalParametersValues.Count > 0) { if (!IsValidPercentage(calledCommand.OptionalParametersValues[0], out testingDataAmount)) { FailCommand("Invalid parameter value: testing set size."); } } DataSampler.CreateTrainingAndTestSets(pathDataDir, trainingSetType, testingSetType, trainingSetSize, testingSetSize, testingDataAmount); break; } case "test": { switch (calledCommand.MandatoryParametersValues[0]) { case "graph_linkage": TestManager.TestLinkageGraph(pathDataDir); break; case "graph_mapping": TestManager.TestMapping(pathDataDir); break; case "graph_id": TestManager.TestID(pathDataDir); break; } break; } case "stat": { switch (calledCommand.MandatoryParametersValues[0]) { case "graph": TestManager.GetStatisticsGraph(pathDataDir); break; case "connectivity": StatisticsCollector.GetConnectivityStatistics(pathDataDir); break; } break; } default: { FailCommand("Cannot recognize the input commands."); break; } } }