Skip to content

PERCENTRANK: match Excel significance limits - #2980

Merged
h-a-n-a-s-h-i merged 2 commits into
storytold:mainfrom
Harrison-Booth:gc-fix-2657-percentrank
Oct 31, 2026
Merged

h-a-n-a-s-h-i merged 2 commits into
storytold:mainfrom
Harrison-Booth:gc-fix-2657-percentrank

Conversation

@Harrison-Booth

@Harrison-Booth Harrison-Booth commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

Matches Excel 16.0 for PERCENTRANK, PERCENTRANK.INC and PERCENTRANK.EXC significance edge cases: significance 309 and above returns #DIV/0!; significance 15–308 returns 15 significant digits rounded. Adds a docs/function-parity.md row and regression coverage, including significance 14, 15, 16, 308 and 309.

Verification: Expected results come from the Excel 16.0 COM observations documented in the original combined PR. cargo fmt --check passed locally. Per task instructions, Rust tests were not run locally; fork CI runs them.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Updated PERCENTRANK results for high significance values: significance 309 and above now returns #DIV/0!.
    • For significance values from 15 through 308, results are rounded to 15 significant digits, improving consistency across the PERCENTRANK variants.
  • Documentation
    • Updated the function compatibility reference to reflect these results.

@coderabbitai

coderabbitai Bot commented Oct 30, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
Commits

Reviewing files that changed from the base of the PR and between 75f7056 and 3de6cb1.

Files selected for processing: 3
  • crates/functions/src/stat/descriptive.rs
  • crates/functions/src/stat/tests.rs
  • docs/function-parity.md

Limit details: You’ve used all 10 included reviews currently available.

Walkthrough

PERCENTRANK now returns #DIV/0! at significance 309 or higher. For significance 15 and above, it rounds the rank to 15 significant digits. Tests and parity documentation cover these changes.

Changes: PERCENTRANK behavior

Layer / File(s) Summary
Update significance handling
crates/functions/src/stat/descriptive.rs
percentrank_impl returns #DIV/0! when significance is at least 309. For significance 15 and above, it formats the rank to 15 significant digits instead of truncating it.
Verify and document parity
crates/functions/src/stat/tests.rs, docs/function-parity.md
Tests cover significance values 14, 15, 16, 308, 309, and 400 across PERCENTRANK variants. The parity document records the Excel 16.0 behavior and its revision date.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Suggested reviewers: aiongg, dylanmtaylor

Merge Risk: Minimal · up to 3de6c

No actionable merge-blocking risk remains in the reviewed changes.

Security architecture risk: Minimal · up to 3de6c

The changes affect numerical precision and significance errors without adding callable functions, privileges, external access, or shared-state transitions. No introduced or worsened security risk was identified in the changed behavior.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — The direct behavioral exposure remains calculations invoking the three existing PERCENTRANK names. No expanded caller authority or resource scope was identified in the base-to-head comparison; downstream numerical consumers can receive different results or errors.

Trust Boundaries and Controls

  • inferred — Even when worksheet arguments are attacker-controlled, the changed branches affect a numeric result or cell error rather than forwarding input to a privileged sink. Existing invocation reachability is unchanged. This conclusion is limited to the inspected library boundary, not an assessment of host-side sandboxing.
Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely describes the main change: matching Excel significance limits for PERCENTRANK variants.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 2 functions across 2 files. (1 skipped: 1 unsupported.)

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

Finishing Touches: 💡 1
⚔️ Resolve merge conflicts: 💡
  • Resolve merge conflict in branch gc-fix-2657-percentrank
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Usage-based review receipt

  • Mode: Continue automatically
  • Reviewed files: 3
  • Waived: $0.75 (charged $0.00)
  • View usage details

Note

This review exceeded your plan’s limits and used usage-based reviews—free during trial, billed after paid activation unless disabled. Manage usage-based reviews.

Comment @coderabbitai help to get the list of available commands.

@echelon

echelon commented Oct 31, 2026

Copy link
Copy Markdown
Member

Thanks for splitting #2657! Could you close #2657 (or say which parts it still carries)? While both are open they overlap, so we'll land this as soon as #2657 is closed.

@h-a-n-a-s-h-i
h-a-n-a-s-h-i merged commit 59fd17a into storytold:main Oct 31, 2026
1 check passed
@echelon

echelon commented Oct 31, 2026

Copy link
Copy Markdown
Member

Landed in main (67e39fa). Thank you for the contribution, @Harrison-Booth, and for splitting and following up on the review!

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.

3 participants