[CodeFactor] Apply fixes to commit 0606491

This commit is contained in:
codefactor-io
2026-03-12 19:37:50 +00:00
parent 060649192f
commit 8f79257155
384 changed files with 1197 additions and 1215 deletions
+3 -3
View File
@@ -328,7 +328,7 @@ public class NwTests
double[] dst = new double[len];
for (int i = 0; i < len; i++)
{
src[i] = 100.0 + i * 0.01;
src[i] = 100.0 + (i * 0.01);
}
Nw.Batch(src, dst, 500, 50.0); // period > StackallocThreshold
Assert.False(double.IsNaN(dst[len - 1]));
@@ -402,7 +402,7 @@ public class NwTests
}
nw.Update(new TValue(DateTime.UtcNow, 200.0), isNew: true);
// With h=100 and period=20, all weights nearly equal → nearly SMA
double expected = (100.0 * 19 + 200.0) / 20.0; // ~105
double expected = ((100.0 * 19) + 200.0) / 20.0; // ~105
Assert.True(Math.Abs(nw.Last.Value - expected) < 5.0);
}
@@ -429,7 +429,7 @@ public class NwTests
var n2 = new Nw(10, 3.0);
for (int i = 0; i < 30; i++)
{
double v = 100.0 + Math.Sin(i * 0.3) * 10.0;
double v = 100.0 + (Math.Sin(i * 0.3) * 10.0);
n1.Update(new TValue(DateTime.UtcNow, v));
n2.Update(new TValue(DateTime.UtcNow, v));
}
+2 -2
View File
@@ -167,12 +167,12 @@ public sealed class NwValidationTests : IDisposable
// Bar 1: src[1] with w0=1.0, src[0] with w1=exp(-1/(2*1))=exp(-0.5)
double w0 = 1.0;
double w1 = Math.Exp(-0.5);
double expected1 = (w0 * 20.0 + w1 * 10.0) / (w0 + w1);
double expected1 = ((w0 * 20.0) + (w1 * 10.0)) / (w0 + w1);
Assert.Equal(expected1, dst[1], 10);
// Bar 2: src[2] w0=1, src[1] w1=exp(-0.5), src[0] w2=exp(-4/2)=exp(-2)
double w2 = Math.Exp(-2.0);
double expected2 = (w0 * 30.0 + w1 * 20.0 + w2 * 10.0) / (w0 + w1 + w2);
double expected2 = ((w0 * 30.0) + (w1 * 20.0) + (w2 * 10.0)) / (w0 + w1 + w2);
Assert.Equal(expected2, dst[2], 10);
_output.WriteLine($"Manual calc: bar0={dst[0]:F6}, bar1={dst[1]:F6} (expect {expected1:F6}), bar2={dst[2]:F6} (expect {expected2:F6})");