fix(stat): harden --stat flag across the full stack#136
Merged
Conversation
Replace regular double-centering (/n) with Székely & Rizzo 2014 U-centering (/(n-2)) in bcCenter, clamp dCor² to 0 with Math.max instead of Math.abs, raise guard from m<3 to m<4 since the 1/(n*(n-3)) factor is undefined at n=3, and update the V-shape test to use n=15 where U-centering produces positive dCovXY.
- Updated test name from '< 3 complete pairs' to '< 4 complete pairs' - Added missing n=3 test case to the boundary check (1/(m*(m-3)) undefined) - Fixed comment in distanceCorr function to reflect n<4 boundary Co-Authored-By: fahimfaisaal <[email protected]>
…o computeCorrelation
Zero-valued measurements were silently omitted from JSON output because the old float64 field used omitempty. *float64 + F64() lets callers explicitly encode zero while nil still serialises as absent.
…lone - Add StatConfig.StatEnabled/StatMath methods as single source of truth - Add MaterialiseStatFlags to build *StatConfig from flag slice (nil = omit) - Add ChartConfigNeedsCorrelation shared predicate - Fix AggregateDataPoints: treat nil Value as 0 not skip (data loss bug) - Fix deepCloneData: deep-copy *float64 pointers to avoid shared mutation
…ateUI Ships the heatmap echarts module even when heatmap is not a visible chart tab, so StatsPanel correlation renderer works regardless of chart selection.
…Stat field Extends ChartConfig interface with StatEnabled/StatMath. All five chart configs carry a *StatConfig field and delegate to StatConfig methods so logic lives in one place. Materialise uses shared.MaterialiseStatFlags so absent --stat produces nil (omitted from JSON) not a zero-value struct.
Each chart subcommand's RunE now reads stat flags from the cobra config registry and passes them to Materialise, which calls MaterialiseStatFlags once. Removes the per-chart inline stat-block duplication.
- RewriteStatArg: skip consuming next arg if it resolves to a real file - validateStat: replace hand-rolled fatal validation with ApplyValidationRules - settingsNeedCorrelation / anyDatasetNeedsCorrelation: use shared predicate - applyStatToSettings: add exhaustive default panic - options: add 'confidence' to --stat help text (was missing from both strings)
- ChartCard: hasStats checks stat.enabled===true (not !=false) so legacy files without a stat field never show the Stats button - StatsPanel / stats.worker: correlation method picker and adaptive scale - chartConfig / common: stat-aware series and axis config helpers - bar/line/pie/radar chart options: consume stat math for category gating
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Stat.Value *float64— pointer field enables explicit zero encoding;F64()helper for assignments; all parsers updatedshared.StatConfigmethods —StatEnabled()/StatMath()on the receiver collapse 5×2 copy-pasted methods into delegation one-linersMaterialiseStatFlags— single helper replaces 5 identical Materialise stat blocks; nil flags → nil pointer (omitted byomitempty) instead of always-emitted zero structChartConfigNeedsCorrelation— shared predicate removes duplicate inline logic inpipeline.goandui.goAggregateDataPointswas silently dropping sums when eitherValuewas nil (treated nil as skip, not 0)deepCloneDatashallow-copy bug —copy()of[]Statshared*float64pointers between src and dst; now deep-copies each pointerRewriteStatArgfile-eating bug —--stat countsconsumedcountsas a stat value even when a file namedcountsexisted;os.Statcheck guards itvalidateStat— replaced hand-rolled fatal validation withApplyValidationRules(warn-and-default, consistent with chart subcommands)hasStatsUI guard —enabled !== false(true for legacy files) →enabled === true(false for legacy files)--stathelp text — added missingconfidencecategory to both flag descriptionsSelectChunks/GenerateUIgainneedsHeatmapChunkso the heatmap ECharts module is included whenever correlations are requested, regardless of active chart tabTest plan
task test)pnpm testinui/)vizb bar bench.txt --stat— Stats button visible, all categories shownvizb bar bench.txt --stat=counts— only counts shownvizb bar bench.txt— no Stats button, JSON output has no"stat"keyecho '{}' > counts && vizb bar counts—countstreated as file, not stat value