Skip to content

fix: correct argument validation error messages in random/iter/frechet and random/iter/negative-binomial - #15894

Draft
Planeshifter wants to merge 2 commits into
developfrom
claude/cool-johnson-wier6t
Draft

Planeshifter wants to merge 2 commits into
developfrom
claude/cool-johnson-wier6t

Conversation

@Planeshifter

Copy link
Copy Markdown
Member

Description

What is the purpose of this pull request?

This pull request:

  • corrects two argument validation error messages in random/iter so that they describe what the validation predicate actually checks, matching the wording used by sibling packages and by the corresponding random/base packages.

@stdlib/random/iter/frechet

The third-argument check is !isNumber( m ) || isnan( m ), but the message said only "must be a number". It now says "must be a number and not NaN". This is the wording used for the same predicate in 15 of 16 checks across random/iter (94%) and in random/base/frechet/lib/validate.js.

@stdlib/random/iter/negative-binomial

The first-argument check is isPositiveNumber( r ), but the message said "must be a positive integer". r is real-valued. The message now says "must be a positive number", which matches the package's own @param {PositiveNumber} r, its @throws tag, its TypeScript declaration, and random/base/negative-binomial. Across random/iter, 33 of 34 isPositiveNumber checks (97%) already use this wording.

Related Issues

Does this pull request have any related issues?

No.

Questions

Any questions for reviewers of this pull request?

No.

Other

Any other information relevant to this pull request? This may include screenshots, references, and/or implementation notes.

How the namespace was checked. All 41 packages in random/iter were compared feature by feature, and a package was flagged when it disagreed with a pattern shared by at least 75% of its siblings.

  • Structural features: file tree, package.json key sets, and README section lists. All 41 packages conform.
  • Semantic features: return kind, use of format for errors, JSDoc shape, dependency set, and validation prologue. Every feature has a clear majority.
  • Only the two error messages above survived review.

Validation. Each candidate was reviewed for:

  • whether the deviation was intentional;
  • whether tests, examples, or docs depend on the current message text;
  • structural applicability.

The tests assert only TypeError, not the message text, so no test changes are needed. Both new strings already exist in the error database (codes 7C and 71).

Deliberately excluded. minstd, minstd-shuffle, mt19937, randi, and randu do not depend on @stdlib/utils/constant-function or @stdlib/utils/noop, unlike 88% of their siblings. This is intentional: these are the base PRNG iterators and have no options.prng branch that would use them.

Out of scope. random/streams/frechet/lib/main.js has the same "must be a number." text. It is a different namespace and is left for a follow-up.

Checklist

Please ensure the following tasks are completed before submitting this pull request.

AI Assistance

When authoring the changes proposed in this PR, did you use any kind of 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

If you answered "yes" to using AI assistance, please provide a short disclosure indicating how you used AI assistance. This helps reviewers determine how much scrutiny to apply when reviewing your contribution. Example disclosures: "This PR was written primarily by Claude Code." or "I consulted ChatGPT to understand the codebase, but the proposed changes were fully authored manually by myself.".

This PR was written primarily by Claude Code, as part of an automated cross-package drift-detection run that compares each package against the majority pattern of its namespace.


@stdlib-js/reviewers

🤖 Generated with Claude Code

https://claude.ai/code/session_01VEFEdGXxS5GMXpwxwp2YiX


Generated by Claude Code

claude added 2 commits October 4, 2026 20:39
Updated the third-argument `TypeError` message to "must be a number and not NaN" to match the `!isNumber( m ) || isnan( m )` predicate. This is the message used for the same predicate in 15 of 16 such checks across `random/iter` siblings (94%) and in `random/base/frechet`.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VEFEdGXxS5GMXpwxwp2YiX
Updated the first-argument `TypeError` message from "positive integer" to "positive number" to match the `isPositiveNumber` predicate, the package's own JSDoc (`@param {PositiveNumber} r`, `@throws`), and `random/base/negative-binomial`. `isPositiveNumber` checks use "positive number" in 33 of 34 cases across `random/iter` (97%).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VEFEdGXxS5GMXpwxwp2YiX
@stdlib-bot

Copy link
Copy Markdown
Contributor

Coverage Report

Package Statements Branches Functions Lines
random/iter/frechet $\\color{green}307/307$
$\\color{green}+100.00\\%$
$\\color{green}38/38$
$\\color{green}+100.00\\%$
$\\color{green}10/10$
$\\color{green}+100.00\\%$
$\\color{green}307/307$
$\\color{green}+100.00\\%$
random/iter/negative-binomial $\\color{green}301/301$
$\\color{green}+100.00\\%$
$\\color{green}35/35$
$\\color{green}+100.00\\%$
$\\color{green}10/10$
$\\color{green}+100.00\\%$
$\\color{green}301/301$
$\\color{green}+100.00\\%$

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

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants