Skip to content

test: migrate stats/base/dists/f/pdf to ULP-based assertions - #14853

Merged
kgryte merged 3 commits into
stdlib-js:developfrom
aryan7071:test-migrate-f-pdf-ulp
Sep 1, 2026
Merged

test: migrate stats/base/dists/f/pdf to ULP-based assertions#14853
kgryte merged 3 commits into
stdlib-js:developfrom
aryan7071:test-migrate-f-pdf-ulp

Conversation

@aryan7071

@aryan7071 aryan7071 commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

Progresses #11352

Description

What is the purpose of this pull request?

This pull request:

  • migrates the test suite for stats/base/dists/f/pdf from relative tolerance (abs/EPS-based) assertions to ULP difference assertions using @stdlib/assert/is-almost-same-value.
  • updates test/test.factory.js, test/test.pdf.js, and test/test.native.js. test/test.js contains no fixture-based numeric assertions and required no changes.
  • removes the now-unused abs and EPS imports and the corresponding delta/tol variable declarations, collapsing each if/else exact-match-or-tolerance branch into a single isAlmostSameValue assertion.

Each of the six fixture blocks (bothLarge, largeD1, largeD2 tested against both Julia and Boost C++ reference values) required its own independently-determined minimum ULP bound. The pure JS implementation (test.factory.js, test.pdf.js) and the native binding (test.native.js) required different bounds, since the native binding diverges from the JS implementation at the level of individual floating-point bits, similar to compiler-optimization-driven divergence noted in other previously migrated packages.

Measured minimum ULP bounds:

Fixture Reference JS ULP Native ULP
both_large Julia 4003 230
large_d1 Julia 95 137
large_d2 Julia 103 122
both_large Boost C++ 148 1474
large_d1 Boost C++ 105 694
large_d2 Boost C++ 1285 660

Each bound is the exact maximum observed ULP difference over its fixture, measured separately against the pure JS implementation and a locally-built native addon.

Two of the JS bounds are notably larger than the rest: both_large/Julia (4003) and large_d2/Boost C++ (1285). Both outlier cases occur at inputs where d1 is very close to 2.0 — a value this distribution already treats as a special boundary elsewhere in the test suite (see the existing d1<2.0/d1=2.0/d1>2.0 boundary tests). Inspecting these cases directly shows actual and expected values still agree closely in absolute/relative terms; the large ULP counts reflect the fine representable spacing of floating-point values in this region rather than a correctness issue.

The pre-existing "baseline case" test in test.native.js (a single hardcoded input/output check, unrelated to the six fixture-driven blocks above) already used isAlmostSameValue with ULP=2 prior to this PR and was not 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.

No.

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.".

{{TODO: add disclosure if applicable}}


@stdlib-js/reviewers

@aryan7071
aryan7071 requested a review from a team August 31, 2026 18:59
@stdlib-bot stdlib-bot added Statistics Issue or pull request related to statistical functionality. Needs Review A pull request which needs code review. labels Aug 31, 2026
@aryan7071
aryan7071 marked this pull request as draft August 31, 2026 19:08
@stdlib-bot stdlib-bot removed the Needs Review A pull request which needs code review. label Aug 31, 2026
@stdlib-bot stdlib-bot added the Good First PR A pull request resolving a Good First Issue. label Sep 1, 2026
@stdlib-bot

stdlib-bot commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

Coverage Report

Package Statements Branches Functions Lines
stats/base/dists/f/pdf $\\color{red}599/647$
$\\color{green}+92.58\\%$
$\\color{red}62/66$
$\\color{green}+93.94\\%$
$\\color{green}6/6$
$\\color{green}+100.00\\%$
$\\color{red}599/647$
$\\color{green}+92.58\\%$

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

@aryan7071
aryan7071 marked this pull request as ready for review September 1, 2026 18:56
@stdlib-bot stdlib-bot added the Needs Review A pull request which needs code review. label Sep 1, 2026
@kgryte kgryte added difficulty: 1 Low degree of difficulty. Should be straightforward to implement and/or resolve. Tests Pull requests specifically adding tests. review: 5 and removed Needs Review A pull request which needs code review. labels Sep 1, 2026
@kgryte
kgryte merged commit 6b37f33 into stdlib-js:develop Sep 1, 2026
81 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

difficulty: 1 Low degree of difficulty. Should be straightforward to implement and/or resolve. Good First PR A pull request resolving a Good First Issue. review: 5 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