Skip to content

test: migrate stats/base/dists/erlang/stdev to ULP-based assertions - #14439

Merged
kgryte merged 1 commit into
developfrom
kgryte/ulp-erlang-stdev
Aug 20, 2026
Merged

kgryte merged 1 commit into
developfrom
kgryte/ulp-erlang-stdev

Conversation

@kgryte

@kgryte kgryte commented Aug 20, 2026

Copy link
Copy Markdown
Member

Description

What is the purpose of this pull request?

This pull request:

  • migrates the tests for @stdlib/stats/base/dists/erlang/stdev from computed EPS-based relative tolerance assertions to ULP-based assertions using @stdlib/assert/is-almost-same-value, as described in [RFC]: Migrate math/base/special packages from relative tolerance testing to ULP difference testing (tracking issue) #11352.
  • replaces the if ( y === expected[i] ) { ... } else { delta/tol ... } idiom in test/test.js and test/test.native.js with t.strictEqual( isAlmostSameValue( y, expected[ i ], 2 ), true, 'returns expected value' );.
  • removes the now unused @stdlib/math/base/special/abs and @stdlib/constants/float64/eps requires.

Only test files are modified; no implementation changes.

ULP bounds

Both test/test.js and test/test.native.js use a bound of 2 ULP, which is the measured minimum over the full Julia fixture set:

File ULP Notes
test/test.js 2 max observed ULP difference over all 217 fixture values is 2 (worst case: k = 19, lambda = 18.453885592489083); a bound of 1 fails
test/test.native.js 2 native addon built locally and exercised; identical worst case, 1 fails

Verification performed:

  • Started at N = 64, then tightened to the measured minimum by computing, for every fixture value, the smallest N for which isAlmostSameValue returns true.
  • Confirmed N = 1 fails in both test/test.js and test/test.native.js, and N = 2 passes.
  • Ran the full suite twice at N = 2 for both files with identical results (217/217 and 215/215 passing), confirming determinism.
  • The native addon was compiled locally (make install-node-addons) so the test.native.js assertions actually executed rather than being skipped. This is expected, since both implementations compute sqrt( k ) / lambda with a correctly rounded square root and division, leaving no room for FMA-related divergence.
  • eslint (tests configuration) is clean for both files.

Related Issues

Does this pull request have any related issues?

This pull request has the following related issues:

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.

Note that make lint-editorconfig-files could not be run in this environment, as it attempts to download the editorconfig-checker binary from a GitHub release which is not reachable here. The changed files were instead checked manually for tab indentation, absence of trailing whitespace, LF line endings, UTF-8 encoding, and a final newline.

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 authored by Claude Code running as an unattended task. The test conversion mirrors the idiom already established in previously converted packages (e.g. stats/base/dists/erlang/skewness), and the ULP bound was determined empirically by measuring the maximum ULP difference across the fixture set.


@stdlib-js/reviewers


Generated by Claude Code

@stdlib-bot stdlib-bot added Statistics Issue or pull request related to statistical functionality. Good First PR A pull request resolving a Good First Issue. labels Aug 20, 2026
@stdlib-bot

Copy link
Copy Markdown
Contributor

Coverage Report

Package Statements Branches Functions Lines
stats/base/dists/erlang/stdev $\\color{green}200/200$
$\\color{green}+100.00\\%$
$\\color{green}9/9$
$\\color{green}+100.00\\%$
$\\color{green}2/2$
$\\color{green}+100.00\\%$
$\\color{green}200/200$
$\\color{green}+100.00\\%$

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

@kgryte kgryte added the Tests Pull requests specifically adding tests. label Aug 20, 2026
@kgryte
kgryte marked this pull request as ready for review August 20, 2026 10:22
@kgryte
kgryte requested a review from a team August 20, 2026 10:22
@stdlib-bot stdlib-bot added the Needs Review A pull request which needs code review. label Aug 20, 2026
@kgryte
kgryte merged commit 149f728 into develop Aug 20, 2026
74 checks passed
@kgryte
kgryte deleted the kgryte/ulp-erlang-stdev branch August 20, 2026 10:23
@stdlib-bot stdlib-bot removed the Needs Review A pull request which needs code review. label Aug 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Good First PR A pull request resolving a Good First Issue. Statistics Issue or pull request related to statistical functionality. Tests Pull requests specifically adding tests.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants