Skip to content

test: migrate stats/base/dists/planck/skewness to ULP-based assertions - #14797

Merged
kgryte merged 1 commit into
developfrom
kgryte/ulp-planck-skewness
Aug 30, 2026
Merged

kgryte merged 1 commit into
developfrom
kgryte/ulp-planck-skewness

Conversation

@kgryte

@kgryte kgryte commented Aug 30, 2026

Copy link
Copy Markdown
Member

Resolves a part of #11352.

Description

What is the purpose of this pull request?

This pull request:

Changes are confined to test/test.js and test/test.native.js. In each, the fixture loop's delta/tol computation and the y === expected[i] branch are replaced with a single isAlmostSameValue assertion, @stdlib/assert/is-almost-same-value is added to the module requires, and the now-unused @stdlib/math/base/special/abs and @stdlib/constants/float64/eps requires are removed. No other test cases, loop bounds, or fixtures are touched.

ULP bound: 1 in both test/test.js and test/test.native.js.

This is the measured minimum, not a guess. The JS and native implementations were each evaluated against all 1000 Python fixture cases, and the per-case ULP distance between the returned and expected values was computed directly via @stdlib/number/float64/base/ulp-difference. The resulting distribution was identical for both implementations: 891 cases at 0 ULP and 109 cases at exactly 1 ULP, so the maximum over the full fixture set is 1. The worst case is lambda = 7.28771354747294, where the returned 38.265183277421535 differs from the expected 38.26518327742153 by one representable step. Lowering the bound to 0 fails 109 of the 1000 cases, so 1 is the tightest integer bound that holds.

The C and JavaScript implementations return bit-identical results across all 1000 fixture cases, so a single bound is correct for both files.

The previous bound was 1.0 * EPS in both files (guarded by an exact-equality fast path). A 1 ULP bound is at least as tight everywhere, and strictly tighter for values just above a power of two, where 1.0 * EPS * |expected| spans nearly two representable steps.

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.

Verification performed:

  • make test TESTS_FILTER=".*/stats/base/dists/planck/skewness/.*" passes: 1005/1005 in test/test.js and 1005/1005 in test/test.native.js.
  • The native addon was built locally (node-gyp rebuild) so that test/test.native.js actually exercised the C implementation rather than being skipped; it passes at the same 1 ULP bound. The build artifacts were removed before committing.
  • The full suite was run twice at the final bound to confirm determinism (no FMA/architecture-dependent variation).
  • The lower bound was confirmed empirically as well as analytically: temporarily setting the bound to 0 produces 109 failures, matching the measured ULP histogram exactly.
  • Both files lint clean under etc/eslint/.eslintrc.tests.js, and pass editorconfig-checker under both etc/editorconfig-checker/.editorconfig_checker.json and .editorconfig_checker.markdown.json.
  • Only the two test files are changed; no build artifacts are included.

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

This PR was authored by Claude Code running as an automated task. The conversion mirrors the idiom established by previously merged stats/base/dists/* conversions (for example planck/stdev, rayleigh/variance, negative-binomial/stdev), and the ULP bound was determined empirically by measuring the per-case ULP distance across the full fixture set for both the JavaScript and C implementations, rather than by trial and error.


@stdlib-js/reviewers


Generated by Claude Code

Replaces relative tolerance assertions with ULP difference assertions
using `@stdlib/assert/is-almost-same-value`. The ULP bound was tightened
to the measured minimum of 1 ULP over the full Python fixture set.

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

Copy link
Copy Markdown
Contributor

Coverage Report

Package Statements Branches Functions Lines
stats/base/dists/planck/skewness $\\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.

@kgryte kgryte added the Tests Pull requests specifically adding tests. label Aug 30, 2026
@kgryte
kgryte marked this pull request as ready for review August 30, 2026 02:27
@kgryte
kgryte requested a review from a team August 30, 2026 02:27
@kgryte
kgryte merged commit d72b6e9 into develop Aug 30, 2026
66 checks passed
@kgryte
kgryte deleted the kgryte/ulp-planck-skewness branch August 30, 2026 02:28
@stdlib-bot stdlib-bot added Needs Review A pull request which needs code review. and removed Needs Review A pull request which needs code review. labels Aug 30, 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