public void CanFormatStatistics() { var stats = new BinaryStatistics() { ConditionPositives = 99, ConditionNegatives = 0, PredictedPositives = 0, TruePositives = 34, FalsePositives = 0, PredictedNegatives = 0, FalseNegatives = 65, TrueNegatives = 0 }; var expected = new string[] { "test title:", " Labelled +ve Labelled -ve ", "Total segments: 99 99 0 Prevalance: 100.00% Accuracy: 34.34% ", "Results +ve: 0 TP: 34 FP: 0 Precision (PPV): ∞ FDR: NaN ", "Results -ve: 0 FN: 65 TN: 0 FOR: ∞ NPV: NaN ", "Results Count: 99 Sensitivity: 34.34% FPR: NaN ", " FNR: ∞ Specificity: NaN ", }.Join(Environment.NewLine) + Environment.NewLine; var formatted = ConsoleResultFormatter.FormatStatistics("test title", "segments", stats); var actual = formatted.ToString(System.CommandLine.Rendering.OutputMode.PlainText); Assert.Equal(expected, actual); }
public async ValueTask WriteResultsFooter(FinalResults finalResults) { var stats = finalResults.ResultStatistics; var performance = stats.TotalSuccesses / (double)stats.TotalResults; var resultSpan = performance.ToString("P").StyleGrade(performance, new Interval(0, 100, Topology.Inclusive)); var finalMessage = new ContainerSpan( NewLine, "Finished.".StyleUnderline(), NewLine, "Final results:".AsTextSpan(), NewLine, FormatStat("Successes", stats.TotalSuccesses.ToString().StyleSuccess()), FormatStat("Failures", stats.TotalFailures.ToString().StyleFailure()), FormatStat("Errors", stats.TotalErrors.ToString().StyleFailure()), FormatStat("Total", resultSpan), FormatStat("Elapsed", finalResults.TimeTaken.ToString().StyleNumber()) ); console.WriteLine(finalMessage); foreach (var(suiteName, suite) in finalResults.Config.TestSuites) { console.WriteLine($"Results for suite {suiteName.StyleBold()}:".StyleUnderline()); foreach (var(toolName, _) in suite.ToolConfigs) { var processingErrors = stats.ProcessingErrors.Find(suiteName, toolName); if (processingErrors.Case is int i && i > 0) { console.WriteLine(new ContainerSpan( i.ToString().StyleFailure(), " errors were encountered while running ".AsTextSpan(), toolName.StyleValue(), NewLine )); } foreach (var type in ResultsStatistics.Keys) { var summary = stats.Stats.Find(suiteName, toolName, type); console.WriteLine(summary.Case switch { BinaryStatistics b => FormatStatistics($"Summary for {suiteName}, {toolName}, {type}-level", type, b), _ => $"No summary statistics found for {suiteName}, {toolName}, {type}-level".AsTextSpan() });