Skip to content

refactor: use format for error construction in stats/incr/pcorrmat#12268

Merged
kgryte merged 1 commit into
developfrom
philipp/drift-stats-incr-2026-05-24
May 24, 2026
Merged

refactor: use format for error construction in stats/incr/pcorrmat#12268
kgryte merged 1 commit into
developfrom
philipp/drift-stats-incr-2026-05-24

Conversation

@Planeshifter
Copy link
Copy Markdown
Member

Description

This pull request:

  • Normalizes a stray plain-string-concatenation error throw in @stdlib/stats/incr/pcorrmat to use the format helper from @stdlib/string/format, matching the canonical pattern already used by every other throw in the same file and by sibling matrix packages (covmat, pcorrdistmat). Behavior is unchanged; the same Error is thrown with the same fields substituted into the message.

Questions

No.

Other

@stdlib/stats/incr/pcorrmat

lib/main.js:299 constructed its error message with '…' + order + '…' + numel(...) + '…'. The surrounding code already requires @stdlib/string/format and uses it in every other throw in the file (six of seven before this change). The analogous "means length must match matrix dimensions" throw in covmat/lib/main.js:228 and pcorrdistmat/lib/main.js both use format( '… Expected: \%u`. Actual: `%u`.', order, numel( means.shape ) )— 100% conformance among throw-bearing matrix packages instats/incr`. Rewrite mirrors that pattern verbatim; substituted values are now backtick-wrapped to match. Tests assert on error type only, not message text, and no examples trigger this path.

Checklist

AI Assistance

  • Yes
  • No

If you answered "yes" above, how did you use AI assistance?

  • Code generation (e.g., when writing an implementation or fixing a bug)
  • Test/benchmark generation
  • Documentation (including examples)
  • Research and understanding

Disclosure

This PR was authored with assistance from Claude Code, which ran a cross-package API drift detection routine over the stats/incr namespace. The routine performed structural and semantic feature extraction across all 108 member packages, identified pcorrmat/lib/main.js:299 as the sole outlier on error-construction conformance (98% of throw-bearing siblings use format exclusively), and proposed the one-line fix after passing two-agent validation (semantic-review confirmed the deviation was unintentional; cross-reference confirmed no test or example relies on the exact message text).


@stdlib-js/reviewers


Generated by Claude Code

Normalize a stray plain-string-concatenation throw at `lib/main.js:299`
to use the `format` helper from `@stdlib/string/format`. The `format`
import was already present and used by every other throw in the same
file (six of seven) and by the analogous throw in sibling matrix
packages `covmat` and `pcorrdistmat` (100% of throw-bearing matrix
packages in `stats/incr`).

Behavior is unchanged: the same `Error` is thrown with the same fields
substituted; the surrounding text is preserved and the substituted
values are wrapped in backticks to match the sibling pattern.
@stdlib-bot stdlib-bot added the Statistics Issue or pull request related to statistical functionality. label May 24, 2026
@stdlib-bot
Copy link
Copy Markdown
Contributor

Coverage Report

Package Statements Branches Functions Lines
stats/incr/pcorrmat $\color{green}545/545$
$\color{green}+100.00%$
$\color{green}47/47$
$\color{green}+100.00%$
$\color{green}6/6$
$\color{green}+100.00%$
$\color{green}545/545$
$\color{green}+100.00%$

The above coverage report was generated for the changes in this PR.

@kgryte kgryte marked this pull request as ready for review May 24, 2026 19:32
@kgryte kgryte requested a review from a team May 24, 2026 19:32
@stdlib-bot stdlib-bot added the Needs Review A pull request which needs code review. label May 24, 2026
@kgryte kgryte removed the Needs Review A pull request which needs code review. label May 24, 2026
@kgryte kgryte merged commit 8fdaa49 into develop May 24, 2026
53 checks passed
@kgryte kgryte deleted the philipp/drift-stats-incr-2026-05-24 branch May 24, 2026 19:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Statistics Issue or pull request related to statistical functionality.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants