Skip to content

refactor: use floating-point zero literals in stats/base/dists/rayleigh#12204

Merged
kgryte merged 2 commits into
developfrom
philipp/drift-stats-base-dists-rayleigh-2026-05-19
May 19, 2026
Merged

refactor: use floating-point zero literals in stats/base/dists/rayleigh#12204
kgryte merged 2 commits into
developfrom
philipp/drift-stats-base-dists-rayleigh-2026-05-19

Conversation

@Planeshifter
Copy link
Copy Markdown
Member

@Planeshifter Planeshifter commented May 19, 2026

Description

This pull request normalizes the sigma scale-parameter validation guard in two @stdlib/stats/base/dists/rayleigh packages to compare the scale parameter against 0.0 (an explicit floating-point zero literal) rather than 0 (a bare integer literal). The explicit floating-point form is used by 12 of the 14 numeric-function packages in the namespace (86%) and is the sole form used elsewhere in @stdlib/stats/base/dists: variance and stdev were the only two lib/main.js parameter guards in the entire distribution namespace using a bare integer literal (~94% ecosystem conformance). The change is behavior-preserving, since 0 and 0.0 denote the same IEEE 754 value.

stats/base/dists/rayleigh/variance

variance/lib/main.js guarded the sigma scale parameter against a bare integer 0. The parameter is a float64 NonNegativeNumber, and the function body already uses floating-point literals throughout (4.0, 2.0); the bare integer was incidental. The guard now compares against 0.0.

stats/base/dists/rayleigh/stdev

stdev/lib/main.js carried the same bare-integer guard. It now compares against 0.0, consistent with sibling packages including mean, median, and kurtosis.

Related Issues

No.

Questions

No.

Other

The change touches only the JavaScript validation guard in each package; tests, examples, REPL fixtures, and TypeScript declarations are unaffected, and the native (C) implementations were not modified.

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 produced by Claude Code running an automated cross-package consistency check. The routine extracted structural and semantic features from every package in the rayleigh namespace, identified the explicit floating-point parameter-guard literal as the majority convention, flagged variance and stdev as the outliers, and applied the two-line normalization. The change was independently reviewed for behavior preservation and for the absence of any dependent tests or documentation.


@stdlib-js/reviewers

claude added 2 commits May 19, 2026 16:19
…igh/variance`

Normalize the `sigma` scale-parameter guard to compare against an
explicit floating-point zero (`sigma < 0.0`) rather than a bare integer
literal (`sigma < 0`). The explicit form is used by 12 of the 14
numeric-function packages in the `rayleigh` namespace (86%) and by ~94%
of `main.js` guards across `@stdlib/stats/base/dists`. The change is
behavior-preserving.
…igh/stdev`

Normalize the `sigma` scale-parameter guard to compare against an
explicit floating-point zero (`sigma < 0.0`) rather than a bare integer
literal (`sigma < 0`). The explicit form is used by 12 of the 14
numeric-function packages in the `rayleigh` namespace (86%) and by ~94%
of `main.js` guards across `@stdlib/stats/base/dists`. The change is
behavior-preserving.
@stdlib-bot stdlib-bot added the Statistics Issue or pull request related to statistical functionality. label May 19, 2026
@stdlib-bot
Copy link
Copy Markdown
Contributor

Coverage Report

Package Statements Branches Functions Lines
stats/base/dists/rayleigh/stdev $\color{green}169/169$
$\color{green}+100.00%$
$\color{green}8/8$
$\color{green}+100.00%$
$\color{green}2/2$
$\color{green}+100.00%$
$\color{green}169/169$
$\color{green}+100.00%$
stats/base/dists/rayleigh/variance $\color{green}162/162$
$\color{green}+100.00%$
$\color{green}8/8$
$\color{green}+100.00%$
$\color{green}2/2$
$\color{green}+100.00%$
$\color{green}162/162$
$\color{green}+100.00%$

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

@Planeshifter Planeshifter marked this pull request as ready for review May 19, 2026 16:47
@Planeshifter Planeshifter requested review from a team and kgryte May 19, 2026 16:47
@stdlib-bot stdlib-bot added the Needs Review A pull request which needs code review. label May 19, 2026
@kgryte kgryte removed the Needs Review A pull request which needs code review. label May 19, 2026
@kgryte kgryte merged commit 4589958 into develop May 19, 2026
58 checks passed
@kgryte kgryte deleted the philipp/drift-stats-base-dists-rayleigh-2026-05-19 branch May 19, 2026 22:52
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