mirror of
https://github.com/mihakralj/QuanTAlib.git
synced 2026-08-21 20:18:05 +00:00
style patterns
This commit is contained in:
@@ -320,8 +320,15 @@ public class MapeTests
|
||||
var actual = new TSeries();
|
||||
var predicted = new TSeries();
|
||||
|
||||
for (int i = 0; i < 10; i++) actual.Add(DateTime.UtcNow, i + 1);
|
||||
for (int i = 0; i < 5; i++) predicted.Add(DateTime.UtcNow, i + 1);
|
||||
for (int i = 0; i < 10; i++)
|
||||
{
|
||||
actual.Add(DateTime.UtcNow, i + 1);
|
||||
}
|
||||
|
||||
for (int i = 0; i < 5; i++)
|
||||
{
|
||||
predicted.Add(DateTime.UtcNow, i + 1);
|
||||
}
|
||||
|
||||
Assert.Throws<ArgumentException>(() => Mape.Calculate(actual, predicted, 3));
|
||||
}
|
||||
@@ -386,4 +393,4 @@ public class MapeTests
|
||||
// Over-prediction should have higher MAPE due to smaller denominator
|
||||
Assert.True(overPrediction.Value > underPrediction.Value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,7 +52,10 @@ public sealed class Mape : BiInputIndicatorBase
|
||||
ValidateBatchInputs(actual, predicted, output, period);
|
||||
|
||||
int len = actual.Length;
|
||||
if (len == 0) return;
|
||||
if (len == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
const int StackAllocThreshold = 256;
|
||||
Span<double> percentErrors = len <= StackAllocThreshold
|
||||
@@ -62,4 +65,4 @@ public sealed class Mape : BiInputIndicatorBase
|
||||
ErrorHelpers.ComputePercentageErrors(actual, predicted, percentErrors, Epsilon);
|
||||
ErrorHelpers.ApplyRollingMean(percentErrors, output, period);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user