Skip to content

test: migrate stats/base/dists/erlang/skewness to ULP-based assertions - #14022

Merged
kgryte merged 1 commit into
developfrom
kgryte/ulp-erlang-skewness
Aug 7, 2026
Merged

test: migrate stats/base/dists/erlang/skewness to ULP-based assertions#14022
kgryte merged 1 commit into
developfrom
kgryte/ulp-erlang-skewness

Conversation

@kgryte

@kgryte kgryte commented Aug 7, 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 tests for stats/base/dists/erlang/skewness from relative tolerance testing (delta = abs( y - expected[i] ), tol = 1.0 * EPS * abs( expected[i] ), t.ok( delta <= tol, ... )) to ULP difference testing using @stdlib/assert/is-almost-same-value.
  • updates both test/test.js and test/test.native.js, which mirror one another.
  • removes the now unused @stdlib/math/base/special/abs and @stdlib/constants/float64/eps imports from both test files (unlike some other conversions, EPS is not used anywhere else in these files).

The ULP bounds were tightened to the measured minimum which passes over the full fixture set, for both the JavaScript and the C implementations:

Fixture file Test case ULP bound Measured maximum ULP difference
fixtures/julia/data.json the function returns the skewness of an Erlang distribution 0 0 (JS and native)

Notes on how the bound was determined:

  • Each bound is the minimum non-negative integer for which every fixture value passes. All 200 fixture values are bit-for-bit exact against the Julia reference values, for both implementations, so 0 is both the measured maximum and the tightest possible bound.
  • This is expected: the skewness of an Erlang distribution is 2 / sqrt( k ), and both the JavaScript and C implementations evaluate exactly that expression. sqrt is correctly rounded under IEEE 754 and the subsequent division is a single correctly rounded operation, so there is no room for the two implementations, or the reference values, to diverge.
  • Because the results are exact, the old y === expected[i] fast path was taken for every fixture value and the tolerance branch was never exercised.
  • The JavaScript and C implementations agree exactly, so test.js and test.native.js use identical bounds.
  • The native add-on was compiled locally, so test/test.native.js was exercised against the actual C implementation rather than skipped. Both test files were run twice at the final bounds, with identical results (217 assertions for test.js, 215 for test.native.js, all passing, per run).

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?

Given that every fixture value is bit-for-bit exact, a bound of 0 is equivalent to a strict equality check. Reviewers may prefer plain t.strictEqual( y, expected[ i ], ... ) here instead; isAlmostSameValue( ..., 0 ) was chosen for consistency with the other converted packages, which already use a 0 bound in 300+ places.

Other

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

  • Only the two test files are modified; no source, documentation, benchmark, or fixture files are touched.
  • Verified with make test TESTS_FILTER=".*/stats/base/dists/erlang/skewness/.*" and by running test/test.native.js directly against the compiled add-on. Linting is clean via ESLint using etc/eslint/.eslintrc.tests.js.
  • The editorconfig pre-commit hook could not run in this environment, as it downloads its binary from a GitHub repository that this session cannot reach. The two files were instead checked manually against .editorconfig (LF endings, tab indentation, final newline, UTF-8); the diff introduces no new violations.

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 scheduled task. The test migration follows the idiom established by previously merged conversions, and the ULP bound was measured empirically against both the JavaScript and compiled C implementations rather than guessed.


@stdlib-js/reviewers


Generated by Claude Code

Migrate the tests for `stats/base/dists/erlang/skewness` from relative
tolerance testing to ULP difference testing using
`@stdlib/assert/is-almost-same-value`.

All 200 fixture values are bit-for-bit exact for both the JavaScript and
the C implementations, so the ULP bound is tightened to the measured
minimum of 0.

Ref: #11352

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01T1qAkJFoiG9eerDmaEhcUC
@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 7, 2026
@stdlib-bot

Copy link
Copy Markdown
Contributor

Coverage Report

Package Statements Branches Functions Lines
stats/base/dists/erlang/skewness $\\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 7, 2026
@kgryte
kgryte marked this pull request as ready for review August 7, 2026 22:52
@kgryte
kgryte requested a review from a team August 7, 2026 22:52
@stdlib-bot stdlib-bot added the Needs Review A pull request which needs code review. label Aug 7, 2026
@kgryte
kgryte merged commit 8500b0f into develop Aug 7, 2026
82 checks passed
@kgryte
kgryte deleted the kgryte/ulp-erlang-skewness branch August 7, 2026 22:53
@stdlib-bot stdlib-bot removed the Needs Review A pull request which needs code review. label Aug 7, 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.

3 participants