mirror of
https://github.com/UglyToad/PdfPig.git
synced 2025-11-28 17:47:12 +08:00
Update MathExtensions.cs
Handling null or empty double array.
This commit is contained in:
@@ -24,6 +24,7 @@ namespace UglyToad.PdfPig.DocumentLayoutAnalysis
|
||||
/// <param name="array">The array of decimal.</param>
|
||||
public static double Mode(this IEnumerable<double> array)
|
||||
{
|
||||
if (array == null || array.Count() == 0) return double.NaN;
|
||||
return array.GroupBy(v => v).OrderByDescending(g => g.Count()).First().Key;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user