static void Main(string[] args) { MathService service = new MathService(); service.OutboundDelegate += OnOutboundDelegate; var result = service.MathDelegate(5, 8); }
public MashapeModule(EmbedService embedService, HttpService httpService, MathService mathService, Config config) : base(mathService) { EmbedService = embedService; HttpService = httpService; MathService = mathService; Config = config; }
public static double[] GetStochasticsOut(Stochastics stochastics, bool discretized = true) { if (discretized) { double[] stochasticsOut = new double[stochastics.SlowK.Length - 1]; for (int i = 0; i < stochastics.SlowK.Length - 1; i++) { if (stochastics.SlowK[i] >= 80) { stochasticsOut[i] = 0; } else if (stochastics.SlowK[i] <= 20) { stochasticsOut[i] = 1; } else { if (stochastics.SlowK[i] > stochastics.SlowK[i + 1]) { stochasticsOut[i] = 1; } else { stochasticsOut[i] = 0; } } } return(stochasticsOut); } else { return(MathService.Normalize(stochastics.FastD)); } }
public void GenerateProblemsWithOptionalParameters() { var service = new MathService(); var expectedProblems = 4; var minOperations = 2; var maxOperations = 3; var expressions = service.Generate(expectedProblems, minOperations, maxOperations); var problems = expressions.Split('\n'); problems = problems.Take(problems.Length - 1).ToArray(); foreach (var problem in problems) { var count1 = problem.Distinct().Count(x => x == '+'); var count2 = problem.Distinct().Count(x => x == '-'); var count3 = problem.Distinct().Count(x => x == '*'); var count4 = problem.Distinct().Count(x => x == '/'); var count = count1 + count2 + count3 + count4; Assert.IsTrue(minOperations <= count && maxOperations >= count); } }
public VoiceModule(AudioService audioService, EmbedService embedService, Config config, MathService mathService) : base(mathService) { AudioService = audioService; EmbedService = embedService; MathService = mathService; Config = config; }
static void Main(string[] args) { MathService service = new MathService(); Console.WriteLine(service.TxtFile()); Console.ReadLine(); }
public async Task MathCommandAsync([Summary("The LaTeX input."), Remainder] string input) { if (FilterService.ContainsBlockedWord(input)) { return; } bool canOverride = (Context.User as IGuildUser).GetPermissionLevel(Context) >= PermissionLevel.Guru; int remaining = MathService.LatexTimeoutRemaining(Context.User); if (!canOverride && remaining > 0) { throw new TimeoutException($"You need to wait {TimeSpan.FromMilliseconds(remaining).Humanize(2, minUnit: TimeUnit.Second)} before you can use this command again!"); } MathService.UpdateLatexTimeout(Context.User); if (!TryRender(input, out Image originalImage, out string errorMessage)) { await new EmbedBuilder() .WithDescription(Format.Code(errorMessage)) .WithColor(Discord.Color.Red) .Build() .SendToChannel(Context.Channel); return; } using Image image = AddPadding(originalImage); await using Stream stream = GetImageStream(image); await Context.Channel.SendFileAsync(stream, "equation.png"); image.Dispose(); }
public IActionResult Math(int x, int y) { // int result = x + y; MathService mathService = new MathService(); return(View(mathService.MathAddition(x, y))); }
public void ValidTableUpdateCalculation() { // ARRANGE IMathService mathService = new MathService(); IDynamicTableService dynamicTableService = new DynamicTableService(mathService); dynamicTableService.SelectedTableType = new TableType() { Id = 1, Name = "AddThreeNumbersModel", Type = typeof(AddThreeNumbersModel) }; var threeNumberModel = new AddThreeNumbersModel(mathService) { Number1 = 1, Number2 = 2, Number3 = 3 }; // ACT var table = dynamicTableService.GetDynamicTable(threeNumberModel); var row = table.Rows[0]; var updatedRow = (new AddThreeNumbersModel(mathService) { Number1 = 1, Number2 = 1, Number3 = 1 }).ToTableRow(0); table.Rows[0] = updatedRow; // ASSERT Assert.NotNull(table); Assert.NotNull(table.Rows); Assert.Single(table.Rows); var totalCellValue = table.Rows[0].Cells.FirstOrDefault(c => c.ColumnName.Equals(nameof(threeNumberModel.Total)))?.Value ?? "0"; Assert.Equal(3, int.Parse(totalCellValue)); }
public AdminModule(CommandService commandService, MathService mathService, EmbedService embedService, ExecuteService executeService, Config config) : base(mathService) { CommandService = commandService; EmbedService = embedService; ExecuteService = executeService; Config = config; }
public static double[] GetRSIOut(double[] rsi, bool discretized = true) { if (discretized) { double[] rsiOut = new double[rsi.Length - 1]; for (int i = 0; i < rsi.Length - 1; i++) { if (rsi[i] > 70) { rsiOut[i] = 0; } else if (rsi[i] < 30) { rsiOut[i] = 1; } else { if (rsi[i] > rsi[i + 1]) { rsiOut[i] = 1; } else { rsiOut[i] = 0; } } } return(rsiOut); } else { return(MathService.Normalize(rsi)); } }
public Tree(Platform pl, TreeShape shape) : base(pl) { this.shape = shape; Texture2D[] arr = AssetManager.getSprite("Tree/" + shape.ToString()); int idx = MathService.randomInt(0, arr.Length); setTexture(new Texture2D[] { arr[idx] }); }
public SciKitFeatureVector(IEnumerable <decimal> values) { Mean = values.Average(); Variance = MathService.GetVariance(values.ToList()); Skewness = MathService.GetSkewness(values.ToList()); Kurtosis = MathService.GetKurtosis(values.ToList()); RMS = MathService.GetRMS(values.ToList()); }
public void GenerateZeroProblems() { var service = new MathService(); var expressions = service.Generate(0, null, null); Assert.AreEqual("No problems to generate", expressions); }
public void WhenBaseNumberIs0_ShouldReturn0() { var service = new MathService(LoggerMock.Object); var result = service.GetNextFibonaciNumber(0); result.ShouldBe((ulong)0); }
public void WhenBaseNumberIsValid_ShouldReturnExpectedResult(ulong baseNumber, ulong expected) { var service = new MathService(LoggerMock.Object); var result = service.GetNextFibonaciNumber(baseNumber); result.ShouldBe(expected); }
public void DivideTest_ThrowsException() { // Arrange IMathService math = new MathService(); // Act & Assert Assert.Throws <DivideByZeroException>(() => math.Divide(10, 0)); }
public MathController(MathService mathService, MathRepository mathRepository, DiscordSocketClient discordClient, UserService userService) { MathService = mathService; MathRepository = mathRepository; DiscordClient = discordClient; UserService = userService; }
public void GenerateNegativeProblems() { var service = new MathService(); var expectedProblems = -4; var expressions = service.Generate(expectedProblems, null, null); }
/// <summary> /// Analyze the specified input and parameters. /// </summary> /// <returns>The analyze.</returns> /// <param name="input">Input.</param> /// <param name="parameters">Parameters.</param> public IEnumerable <ICsvWritable> Analyze(IEnumerable <SensorReading> input, IEnumerable <Parameter> parameters) { // first, split records according to distinct labels containing the word "select" var inputGroups = input.Where(x => x.Label.Contains("select")).GroupBy(x => x.Label); if (inputGroups == null || !inputGroups.Any()) { return(new List <SelectResult>()); } // next, parse out the parameters we need var pauseCommand = parameters.Where(x => x.Field.Equals(CommandParameters.InstantaneousSpeed)).FirstOrDefault(); var pauseThreshold = decimal.Parse(pauseCommand.Clauses.Where(x => x.Key.Equals(CommandParameters.Threshold)).FirstOrDefault().Value); var pauseWindow = int.Parse(pauseCommand.Clauses.Where(x => x.Key.Equals(CommandParameters.Window)).FirstOrDefault().Value); var varianceCommand = parameters.Where(x => x.Field.Equals(CommandParameters.Acceleration)).FirstOrDefault(); var varianceThreshold = varianceCommand.Clauses.Where(x => x.Key.Equals(CommandParameters.Variance)).FirstOrDefault().Value; // next, for each group with a distinct label, calculate: // total task time // num of first record (when task starts) // num of first record when user starts moving // count of significant pauses // accel-x std. dev. // accel-y std. dev. // accel-z std. dev. var results = new List <SelectResult>(); foreach (var inputGroup in inputGroups) { // generating a result var result = new SelectResult { Label = inputGroup.First().Label, Duration = ((inputGroup.Last().RecordNum - inputGroup.First().RecordNum) * Constants.BAT.SAMPLING_PERIOD_IN_MS) / 1000.0M, TaskStartRecordNum = inputGroup.First().RecordNum, Pauses = PauseDurationAnalysis.EvaluatePause(inputGroup, CommandParameters.InstantaneousSpeed, pauseThreshold, pauseWindow), AccelXStdDev = MathService.StandardDeviation(inputGroup.Select(x => x.AccelX)), AccelYStdDev = MathService.StandardDeviation(inputGroup.Select(x => x.AccelY)), AccelZStdDev = MathService.StandardDeviation(inputGroup.Select(x => x.AccelZ)), StdDevThreshold = decimal.Parse(varianceThreshold) }; results.Add(result); } // finally, return the results (one record per input group) return(results); }
public void OutOfRangeMinOperations() { var service = new MathService(); var expectedProblems = 4; var minOperations = -2; var expressions = service.Generate(expectedProblems, minOperations, null); }
public StatsModule(EmbedService embedService, Config config, TrackingService trackingService, MathService mathService, ImageService imageService, DBContextFactory dbFactory) : base(mathService) { EmbedService = embedService; Config = config; TrackingService = trackingService; MathService = mathService; ImageService = imageService; DBFactory = dbFactory; }
public void MinOperationsGreaterThanMaxOperations() { var service = new MathService(); var expectedProblems = 4; var minOperations = 3; var maxOperations = 1; var expressions = service.Generate(expectedProblems, minOperations, maxOperations); }
public void DivideTest(int firstValue, int secondValue, int expected) { // Arrange IMathService math = new MathService(); // Act decimal actual = math.Divide(firstValue, secondValue); // Assert Assert.Equal(expected, actual); }
private double[] CalculateStandardDeviation(double[] closes) { double[] std = new double[NumberOfData]; for (int i = 0; i < NumberOfData; i++) { // can be optimized std[i] = MathService.StandardDeviation(closes.Skip(i).Take(Period), Middle[i]); } return(std); }
bool RayBoxIntersection1(Vector3 ray_pos, float dx, float dy, float dz, out float tmin, out float tmax) { MathService.Min(out float lo0, out float hi0, -ray_pos.X / dx, (object_width - ray_pos.X) / dx); MathService.Min(out float lo1, out float hi1, -ray_pos.Y / dy, (object_height - ray_pos.Y) / dy); MathService.Min(out float lo2, out float hi2, -ray_pos.Z / dz, (object_length - ray_pos.Z) / dz); tmin = MathService.Max(lo0, MathService.Max(lo1, lo2)); tmax = MathService.Min(hi0, MathService.Min(hi1, hi2)); return((tmin <= tmax) && (tmax >= 0)); }
public void MarhService_Can_Do_Addition() { // Arrange MathService mathService = new MathService(); // Act int result = mathService.Add(10, 5); // Assert Assert.AreEqual(expected: 15, actual: result); }
public void MarhService_Can_Do_Multiplication() { // Arrange MathService mathService = new MathService(); // Act int result = mathService.Multiply(10, 5); // Assert Assert.AreEqual(expected: 50, actual: result); }
public void MarhService_Can_Do_Devision_Resulting_Double() { // Arrange MathService mathService = new MathService(); // Act double result = mathService.Devide(5, 10); // Assert Assert.AreEqual(expected: 0.5f, actual: result); }
public void MarhService_Can_Do_Devision() { // Arrange MathService mathService = new MathService(); // Act int result = mathService.Devide(10, 5); // Assert Assert.AreEqual(expected: 2, actual: result); }
public static void Main(String[] args) { MathService m = new MathService(); Console.WriteLine(m.add(4,5)); }