[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
+8 -8
View File
@@ -85,12 +85,12 @@ public class Sp15Tests
const int n = 30;
for (int i = 0; i < n; i++)
{
double val = intercept + slope * i;
double val = intercept + (slope * i);
sp15.Update(new TValue(DateTime.UtcNow.AddMinutes(i).Ticks, val));
}
// Centered at lag 7: output at bar n-1 matches polynomial at bar (n-1)-7
int centerIdx = n - 1 - 7;
double expected = intercept + slope * centerIdx;
double expected = intercept + (slope * centerIdx);
Assert.Equal(expected, sp15.Last.Value, 1e-6);
}
@@ -101,11 +101,11 @@ public class Sp15Tests
const int n = 40;
for (int i = 0; i < n; i++)
{
double val = 0.1 * i * i + 2.0 * i + 5.0;
double val = (0.1 * i * i) + (2.0 * i) + 5.0;
sp15.Update(new TValue(DateTime.UtcNow.AddMinutes(i).Ticks, val));
}
int k = n - 1 - 7;
double expected = 0.1 * k * k + 2.0 * k + 5.0;
double expected = (0.1 * k * k) + (2.0 * k) + 5.0;
Assert.Equal(expected, sp15.Last.Value, 1e-4);
}
@@ -116,11 +116,11 @@ public class Sp15Tests
const int n = 40;
for (int i = 0; i < n; i++)
{
double val = 0.001 * i * i * i + 0.1 * i * i + 2.0 * i + 5.0;
double val = (0.001 * i * i * i) + (0.1 * i * i) + (2.0 * i) + 5.0;
sp15.Update(new TValue(DateTime.UtcNow.AddMinutes(i).Ticks, val));
}
int k = n - 1 - 7;
double expected = 0.001 * k * k * k + 0.1 * k * k + 2.0 * k + 5.0;
double expected = (0.001 * k * k * k) + (0.1 * k * k) + (2.0 * k) + 5.0;
Assert.Equal(expected, sp15.Last.Value, 1e-2);
}
@@ -174,7 +174,7 @@ public class Sp15Tests
// Multiple corrections
for (int c = 0; c < 5; c++)
{
sp15.Update(new TValue(DateTime.UtcNow.Ticks, 500.0 + c * 10), isNew: false);
sp15.Update(new TValue(DateTime.UtcNow.Ticks, 500.0 + (c * 10)), isNew: false);
}
// Restore
sp15.Update(series[19], isNew: false);
@@ -527,7 +527,7 @@ public class Sp15Tests
// All 100 contributes: 100 * sum(weights) = 100
// Extra 100 at center contributes: 100 * (74/320) = 23.125
// Total = 100 + 23.125 = 123.125
double expected = 100.0 + 100.0 * 74.0 / 320.0;
double expected = 100.0 + (100.0 * 74.0 / 320.0);
Assert.Equal(expected, sp15.Last.Value, 1e-10);
}
}
@@ -68,12 +68,12 @@ public class Sp15ValidationTests
for (int i = 0; i < total; i++)
{
double val = a + b * i;
double val = a + (b * i);
sp15.Update(new TValue(DateTime.UtcNow.AddSeconds(i), val));
}
int centerIdx = total - 1 - 7;
double expected = a + b * centerIdx;
double expected = a + (b * centerIdx);
Assert.Equal(expected, sp15.Last.Value, 1e-6);
}
@@ -86,12 +86,12 @@ public class Sp15ValidationTests
for (int i = 0; i < total; i++)
{
double val = a + b * i + c * i * i;
double val = a + (b * i) + (c * i * i);
sp15.Update(new TValue(DateTime.UtcNow.AddSeconds(i), val));
}
int centerIdx = total - 1 - 7;
double expected = a + b * centerIdx + c * centerIdx * centerIdx;
double expected = a + (b * centerIdx) + (c * centerIdx * centerIdx);
Assert.Equal(expected, sp15.Last.Value, 1e-4);
}
@@ -104,12 +104,12 @@ public class Sp15ValidationTests
for (int i = 0; i < total; i++)
{
double val = a + b * i + c * i * i + d * i * i * i;
double val = a + (b * i) + (c * i * i) + (d * i * i * i);
sp15.Update(new TValue(DateTime.UtcNow.AddSeconds(i), val));
}
int centerIdx = total - 1 - 7;
double expected = a + b * centerIdx + c * centerIdx * centerIdx + d * centerIdx * centerIdx * centerIdx;
double expected = a + (b * centerIdx) + (c * centerIdx * centerIdx) + (d * centerIdx * centerIdx * centerIdx);
Assert.Equal(expected, sp15.Last.Value, 1.0);
}
@@ -172,8 +172,8 @@ public class Sp15ValidationTests
double[] reverse = new double[15];
for (int i = 0; i < 15; i++)
{
forward[i] = 10.0 + 2.0 * i;
reverse[i] = 10.0 + 2.0 * (14 - i);
forward[i] = 10.0 + (2.0 * i);
reverse[i] = 10.0 + (2.0 * (14 - i));
}
TValue fwdResult = default;
@@ -186,7 +186,7 @@ public class Sp15ValidationTests
// For linear input centered at i=7: forward center = 10+14=24, reverse center = 10+14=24
// Both should give the same result for symmetric weights applied to symmetric-about-center linear data
double expected = 2.0 * (10.0 + 2.0 * 7.0);
double expected = 2.0 * (10.0 + (2.0 * 7.0));
Assert.Equal(expected, fwdResult.Value + revResult.Value, 1e-6);
}
@@ -199,7 +199,7 @@ public class Sp15ValidationTests
for (int i = 0; i < n; i++)
{
// Pure period-4 sinusoid centered at 100
double val = 100.0 + 10.0 * Math.Sin(2.0 * Math.PI * i / 4.0);
double val = 100.0 + (10.0 * Math.Sin(2.0 * Math.PI * i / 4.0));
sp15.Update(new TValue(DateTime.UtcNow.AddSeconds(i), val));
}
// After warmup, the output should be ~100 (sinusoid suppressed)
@@ -214,7 +214,7 @@ public class Sp15ValidationTests
const int n = 60;
for (int i = 0; i < n; i++)
{
double val = 100.0 + 10.0 * Math.Sin(2.0 * Math.PI * i / 5.0);
double val = 100.0 + (10.0 * Math.Sin(2.0 * Math.PI * i / 5.0));
sp15.Update(new TValue(DateTime.UtcNow.AddSeconds(i), val));
}
Assert.Equal(100.0, sp15.Last.Value, 0.5);