feat(validation): add input validation for Bilateral and Blma constructors; enhance Butter and Mgdi calculations with NaN handling

This commit is contained in:
Miha Kralj
2025-12-25 20:53:56 -08:00
parent ac8b2dbb3f
commit 0d077c24d8
15 changed files with 195 additions and 66 deletions
+10 -2
View File
@@ -24,7 +24,7 @@ public class ButterTests
{
var source = new double[10];
var destination = new double[5];
Assert.Throws<ArgumentOutOfRangeException>(() => Butter.Calculate(source, destination, 5));
Assert.Throws<ArgumentOutOfRangeException>(() => Butter.Calculate(source, destination, 5, double.NaN));
}
[Fact]
@@ -59,6 +59,14 @@ public class ButterTests
Assert.Equal(100, result.Value);
}
[Fact]
public void Initial_NaN_Input_ReturnsNaN()
{
var butter = new Butter(10);
var result = butter.Update(new TValue(DateTime.UtcNow, double.NaN));
Assert.True(double.IsNaN(result.Value));
}
[Fact]
public void AllModes_ProduceSameResult()
{
@@ -74,7 +82,7 @@ public class ButterTests
var tValues = series.Values.ToArray();
var spanInput = new ReadOnlySpan<double>(tValues);
var spanOutput = new double[tValues.Length];
Butter.Calculate(spanInput, spanOutput, period);
Butter.Calculate(spanInput, spanOutput, period, double.NaN);
double spanResult = spanOutput[^1];
// 3. Streaming Mode