style patterns

This commit is contained in:
Miha Kralj
2026-01-25 16:01:45 -08:00
parent 2836f253c4
commit e59665c8f0
399 changed files with 6892 additions and 1323 deletions
+1 -1
View File
@@ -134,4 +134,4 @@ public class BpfIndicatorTests
Assert.Equal(60, indicator.LowerPeriod);
Assert.Equal(20, indicator.UpperPeriod);
}
}
}
+1 -1
View File
@@ -116,4 +116,4 @@ public class BpfTests
// Last value should be close to 0
Assert.True(Math.Abs(output[^1]) < 1e-6);
}
}
}
+2 -1
View File
@@ -20,7 +20,8 @@ public class BpfValidationTests
double[] sine15 = new double[T]; // Period 15 (Inside band, 10 < P < 40). Should pass.
double[] sine100 = new double[T]; // Period 100 (Too slow, should be blocked by HP(40)). HP(40) passes P < 40.
for (int i = 0; i < T; i++) {
for (int i = 0; i < T; i++)
{
sine5[i] = Math.Sin(2 * Math.PI * i / 5.0);
sine15[i] = Math.Sin(2 * Math.PI * i / 15.0);
sine100[i] = Math.Sin(2 * Math.PI * i / 100.0);
+16 -3
View File
@@ -53,9 +53,14 @@ public sealed class Bpf : AbstractBase
public Bpf(int lowerPeriod, int upperPeriod)
{
if (lowerPeriod < 1)
{
throw new ArgumentOutOfRangeException(nameof(lowerPeriod), "Lower period must be >= 1");
}
if (upperPeriod < 1)
{
throw new ArgumentOutOfRangeException(nameof(upperPeriod), "Upper period must be >= 1");
}
LowerPeriod = lowerPeriod;
UpperPeriod = upperPeriod;
@@ -95,7 +100,10 @@ public sealed class Bpf : AbstractBase
public override TSeries Update(TSeries source)
{
if (source.Count == 0) return [];
if (source.Count == 0)
{
return [];
}
double[] values = source.Values.ToArray();
double[] results = new double[values.Length];
@@ -186,7 +194,9 @@ public sealed class Bpf : AbstractBase
public static void Calculate(ReadOnlySpan<double> source, Span<double> output, int lowerPeriod, int upperPeriod)
{
if (source.Length != output.Length)
{
throw new ArgumentException("Source and output spans must be of the same length.", nameof(output));
}
// Coefficients
double sqrt2Pi = Math.Sqrt(2.0) * Math.PI;
@@ -213,7 +223,10 @@ public sealed class Bpf : AbstractBase
if (source.Length > 0)
{
lastValid = source[0];
if (!double.IsFinite(lastValid)) lastValid = 0;
if (!double.IsFinite(lastValid))
{
lastValid = 0;
}
}
for (int i = 0; i < source.Length; i++)
@@ -260,4 +273,4 @@ public sealed class Bpf : AbstractBase
}
base.Dispose(disposing);
}
}
}