Skip to content

docs: fix assign examples in random/array TypeScript declarations#12738

Merged
kgryte merged 1 commit into
developfrom
philipp/fix-random-array-assign-examples
Jun 10, 2026
Merged

docs: fix assign examples in random/array TypeScript declarations#12738
kgryte merged 1 commit into
developfrom
philipp/fix-random-array-assign-examples

Conversation

@Planeshifter

@Planeshifter Planeshifter commented Jun 9, 2026

Copy link
Copy Markdown
Member

Description

What is the purpose of this pull request?

This pull request fixes the assign method @example blocks in the TypeScript declaration (index.d.ts) files across the @stdlib/random/array namespace.

The examples called the main function with the output array as an argument (e.g. normal( 2.0, 5.0, x )) rather than the assign method (normal.assign( 2.0, 5.0, x )). The bare call throws at runtime because the main function's first argument must be a nonnegative integer (the array length):

invalid argument. First argument must be a nonnegative integer. Value: `0.01`.

As a result, the documented var bool = ( out === x ); // returns true assertion never holds. The fix:

  • Corrects the assign example to call <name>.assign( ... ) in 32 random/array/* declaration files (arcsine, bernoulli, beta, betaprime, binomial, cauchy, chi, chisquare, cosine, discrete-uniform, erlang, exponential, f, frechet, gamma, gumbel, hypergeometric, invgamma, kumaraswamy, laplace, levy, logistic, lognormal, negative-binomial, normal, pareto-type1, poisson, rayleigh, t, triangular, uniform, weibull).
  • Fixes the unary, binary, and ternary scaffold templates under random/array/scripts/scaffolds, which generate these declarations. The templates additionally passed out (undefined) instead of x as the output array; both issues are corrected to prevent regeneration of the error.

Each corrected example was verified at runtime (out === x is now true). The READMEs already used the correct .assign form, so this brings the declarations into alignment with them. No types or signatures are modified.

random/array/geometric is intentionally excluded: it is already correct on develop.

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.

Surfaced while reviewing #12571 (a TSDoc audit of the random namespace).

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)
  • Documentation (including examples)
  • Research and understanding

Disclosure

The bug was surfaced and fixed using Claude Code. Each corrected example was verified at runtime against the actual implementation, and the changes were reviewed by myself before submitting.


@stdlib-js/reviewers

The `assign` method `@example` blocks in the `random/array/*` declaration
files called the main function (e.g. `normal( 2.0, 5.0, x )`) instead of
`normal.assign( 2.0, 5.0, x )`. The bare call throws at runtime because the
main function's first argument must be a nonnegative integer (array length),
so the example's `out === x` assertion never holds.

Correct the example in all affected packages and fix the unary, binary, and
ternary scaffold templates (which additionally passed `out` instead of `x`
as the output array) to prevent regeneration of the error.
@Planeshifter Planeshifter marked this pull request as ready for review June 9, 2026 16:50
@Planeshifter Planeshifter requested review from a team and kgryte June 9, 2026 16:50
@stdlib-bot

Copy link
Copy Markdown
Contributor

Coverage Report

Package Statements Branches Functions Lines
random/array/arcsine $\color{green}212/212$
$\color{green}+100.00\%$
$\color{green}3/3$
$\color{green}+100.00\%$
$\color{green}0/0$
$\color{green}+100.00\%$
$\color{green}212/212$
$\color{green}+100.00\%$
random/array/bernoulli $\color{green}209/209$
$\color{green}+100.00\%$
$\color{green}3/3$
$\color{green}+100.00\%$
$\color{green}0/0$
$\color{green}+100.00\%$
$\color{green}209/209$
$\color{green}+100.00\%$
random/array/beta $\color{green}212/212$
$\color{green}+100.00\%$
$\color{green}3/3$
$\color{green}+100.00\%$
$\color{green}0/0$
$\color{green}+100.00\%$
$\color{green}212/212$
$\color{green}+100.00\%$
random/array/betaprime $\color{green}212/212$
$\color{green}+100.00\%$
$\color{green}3/3$
$\color{green}+100.00\%$
$\color{green}0/0$
$\color{green}+100.00\%$
$\color{green}212/212$
$\color{green}+100.00\%$
random/array/binomial $\color{green}212/212$
$\color{green}+100.00\%$
$\color{green}3/3$
$\color{green}+100.00\%$
$\color{green}0/0$
$\color{green}+100.00\%$
$\color{green}212/212$
$\color{green}+100.00\%$
random/array/cauchy $\color{green}212/212$
$\color{green}+100.00\%$
$\color{green}3/3$
$\color{green}+100.00\%$
$\color{green}0/0$
$\color{green}+100.00\%$
$\color{green}212/212$
$\color{green}+100.00\%$
random/array/chi $\color{green}209/209$
$\color{green}+100.00\%$
$\color{green}3/3$
$\color{green}+100.00\%$
$\color{green}0/0$
$\color{green}+100.00\%$
$\color{green}209/209$
$\color{green}+100.00\%$
random/array/chisquare $\color{green}209/209$
$\color{green}+100.00\%$
$\color{green}3/3$
$\color{green}+100.00\%$
$\color{green}0/0$
$\color{green}+100.00\%$
$\color{green}209/209$
$\color{green}+100.00\%$
random/array/cosine $\color{green}212/212$
$\color{green}+100.00\%$
$\color{green}3/3$
$\color{green}+100.00\%$
$\color{green}0/0$
$\color{green}+100.00\%$
$\color{green}212/212$
$\color{green}+100.00\%$
random/array/discrete-uniform $\color{green}212/212$
$\color{green}+100.00\%$
$\color{green}3/3$
$\color{green}+100.00\%$
$\color{green}0/0$
$\color{green}+100.00\%$
$\color{green}212/212$
$\color{green}+100.00\%$
random/array/erlang $\color{green}212/212$
$\color{green}+100.00\%$
$\color{green}3/3$
$\color{green}+100.00\%$
$\color{green}0/0$
$\color{green}+100.00\%$
$\color{green}212/212$
$\color{green}+100.00\%$
random/array/exponential $\color{green}209/209$
$\color{green}+100.00\%$
$\color{green}3/3$
$\color{green}+100.00\%$
$\color{green}0/0$
$\color{green}+100.00\%$
$\color{green}209/209$
$\color{green}+100.00\%$
random/array/f $\color{green}212/212$
$\color{green}+100.00\%$
$\color{green}3/3$
$\color{green}+100.00\%$
$\color{green}0/0$
$\color{green}+100.00\%$
$\color{green}212/212$
$\color{green}+100.00\%$
random/array/frechet $\color{green}215/215$
$\color{green}+100.00\%$
$\color{green}3/3$
$\color{green}+100.00\%$
$\color{green}0/0$
$\color{green}+100.00\%$
$\color{green}215/215$
$\color{green}+100.00\%$
random/array/gamma $\color{green}212/212$
$\color{green}+100.00\%$
$\color{green}3/3$
$\color{green}+100.00\%$
$\color{green}0/0$
$\color{green}+100.00\%$
$\color{green}212/212$
$\color{green}+100.00\%$
random/array/gumbel $\color{green}212/212$
$\color{green}+100.00\%$
$\color{green}3/3$
$\color{green}+100.00\%$
$\color{green}0/0$
$\color{green}+100.00\%$
$\color{green}212/212$
$\color{green}+100.00\%$
random/array/hypergeometric $\color{green}215/215$
$\color{green}+100.00\%$
$\color{green}3/3$
$\color{green}+100.00\%$
$\color{green}0/0$
$\color{green}+100.00\%$
$\color{green}215/215$
$\color{green}+100.00\%$
random/array/invgamma $\color{green}212/212$
$\color{green}+100.00\%$
$\color{green}3/3$
$\color{green}+100.00\%$
$\color{green}0/0$
$\color{green}+100.00\%$
$\color{green}212/212$
$\color{green}+100.00\%$
random/array/kumaraswamy $\color{green}212/212$
$\color{green}+100.00\%$
$\color{green}3/3$
$\color{green}+100.00\%$
$\color{green}0/0$
$\color{green}+100.00\%$
$\color{green}212/212$
$\color{green}+100.00\%$
random/array/laplace $\color{green}212/212$
$\color{green}+100.00\%$
$\color{green}3/3$
$\color{green}+100.00\%$
$\color{green}0/0$
$\color{green}+100.00\%$
$\color{green}212/212$
$\color{green}+100.00\%$
random/array/levy $\color{green}212/212$
$\color{green}+100.00\%$
$\color{green}3/3$
$\color{green}+100.00\%$
$\color{green}0/0$
$\color{green}+100.00\%$
$\color{green}212/212$
$\color{green}+100.00\%$
random/array/logistic $\color{green}212/212$
$\color{green}+100.00\%$
$\color{green}3/3$
$\color{green}+100.00\%$
$\color{green}0/0$
$\color{green}+100.00\%$
$\color{green}212/212$
$\color{green}+100.00\%$
random/array/lognormal $\color{green}212/212$
$\color{green}+100.00\%$
$\color{green}3/3$
$\color{green}+100.00\%$
$\color{green}0/0$
$\color{green}+100.00\%$
$\color{green}212/212$
$\color{green}+100.00\%$
random/array/negative-binomial $\color{green}212/212$
$\color{green}+100.00\%$
$\color{green}3/3$
$\color{green}+100.00\%$
$\color{green}0/0$
$\color{green}+100.00\%$
$\color{green}212/212$
$\color{green}+100.00\%$
random/array/normal $\color{green}212/212$
$\color{green}+100.00\%$
$\color{green}3/3$
$\color{green}+100.00\%$
$\color{green}0/0$
$\color{green}+100.00\%$
$\color{green}212/212$
$\color{green}+100.00\%$
random/array/pareto-type1 $\color{green}212/212$
$\color{green}+100.00\%$
$\color{green}3/3$
$\color{green}+100.00\%$
$\color{green}0/0$
$\color{green}+100.00\%$
$\color{green}212/212$
$\color{green}+100.00\%$
random/array/poisson $\color{green}209/209$
$\color{green}+100.00\%$
$\color{green}3/3$
$\color{green}+100.00\%$
$\color{green}0/0$
$\color{green}+100.00\%$
$\color{green}209/209$
$\color{green}+100.00\%$
random/array/rayleigh $\color{green}209/209$
$\color{green}+100.00\%$
$\color{green}3/3$
$\color{green}+100.00\%$
$\color{green}0/0$
$\color{green}+100.00\%$
$\color{green}209/209$
$\color{green}+100.00\%$
random/array $\color{red}10923/11701$
$\color{green}+93.35\%$
$\color{red}148/188$
$\color{green}+78.72\%$
$\color{red}13/91$
$\color{green}+14.29\%$
$\color{red}10923/11701$
$\color{green}+93.35\%$
random/array/t $\color{green}209/209$
$\color{green}+100.00\%$
$\color{green}3/3$
$\color{green}+100.00\%$
$\color{green}0/0$
$\color{green}+100.00\%$
$\color{green}209/209$
$\color{green}+100.00\%$
random/array/triangular $\color{green}215/215$
$\color{green}+100.00\%$
$\color{green}3/3$
$\color{green}+100.00\%$
$\color{green}0/0$
$\color{green}+100.00\%$
$\color{green}215/215$
$\color{green}+100.00\%$
random/array/uniform $\color{green}212/212$
$\color{green}+100.00\%$
$\color{green}3/3$
$\color{green}+100.00\%$
$\color{green}0/0$
$\color{green}+100.00\%$
$\color{green}212/212$
$\color{green}+100.00\%$
random/array/weibull $\color{green}212/212$
$\color{green}+100.00\%$
$\color{green}3/3$
$\color{green}+100.00\%$
$\color{green}0/0$
$\color{green}+100.00\%$
$\color{green}212/212$
$\color{green}+100.00\%$

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

@stdlib-bot stdlib-bot added the Needs Review A pull request which needs code review. label Jun 9, 2026
@kgryte kgryte added Documentation Improvements, additions, or changes to documentation. and removed Needs Review A pull request which needs code review. labels Jun 10, 2026
@kgryte

kgryte commented Jun 10, 2026

Copy link
Copy Markdown
Member

As the CI failure is not due to changes introduced in this PR, I'll go ahead and merge.

@kgryte kgryte changed the title docs: fix assign examples in random/array TypeScript declarations docs: fix assign examples in random/array TypeScript declarations Jun 10, 2026
@kgryte kgryte merged commit 58b187e into develop Jun 10, 2026
56 of 58 checks passed
@kgryte kgryte deleted the philipp/fix-random-array-assign-examples branch June 10, 2026 02:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Documentation Improvements, additions, or changes to documentation.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants