Skip to content

feat(pivotp): Smarter pivotp with moarstats#3606

Merged
jqnatividad merged 3 commits into
masterfrom
smarter-pivotp-with-moarstats
Mar 12, 2026
Merged

feat(pivotp): Smarter pivotp with moarstats#3606
jqnatividad merged 3 commits into
masterfrom
smarter-pivotp-with-moarstats

Conversation

@jqnatividad

Copy link
Copy Markdown
Collaborator

No description provided.

jqnatividad and others added 2 commits March 11, 2026 18:51
When moarstats has been run on input data, pivotp's `--agg smart` mode
now uses advanced statistics (kurtosis, bimodality, outlier profile,
entropy, Gini coefficient) for better aggregation choices. Also makes
moarstats regenerate the .stats.csv.data.jsonl cache so downstream
commands can see the enriched statistics.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- pivotp: differentiate string branch when normalized_entropy is available —
  high-cardinality and low-entropy cases now select First instead of
  duplicating Len across all branches
- moarstats: guard against non-UTF-8 output paths with early return
  instead of silently using an empty string
- tests: clarify bimodal test assertion with comment explaining when
  each aggregation (Len vs Median) fires

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR extends pivotp --agg smart to leverage additional statistics produced by moarstats, by plumbing moarstats-generated columns through the stats JSONL cache and adding targeted integration tests.

Changes:

  • Add moarstats-derived fields (e.g., kurtosis, bimodality coefficient, entropy, outlier profile) to StatsData and the stats-to-JSONL typing map.
  • Update pivotp smart aggregation selection logic to consider bimodality, outliers, kurtosis, Gini, and entropy (when available).
  • Regenerate the .stats.csv.data.jsonl cache at the end of moarstats so other “smart” commands can read the new columns; add pivotp tests for the new behavior.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 5 comments.

File Description
tests/test_pivotp.rs Adds integration tests for smart aggregation with/without moarstats-generated stats.
src/cmd/stats.rs Extends StatsData and STATSDATA_TYPES_MAP to include moarstats columns for JSONL cache deserialization.
src/cmd/pivotp.rs Enhances --agg smart logic using moarstats metrics and updates CLI help text accordingly.
src/cmd/moarstats.rs Regenerates stats JSONL cache after writing the augmented stats CSV.

Comment thread src/cmd/moarstats.rs Outdated
Comment thread src/cmd/pivotp.rs Outdated
Comment thread tests/test_pivotp.rs Outdated
Comment thread tests/test_pivotp.rs Outdated
Comment thread tests/test_pivotp.rs Outdated
…advanced to tests

- moarstats: use if-let instead of early return to avoid skipping temp file cleanup
- pivotp USAGE: clarify which stats need --advanced vs base moarstats
- tests: add --advanced flag to kurtosis/bimodal tests, fix misleading comment

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@jqnatividad jqnatividad merged commit 2edec44 into master Mar 12, 2026
15 of 16 checks passed
@jqnatividad jqnatividad deleted the smarter-pivotp-with-moarstats branch March 12, 2026 10:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants