Skip to content

test: migrate stats/base/dists/erlang/mean to ULP-based assertions - #14593

Draft
kgryte wants to merge 1 commit into
developfrom
kgryte/ulp-erlang-mean
Draft

test: migrate stats/base/dists/erlang/mean to ULP-based assertions#14593
kgryte wants to merge 1 commit into
developfrom
kgryte/ulp-erlang-mean

Conversation

@kgryte

@kgryte kgryte commented Aug 24, 2026

Copy link
Copy Markdown
Member

Resolves a part of #11352.

Description

What is the purpose of this pull request?

This pull request:

  • Migrates the test suite for stats/base/dists/erlang/mean from relative-tolerance comparisons to ULP-based assertions using @stdlib/assert/is-almost-same-value.
  • Replaces the abs( y - expected[i] ) <= tol (where tol = 1.0 * EPS * abs( expected[i] )) idiom, along with its y === expected[i] fast-path branch, with t.strictEqual( isAlmostSameValue( y, expected[ i ], 1 ), true, 'returns expected value' ) and removes the now-unused abs and EPS imports.
  • Applies the same change to both test/test.js and test/test.native.js.

The ULP bound was tightened to the minimum integer which passes over the full fixture set (200 fixture values): 1 ULP, for both test/test.js and test/test.native.js. The bound is genuinely minimal — at a bound of 0 ULPs, 44 of the 200 fixture values fail for both the JavaScript and the native implementation, so the bound cannot be lowered further.

The JavaScript and C implementations agree exactly here: sweeping each fixture value individually, both require a maximum of 1 ULP and both diverge from the Julia fixtures on the same 44 values, which is consistent with both computing a single division k / lambda and the fixtures having been generated in a different order of operations.

The native addon was built locally so that test/test.native.js actually executed rather than skipping. Both suites were run twice at the final bound and pass deterministically (217 assertions in test/test.js and 215 in test/test.native.js, per run, no failures). Only the test files are modified.

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.

The repository's editorconfig-checker lint step could not run in this environment, as the tool is downloaded on demand from a third-party GitHub release which was unreachable from the sandbox. The two changed files were instead verified by hand against .editorconfig (LF endings, UTF-8, tab indentation, no trailing whitespace, final newline). ESLint (tests configuration), the license-header lint, and the filename lint all ran and passed.

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 PR was authored by Claude Code, following the migration pattern established in prior ULP-conversion PRs. The minimum ULP bound was measured empirically against the package's fixtures.


@stdlib-js/reviewers


Generated by Claude Code

Replace the relative-tolerance comparison (and its exact-equality
fast-path branch) in the fixture loop with an `isAlmostSameValue`
assertion using a bound of 1 ULP, which is the minimum integer bound
which passes over the full fixture set for both the JavaScript and
native implementations.

Ref: #11352
@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 24, 2026
@stdlib-bot

Copy link
Copy Markdown
Contributor

Coverage Report

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

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

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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants