Skip to content

test: migrate stats/base/dists/exponential/quantile to ULP-based assertions - #14706

Merged
kgryte merged 1 commit into
developfrom
kgryte/ulp-exponential-quantile
Aug 27, 2026
Merged

kgryte merged 1 commit into
developfrom
kgryte/ulp-exponential-quantile

Conversation

@kgryte

@kgryte kgryte commented Aug 27, 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/exponential/quantile from relative-tolerance assertions (delta <= tol, with delta = abs( y - expected[ i ] ) and tol = 110.0 * EPS * abs( expected[ i ] )) to ULP-difference assertions using @stdlib/assert/is-almost-same-value.
  • applies the same migration to all three test files containing tolerance-based fixture loops: test/test.quantile.js, test/test.factory.js, and test/test.native.js. (test/test.js contains only smoke tests and is unchanged.)
  • preserves all existing test cases and structure, including the non-tolerance assertions (NaN parameters, p outside [0,1], +infinity for lambda, and negative lambda) and the Inf/-Inf fixture normalization.

The ULP bound used is:

Test file Fixture block ULP
test/test.quantile.js fixtures/r/data.json (1000 cases) 172
test/test.factory.js fixtures/r/data.json (1000 cases) 172
test/test.native.js fixtures/r/data.json (1000 cases) 172

172 is the measured minimum: starting from N = 64 and searching upward/tightening, N = 172 passes over the full fixture set while N = 171 fails on exactly one fixture entry (p = 0.001001001001001001, lambda = 38.7, where the returned value 0.000025878613361486335 differs from the R expected value 0.000025878613361486918 by exactly 172 ULP). The suite was run twice at the final N to confirm deterministic passing (1013 assertions per file, all passing on both runs, no FMA/arch variation).

Because the native add-on is not built in this environment, test/test.native.js is skipped locally and its bound could not be measured by running that file directly. Instead, the C implementation was compiled standalone against its resolved C dependency closure (math/base/special/ln, math/base/assert/is-nan, number/float64/base/get-high-word, number/float64/base/set-high-word) and evaluated over all 1000 fixture inputs: its results are bit-for-bit identical to the JavaScript implementation for every input, so the same bound of 172 applies to all three files.

Linting was checked over the changed files and is clean. The only files changed are the three test 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.

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 PR was authored by Claude Code: the assistant mechanically converted the tolerance-based assertions to isAlmostSameValue, agentically searched for the minimum ULP bound, verified that the C implementation matches the JavaScript implementation bit-for-bit over the fixture set, confirmed determinism across two full runs, and ran the local lint and test suites before submitting.


@stdlib-js/reviewers


Generated by Claude Code

@stdlib-bot stdlib-bot added the Good First PR A pull request resolving a Good First Issue. label Aug 27, 2026
@stdlib-bot

Copy link
Copy Markdown
Contributor

Hello! 👋

We've noticed that you've been opening a number of PRs addressing good first issues. Thank you for your interest and enthusiasm!

Now that you've made a few contributions, we suggest no longer working on good first issues. Instead, we encourage you to prioritize cleaning up any PRs which have yet to be merged and then proceed to work on more involved tasks.

Not only does this ensure that other new contributors can work on things and get ramped up on all things stdlib, it also ensures that you can spend your time on more challenging problems. 🚀

For ideas for future PRs, feel free to search the codebase for TODOs and FIXMEs and be sure to check out other open issues on the issue tracker. Cheers!

@stdlib-bot stdlib-bot added the Statistics Issue or pull request related to statistical functionality. label Aug 27, 2026
@kgryte kgryte added the Tests Pull requests specifically adding tests. label Aug 27, 2026
@kgryte
kgryte marked this pull request as ready for review August 27, 2026 10:24
@kgryte
kgryte requested a review from a team August 27, 2026 10:24
@stdlib-bot stdlib-bot added the Needs Review A pull request which needs code review. label Aug 27, 2026
@stdlib-bot

Copy link
Copy Markdown
Contributor

Coverage Report

Package Statements Branches Functions Lines
stats/base/dists/exponential/quantile $\\color{green}283/283$
$\\color{green}+100.00\\%$
$\\color{green}23/23$
$\\color{green}+100.00\\%$
$\\color{green}4/4$
$\\color{green}+100.00\\%$
$\\color{green}283/283$
$\\color{green}+100.00\\%$

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

@kgryte
kgryte merged commit 6ecc151 into develop Aug 27, 2026
82 checks passed
@kgryte
kgryte deleted the kgryte/ulp-exponential-quantile branch August 27, 2026 10:31
@stdlib-bot stdlib-bot removed the Needs Review A pull request which needs code review. label Aug 27, 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