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
+20 -5
View File
@@ -33,7 +33,11 @@ public sealed class Mgdi : AbstractBase
public Mgdi(int period = 14, double k = 0.6)
{
ArgumentOutOfRangeException.ThrowIfLessThan(period, 1);
if (double.IsNaN(k) || double.IsInfinity(k) || k <= 0) throw new ArgumentOutOfRangeException(nameof(k), "k must be a finite value greater than 0");
if (double.IsNaN(k) || double.IsInfinity(k) || k <= 0)
{
throw new ArgumentOutOfRangeException(nameof(k), "k must be a finite value greater than 0");
}
_period = period;
_k = k;
Name = $"Mgdi({period},{k})";
@@ -123,7 +127,10 @@ public sealed class Mgdi : AbstractBase
public override TSeries Update(TSeries source)
{
if (source.Count == 0) return new TSeries([], []);
if (source.Count == 0)
{
return new TSeries([], []);
}
int len = source.Count;
var t = new List<long>(len);
@@ -167,12 +174,20 @@ public sealed class Mgdi : AbstractBase
public static void Calculate(ReadOnlySpan<double> source, Span<double> output, int period = 14, double k = 0.6)
{
ArgumentOutOfRangeException.ThrowIfLessThan(period, 1);
if (double.IsNaN(k) || double.IsInfinity(k) || k <= 0) throw new ArgumentOutOfRangeException(nameof(k), "k must be a finite value greater than 0");
if (double.IsNaN(k) || double.IsInfinity(k) || k <= 0)
{
throw new ArgumentOutOfRangeException(nameof(k), "k must be a finite value greater than 0");
}
if (source.Length != output.Length)
{
throw new ArgumentException("Source and output must have the same length", nameof(output));
}
if (source.Length == 0) return;
if (source.Length == 0)
{
return;
}
double lastMgdi = 0;
double lastValid = 0;
@@ -225,4 +240,4 @@ public sealed class Mgdi : AbstractBase
{
Init();
}
}
}