Skip to content

feat: add StdDev, StdDevPop, Var, VarPop and DistinctCount summary types (#389) - #516

Open
michaelstonis wants to merge 1 commit into
mainfrom
feat/389-stddev-var-distinct
Open

michaelstonis wants to merge 1 commit into
mainfrom
feat/389-stddev-var-distinct

Conversation

@michaelstonis

Copy link
Copy Markdown
Contributor

Closes #389.

Changes

SummaryType gains StdDev = 6, StdDevPop = 7, Var = 8, VarPop = 9 and DistinctCount = 10, appended after Custom (existing members now carry explicit values 0 to 5, which are the same numbers they always had).

  • PropertyAggregate (SummaryAggregates.cs): Welford's streaming mean and M2 in double for the four statistics (decimal and every built-in numeric type converted; nulls and non-numbers skipped without exceptions). Sample variants are empty for fewer than two numbers, population variants for zero numbers (one number gives 0). Results are clamped at 0.
  • DistinctCount: a HashSet<object> with GroupKeyComparer over the source's text comparer, so it matches grouping. Allocated once per aggregate, cleared by Begin() between passes, and rebuilt only if the source's KumikoComparer instance changes (culture or StringCompareOptions change).
  • Both are treated like Min/Max for changed values: CanUpdateInPlace is false, so table and group summaries recompute (foreground or background) instead of adjusting in place. Table, group and caption summaries and the worker path all go through the same aggregate type, so no other code changed.
  • KumikoStrings: five new init properties with defaults, and SummaryLabel handles them.
  • Excel export: new types keep the General number format (variance is not in the column's unit); nothing else in the CSV/XLSX paths switches on the type.
  • No renderer, input or host changes; summaries are computed per rebuild, not per frame.

Public API (all in src/KumikoUI.Core/PublicAPI.Unshipped.txt): SummaryType.StdDev, StdDevPop, Var, VarPop, DistinctCount; KumikoStrings.SummaryStdDev, SummaryStdDevPop, SummaryVar, SummaryVarPop, SummaryDistinctCount (get and init). The Unshipped lines were added by hand because eng/update-public-api.sh ran but its dotnet format step produced no output in this environment (it left the file empty); the lines follow the format of the Shipped file.

Acceptance criteria

  • Each new type matches a reference on integer, decimal, double and mixed data, nulls and non-numbers skipped, zero and one value (SummaryStatisticsTests, including a 1e9-offset stability case and huge values).
  • Works in table, group and caption summaries, foreground and background (SummaryStatisticsTests, BackgroundRebuildTests.StatisticsAndDistinctCount_OnTheWorker_...).
  • A changed item value recomputes variance and distinct count (table and group tests, and the background test).
  • DistinctCount follows the source's string comparison (ignore-case, ordinal, and a runtime change).
  • Default labels through KumikoStrings; LocalizationTests updated (the German table and the label test).
  • MAUI and Uno: Core only; SummaryType is bound through the existing SummaryColumnDescription in XAML on both hosts, so no host change was needed. Not built or tested on the hosts.
  • XML docs on every new enum member and string; PublicAPI.Unshipped.txt updated (by hand, see above).
  • README "Summaries" section and feature table list the new types; CHANGELOG entry under Unreleased.
  • No render-path change, so no per-frame allocations.

Verification

  • dotnet test tests/KumikoUI.Core.Tests: 4386 passed, 5 skipped, 0 failed.
  • dotnet test tests/KumikoUI.Export.Excel.Tests: 127 passed. dotnet test tests/KumikoUI.SkiaSharp.Tests: 42 passed.
  • dotnet build src/KumikoUI.Core and src/KumikoUI.SkiaSharp: 0 warnings, 0 errors.

Comment on lines +475 to +483
foreach (var city in Cities)
{
var path = $"{nameof(Item.City)}={city}";
var fg = foreground.GetGroupSummaries(path)![0];
var bg = background.GetGroupSummaries(path)![0];
Assert.Equal(fg.GetRawValue(nameof(Item.Quantity), SummaryType.StdDev), bg.GetRawValue(nameof(Item.Quantity), SummaryType.StdDev));
Assert.Equal(fg.GetRawValue(nameof(Item.Quantity), SummaryType.DistinctCount), bg.GetRawValue(nameof(Item.Quantity), SummaryType.DistinctCount));
Assert.Equal(foreground.GetCaptionSummaryText(path), background.GetCaptionSummaryText(path));
}

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

Summaries: add StdDev, StdDevPop, Var, VarPop and DistinctCount aggregates to SummaryType

2 participants